OLD | NEW |
1 var initialize_ElementTest = function() { | 1 var initialize_ElementTest = function() { |
2 | 2 |
3 InspectorTest.findNode = function(matchFunction, callback) | 3 InspectorTest.findNode = function(matchFunction, callback) |
4 { | 4 { |
5 callback = InspectorTest.safeWrap(callback); | 5 callback = InspectorTest.safeWrap(callback); |
6 var result = null; | 6 var result = null; |
7 var topLevelChildrenRequested = false; | 7 var topLevelChildrenRequested = false; |
8 var pendingRequests = 0; | 8 var pendingRequests = 0; |
9 function processChildren(topLevel, children) | 9 function processChildren(topLevel, children) |
10 { | 10 { |
11 pendingRequests--; | 11 pendingRequests--; |
12 if (result) | 12 if (result) |
13 return; | 13 return; |
14 | 14 |
15 for (var i = 0; children && i < children.length; ++i) { | 15 for (var i = 0; children && i < children.length; ++i) { |
16 var childNode = children[i]; | 16 var childNode = children[i]; |
17 if (matchFunction(childNode)) { | 17 if (matchFunction(childNode)) { |
18 result = childNode; | 18 result = childNode; |
19 callback(result); | 19 callback(result); |
20 return; | 20 return; |
21 } | 21 } |
22 if (childNode.shadowRoot && matchFunction(childNode.shadowRoot)) { | 22 if (childNode.shadowRoot && matchFunction(childNode.shadowRoot)) { |
23 result = childNode.shadowRoot; | 23 result = childNode.shadowRoot; |
24 callback(result); | 24 callback(result); |
25 return; | 25 return; |
26 } | 26 } |
27 pendingRequests++; | 27 pendingRequests++; |
28 childNode.getChildNodes(processChildren.bind(null, false)); | 28 childNode.getChildNodes(processChildren.bind(null, false)); |
29 if (childNode.shadowRoot) { | |
30 pendingRequests++; | |
31 childNode.shadowRoot.getChildNodes(processChildren.bind(null, fa
lse)); | |
32 } | |
33 } | 29 } |
34 | 30 |
35 if (topLevel) | 31 if (topLevel) |
36 topLevelChildrenRequested = true; | 32 topLevelChildrenRequested = true; |
37 if (topLevelChildrenRequested && !result && !pendingRequests) | 33 if (topLevelChildrenRequested && !result && !pendingRequests) |
38 callback(null); | 34 callback(null); |
39 } | 35 } |
40 pendingRequests++; | 36 pendingRequests++; |
41 | 37 |
42 WebInspector.domAgent.requestDocument(documentRequested.bind(this)); | 38 WebInspector.domAgent.requestDocument(documentRequested.bind(this)); |
43 function documentRequested(doc) | 39 function documentRequested(doc) |
44 { | 40 { |
45 doc.getChildNodes(processChildren.bind(null, true)); | 41 doc.getChildNodes(processChildren.bind(this, true)); |
46 } | 42 } |
47 }; | 43 }; |
48 | 44 |
49 InspectorTest.nodeWithId = function(idValue, callback) | 45 InspectorTest.nodeWithId = function(idValue, callback) |
50 { | 46 { |
51 function nodeIdMatches(node) | 47 function nodeIdMatches(node) |
52 { | 48 { |
53 return node.getAttribute("id") === idValue; | 49 return node.getAttribute("id") === idValue; |
54 } | 50 } |
55 InspectorTest.findNode(nodeIdMatches, callback); | 51 InspectorTest.findNode(nodeIdMatches, callback); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 }; | 231 }; |
236 | 232 |
237 InspectorTest.rangeText = function(range) | 233 InspectorTest.rangeText = function(range) |
238 { | 234 { |
239 if (!range) | 235 if (!range) |
240 return "[undefined-undefined]"; | 236 return "[undefined-undefined]"; |
241 return "[" + range.start + "-" + range.end + "]"; | 237 return "[" + range.start + "-" + range.end + "]"; |
242 }; | 238 }; |
243 | 239 |
244 }; | 240 }; |
OLD | NEW |