diff --git a/dom/workers/URL.cpp b/dom/workers/URL.cpp index c1220fbab2c..2bb0f2802c4 100644 --- a/dom/workers/URL.cpp +++ b/dom/workers/URL.cpp @@ -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(); } diff --git a/dom/workers/test/Makefile.in b/dom/workers/test/Makefile.in index fa969da9c7d..741d7048f1c 100644 --- a/dom/workers/test/Makefile.in +++ b/dom/workers/test/Makefile.in @@ -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 diff --git a/dom/workers/test/jsm_url_worker.js b/dom/workers/test/jsm_url_worker.js new file mode 100644 index 00000000000..05667993d40 --- /dev/null +++ b/dom/workers/test/jsm_url_worker.js @@ -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' }); +} diff --git a/dom/workers/test/test_bug883784.jsm b/dom/workers/test/test_bug883784.jsm index 40066af0409..096272d3169 100644 --- a/dom/workers/test/test_bug883784.jsm +++ b/dom/workers/test/test_bug883784.jsm @@ -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); } }; diff --git a/dom/workers/test/test_url.html b/dom/workers/test/test_url.html index 0ce5976c2a3..3dc679709b9 100644 --- a/dom/workers/test/test_url.html +++ b/dom/workers/test/test_url.html @@ -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(); diff --git a/dom/workers/test/url_worker.js b/dom/workers/test/url_worker.js index 0c7c2d8b930..4d8c84fc610 100644 --- a/dom/workers/test/url_worker.js +++ b/dom/workers/test/url_worker.js @@ -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)) {