[JSC] Specifying same module entry point multiple times cause TypeError
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 03:56:12 +0000 (03:56 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 03:56:12 +0000 (03:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164858

Reviewed by Saam Barati.

Source/JavaScriptCore:

Allow importing the same module multiple times. Previously, when specifying the same
module in the <script type="module" src="here">, it throws TypeError.

* builtins/ModuleLoaderPrototype.js:
(requestFetch):
(requestTranslate):
(requestInstantiate):
(requestSatisfy):

LayoutTests:

* js/dom/modules/module-load-same-module-from-different-entry-point-in-src-expected.txt: Added.
* js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209172 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src-expected.txt [new file with mode: 0644]
LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js

index c3a3806..78dcd58 100644 (file)
@@ -1,3 +1,13 @@
+2016-11-30  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Specifying same module entry point multiple times cause TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=164858
+
+        Reviewed by Saam Barati.
+
+        * js/dom/modules/module-load-same-module-from-different-entry-point-in-src-expected.txt: Added.
+        * js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html: Added.
+
 2016-11-30  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] Add support for right-to-left layouts
diff --git a/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src-expected.txt b/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src-expected.txt
new file mode 100644 (file)
index 0000000..3ccb84a
--- /dev/null
@@ -0,0 +1,15 @@
+2 different module tag will attempt to load the same module with "src" attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Module is not executed yet.
+PASS window.moduleExecutedCount is 0
+Executing module-load-same-module-from-different-entry-point.js.
+PASS window.moduleExecutedCount is 1
+PASS window.moduleExecutedCount is 1
+PASS counter is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html b/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html
new file mode 100644 (file)
index 0000000..bee9c10
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description('2 different module tag will attempt to load the same module with "src" attribute.');
+window.jsTestIsAsync = true;
+window.moduleExecutedCount = 0;
+debug('Module is not executed yet.');
+shouldBe(`window.moduleExecutedCount`, `0`);
+var counter = 0;
+function onLoad() {
+    shouldBe(`window.moduleExecutedCount`, `1`);
+    ++counter;
+}
+function finish() {
+    shouldBe(`counter`, `2`);
+    finishJSTest();
+}
+
+</script>
+<script src="../../../resources/js-test-post.js"></script>
+<script type="module" src="./script-tests/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>
+<script type="module" src="./script-tests/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>
+<script type="module">
+finish();
+</script>
+</body>
+</html>
index eb57d30..a5b017f 100644 (file)
@@ -1,5 +1,21 @@
 2016-11-30  Yusuke Suzuki  <utatane.tea@gmail.com>
 
+        [JSC] Specifying same module entry point multiple times cause TypeError
+        https://bugs.webkit.org/show_bug.cgi?id=164858
+
+        Reviewed by Saam Barati.
+
+        Allow importing the same module multiple times. Previously, when specifying the same
+        module in the <script type="module" src="here">, it throws TypeError.
+
+        * builtins/ModuleLoaderPrototype.js:
+        (requestFetch):
+        (requestTranslate):
+        (requestInstantiate):
+        (requestSatisfy):
+
+2016-11-30  Yusuke Suzuki  <utatane.tea@gmail.com>
+
         WebAssembly JS API: export a module namespace object instead of a module environment
         https://bugs.webkit.org/show_bug.cgi?id=165121
 
index 0a98258..063b2c9 100644 (file)
@@ -230,12 +230,6 @@ function requestFetch(key, initiator)
     "use strict";
 
     var entry = this.ensureRegistered(key);
-    if (entry.state > @ModuleLink) {
-        var deferred = @newPromiseCapability(@InternalPromise);
-        deferred.@reject.@call(@undefined, new @TypeError("Requested module is already ready to be executed."));
-        return deferred.@promise;
-    }
-
     if (entry.fetch)
         return entry.fetch;
 
@@ -260,12 +254,6 @@ function requestTranslate(key, initiator)
     "use strict";
 
     var entry = this.ensureRegistered(key);
-    if (entry.state > @ModuleLink) {
-        var deferred = @newPromiseCapability(@InternalPromise);
-        deferred.@reject.@call(@undefined, new @TypeError("Requested module is already ready to be executed."));
-        return deferred.@promise;
-    }
-
     if (entry.translate)
         return entry.translate;
 
@@ -291,12 +279,6 @@ function requestInstantiate(key, initiator)
     "use strict";
 
     var entry = this.ensureRegistered(key);
-    if (entry.state > @ModuleLink) {
-        var deferred = @newPromiseCapability(@InternalPromise);
-        deferred.@reject.@call(@undefined, new @TypeError("Requested module is already ready to be executed."));
-        return deferred.@promise;
-    }
-
     if (entry.instantiate)
         return entry.instantiate;
 
@@ -324,12 +306,6 @@ function requestSatisfy(key, initiator)
     "use strict";
 
     var entry = this.ensureRegistered(key);
-    if (entry.state > @ModuleLink) {
-        var deferred = @newPromiseCapability(@InternalPromise);
-        deferred.@reject.@call(@undefined, new @TypeError("Requested module is already ready to be executed."));
-        return deferred.@promise;
-    }
-
     if (entry.satisfy)
         return entry.satisfy;