Upstream version 7.35.144.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / console-switch-contexts.html
1 <html>
2 <head>
3 <script src="console-test.js"></script>
4 <script src="inspector-test.js"></script>
5 <script>
6 function removeFrame() {
7     var frame = document.querySelector("#myFrame");
8     frame.parentElement.removeChild(frame);
9 }
10
11 function test()
12 {
13     InspectorTest.showConsolePanel();
14
15     var consoleView = WebInspector.ConsolePanel._view();
16     var selector = consoleView._executionContextSelector._selectElement;
17     var contextList = WebInspector.runtimeModel.contextLists()[1];
18     var contextId = 5;
19
20     function checkAndDumpExecutionContextSelector()
21     {
22         var option = selector.firstChild;
23         while (option) {
24             InspectorTest.addResult(option.textContent);
25             option = option.nextSibling;
26         }
27         var selectedOption = consoleView._executionContextSelector.selectedOption();
28         InspectorTest.addResult("Selected option: " +  (selectedOption ? selectedOption.textContent : "none!"));
29         InspectorTest.assertEquals(WebInspector.runtimeModel.currentExecutionContext(), consoleView._currentExecutionContext());
30     }
31
32     function addFakeExecutionContext()
33     {
34         contextId++;
35         var executionContext = new WebInspector.ExecutionContext(contextId, "fake-execution-context " + contextId , false);
36         contextList._addExecutionContext(executionContext);
37     }
38
39     InspectorTest.addResult("Initial State:")
40     checkAndDumpExecutionContextSelector();
41
42     InspectorTest.addResult("Test execution context addition:")
43     addFakeExecutionContext();
44     addFakeExecutionContext();
45
46     consoleView._executionContextSelector.select(selector.children[2]);
47     consoleView._executionContextChanged();
48
49     addFakeExecutionContext();
50     addFakeExecutionContext();
51
52     checkAndDumpExecutionContextSelector();
53
54     InspectorTest.addResult("Test frame navigation:")
55
56     contextList._frame._name = "changed frame " + contextList._frame._name;
57     contextList._frameNavigated(contextList._frame);
58
59     checkAndDumpExecutionContextSelector();
60
61     InspectorTest.addResult("Test frame detach: ")
62     InspectorTest.evaluateInPage("removeFrame()", onFrameRemoved);
63
64     function onFrameRemoved() {
65         checkAndDumpExecutionContextSelector();
66         InspectorTest.completeTest();
67     }
68 }
69
70 </script>
71 </head>
72
73 <body>
74 <p>
75
76 </p>
77 <iframe name="myIFrame" id="myFrame" src="http://localhost:8000/inspector/resources/console-cd-completions-iframe.html" onload="runTest()"></iframe>
78
79 </body>
80 </html>