Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / elements / elements-panel-shadow-selection-on-refresh.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/elements-test.js"></script>
5 <script>
6
7 function test()
8 {
9
10     InspectorTest.runTestSuite([
11         function setup(next)
12         {
13             WebInspector.settings.showUAShadowDOM.set(true);
14             InspectorTest.expandElementsTree(next);
15         },
16
17         function testAuthorShadowRoot(next)
18         {
19             InspectorTest.findNode(isAuthorShadowRoot, selectReloadAndDump.bind(null, next));
20         },
21
22         function testUserAgentShadowRoot(next)
23         {
24             InspectorTest.findNode(isUserAgentShadowRoot, selectReloadAndDump.bind(null, next));
25         },
26
27         function testAuthorShadowRootChild(next)
28         {
29             InspectorTest.findNode(isAuthorShadowRootChild, selectReloadAndDump.bind(null, next));
30         },
31
32         function testUserAgentShadowRootChild(next)
33         {
34             InspectorTest.findNode(isUserAgentShadowRootChild, selectReloadAndDump.bind(null, next));
35         }
36     ]);
37
38     function isAuthorShadowRoot(node)
39     {
40         return node && node.shadowRootType() === WebInspector.DOMNode.ShadowRootTypes.Author;
41     }
42
43     function isUserAgentShadowRoot(node)
44     {
45         return node && node.shadowRootType() === WebInspector.DOMNode.ShadowRootTypes.UserAgent;
46     }
47
48     function isAuthorShadowRootChild(node)
49     {
50         return isAuthorShadowRoot(node.parentNode);
51     }
52
53     function isUserAgentShadowRootChild(node)
54     {
55         return isUserAgentShadowRoot(node.parentNode);
56     }
57
58     function selectReloadAndDump(next, node)
59     {
60         InspectorTest.selectNode(node).then(step0);
61
62         function step0()
63         {
64             InspectorTest.reloadPage(step1);
65         }
66
67         function step1()
68         {
69             InspectorTest.runAfterPendingDispatches(step2);
70         }
71
72         function step2()
73         {
74             dumpSelectedNode();
75             next();
76         }
77
78         function dumpSelectedNode()
79         {
80             var selectedElement = InspectorTest.firstElementsTreeOutline().selectedTreeElement;
81             var nodeName = selectedElement ? selectedElement.representedObject.nodeNameInCorrectCase() : "null";
82             InspectorTest.addResult("Selected node: '" + nodeName + "'");
83         }
84     }
85 }
86
87 </script>
88 </head>
89
90 <body onload="runTest()">
91 <p>
92 Tests that elements panel preserves selected shadow DOM node on page refresh.
93 </p>
94 <span id="hostElement"></span>
95 <script>
96 var root = document.getElementById("hostElement").createShadowRoot();
97 root.innerHTML = "<input type='text'>";
98 </script>
99 </body>
100 </html>