OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="../../http/tests/inspector/elements-test.js"></script> | 4 <script src="../../http/tests/inspector/elements-test.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 function test() | 7 function test() |
8 { | 8 { |
9 InspectorTest.selectNodeWithId("test-topic", step1); | |
10 | 9 |
11 function step1() | 10 InspectorTest.runTestSuite([ |
| 11 function setup(next) |
| 12 { |
| 13 WebInspector.settings.showUAShadowDOM.set(true); |
| 14 InspectorTest.expandElementsTree(next); |
| 15 }, |
| 16 |
| 17 function testOrdinaryElement(next) |
| 18 { |
| 19 selectReloadAndDump(next, InspectorTest.expandedNodeWithId("test-top
ic")); |
| 20 }, |
| 21 |
| 22 function testAuthorShadowRoot(next) |
| 23 { |
| 24 InspectorTest.findNode(isAuthorShadowRoot, selectReloadAndDump.bind(
null, next)); |
| 25 }, |
| 26 |
| 27 function testUserAgentShadowRoot(next) |
| 28 { |
| 29 InspectorTest.findNode(isUserAgentShadowRoot, selectReloadAndDump.bi
nd(null, next)); |
| 30 }, |
| 31 |
| 32 function testAuthorShadowRootChild(next) |
| 33 { |
| 34 InspectorTest.findNode(isAuthorShadowRootChild, selectReloadAndDump.
bind(null, next)); |
| 35 }, |
| 36 |
| 37 function testUserAgentShadowRootChild(next) |
| 38 { |
| 39 InspectorTest.findNode(isUserAgentShadowRootChild, selectReloadAndDu
mp.bind(null, next)); |
| 40 } |
| 41 ]); |
| 42 |
| 43 function isAuthorShadowRoot(node) |
12 { | 44 { |
13 InspectorTest.reloadPage(step2); | 45 return node && node.shadowRootType() === WebInspector.DOMNode.ShadowRoot
Types.Author; |
14 } | |
15 | |
16 function step2() | |
17 { | |
18 InspectorTest.runAfterPendingDispatches(step3); | |
19 } | 46 } |
20 | 47 |
21 function step3() | 48 function isUserAgentShadowRoot(node) |
22 { | 49 { |
23 // We should have "test-topic" element selected after refresh. | 50 return node && node.shadowRootType() === WebInspector.DOMNode.ShadowRoot
Types.UserAgent; |
24 var selectedElement = WebInspector.panels.elements.treeOutline.selectedT
reeElement; | 51 } |
25 var nodeName = selectedElement ? selectedElement.representedObject.nodeN
ame() : "null"; | 52 |
26 InspectorTest.addResult("Selected element should be 'P', was: '" + nodeN
ame + "'"); | 53 function isAuthorShadowRootChild(node) |
27 InspectorTest.completeTest(); | 54 { |
| 55 return isAuthorShadowRoot(node.parentNode); |
| 56 } |
| 57 |
| 58 function isUserAgentShadowRootChild(node) |
| 59 { |
| 60 return isUserAgentShadowRoot(node.parentNode); |
| 61 } |
| 62 |
| 63 function selectReloadAndDump(next, node) |
| 64 { |
| 65 InspectorTest.selectNode(node); |
| 66 InspectorTest.reloadPage(step1); |
| 67 |
| 68 function step1() |
| 69 { |
| 70 InspectorTest.runAfterPendingDispatches(step2); |
| 71 } |
| 72 |
| 73 function step2() |
| 74 { |
| 75 dumpSelectedNode(); |
| 76 next(); |
| 77 } |
| 78 |
| 79 function dumpSelectedNode() |
| 80 { |
| 81 var selectedElement = WebInspector.panels.elements.treeOutline.selec
tedTreeElement; |
| 82 var nodeName = selectedElement ? selectedElement.representedObject.n
odeNameInCorrectCase() : "null"; |
| 83 InspectorTest.addResult("Selected node: '" + nodeName + "'"); |
| 84 } |
28 } | 85 } |
29 } | 86 } |
30 | 87 |
31 </script> | 88 </script> |
32 </head> | 89 </head> |
33 | 90 |
34 <body onload="runTest()"> | 91 <body onload="runTest()"> |
35 <p id="test-topic"> | 92 <p id="test-topic"> |
36 Tests that elements panel preserves selected node on page refresh. | 93 Tests that elements panel preserves selected node on page refresh. |
37 </p> | 94 </p> |
38 | 95 <span id="hostElement"></span> |
| 96 <script> |
| 97 var root = document.getElementById("hostElement").createShadowRoot(); |
| 98 root.innerHTML = "<input type='text'>"; |
| 99 </script> |
39 </body> | 100 </body> |
40 </html> | 101 </html> |
OLD | NEW |