| 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 |
| 38 function dumpContextAndNext(next) |
| 12 { | 39 { |
| 13 previousContext = WebInspector.context.flavor(WebInspector.ExecutionCont
ext); | 40 var context = WebInspector.context.flavor(WebInspector.ExecutionContext)
; |
| 14 InspectorTest.selectNodeWithId("head", iframeNodeSelected); | 41 var node = WebInspector.context.flavor(WebInspector.DOMNode); |
| 15 } | 42 var contextName = context === mainContext ? "main" : "iframe"; |
| 16 | 43 var matchesNode = context.frameId === node.frameId(); |
| 17 function iframeNodeSelected() | 44 InspectorTest.addResult("Execution Context: " + contextName); |
| 18 { | 45 InspectorTest.addResult(" matches: " + matchesNode); |
| 19 var node = WebInspector.panels.elements.selectedDOMNode(); | 46 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 } | 47 } |
| 39 } | 48 } |
| 40 </script> | 49 </script> |
| 41 </head> | 50 </head> |
| 42 <body> | 51 <body> |
| 43 <p>Tests that the execution context is changed to match new selected node.</
p> | 52 <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> | 53 <iframe id="iframe-per-se" src="resources/set-outer-html-body-iframe.html" o
nload="runTest()"></iframe> |
| 45 <div id="element"></div> | 54 <div id="element"></div> |
| 46 </body> | 55 </body> |
| 47 </html> | 56 </html> |
| OLD | NEW |