Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector-enabled / shadow-dom-rules-restart.html
1 <html>
2 <head>
3 <script src="../inspector/inspector-test.js"></script>
4 <script src="../inspector/elements-test.js"></script>
5 <script>
6
7 function reopenWebInspector(objectId)
8 {
9     window.didReopen = 1;
10     testRunner.closeWebInspector();
11     setTimeout(function() {
12       testRunner.showWebInspector();
13       runTest();
14     }, 0);
15 }
16
17 function createShadowRoot()
18 {
19     delete window.didReopen;
20     if (window.testRunner)
21         testRunner.waitUntilDone();
22     var template = document.querySelector('#tmpl');
23     var root = document.querySelector('#host').createShadowRoot();
24     root.appendChild(template.content.cloneNode(true));
25     if (window.testRunner)
26         testRunner.showWebInspector();
27     runTest();
28 }
29
30 function test()
31 {
32     RuntimeAgent.evaluate("window.didReopen", dispatch);
33
34     function dispatch(error, result, wasThrown)
35     {
36         if (result.type !== "number") {
37             InspectorTest.evaluateInPage("console.log('Opening front-end for the first time')");
38             runTests(reopenInspector);
39         } else {
40             InspectorTest.evaluateInPage("console.log('Opening front-end second time')");
41             runTests(InspectorTest.completeTest);
42         }
43     }
44
45     function reopenInspector()
46     {
47         InspectorTest.evaluateInPage("reopenWebInspector()");
48     }
49
50     function runTests(callback)
51     {
52         InspectorTest.selectNodeAndWaitForStyles("inner", step2);
53         
54         function step2()
55         {
56             InspectorTest.dumpSelectedElementStyles(true);
57             callback();
58         }
59     }
60 }
61 </script>
62 </head>
63
64 <body onload="createShadowRoot()">
65 <p>This test checks that style sheets hosted inside shadow roots could be inspected if inspector is reopened.</p>
66 <div id="host"></div>
67 <template id="tmpl">
68     <style> .red { color: red; } </style>
69     <div id="inner" class="red">hi!</div>
70 </template>
71 </body>
72 </html>