Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: LayoutTests/resources/dump-as-markup.js

Issue 9477008: REGRESSION(r99076): WebKit pastes the trailing newline into a single-line text field (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * There are three basic use cases of dumpAsMarkup 2 * There are three basic use cases of dumpAsMarkup
3 * 3 *
4 * 1. Dump the entire DOM when the page is loaded 4 * 1. Dump the entire DOM when the page is loaded
5 * When this script is included but no method of Markup is called, 5 * When this script is included but no method of Markup is called,
6 * it dumps the DOM of each frame loaded. 6 * it dumps the DOM of each frame loaded.
7 * 7 *
8 * 2. Dump the content of a specific element when the page is loaded 8 * 2. Dump the content of a specific element when the page is loaded
9 * When Markup.setNodeToDump is called with some element or the id of some el ement, 9 * When Markup.setNodeToDump is called with some element or the id of some el ement,
10 * it dumps the content of the specified element as supposed to the entire DO M tree. 10 * it dumps the content of the specified element as supposed to the entire DO M tree.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 layoutTestController.notifyDone(); 119 layoutTestController.notifyDone();
120 } 120 }
121 121
122 Markup.useHTML5libOutputFormat = function() 122 Markup.useHTML5libOutputFormat = function()
123 { 123 {
124 Markup._useHTML5libOutputFormat = true; 124 Markup._useHTML5libOutputFormat = true;
125 } 125 }
126 126
127 Markup.get = function(node) 127 Markup.get = function(node)
128 { 128 {
129 var markup = Markup._getShadowHostIfPossible(node, 0);
130 if (markup)
131 return markup.substring(1);
132
129 if (!node.firstChild) 133 if (!node.firstChild)
130 return '| '; 134 return '| ';
131 135
132 // Don't print any markup for the root node. 136 // Don't print any markup for the root node.
133 var markup = ''; 137 for (var i = 0, len = node.childNodes.length; i < len; i++)
134 for (var i = 0, len = node.childNodes.length; i < len; i++) {
135 markup += Markup._get(node.childNodes[i], 0); 138 markup += Markup._get(node.childNodes[i], 0);
136 }
137 return markup.substring(1); 139 return markup.substring(1);
138 } 140 }
139 141
140 // Returns the markup for the given node. To be used for cases where a test need s 142 // Returns the markup for the given node. To be used for cases where a test need s
141 // to get the markup but not clobber the whole page. 143 // to get the markup but not clobber the whole page.
142 Markup._get = function(node, depth) 144 Markup._get = function(node, depth)
143 { 145 {
144 var str = Markup._indent(depth); 146 var str = Markup._indent(depth);
145 147
146 switch (node.nodeType) { 148 switch (node.nodeType) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 222 }
221 223
222 for (var i = 0, len = node.childNodes.length; i < len; i++) { 224 for (var i = 0, len = node.childNodes.length; i < len; i++) {
223 var selection = Markup._getSelectionMarker(node, i); 225 var selection = Markup._getSelectionMarker(node, i);
224 if (selection) 226 if (selection)
225 str += Markup._indent(depth + 1) + selection; 227 str += Markup._indent(depth + 1) + selection;
226 228
227 str += Markup._get(node.childNodes[i], depth + 1); 229 str += Markup._get(node.childNodes[i], depth + 1);
228 } 230 }
229 231
230 if (!Markup._useHTML5libOutputFormat && node.nodeType == Node.ELEMENT_NODE & & window.internals) { 232 str += Markup._getShadowHostIfPossible(node, depth);
231 var root = window.internals.shadowRoot(node);
232 if (root)
233 str += Markup._get(root, depth + 1);
234 }
235 233
236 var selection = Markup._getSelectionMarker(node, i); 234 var selection = Markup._getSelectionMarker(node, i);
237 if (selection) 235 if (selection)
238 str += Markup._indent(depth + 1) + selection; 236 str += Markup._indent(depth + 1) + selection;
239 237
240 return str; 238 return str;
241 } 239 }
242 240
241 Markup._getShadowHostIfPossible = function (node, depth)
242 {
243 if (!Markup._useHTML5libOutputFormat && node.nodeType == Node.ELEMENT_NODE & & window.internals) {
244 var root = window.internals.shadowRoot(node);
245 if (root)
246 return Markup._get(root, depth + 1);
247 }
248 return '';
249 }
250
243 Markup._namespace = function(node) 251 Markup._namespace = function(node)
244 { 252 {
245 if (Markup._NAMESPACE_URI_MAP[node.namespaceURI]) 253 if (Markup._NAMESPACE_URI_MAP[node.namespaceURI])
246 return Markup._NAMESPACE_URI_MAP[node.namespaceURI] + ' '; 254 return Markup._NAMESPACE_URI_MAP[node.namespaceURI] + ' ';
247 return ''; 255 return '';
248 } 256 }
249 257
250 Markup._dumpCalls = 0 258 Markup._dumpCalls = 0
251 259
252 Markup._indent = function(depth) 260 Markup._indent = function(depth)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 return Markup._SELECTION_CARET; 350 return Markup._SELECTION_CARET;
343 else 351 else
344 return Markup._SELECTION_ANCHOR; 352 return Markup._SELECTION_ANCHOR;
345 } else if (index == sel.focusOffset && node == sel.focusNode) 353 } else if (index == sel.focusOffset && node == sel.focusNode)
346 return Markup._SELECTION_FOCUS; 354 return Markup._SELECTION_FOCUS;
347 355
348 return ''; 356 return '';
349 } 357 }
350 358
351 window.addEventListener('load', Markup.notifyDone, false); 359 window.addEventListener('load', Markup.notifyDone, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698