зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1273070 P2 Execute fetch() mochitests in nested workers. r=khuey
This commit is contained in:
Родитель
f671f48c5d
Коммит
f3cfddb783
|
@ -36,6 +36,27 @@ function testScript(script) {
|
|||
});
|
||||
}
|
||||
|
||||
function nestedWorkerTest() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var worker = new Worker("nested_worker_wrapper.js");
|
||||
worker.onmessage = function(event) {
|
||||
if (event.data.context != "NestedWorker") {
|
||||
return;
|
||||
}
|
||||
if (event.data.type == 'finish') {
|
||||
resolve();
|
||||
} else if (event.data.type == 'status') {
|
||||
ok(event.data.status, event.data.context + ": " + event.data.msg);
|
||||
}
|
||||
}
|
||||
worker.onerror = function(event) {
|
||||
reject("Nested Worker error: " + event.message);
|
||||
};
|
||||
|
||||
worker.postMessage({ "script": script });
|
||||
});
|
||||
}
|
||||
|
||||
function serviceWorkerTest() {
|
||||
var isB2G = !navigator.userAgent.includes("Android") &&
|
||||
/Mobile|Tablet/.test(navigator.userAgent);
|
||||
|
@ -112,6 +133,9 @@ function testScript(script) {
|
|||
.then(function() {
|
||||
return workerTest();
|
||||
})
|
||||
.then(function() {
|
||||
return nestedWorkerTest();
|
||||
})
|
||||
.then(function() {
|
||||
return serviceWorkerTest();
|
||||
})
|
||||
|
|
|
@ -10,6 +10,7 @@ support-files =
|
|||
test_request.js
|
||||
test_response.js
|
||||
utils.js
|
||||
nested_worker_wrapper.js
|
||||
worker_wrapper.js
|
||||
message_receiver.html
|
||||
reroute.html
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
addEventListener('message', function nestedWorkerWrapperOnMessage(evt) {
|
||||
removeEventListener('message', nestedWorkerWrapperOnMessage);
|
||||
|
||||
var worker = new Worker('worker_wrapper.js');
|
||||
|
||||
worker.addEventListener('message', function(evt) {
|
||||
self.postMessage({
|
||||
context: 'NestedWorker',
|
||||
type: evt.data.type,
|
||||
status: evt.data.status,
|
||||
msg: evt.data.msg,
|
||||
});
|
||||
});
|
||||
|
||||
worker.addEventListener('error', function(evt) {
|
||||
self.postMessage({
|
||||
context: 'NestedWorker',
|
||||
type: 'status',
|
||||
status: false,
|
||||
msg: 'Nested worker error: ' + evt.message,
|
||||
});
|
||||
});
|
||||
|
||||
worker.postMessage(evt.data);
|
||||
});
|
Загрузка…
Ссылка в новой задаче