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 WebInspector.Context(); |
11 context.addFlavorChangeListener(WebInspector.ExecutionContext, executionCont
extChanged, this); | 11 context.addFlavorChangeListener(WebInspector.ExecutionContext, executionCont
extChanged, this); |
12 context.addFlavorChangeListener(WebInspector.Target, targetChanged, this); | 12 context.addFlavorChangeListener(WebInspector.Target, targetChanged, this); |
13 new WebInspector.ExecutionContextSelector(InspectorTest.testTargetManager, c
ontext); | 13 new WebInspector.ExecutionContextSelector(InspectorTest.testTargetManager, c
ontext); |
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
: "")); | 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("Adding page target:"); | 27 InspectorTest.addResult(""); |
| 28 InspectorTest.addResult("Adding page target"); |
28 var pageTarget = InspectorTest.createMockTarget("page-target"); | 29 var pageTarget = InspectorTest.createMockTarget("page-target"); |
29 pageTarget.runtimeModel._executionContextCreated({id: "p1", isDefault: true,
origin: "origin", name: "pageContext1Name", frameId: "pageFrame1"}); | 30 pageTarget.runtimeModel._executionContextCreated({id: "cs1", isDefault: fals
e, origin: "origin", name: "contentScript1", frameId: "42"}); |
| 31 pageTarget.runtimeModel._executionContextCreated({id: "if1", isDefault: true
, origin: "origin", name: "iframeContext1", frameId: "iframe1"}); |
| 32 pageTarget.runtimeModel._executionContextCreated({id: "p1", isDefault: true,
origin: "origin", name: "pageContext1Name", frameId: "42"}); |
| 33 |
30 InspectorTest.addResult(""); | 34 InspectorTest.addResult(""); |
31 | 35 InspectorTest.addResult("Adding sw target"); |
32 InspectorTest.addResult("Adding sw target:"); | 36 var swTarget = InspectorTest.createMockTarget("sw-target", null, WebInspecto
r.Target.Type.Worker); |
33 var swTarget = InspectorTest.createMockTarget("sw-target"); | |
34 swTarget.runtimeModel._executionContextCreated({id: "sw1", isDefault: true,
origin: "origin", name: "swContext1Name", frameId: ""}); | 37 swTarget.runtimeModel._executionContextCreated({id: "sw1", isDefault: true,
origin: "origin", name: "swContext1Name", frameId: ""}); |
35 | 38 |
36 InspectorTest.addResult(""); | 39 InspectorTest.addResult(""); |
37 InspectorTest.addResult("Removing page target:"); | 40 InspectorTest.addResult("Removing page main frame"); |
38 pageTarget.runtimeModel._executionContextDestroyed("p1"); | 41 pageTarget.runtimeModel._executionContextDestroyed("p1"); |
39 | 42 |
40 InspectorTest.addResult(""); | 43 InspectorTest.addResult(""); |
41 InspectorTest.addResult("Readding page target:"); | 44 InspectorTest.addResult("Readding page main frame"); |
42 pageTarget.runtimeModel._executionContextCreated({id: "p2", isDefault: true,
origin: "", name: "", frameId: "pageFrame1"}); | 45 pageTarget.runtimeModel._executionContextCreated({id: "p2", isDefault: true,
origin: "origin", name: "pageContext1Name", frameId: "42"}); |
| 46 |
| 47 InspectorTest.addResult(""); |
| 48 InspectorTest.addResult("Switching to sw target"); |
| 49 context.setFlavor(WebInspector.Target, swTarget); |
| 50 |
| 51 InspectorTest.addResult(""); |
| 52 InspectorTest.addResult("Switching to page target"); |
| 53 context.setFlavor(WebInspector.Target, pageTarget); |
| 54 |
| 55 InspectorTest.addResult(""); |
| 56 InspectorTest.addResult("User selected content script"); |
| 57 context.setFlavor(WebInspector.ExecutionContext, pageTarget.runtimeModel.exe
cutionContexts()[0]); |
| 58 |
| 59 InspectorTest.addResult(""); |
| 60 InspectorTest.addResult("Switching to sw target"); |
| 61 context.setFlavor(WebInspector.Target, swTarget); |
| 62 |
| 63 InspectorTest.addResult(""); |
| 64 InspectorTest.addResult("Switching to page target"); |
| 65 context.setFlavor(WebInspector.Target, pageTarget); |
| 66 |
| 67 InspectorTest.addResult(""); |
| 68 InspectorTest.addResult("User selected iframe1"); |
| 69 context.setFlavor(WebInspector.ExecutionContext, pageTarget.runtimeModel.exe
cutionContexts()[1]); |
| 70 |
| 71 InspectorTest.addResult(""); |
| 72 InspectorTest.addResult("Switching to sw target"); |
| 73 context.setFlavor(WebInspector.Target, swTarget); |
| 74 |
| 75 InspectorTest.addResult(""); |
| 76 InspectorTest.addResult("Switching to page target"); |
| 77 context.setFlavor(WebInspector.Target, pageTarget); |
| 78 |
| 79 InspectorTest.addResult(""); |
| 80 InspectorTest.addResult("Switching to sw target"); |
| 81 context.setFlavor(WebInspector.Target, swTarget); |
| 82 |
| 83 InspectorTest.addResult(""); |
| 84 InspectorTest.addResult("Removing page main frame"); |
| 85 pageTarget.runtimeModel._executionContextDestroyed("p2"); |
| 86 |
| 87 InspectorTest.addResult(""); |
| 88 InspectorTest.addResult("Readding page main frame"); |
| 89 pageTarget.runtimeModel._executionContextCreated({id: "p3", isDefault: true,
origin: "origin", name: "pageContext1Name", frameId: "42"}); |
43 | 90 |
44 InspectorTest.completeTest(); | 91 InspectorTest.completeTest(); |
45 } | 92 } |
46 | 93 |
47 </script> | 94 </script> |
48 </head> | 95 </head> |
49 | 96 |
50 <body onload="runTest()"> | 97 <body onload="runTest()"> |
51 <p> | 98 <p> |
52 Tests that re-adding a removed target restores the last selected execution conte
xt. | 99 Tests how execution context and target are selected. |
53 </p> | 100 </p> |
54 | 101 |
55 </body> | 102 </body> |
56 </html> | 103 </html> |
OLD | NEW |