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 function test() | 6 function test() |
7 { | 7 { |
8 InspectorTest.expandElementsTree(selectNode); | 8 var mainContext; |
9 var previousContext; | |
10 | 9 |
11 function selectNode() | 10 InspectorTest.runTestSuite([ |
| 11 function initialize(next) |
| 12 { |
| 13 InspectorTest.expandElementsTree(onExpanded); |
| 14 |
| 15 function onExpanded() |
| 16 { |
| 17 mainContext = WebInspector.context.flavor(WebInspector.Execution
Context); |
| 18 dumpContextAndNext(next); |
| 19 } |
| 20 }, |
| 21 |
| 22 function selectIframeInnerNode(next) |
| 23 { |
| 24 InspectorTest.selectNodeWithId("head", dumpContextAndNext.bind(null,
next)); |
| 25 }, |
| 26 |
| 27 function selectMainFrameNode(next) |
| 28 { |
| 29 InspectorTest.selectNodeWithId("element", dumpContextAndNext.bind(nu
ll, next)); |
| 30 }, |
| 31 |
| 32 function selectIframeNode(next) |
| 33 { |
| 34 InspectorTest.selectNodeWithId("iframe-per-se", dumpContextAndNext.b
ind(null, next)); |
| 35 }, |
| 36 |
| 37 function selectIframeImmediateChild(next) |
| 38 { |
| 39 var iframe = WebInspector.context.flavor(WebInspector.DOMNode); |
| 40 var child = iframe.firstChild; |
| 41 InspectorTest.selectNode(child).then(dumpContextAndNext.bind(null, n
ext)); |
| 42 }, |
| 43 ]); |
| 44 |
| 45 function dumpContextAndNext(next) |
12 { | 46 { |
13 previousContext = WebInspector.context.flavor(WebInspector.ExecutionCont
ext); | 47 var context = WebInspector.context.flavor(WebInspector.ExecutionContext)
; |
14 InspectorTest.selectNodeWithId("head", iframeNodeSelected); | 48 var node = WebInspector.context.flavor(WebInspector.DOMNode); |
15 } | 49 var contextName = context === mainContext ? "main" : "iframe"; |
16 | 50 var matchesNode = context.frameId === node.frameId(); |
17 function iframeNodeSelected() | 51 InspectorTest.addResult("Execution Context: " + contextName); |
18 { | 52 InspectorTest.addResult(" matches: " + matchesNode); |
19 var node = WebInspector.panels.elements.selectedDOMNode(); | 53 next(); |
20 var currentContext = WebInspector.context.flavor(WebInspector.ExecutionC
ontext); | |
21 InspectorTest.addResult("Context has changed:"); | |
22 InspectorTest.addResult(previousContext.id !== currentContext.id); | |
23 InspectorTest.addResult("Context matches node frameId: "); | |
24 InspectorTest.addResult(currentContext.frameId == node.frameId()); | |
25 previousContext = currentContext; | |
26 InspectorTest.selectNodeWithId("element", elementSelected); | |
27 } | |
28 | |
29 function elementSelected() | |
30 { | |
31 var node = WebInspector.panels.elements.selectedDOMNode(); | |
32 var currentContext = WebInspector.context.flavor(WebInspector.ExecutionC
ontext); | |
33 InspectorTest.addResult("Context has changed:"); | |
34 InspectorTest.addResult(previousContext.id !== currentContext.id); | |
35 InspectorTest.addResult("Context matches node frameId: "); | |
36 InspectorTest.addResult(currentContext.frameId == node.frameId()); | |
37 InspectorTest.completeTest(); | |
38 } | 54 } |
39 } | 55 } |
40 </script> | 56 </script> |
41 </head> | 57 </head> |
42 <body> | 58 <body> |
43 <p>Tests that the execution context is changed to match new selected node.</
p> | 59 <p>Tests that the execution context is changed to match new selected node.</
p> |
44 <iframe src="resources/set-outer-html-body-iframe.html" onload="runTest()"><
/iframe> | 60 <iframe id="iframe-per-se" src="resources/set-outer-html-body-iframe.html" o
nload="runTest()"></iframe> |
45 <div id="element"></div> | 61 <div id="element"></div> |
46 </body> | 62 </body> |
47 </html> | 63 </html> |
OLD | NEW |