зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1249673. Muted errors should be turned into NetworkError DOMExceptions when returning from importScripts on workers, instead of becoming NS_ERROR_FAILURE. r=baku
This commit is contained in:
Родитель
bb7c756f0e
Коммит
44f8a852c3
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче