| 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/workspace-test.js"></script> | 4 <script src="../../../http/tests/inspector/workspace-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function test() | 7 function test() |
| 8 { | 8 { |
| 9 InspectorTest.createWorkspace(true); | 9 InspectorTest.createWorkspace(true); |
| 10 var context = new WebInspector.Context(); | 10 var context = new UI.Context(); |
| 11 context.addFlavorChangeListener(WebInspector.ExecutionContext, executionCont
extChanged, this); | 11 context.addFlavorChangeListener(SDK.ExecutionContext, executionContextChange
d, this); |
| 12 context.addFlavorChangeListener(WebInspector.Target, targetChanged, this); | 12 context.addFlavorChangeListener(SDK.Target, targetChanged, this); |
| 13 new WebInspector.ExecutionContextSelector(InspectorTest.testTargetManager, c
ontext); | 13 new Components.ExecutionContextSelector(InspectorTest.testTargetManager, con
text); |
| 14 | 14 |
| 15 function executionContextChanged(event) | 15 function executionContextChanged(event) |
| 16 { | 16 { |
| 17 var executionContext = event.data; | 17 var executionContext = event.data; |
| 18 InspectorTest.addResult("Execution context selected: " + (executionConte
xt.isDefault ? executionContext.target().name() + ":" + executionContext.frameId
: executionContext.name)); | 18 InspectorTest.addResult("Execution context selected: " + (executionConte
xt.isDefault ? executionContext.target().name() + ":" + executionContext.frameId
: executionContext.name)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 function targetChanged(event) | 21 function targetChanged(event) |
| 22 { | 22 { |
| 23 InspectorTest.addResult("Target selected: " + event.data.name()); | 23 InspectorTest.addResult("Target selected: " + event.data.name()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 InspectorTest.addResult(""); | 27 InspectorTest.addResult(""); |
| 28 InspectorTest.addResult("Adding page target"); | 28 InspectorTest.addResult("Adding page target"); |
| 29 var pageTarget = InspectorTest.createMockTarget("page-target"); | 29 var pageTarget = InspectorTest.createMockTarget("page-target"); |
| 30 pageTarget.runtimeModel._executionContextCreated({id: "cs1", auxData: { isDe
fault: false, frameId: "42" }, origin: "origin", name: "contentScript1"}); | 30 pageTarget.runtimeModel._executionContextCreated({id: "cs1", auxData: { isDe
fault: false, frameId: "42" }, origin: "origin", name: "contentScript1"}); |
| 31 pageTarget.runtimeModel._executionContextCreated({id: "if1", auxData: { isDe
fault: true, frameId: "iframe1" }, origin: "origin", name: "iframeContext1"}); | 31 pageTarget.runtimeModel._executionContextCreated({id: "if1", auxData: { isDe
fault: true, frameId: "iframe1" }, origin: "origin", name: "iframeContext1"}); |
| 32 pageTarget.runtimeModel._executionContextCreated({id: "p1", auxData: { isDef
ault: true, frameId: "42" }, origin: "origin", name: "pageContext1Name"}); | 32 pageTarget.runtimeModel._executionContextCreated({id: "p1", auxData: { isDef
ault: true, frameId: "42" }, origin: "origin", name: "pageContext1Name"}); |
| 33 | 33 |
| 34 InspectorTest.addResult(""); | 34 InspectorTest.addResult(""); |
| 35 InspectorTest.addResult("Adding sw target"); | 35 InspectorTest.addResult("Adding sw target"); |
| 36 var swTarget = InspectorTest.createMockTarget("sw-target", null, WebInspecto
r.Target.Capability.Network | WebInspector.Target.Capability.Worker); | 36 var swTarget = InspectorTest.createMockTarget("sw-target", null, SDK.Target.
Capability.Network | SDK.Target.Capability.Worker); |
| 37 swTarget.runtimeModel._executionContextCreated({id: "sw1", auxData: { isDefa
ult: true, frameId: "" }, origin: "origin", name: "swContext1Name"}); | 37 swTarget.runtimeModel._executionContextCreated({id: "sw1", auxData: { isDefa
ult: true, frameId: "" }, origin: "origin", name: "swContext1Name"}); |
| 38 | 38 |
| 39 InspectorTest.addResult(""); | 39 InspectorTest.addResult(""); |
| 40 InspectorTest.addResult("Removing page main frame"); | 40 InspectorTest.addResult("Removing page main frame"); |
| 41 pageTarget.runtimeModel._executionContextDestroyed("p1"); | 41 pageTarget.runtimeModel._executionContextDestroyed("p1"); |
| 42 | 42 |
| 43 InspectorTest.addResult(""); | 43 InspectorTest.addResult(""); |
| 44 InspectorTest.addResult("Readding page main frame"); | 44 InspectorTest.addResult("Readding page main frame"); |
| 45 pageTarget.runtimeModel._executionContextCreated({id: "p2", auxData: { isDef
ault: true, frameId: "42" }, origin: "origin", name: "pageContext1Name"}); | 45 pageTarget.runtimeModel._executionContextCreated({id: "p2", auxData: { isDef
ault: true, frameId: "42" }, origin: "origin", name: "pageContext1Name"}); |
| 46 | 46 |
| 47 InspectorTest.addResult(""); | 47 InspectorTest.addResult(""); |
| 48 InspectorTest.addResult("Switching to sw target"); | 48 InspectorTest.addResult("Switching to sw target"); |
| 49 context.setFlavor(WebInspector.Target, swTarget); | 49 context.setFlavor(SDK.Target, swTarget); |
| 50 | 50 |
| 51 InspectorTest.addResult(""); | 51 InspectorTest.addResult(""); |
| 52 InspectorTest.addResult("Switching to page target"); | 52 InspectorTest.addResult("Switching to page target"); |
| 53 context.setFlavor(WebInspector.Target, pageTarget); | 53 context.setFlavor(SDK.Target, pageTarget); |
| 54 | 54 |
| 55 InspectorTest.addResult(""); | 55 InspectorTest.addResult(""); |
| 56 InspectorTest.addResult("User selected content script"); | 56 InspectorTest.addResult("User selected content script"); |
| 57 context.setFlavor(WebInspector.ExecutionContext, pageTarget.runtimeModel.exe
cutionContexts()[2]); | 57 context.setFlavor(SDK.ExecutionContext, pageTarget.runtimeModel.executionCon
texts()[2]); |
| 58 | 58 |
| 59 InspectorTest.addResult(""); | 59 InspectorTest.addResult(""); |
| 60 InspectorTest.addResult("Switching to sw target"); | 60 InspectorTest.addResult("Switching to sw target"); |
| 61 context.setFlavor(WebInspector.Target, swTarget); | 61 context.setFlavor(SDK.Target, swTarget); |
| 62 | 62 |
| 63 InspectorTest.addResult(""); | 63 InspectorTest.addResult(""); |
| 64 InspectorTest.addResult("Switching to page target"); | 64 InspectorTest.addResult("Switching to page target"); |
| 65 context.setFlavor(WebInspector.Target, pageTarget); | 65 context.setFlavor(SDK.Target, pageTarget); |
| 66 | 66 |
| 67 InspectorTest.addResult(""); | 67 InspectorTest.addResult(""); |
| 68 InspectorTest.addResult("User selected iframe1"); | 68 InspectorTest.addResult("User selected iframe1"); |
| 69 context.setFlavor(WebInspector.ExecutionContext, pageTarget.runtimeModel.exe
cutionContexts()[0]); | 69 context.setFlavor(SDK.ExecutionContext, pageTarget.runtimeModel.executionCon
texts()[0]); |
| 70 | 70 |
| 71 InspectorTest.addResult(""); | 71 InspectorTest.addResult(""); |
| 72 InspectorTest.addResult("Switching to sw target"); | 72 InspectorTest.addResult("Switching to sw target"); |
| 73 context.setFlavor(WebInspector.Target, swTarget); | 73 context.setFlavor(SDK.Target, swTarget); |
| 74 | 74 |
| 75 InspectorTest.addResult(""); | 75 InspectorTest.addResult(""); |
| 76 InspectorTest.addResult("Switching to page target"); | 76 InspectorTest.addResult("Switching to page target"); |
| 77 context.setFlavor(WebInspector.Target, pageTarget); | 77 context.setFlavor(SDK.Target, pageTarget); |
| 78 | 78 |
| 79 InspectorTest.addResult(""); | 79 InspectorTest.addResult(""); |
| 80 InspectorTest.addResult("Switching to sw target"); | 80 InspectorTest.addResult("Switching to sw target"); |
| 81 context.setFlavor(WebInspector.Target, swTarget); | 81 context.setFlavor(SDK.Target, swTarget); |
| 82 | 82 |
| 83 InspectorTest.addResult(""); | 83 InspectorTest.addResult(""); |
| 84 InspectorTest.addResult("Removing page main frame"); | 84 InspectorTest.addResult("Removing page main frame"); |
| 85 pageTarget.runtimeModel._executionContextDestroyed("p2"); | 85 pageTarget.runtimeModel._executionContextDestroyed("p2"); |
| 86 | 86 |
| 87 InspectorTest.addResult(""); | 87 InspectorTest.addResult(""); |
| 88 InspectorTest.addResult("Readding page main frame"); | 88 InspectorTest.addResult("Readding page main frame"); |
| 89 pageTarget.runtimeModel._executionContextCreated({id: "p3", auxData: { isDef
ault: true, frameId: "42" }, origin: "origin", name: "pageContext1Name"}); | 89 pageTarget.runtimeModel._executionContextCreated({id: "p3", auxData: { isDef
ault: true, frameId: "42" }, origin: "origin", name: "pageContext1Name"}); |
| 90 | 90 |
| 91 InspectorTest.completeTest(); | 91 InspectorTest.completeTest(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 </script> | 94 </script> |
| 95 </head> | 95 </head> |
| 96 | 96 |
| 97 <body onload="runTest()"> | 97 <body onload="runTest()"> |
| 98 <p> | 98 <p> |
| 99 Tests how execution context and target are selected. | 99 Tests how execution context and target are selected. |
| 100 </p> | 100 </p> |
| 101 | 101 |
| 102 </body> | 102 </body> |
| 103 </html> | 103 </html> |
| OLD | NEW |