Bug 1342810 - Check for instantiation failure when a previously-loaded module is requested r=smaug
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 28 Feb 2017 10:47:19 +0000
changeset 394203 8bf9111b7e9cd01f486a34057144e6480cbc66ce
parent 394202 d08acf88f5b385430db1673654435d08cc28c6ce
child 394204 6c8e5c019cbc5d67eb5f1cbd289714e3490dbbd2
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1342810
milestone54.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 1342810 - Check for instantiation failure when a previously-loaded module is requested r=smaug
dom/base/nsScriptLoader.cpp
testing/web-platform/meta/MANIFEST.json
testing/web-platform/mozilla/meta/MANIFEST.json
testing/web-platform/mozilla/meta/html/semantics/scripting-1/the-script-element/reload-failed-module-script.html.ini
testing/web-platform/mozilla/tests/html/semantics/scripting-1/the-script-element/reload-failed-module-script.html
testing/web-platform/mozilla/tests/html/semantics/scripting-1/the-script-element/support/missing_import.js
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -732,17 +732,17 @@ nsScriptLoader::WaitForModuleFetch(nsMod
       promise = new GenericPromise::Private(__func__);
       mFetchingModules.Put(aRequest->mURI, promise);
     }
     return promise;
   }
 
   RefPtr<nsModuleScript> ms;
   MOZ_ALWAYS_TRUE(mFetchedModules.Get(aRequest->mURI, getter_AddRefs(ms)));
-  if (!ms) {
+  if (!ms || ms->InstantiationFailed()) {
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   return GenericPromise::CreateAndResolve(true, __func__);
 }
 
 nsModuleScript*
 nsScriptLoader::GetFetchedModule(nsIURI* aURL) const
@@ -994,16 +994,17 @@ ResolveRequestedModules(nsModuleLoadRequ
 
   return NS_OK;
 }
 
 void
 nsScriptLoader::StartFetchingModuleDependencies(nsModuleLoadRequest* aRequest)
 {
   MOZ_ASSERT(aRequest->mModuleScript);
+  MOZ_ASSERT(!aRequest->mModuleScript->InstantiationFailed());
   MOZ_ASSERT(!aRequest->IsReadyToRun());
   aRequest->mProgress = nsModuleLoadRequest::Progress::FetchingImports;
 
   nsCOMArray<nsIURI> urls;
   nsresult rv = ResolveRequestedModules(aRequest, urls);
   if (NS_FAILED(rv)) {
     aRequest->LoadFailed();
     return;
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -129392,17 +129392,17 @@
      "/webdriver/util/http_request.py",
      {}
     ]
    ]
   }
  },
  "paths": {
   "./.gitignore": [
-   "bfa8422ef9849af857cdbddbe8044c2179953f6d",
+   "a74e35d1ce44dcca7ecb513a8cbd6194fe0f2c58",
    "support"
   ],
   "./.gitmodules": [
    "3deb86ca08a0d6a80a8e897355ba7213dfb6e5bc",
    "support"
   ],
   "./.travis.yml": [
    "68037c26bd4a4c0c1500dd6628ce1d95840c5bb9",
--- a/testing/web-platform/mozilla/meta/MANIFEST.json
+++ b/testing/web-platform/mozilla/meta/MANIFEST.json
@@ -8,16 +8,26 @@
      {}
     ]
    ],
    "fetch/api/redirect/redirect-referrer-mixed-content.js": [
     [
      {}
     ]
    ],
+   "html/semantics/scripting-1/the-script-element/support/missing_import.js": [
+    [
+     {}
+    ]
+   ],
+   "html/semantics/scripting-1/the-script-element/support/module.js": [
+    [
+     {}
+    ]
+   ],
    "wasm/js/address.wast.js": [
     [
      {}
     ]
    ],
    "wasm/js/binary.wast.js": [
     [
      {}
@@ -327,36 +337,37 @@
     [
      {}
     ]
    ],
    "wasm/js/unwind.wast.js": [
     [
      {}
     ]
-   ],
-   "html/semantics/scripting-1/the-script-element/support/module.js": [
-    [
-     {}
-    ]
    ]
   },
   "testharness": {
    "fetch/api/redirect/redirect-referrer.https.html": [
     [
      "/_mozilla/fetch/api/redirect/redirect-referrer.https.html",
      {}
     ]
    ],
    "html/semantics/scripting-1/the-script-element/create-module-script.html": [
     [
      "/_mozilla/html/semantics/scripting-1/the-script-element/create-module-script.html",
      {}
     ]
    ],
+   "html/semantics/scripting-1/the-script-element/reload-failed-module-script.html": [
+    [
+     "/_mozilla/html/semantics/scripting-1/the-script-element/reload-failed-module-script.html",
+     {}
+    ]
+   ],
    "html/syntax/parsing/math-parse01.html": [
     [
      "/_mozilla/html/syntax/parsing/math-parse01.html",
      {}
     ]
    ],
    "wasm/address.wast.js.html": [
     [
@@ -729,19 +740,27 @@
    "f9d7ec9cf9fa8c847e45664b05482e3f8c191385",
    "support"
   ],
   "fetch/api/redirect/redirect-referrer.https.html": [
    "99cbd16b78771f35e075e4012d8dbc5dce3209c0",
    "testharness"
   ],
   "html/semantics/scripting-1/the-script-element/create-module-script.html": [
-   "139c1ae0c7dafc27124dbc648925a3911b54292a",
+   "3214bced5d81e8001a321aea4c80675b6603b11d",
    "testharness"
   ],
+  "html/semantics/scripting-1/the-script-element/reload-failed-module-script.html": [
+   "5b8cf6809bd8d0797f4172bf9a01f9085c0abbaf",
+   "testharness"
+  ],
+  "html/semantics/scripting-1/the-script-element/support/missing_import.js": [
+   "52d9e4b6332f11467c1a7d3d18893fdf8ce6ff72",
+   "support"
+  ],
   "html/semantics/scripting-1/the-script-element/support/module.js": [
    "3de5a5a1fb12e698509ac14ba44d7b2b474330f4",
    "support"
   ],
   "html/syntax/parsing/math-parse01.html": [
    "9b670028f08b5fab713e19a443b9505cb9de5fd3",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/meta/html/semantics/scripting-1/the-script-element/reload-failed-module-script.html.ini
@@ -0,0 +1,2 @@
+[reload-failed-module-script.html]
+  prefs: [dom.moduleScripts.enabled:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/html/semantics/scripting-1/the-script-element/reload-failed-module-script.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Insert non-async module script</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script>
+  setup({allow_uncaught_exception: true});
+  var test = async_test("Reload failed module script")
+  function reloadModule() {
+    var script = document.createElement("script");
+    script.onerror = function() {
+      // An error is expected
+      test.done();
+    };
+    script.onload = function() {
+      test.step(() => assert_unreached("Should not load"));
+      test.done();
+    };
+    script.type = "module";
+    script.src = "support/missing_import.js";
+    script.async = false;
+    document.documentElement.appendChild(script);
+  }
+</script>
+<script type="module" src="support/missing_import.js" onerror="reloadModule()"></script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/mozilla/tests/html/semantics/scripting-1/the-script-element/support/missing_import.js
@@ -0,0 +1,2 @@
+// Import a non-existent export to trigger instantiation failure.
+import {not_found} from "./module.js";