Bug 890928 - Crashfix for URL.createURL in subworker. r=bent

--HG--
rename : dom/workers/test/url_worker.js => dom/workers/test/jsm_url_worker.js
This commit is contained in:
Andrea Marchesini 2013-07-18 10:30:41 -04:00
Родитель f4e9714435
Коммит 8b22bbec69
6 изменённых файлов: 114 добавлений и 8 удалений

Просмотреть файл

@ -144,7 +144,7 @@ public:
principal = doc->NodePrincipal();
} else {
MOZ_ASSERT(mWorkerPrivate->IsChromeWorker());
MOZ_ASSERT_IF(!mWorkerPrivate->GetParent(), mWorkerPrivate->IsChromeWorker());
principal = mWorkerPrivate->GetPrincipal();
}
@ -199,7 +199,7 @@ public:
principal = doc->NodePrincipal();
} else {
MOZ_ASSERT(mWorkerPrivate->IsChromeWorker());
MOZ_ASSERT_IF(!mWorkerPrivate->GetParent(), mWorkerPrivate->IsChromeWorker());
principal = mWorkerPrivate->GetPrincipal();
}

Просмотреть файл

@ -144,7 +144,7 @@ MOCHITEST_CHROME_FILES = \
dom_worker_helper.js \
test_bug883784.xul \
test_bug883784.jsm \
url_worker.js \
jsm_url_worker.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,82 @@
onmessage = function(event) {
if (event.data != 0) {
var worker = new Worker('jsm_url_worker.js');
worker.onmessage = function(event) {
postMessage(event.data);
}
worker.postMessage(event.data - 1);
return;
}
status = false;
try {
if ((URL instanceof Object)) {
status = true;
}
} catch(e) {
}
postMessage({type: 'status', status: status, msg: 'URL object:' + URL});
status = false;
var blob = null;
try {
blob = new Blob([]);
status = true;
} catch(e) {
}
postMessage({type: 'status', status: status, msg: 'Blob:' + blob});
status = false;
var url = null;
try {
url = URL.createObjectURL(blob);
status = true;
} catch(e) {
}
postMessage({type: 'status', status: status, msg: 'Blob URL:' + url});
status = false;
try {
URL.revokeObjectURL(url);
status = true;
} catch(e) {
}
postMessage({type: 'status', status: status, msg: 'Blob Revoke URL'});
status = false;
var url = null;
try {
url = URL.createObjectURL(true);
} catch(e) {
status = true;
}
postMessage({type: 'status', status: status, msg: 'CreateObjectURL should fail if the arg is not a blob'});
status = false;
var url = null;
try {
url = URL.createObjectURL(blob);
status = true;
} catch(e) {
}
postMessage({type: 'status', status: status, msg: 'Blob URL2:' + url});
postMessage({type: 'url', url: url});
status = false;
try {
URL.createObjectURL(new Object());
} catch(e) {
status = true;
}
postMessage({type: 'status', status: status, msg: 'Exception wanted' });
postMessage({type: 'finish' });
}

Просмотреть файл

@ -2,7 +2,7 @@ this.EXPORTED_SYMBOLS = ["Test"];
this.Test = {
start: function(ok, is, finish) {
let worker = new ChromeWorker("url_worker.js");
let worker = new ChromeWorker("jsm_url_worker.js");
worker.onmessage = function(event) {
if (event.data.type == 'finish') {
@ -30,6 +30,6 @@ this.Test = {
finish();
};
worker.postMessage(true);
worker.postMessage(0);
}
};

Просмотреть файл

@ -21,7 +21,7 @@
is(event.target, worker);
if (event.data.type == 'finish') {
SimpleTest.finish();
runTest();
} else if (event.data.type == 'status') {
ok(event.data.status, event.data.msg);
} else if (event.data.type == 'url') {
@ -42,8 +42,22 @@
SimpleTest.finish();
};
worker.postMessage(true);
var tests = [
function() { worker.postMessage(0); },
function() { worker.postMessage(1); }
];
function runTest() {
if (!tests.length) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
runTest();
SimpleTest.waitForExplicitFinish();
</script>

Просмотреть файл

@ -1,4 +1,14 @@
onmessage = function() {
onmessage = function(event) {
if (event.data != 0) {
var worker = new Worker('url_worker.js');
worker.onmessage = function(event) {
postMessage(event.data);
}
worker.postMessage(event.data - 1);
return;
}
status = false;
try {
if ((URL instanceof Object)) {