Bug 1525627 - Report an error if there's no ScriptLoader for the current context. r=baku
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 08 Feb 2019 09:16:00 +0200
changeset 459036 95fd39d659bc
parent 459035 81dc12cc9257
child 459037 68cffca6927a
push id111910
push usercbrindusan@mozilla.com
push dateThu, 14 Feb 2019 02:49:51 +0000
treeherdermozilla-inbound@95fd39d659bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1525627
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1525627 - Report an error if there's no ScriptLoader for the current context. r=baku
dom/script/ScriptLoader.cpp
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -744,16 +744,20 @@ RefPtr<GenericPromise> ScriptLoader::Sta
     childRequest->mReady.Reject(rv, __func__);
     return ready;
   }
 
   return ready;
 }
 
 static ScriptLoader* GetCurrentScriptLoader(JSContext* aCx) {
+  auto reportError = mozilla::MakeScopeExit([aCx]() {
+    JS_ReportErrorASCII(aCx, "No ScriptLoader found for the current context");
+  });
+
   JSObject* object = JS::CurrentGlobalOrNull(aCx);
   if (!object) {
     return nullptr;
   }
 
   nsIGlobalObject* global = xpc::NativeGlobal(object);
   if (!global) {
     return nullptr;
@@ -770,16 +774,17 @@ static ScriptLoader* GetCurrentScriptLoa
     return nullptr;
   }
 
   ScriptLoader* loader = document->ScriptLoader();
   if (!loader) {
     return nullptr;
   }
 
+  reportError.release();
   return loader;
 }
 
 static LoadedScript* GetLoadedScriptOrNull(
     JSContext* aCx, JS::Handle<JS::Value> aReferencingPrivate) {
   if (aReferencingPrivate.isUndefined()) {
     return nullptr;
   }