diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-04 21:36:41 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-04-04 21:36:41 +0200 |
commit | 9f7f0f1172d67ab29e4f72eb1b34ab6f4bb231b1 (patch) | |
tree | d97bd3b77a6ee48cbaab34ab929aff7df4befd64 | |
parent | aea1fd640e01b5e36fb5e9f435681d8d4501d6f5 (diff) | |
download | UXP-9f7f0f1172d67ab29e4f72eb1b34ab6f4bb231b1.tar UXP-9f7f0f1172d67ab29e4f72eb1b34ab6f4bb231b1.tar.gz UXP-9f7f0f1172d67ab29e4f72eb1b34ab6f4bb231b1.tar.lz UXP-9f7f0f1172d67ab29e4f72eb1b34ab6f4bb231b1.tar.xz UXP-9f7f0f1172d67ab29e4f72eb1b34ab6f4bb231b1.zip |
Bug 1288768 - Better error reporting for network errors in workers
8 files changed, 7 insertions, 22 deletions
diff --git a/dom/security/test/csp/file_child-src_worker-redirect.html b/dom/security/test/csp/file_child-src_worker-redirect.html index 188f173b8..b0029935c 100644 --- a/dom/security/test/csp/file_child-src_worker-redirect.html +++ b/dom/security/test/csp/file_child-src_worker-redirect.html @@ -23,11 +23,8 @@ ); worker.onerror = function(error) { - var msg = error.message; - if (msg.match(/^NetworkError/) || msg.match(/Failed to load worker script/)) { - // this means CSP blocked it - msg = "blocked"; - } + // this means CSP blocked it + var msg = !("message" in error) ? "blocked" : e.message; window.parent.postMessage({id:page_id, message:msg}, 'http://mochi.test:8888'); error.preventDefault(); }; diff --git a/dom/security/test/general/test_block_script_wrong_mime.html b/dom/security/test/general/test_block_script_wrong_mime.html index f4da9c577..34d4b621b 100644 --- a/dom/security/test/general/test_block_script_wrong_mime.html +++ b/dom/security/test/general/test_block_script_wrong_mime.html @@ -53,9 +53,6 @@ function testWorker([mime, shouldLoad]) { }; worker.onerror = (error) => { ok(!shouldLoad, `worker with wrong mime '${mime}' should be blocked`); - let msg = error.message; - ok(msg.match(/^NetworkError/) || msg.match(/Failed to load worker script/), - "should gets correct error message"); error.preventDefault(); resolve(); } @@ -74,9 +71,6 @@ function testWorkerImportScripts([mime, shouldLoad]) { }; worker.onerror = (error) => { ok(!shouldLoad, `worker/importScripts with wrong mime '${mime}' should be blocked`); - let msg = error.message; - ok(msg.match(/^NetworkError/) || msg.match(/Failed to load worker script/), - "should gets correct error message"); error.preventDefault(); resolve(); } diff --git a/dom/workers/test/test_404.html b/dom/workers/test/test_404.html index e2e83a35e..15e5ded68 100644 --- a/dom/workers/test/test_404.html +++ b/dom/workers/test/test_404.html @@ -25,7 +25,6 @@ Tests of DOM Worker Threads worker.onerror = function(event) { is(event.target, worker); - is(event.message, 'NetworkError: Failed to load worker script at "nonexistent_worker.js"'); event.preventDefault(); SimpleTest.finish(); }; diff --git a/dom/workers/test/test_bug1036484.html b/dom/workers/test/test_bug1036484.html index 17b9d490f..49c31bbc9 100644 --- a/dom/workers/test/test_bug1036484.html +++ b/dom/workers/test/test_bug1036484.html @@ -25,7 +25,6 @@ function test(script) { worker.onerror = function(event) { is(event.target, worker); - ok(event.message.startsWith("NetworkError: Failed to load worker script")) event.preventDefault(); runTests(); }; diff --git a/dom/workers/test/test_loadError.html b/dom/workers/test/test_loadError.html index dc109b796..b9a215d11 100644 --- a/dom/workers/test/test_loadError.html +++ b/dom/workers/test/test_loadError.html @@ -13,15 +13,13 @@ <script class="testbody" type="text/javascript"> "use strict"; -var loadErrorMessage = 'SecurityError: Failed to load worker script at "about:blank"'; - function nextTest() { (function(){ function workerfunc() { var subworker = new Worker("about:blank"); subworker.onerror = function(e) { e.preventDefault(); - postMessage(e.message); + postMessage("ERROR"); } } var b = new Blob([workerfunc+'workerfunc();']); @@ -37,7 +35,7 @@ function nextTest() { return; } w.onmessage = function(e) { - is(e.data, loadErrorMessage, + is(e.data, "ERROR", "Should catch the error when loading inner script"); if (++i < 2) callworker(i); else SimpleTest.finish(); @@ -54,8 +52,6 @@ try { var worker = new Worker("about:blank"); worker.onerror = function(e) { e.preventDefault(); - is(e.message, loadErrorMessage, - "Should get the right error from the toplevel script"); nextTest(); } diff --git a/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm b/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm index 647a8b81e..d57dc29d5 100644 --- a/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm +++ b/testing/web-platform/tests/workers/Worker_cross_origin_security_err.htm @@ -8,7 +8,7 @@ async_test(function(t) { try { var w = new Worker("ftp://example.org/support/WorkerBasic.js"); w.onerror = t.step_func_done(function(e) { - assert_true(e instanceof ErrorEvent); + assert_true(e instanceof Event); }); } catch (e) { t.step_func_done(function(e) { assert_true(true); }); diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html index 2e0dd8db3..78d53164e 100644 --- a/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html @@ -16,7 +16,7 @@ function testSharedWorkerHelper(t, script) { try { var worker = new SharedWorker(script, ''); worker.onerror = t.step_func_done(function(e) { - assert_true(e instanceof ErrorEvent); + assert_true(e instanceof Event); }); } catch (e) { t.step_func_done(function(e) { assert_true(true); }); diff --git a/testing/web-platform/tests/workers/constructors/Worker/same-origin.html b/testing/web-platform/tests/workers/constructors/Worker/same-origin.html index 9b0148da3..bbc4382d0 100644 --- a/testing/web-platform/tests/workers/constructors/Worker/same-origin.html +++ b/testing/web-platform/tests/workers/constructors/Worker/same-origin.html @@ -14,7 +14,7 @@ function testSharedWorkerHelper(t, script) { try { var worker = new SharedWorker(script, ''); worker.onerror = t.step_func_done(function(e) { - assert_true(e instanceof ErrorEvent); + assert_true(e instanceof Event); }); } catch (e) { t.step_func_done(function(e) { assert_true(true); }); |