OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> | 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
4 <script> | 4 <script> |
5 | 5 |
6 function createFrame() | 6 function createFrame() |
7 { | 7 { |
8 var frame = document.createElement("iframe"); | 8 var frame = document.createElement("iframe"); |
9 frame.src = "../resources/blank.html"; | 9 frame.src = "../resources/blank.html"; |
10 frame.id = "iframe"; | 10 frame.id = "iframe"; |
11 document.body.appendChild(frame); | 11 document.body.appendChild(frame); |
12 } | 12 } |
13 | 13 |
| 14 function createCraftedFrame() |
| 15 { |
| 16 var frame = document.createElement("iframe"); |
| 17 frame.src = "../resources/blank.html"; |
| 18 frame.id = "crafted-iframe"; |
| 19 document.body.appendChild(frame); |
| 20 frame.contentDocument.write("<div>crafted</div>"); |
| 21 } |
| 22 |
14 function test() | 23 function test() |
15 { | 24 { |
16 InspectorTest.evaluate = function(expression) | 25 InspectorTest.evaluate = function(expression) |
17 { | 26 { |
18 InspectorTest.sendCommandOrDie("Runtime.evaluate", {expression: expressi
on}); | 27 InspectorTest.sendCommandOrDie("Runtime.evaluate", {expression: expressi
on}); |
19 } | 28 } |
20 | 29 |
21 InspectorTest.fail = function(message) | 30 InspectorTest.fail = function(message) |
22 { | 31 { |
23 InspectorTest.log(message); | 32 InspectorTest.log(message); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 InspectorTest.evaluate("document.querySelector(\"#iframe\").remove()"); | 70 InspectorTest.evaluate("document.querySelector(\"#iframe\").remove()"); |
62 } | 71 } |
63 | 72 |
64 function frameContextDestroyedAfterFrameRemoved(executionContextId) | 73 function frameContextDestroyedAfterFrameRemoved(executionContextId) |
65 { | 74 { |
66 if (frameExecutionContextId !== executionContextId) { | 75 if (frameExecutionContextId !== executionContextId) { |
67 InspectorTest.fail("Deleted frame had execution context with id = "
+ frameExecutionContextId + " , but executionContext with id = " + executionCont
extId + " was removed"); | 76 InspectorTest.fail("Deleted frame had execution context with id = "
+ frameExecutionContextId + " , but executionContext with id = " + executionCont
extId + " was removed"); |
68 return; | 77 return; |
69 } | 78 } |
70 InspectorTest.log("Frame's context was destroyed"); | 79 InspectorTest.log("Frame's context was destroyed"); |
| 80 InspectorTest.log("Create new crafted frame"); |
| 81 InspectorTest.evaluate("createCraftedFrame()"); |
| 82 } |
| 83 |
| 84 function craftedFrameContextCreated(executionContextId) |
| 85 { |
| 86 InspectorTest.log("Crafted frame context was created"); |
| 87 frameExecutionContextId = executionContextId; |
| 88 InspectorTest.log("Remove crafted frame"); |
| 89 InspectorTest.evaluate("document.querySelector(\"#crafted-iframe\").remo
ve()"); |
| 90 } |
| 91 |
| 92 function craftedFrameContextDestroyedAfterFrameRemoved(executionContextId) |
| 93 { |
| 94 if (frameExecutionContextId !== executionContextId) { |
| 95 InspectorTest.fail("Deleted frame had execution context with id = "
+ frameExecutionContextId + " , but executionContext with id = " + executionCont
extId + " was removed"); |
| 96 return; |
| 97 } |
| 98 InspectorTest.log("Crafted frame's context was destroyed"); |
71 InspectorTest.completeTest(); | 99 InspectorTest.completeTest(); |
72 } | 100 } |
73 | 101 |
74 var contextCreationCounter = 0; | 102 var contextCreationCounter = 0; |
75 | 103 |
76 InspectorTest.eventHandler["Runtime.executionContextCreated"] = function(mes
sageObject) | 104 InspectorTest.eventHandler["Runtime.executionContextCreated"] = function(mes
sageObject) |
77 { | 105 { |
78 contextCreationCounter++; | 106 contextCreationCounter++; |
79 var executionContextId = messageObject.params.context.id; | 107 var executionContextId = messageObject.params.context.id; |
80 switch (contextCreationCounter) { | 108 switch (contextCreationCounter) { |
81 case 1: | 109 case 1: |
82 pageContextCreated(); | 110 pageContextCreated(); |
83 break; | 111 break; |
84 case 2: | 112 case 2: |
85 frameContextCreated(executionContextId); | 113 frameContextCreated(executionContextId); |
86 break; | 114 break; |
87 case 3: | 115 case 3: |
88 frameContextCreatedAfterNavigation(executionContextId); | 116 frameContextCreatedAfterNavigation(executionContextId); |
89 break; | 117 break; |
| 118 case 4: |
| 119 craftedFrameContextCreated(executionContextId); |
| 120 break; |
90 } | 121 } |
91 } | 122 } |
92 | 123 |
93 var contextDestructionCounter = 0; | 124 var contextDestructionCounter = 0; |
94 InspectorTest.eventHandler["Runtime.executionContextDestroyed"] = function(m
essageObject) | 125 InspectorTest.eventHandler["Runtime.executionContextDestroyed"] = function(m
essageObject) |
95 { | 126 { |
96 contextDestructionCounter++; | 127 contextDestructionCounter++; |
97 var executionContextId = messageObject.params.executionContextId; | 128 var executionContextId = messageObject.params.executionContextId; |
98 switch (contextDestructionCounter) { | 129 switch (contextDestructionCounter) { |
99 case 1: | 130 case 1: |
100 frameContextDestroyedBeforeNavigation(executionContextId); | 131 frameContextDestroyedBeforeNavigation(executionContextId); |
101 break; | 132 break; |
102 case 2: | 133 case 2: |
103 frameContextDestroyedAfterFrameRemoved(executionContextId); | 134 frameContextDestroyedAfterFrameRemoved(executionContextId); |
104 break; | 135 break; |
| 136 case 3: |
| 137 craftedFrameContextDestroyedAfterFrameRemoved(executionContextId); |
| 138 break; |
105 } | 139 } |
106 } | 140 } |
107 | 141 |
108 } | 142 } |
109 </script> | 143 </script> |
110 </head> | 144 </head> |
111 <body onload="runTest()"> | 145 <body onload="runTest()"> |
112 </body> | 146 </body> |
113 </html> | 147 </html> |
OLD | NEW |