|
Lines 43-48
function test()
a/LayoutTests/inspector/worker/worker-create-and-terminate.html_sec1
|
| 43 |
ProtocolTest.log("No Workers"); |
43 |
ProtocolTest.log("No Workers"); |
| 44 |
} |
44 |
} |
| 45 |
|
45 |
|
|
|
46 |
async function checkInternalProperties(expression, {terminated} = {}) { |
| 47 |
let evaluateResult = await InspectorProtocol.awaitCommand({ |
| 48 |
method: "Runtime.evaluate", |
| 49 |
params: { |
| 50 |
expression, |
| 51 |
objectGroup: "test", |
| 52 |
}, |
| 53 |
}); |
| 54 |
|
| 55 |
ProtocolTest.assert(evaluateResult.result.type === "object", `Evaluate result of '${expression}' should have type 'object'.`); |
| 56 |
ProtocolTest.assert(evaluateResult.result.className === "Worker", `Evaluate result of '${expression}' should have className 'Worker'.`); |
| 57 |
|
| 58 |
let getPropertiesResult = await InspectorProtocol.awaitCommand({ |
| 59 |
method: "Runtime.getProperties", |
| 60 |
params: { |
| 61 |
objectId: evaluateResult.result.objectId, |
| 62 |
}, |
| 63 |
}); |
| 64 |
|
| 65 |
let internalProperties = getPropertiesResult.internalProperties; |
| 66 |
ProtocolTest.assert(internalProperties.length === 1, `Worker '${expression}' should only have one internal property.`); |
| 67 |
|
| 68 |
ProtocolTest.assert(internalProperties[0].name === "terminated", `Worker '${expression}' should have 'terminated' internal property.`); |
| 69 |
ProtocolTest.assert(internalProperties[0].value.type === "boolean", `Internal 'terminated' property of '${expression}' should be a boolean.`); |
| 70 |
ProtocolTest.assert(internalProperties[0].value.value === terminated, `Internal 'terminated' property of '${expression}' should have value '${terminated}'.`); |
| 71 |
} |
| 72 |
|
| 46 |
|
73 |
|
| 47 |
let triggerNextCreate; |
74 |
let triggerNextCreate; |
| 48 |
let triggerNextTerminate; |
75 |
let triggerNextTerminate; |
|
Lines 78-147
function test()
a/LayoutTests/inspector/worker/worker-create-and-terminate.html_sec2
|
| 78 |
suite.addTestCase({ |
105 |
suite.addTestCase({ |
| 79 |
name: "Worker.enable", |
106 |
name: "Worker.enable", |
| 80 |
description: "Worker.enable informs the frontend of the two existing Workers", |
107 |
description: "Worker.enable informs the frontend of the two existing Workers", |
| 81 |
test(resolve, reject) { |
108 |
async test() { |
| 82 |
InspectorProtocol.awaitCommand({method: "Worker.enable", params: {}}) |
109 |
await InspectorProtocol.awaitCommand({method: "Worker.enable", params: {}}); |
| 83 |
.then(() => { |
110 |
|
| 84 |
ProtocolTest.expectEqual(workers.length, 2, "Should be informed of two existing Workers."); |
111 |
ProtocolTest.expectEqual(workers.length, 2, "Should be informed of two existing Workers."); |
| 85 |
dumpWorkers(); |
112 |
dumpWorkers(); |
| 86 |
resolve(); |
113 |
|
| 87 |
}).catch(reject); |
114 |
await Promise.all([ |
|
|
115 |
checkInternalProperties(`worker1`, {terminated: false}), |
| 116 |
checkInternalProperties(`worker2`, {terminated: false}), |
| 117 |
]); |
| 88 |
} |
118 |
} |
| 89 |
}); |
119 |
}); |
| 90 |
|
120 |
|
| 91 |
suite.addTestCase({ |
121 |
suite.addTestCase({ |
| 92 |
name: "Worker.workerCreated", |
122 |
name: "Worker.workerCreated", |
| 93 |
description: "Should receive a Worker.workerCreated event when creating a Worker.", |
123 |
description: "Should receive a Worker.workerCreated event when creating a Worker.", |
| 94 |
test(resolve, reject) { |
124 |
async test() { |
| 95 |
ProtocolTest.evaluateInPage("createWorker3()"); |
125 |
await Promise.all([ |
| 96 |
waitForWorkerCreatedEvent() |
126 |
waitForWorkerCreatedEvent(), |
| 97 |
.then(() => { |
127 |
ProtocolTest.evaluateInPage("createWorker3()"), |
| 98 |
ProtocolTest.pass("Worker.workerCreated"); |
128 |
]); |
| 99 |
dumpWorkers(); |
129 |
|
| 100 |
resolve(); |
130 |
ProtocolTest.pass("Worker.workerCreated"); |
| 101 |
}).catch(reject); |
131 |
dumpWorkers(); |
|
|
132 |
|
| 133 |
await Promise.all([ |
| 134 |
checkInternalProperties(`worker1`, {terminated: false}), |
| 135 |
checkInternalProperties(`worker2`, {terminated: false}), |
| 136 |
checkInternalProperties(`worker3`, {terminated: false}), |
| 137 |
]); |
| 102 |
} |
138 |
} |
| 103 |
}); |
139 |
}); |
| 104 |
|
140 |
|
| 105 |
suite.addTestCase({ |
141 |
suite.addTestCase({ |
| 106 |
name: "Worker.workerTerminated.Page", |
142 |
name: "Worker.workerTerminated.Page", |
| 107 |
description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Page.", |
143 |
description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Page.", |
| 108 |
test(resolve, reject) { |
144 |
async test() { |
| 109 |
ProtocolTest.evaluateInPage("terminateWorker2FromPage()"); |
145 |
await Promise.all([ |
| 110 |
waitForWorkerTerminatedEvent() |
146 |
waitForWorkerTerminatedEvent(), |
| 111 |
.then(() => { |
147 |
ProtocolTest.evaluateInPage("terminateWorker2FromPage()"), |
| 112 |
ProtocolTest.pass("Worker.workerTerminated"); |
148 |
]); |
| 113 |
dumpWorkers(); |
149 |
|
| 114 |
resolve(); |
150 |
ProtocolTest.pass("Worker.workerTerminated"); |
| 115 |
}).catch(reject); |
151 |
dumpWorkers(); |
|
|
152 |
|
| 153 |
await Promise.all([ |
| 154 |
checkInternalProperties(`worker1`, {terminated: false}), |
| 155 |
checkInternalProperties(`worker2`, {terminated: true}), |
| 156 |
checkInternalProperties(`worker3`, {terminated: false}), |
| 157 |
]); |
| 116 |
} |
158 |
} |
| 117 |
}); |
159 |
}); |
| 118 |
|
160 |
|
| 119 |
suite.addTestCase({ |
161 |
suite.addTestCase({ |
| 120 |
name: "Worker.workerTerminated.Worker", |
162 |
name: "Worker.workerTerminated.Worker", |
| 121 |
description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Worker.", |
163 |
description: "Should receive a Worker.workerTerminated event when terminating a Worker from the Worker.", |
| 122 |
test(resolve, reject) { |
164 |
async test() { |
| 123 |
ProtocolTest.evaluateInPage("terminateWorker3FromWorker()"); |
165 |
await Promise.all([ |
| 124 |
waitForWorkerTerminatedEvent() |
166 |
waitForWorkerTerminatedEvent(), |
| 125 |
.then(() => { |
167 |
ProtocolTest.evaluateInPage("terminateWorker3FromWorker()"), |
| 126 |
ProtocolTest.pass("Worker.workerTerminated"); |
168 |
]); |
| 127 |
dumpWorkers(); |
169 |
|
| 128 |
resolve(); |
170 |
ProtocolTest.pass("Worker.workerTerminated"); |
| 129 |
}).catch(reject); |
171 |
dumpWorkers(); |
|
|
172 |
|
| 173 |
await Promise.all([ |
| 174 |
checkInternalProperties(`worker1`, {terminated: false}), |
| 175 |
checkInternalProperties(`worker2`, {terminated: true}), |
| 176 |
]); |
| 130 |
} |
177 |
} |
| 131 |
}); |
178 |
}); |
| 132 |
|
179 |
|
| 133 |
suite.addTestCase({ |
180 |
suite.addTestCase({ |
| 134 |
name: "Worker.workerTerminated.GC", |
181 |
name: "Worker.workerTerminated.GC", |
| 135 |
description: "Should receive a Worker.workerTerminated event when terminating a Worker via Garbage Collection.", |
182 |
description: "Should receive a Worker.workerTerminated event when terminating a Worker via Garbage Collection.", |
| 136 |
test(resolve, reject) { |
183 |
async test() { |
| 137 |
ProtocolTest.evaluateInPage("terminateWorker1ViaCollection()"); |
184 |
let workerTerminatedPromise = waitForWorkerTerminatedEvent(); |
| 138 |
InspectorProtocol.sendCommand("Heap.gc", {}); |
185 |
await ProtocolTest.evaluateInPage("terminateWorker1ViaCollection()"); |
| 139 |
waitForWorkerTerminatedEvent() |
186 |
await InspectorProtocol.awaitCommand({method: "Runtime.releaseObjectGroup", params: {objectGroup: "test"}}); |
| 140 |
.then(() => { |
187 |
await InspectorProtocol.awaitCommand({method: "Heap.gc", params: {}}); |
| 141 |
ProtocolTest.pass("Worker.workerTerminated"); |
188 |
await workerTerminatedPromise; |
| 142 |
dumpWorkers(); |
189 |
|
| 143 |
resolve(); |
190 |
ProtocolTest.pass("Worker.workerTerminated"); |
| 144 |
}).catch(reject); |
191 |
dumpWorkers(); |
|
|
192 |
|
| 193 |
await checkInternalProperties(`worker2`, {terminated: true}); |
| 145 |
} |
194 |
} |
| 146 |
}); |
195 |
}); |
| 147 |
|
196 |
|