45d0be44aee42d566121ceb43b8a6810a70422aa
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / console-cd-completions.html
1 <html>
2 <head>
3 <script src="console-test.js"></script>
4 <script src="inspector-test.js"></script>
5 <script>
6
7 function test()
8 {
9     InspectorTest.showConsolePanel();
10     var selector = WebInspector.consoleView._executionContextSelector._selectElement;
11     var option = selector.firstChild;
12     while (option) {
13         if (option.textContent && option.textContent.startsWith("myIFrame"))
14             break;
15         option = option.nextSibling;
16     }
17     if (!option) {
18         InspectorTest.addResult("FAILED: myIFrame not found in the context list");
19         InspectorTest.completeTest();
20         return;
21     }
22     option.selected = true;
23     WebInspector.consoleView._executionContextChanged();
24
25     WebInspector.runtimeModel._completionsForExpression("", "myGlob", false, checkCompletions.bind(this));
26     function checkCompletions(completions)
27     {
28         var expected = ["myGlobalVar", "myGlobalFunction"];
29         for (var i = 0; i < expected.length; ++i) {
30             if (completions.indexOf(expected[i]) !== -1)
31                 InspectorTest.addResult(expected[i]);
32             else
33                 InspectorTest.addResult("NOT FOUND: " + expected[i]);
34         }
35         InspectorTest.dumpConsoleMessages();
36         InspectorTest.completeTest();
37     }
38 }
39
40 </script>
41 </head>
42
43 <body>
44 <p>
45 Test that completions in the context of an iframe with a different origin will
46 result in names of its global variables. Test passes if all global variables
47 are found among completions AND there are NO console messages.
48 <a href="https://bugs.webkit.org/show_bug.cgi?id=65457">Bug 65457.</a>
49 </p>
50 <iframe name="myIFrame" src="http://localhost:8000/inspector/resources/console-cd-completions-iframe.html" onload="runTest()"></iframe>
51
52 </body>
53 </html>