diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 53474bded53b..321b602622ea 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -1879,9 +1879,8 @@ ScriptExecutorRunnable::ShutdownScriptLoader(JSContext* aCx, // 1) mScriptLoader.mRv.Failed(). In that case we just want to leave it // as-is, except if it has a JS exception and we need to mute JS // exceptions. In that case, we log the exception without firing any - // events and then replace it on the ErrorResult with a generic - // NS_ERROR_FAILURE for lack of anything better. XXXbz: This should - // throw a NetworkError per spec updates. See bug 1249673. + // events and then replace it on the ErrorResult with a NetworkError, + // per spec. // // 2) mScriptLoader.mRv succeeded. As far as I can tell, this can only // happen when loading the main worker script and @@ -1891,7 +1890,7 @@ ScriptExecutorRunnable::ShutdownScriptLoader(JSContext* aCx, if (mScriptLoader.mRv.Failed()) { if (aMutedError && mScriptLoader.mRv.IsJSException()) { LogExceptionToConsole(aCx, aWorkerPrivate); - mScriptLoader.mRv.Throw(NS_ERROR_FAILURE); + mScriptLoader.mRv.Throw(NS_ERROR_DOM_NETWORK_ERR); } } else { mScriptLoader.mRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); diff --git a/dom/workers/test/importScripts_3rdParty_worker.js b/dom/workers/test/importScripts_3rdParty_worker.js index 11c438db8fe6..ebf2d3b1497a 100644 --- a/dom/workers/test/importScripts_3rdParty_worker.js +++ b/dom/workers/test/importScripts_3rdParty_worker.js @@ -29,12 +29,12 @@ onmessage = function(a) { var fileName2 = 42; if (a.data.test == 'none') { - importScripts([crossOriginURL.href]); + importScripts(crossOriginURL.href); return; } try { - importScripts([sameOriginURL.href]); + importScripts(sameOriginURL.href); } catch(e) { if (!(e instanceof SyntaxError)) { postMessage({ result: false }); @@ -50,13 +50,17 @@ onmessage = function(a) { } if (a.data.test == 'try') { + var exception; try { - importScripts([crossOriginURL.href]); + importScripts(crossOriginURL.href); } catch(e) { fileName2 = e.filename; + exception = e; } - postMessage({ result: fileName2 == workerURL }); + postMessage({ result: fileName2 == workerURL && + exception.name == "NetworkError" && + exception.code == DOMException.NETWORK_ERR }); return; } @@ -74,5 +78,5 @@ onmessage = function(a) { } } - importScripts([crossOriginURL.href]); + importScripts(crossOriginURL.href); }