Bug 1508672 - Finish dynamic module import at a later time in the shell r=jorendorff
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 26 Nov 2018 16:11:45 +0000
changeset 504451 46ce47bd336841a2d71eb53e3bf76f360784e040
parent 504450 93445c3027525c80ac196074b58976a6c648fd83
child 504452 9363b52649ac9b814d4b0b9105cca8416c436223
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1508672
milestone65.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 1508672 - Finish dynamic module import at a later time in the shell r=jorendorff
js/src/shell/ModuleLoader.js
js/src/tests/jstests.list
--- a/js/src/shell/ModuleLoader.js
+++ b/js/src/shell/ModuleLoader.js
@@ -19,16 +19,18 @@ const MapPrototypeHas = Map.prototype.ha
 const MapPrototypeSet = Map.prototype.set;
 const ObjectDefineProperty = Object.defineProperty;
 const ReflectApply = Reflect.apply;
 const StringPrototypeIndexOf = String.prototype.indexOf;
 const StringPrototypeLastIndexOf = String.prototype.lastIndexOf;
 const StringPrototypeStartsWith = String.prototype.startsWith;
 const StringPrototypeSubstring = String.prototype.substring;
 const ErrorClass = Error;
+const PromiseClass = Promise;
+const PromiseResolve = Promise.resolve;
 
 const JAVASCRIPT_SCHEME = "javascript:";
 
 const ReflectLoader = new class {
     constructor() {
         this.registry = new Map();
         this.loadPath = getModuleLoadPath();
     }
@@ -209,32 +211,37 @@ const ReflectLoader = new class {
         let path;
         if (moduleInfo) {
             path = moduleInfo.path;
         } else {
             path = "(unknown)";
         }
         metaObject.url = path;
     }
+
+    dynamicImport(referencingInfo, specifier, promise) {
+        ReflectApply(PromiseResolve, PromiseClass, [])
+            .then(_ => {
+                let path = ReflectLoader.resolve(specifier, referencingInfo);
+                ReflectLoader.loadAndExecute(path);
+                finishDynamicModuleImport(referencingInfo, specifier, promise);
+            }).catch(err => {
+                abortDynamicModuleImport(referencingInfo, specifier, promise, err);
+            });
+    }
 };
 
 setModuleLoadHook((path) => ReflectLoader.importRoot(path));
 
 setModuleResolveHook((referencingInfo, requestName) => {
     let path = ReflectLoader.resolve(requestName, referencingInfo);
     return ReflectLoader.loadAndParse(path);
 });
 
 setModuleMetadataHook((module, metaObject) => {
     ReflectLoader.populateImportMeta(module, metaObject);
 });
 
 setModuleDynamicImportHook((referencingInfo, specifier, promise) => {
-    try {
-        let path = ReflectLoader.resolve(specifier, referencingInfo);
-        ReflectLoader.loadAndExecute(path);
-        finishDynamicModuleImport(referencingInfo, specifier, promise);
-    } catch (err) {
-        abortDynamicModuleImport(referencingInfo, specifier, promise, err);
-    }
+    ReflectLoader.dynamicImport(referencingInfo, specifier, promise);
 });
 
 }
--- a/js/src/tests/jstests.list
+++ b/js/src/tests/jstests.list
@@ -489,34 +489,20 @@ skip script test262/built-ins/RegExp/pro
 skip script test262/built-ins/RegExp/prototype/unicode/cross-realm.js
 skip script test262/built-ins/RegExp/prototype/source/cross-realm.js
 
 # https://bugzilla.mozilla.org/show_bug.cgi?id=1508684
 skip script test262/language/expressions/import.meta/syntax/invalid-assignment-target-update-expr.js
 
 # https://bugzilla.mozilla.org/show_bug.cgi?id=1508672
 skip script test262/language/expressions/dynamic-import/for-await-resolution-and-error-agen-yield.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-fn-named.js
-skip script test262/language/expressions/dynamic-import/imported-self-update.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-cls-name-meth.js
-skip script test262/language/expressions/dynamic-import/eval-self-once-module.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-gen-named.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-cls-anon.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-cls-name-meth.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-in.js
 skip script test262/language/expressions/dynamic-import/for-await-resolution-and-error.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-cls-named.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-gen-anon.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-cls-named.js
 skip script test262/language/expressions/dynamic-import/for-await-resolution-and-error-agen.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-fn-anon.js
 skip script test262/language/expressions/dynamic-import/double-error-resolution-promise.js
 skip script test262/language/expressions/dynamic-import/double-error-resolution.js
-skip script test262/language/expressions/dynamic-import/eval-export-dflt-expr-cls-anon.js
-skip script test262/language/expressions/dynamic-import/namespace/default-property-not-set-own.js
 
 ###########################################################
 # Tests disabled due to issues in test262 importer script #
 ###########################################################
 
 # test262 importer merges all includes in a per directory shell.js file, breaking this harness test case.
 skip script test262/harness/detachArrayBuffer.js