fune/dom/tests/mochitest/fetch/fetch_test_framework.js
Nikhil Marathe dd5c91927a Bug 1109751 - Consume FormData support in Fetch API. r=baku
--HG--
extra : transplant_source : %B0%0F%AB%E9%DBV%D1%86%980%28L%EC%CBI%0A%09%26%FDS
extra : histedit_source : 39fe8278cf135aa63a59ef4024432fab9ce5c7ee
2015-04-02 10:51:13 -07:00

49 lines
1.3 KiB
JavaScript

function testScript(script) {
function workerTest() {
return new Promise(function(resolve, reject) {
var worker = new Worker("worker_wrapper.js");
worker.onmessage = function(event) {
if (event.data.type == 'finish') {
resolve();
} else if (event.data.type == 'status') {
ok(event.data.status, "Worker fetch test: " + event.data.msg);
}
}
worker.onerror = function(event) {
reject("Worker error: " + event.message);
};
worker.postMessage({ "script": script });
});
}
function windowTest() {
return new Promise(function(resolve, reject) {
var scriptEl = document.createElement("script");
scriptEl.setAttribute("src", script);
scriptEl.onload = function() {
runTest().then(resolve, reject);
};
document.body.appendChild(scriptEl);
});
}
SimpleTest.waitForExplicitFinish();
// We have to run the window and worker tests sequentially since some tests
// set and compare cookies and running in parallel can lead to conflicting
// values.
windowTest()
.then(function() {
return workerTest();
})
.catch(function(e) {
ok(false, "Some test failed in " + script);
info(e);
info(e.message);
return Promise.resolve();
})
.then(function() {
SimpleTest.finish();
});
}