Title: [211314] trunk
Revision
211314
Author
utatane....@gmail.com
Date
2017-01-27 16:49:01 -0800 (Fri, 27 Jan 2017)

Log Message

setTimeout / setInterval's string execution should inherit SourceOrigin correctly
https://bugs.webkit.org/show_bug.cgi?id=167097

Reviewed by Darin Adler.

Source/WebCore:

Tests: js/dom/modules/import-from-set-interval.html
       js/dom/modules/import-from-set-timeout.html

* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::executeScriptInWorld):

LayoutTests:

We set the default SourceOrigin for the ScriptController::executeScriptInWorld.
The default SourceOrigin has the document baseURL and CachedScriptFetcher.

setTimeout and setInterval use this interface. And it uses the default SourceOrigin
for the document (Realm of the setTimeout / setInterval). This is the expected
behavior in the dynamic import proposal.

* js/dom/modules/import-from-set-interval-expected.txt: Added.
* js/dom/modules/import-from-set-interval.html: Added.
* js/dom/modules/import-from-set-timeout-expected.txt: Added.
* js/dom/modules/import-from-set-timeout.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (211313 => 211314)


--- trunk/LayoutTests/ChangeLog	2017-01-28 00:47:30 UTC (rev 211313)
+++ trunk/LayoutTests/ChangeLog	2017-01-28 00:49:01 UTC (rev 211314)
@@ -1,3 +1,22 @@
+2017-01-27  Yusuke Suzuki  <utatane....@gmail.com>
+
+        setTimeout / setInterval's string execution should inherit SourceOrigin correctly
+        https://bugs.webkit.org/show_bug.cgi?id=167097
+
+        Reviewed by Darin Adler.
+
+        We set the default SourceOrigin for the ScriptController::executeScriptInWorld.
+        The default SourceOrigin has the document baseURL and CachedScriptFetcher.
+
+        setTimeout and setInterval use this interface. And it uses the default SourceOrigin
+        for the document (Realm of the setTimeout / setInterval). This is the expected
+        behavior in the dynamic import proposal.
+
+        * js/dom/modules/import-from-set-interval-expected.txt: Added.
+        * js/dom/modules/import-from-set-interval.html: Added.
+        * js/dom/modules/import-from-set-timeout-expected.txt: Added.
+        * js/dom/modules/import-from-set-timeout.html: Added.
+
 2017-01-27  Simon Fraser  <simon.fra...@apple.com>
 
         Tweak the test to avoid one pixel of difference on some hardware.

Added: trunk/LayoutTests/js/dom/modules/import-from-set-interval-expected.txt (0 => 211314)


--- trunk/LayoutTests/js/dom/modules/import-from-set-interval-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/dom/modules/import-from-set-interval-expected.txt	2017-01-28 00:49:01 UTC (rev 211314)
@@ -0,0 +1,15 @@
+Test import from setInterval.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Module execution is confined in the module environment.
+PASS typeof cocoa is "undefined"
+PASS typeof exportedCocoa is "object"
+PASS exportedCocoa.taste() is "nice"
+PASS window.imported is true
+PASS window.passedCocoa is window.exportedCocoa
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/dom/modules/import-from-set-interval.html (0 => 211314)


--- trunk/LayoutTests/js/dom/modules/import-from-set-interval.html	                        (rev 0)
+++ trunk/LayoutTests/js/dom/modules/import-from-set-interval.html	2017-01-28 00:49:01 UTC (rev 211314)
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('Test import from setInterval.');
+
+// Module will be executed asynchronously.
+window.jsTestIsAsync = true;
+window.passedCocoa = null;
+window.id = null;
+
+function loaded(cocoa)
+{
+    window.passedCocoa = cocoa;
+    shouldBeTrue(`window.imported`);
+    shouldBe(`window.passedCocoa`, `window.exportedCocoa`);
+    finishJSTest();
+}
+</script>
+<script>
+</script>
+<script src=""
+<script type="module">
+window.id = setInterval(`clearInterval(window.id);import("./resources/import-src-simple.js").then((ns) => loaded(ns.ok));`, 0);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/js/dom/modules/import-from-set-timeout-expected.txt (0 => 211314)


--- trunk/LayoutTests/js/dom/modules/import-from-set-timeout-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/dom/modules/import-from-set-timeout-expected.txt	2017-01-28 00:49:01 UTC (rev 211314)
@@ -0,0 +1,15 @@
+Test import from setTimeout.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Module execution is confined in the module environment.
+PASS typeof cocoa is "undefined"
+PASS typeof exportedCocoa is "object"
+PASS exportedCocoa.taste() is "nice"
+PASS window.imported is true
+PASS window.passedCocoa is window.exportedCocoa
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/dom/modules/import-from-set-timeout.html (0 => 211314)


--- trunk/LayoutTests/js/dom/modules/import-from-set-timeout.html	                        (rev 0)
+++ trunk/LayoutTests/js/dom/modules/import-from-set-timeout.html	2017-01-28 00:49:01 UTC (rev 211314)
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('Test import from setTimeout.');
+
+// Module will be executed asynchronously.
+window.jsTestIsAsync = true;
+window.passedCocoa = null;
+
+function loaded(cocoa)
+{
+    window.passedCocoa = cocoa;
+    shouldBeTrue(`window.imported`);
+    shouldBe(`window.passedCocoa`, `window.exportedCocoa`);
+    finishJSTest();
+}
+</script>
+<script>
+</script>
+<script src=""
+<script type="module">
+setTimeout(`import("./resources/import-src-simple.js").then((ns) => loaded(ns.ok))`, 0);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (211313 => 211314)


--- trunk/Source/WebCore/ChangeLog	2017-01-28 00:47:30 UTC (rev 211313)
+++ trunk/Source/WebCore/ChangeLog	2017-01-28 00:49:01 UTC (rev 211314)
@@ -1,5 +1,18 @@
 2017-01-27  Yusuke Suzuki  <utatane....@gmail.com>
 
+        setTimeout / setInterval's string execution should inherit SourceOrigin correctly
+        https://bugs.webkit.org/show_bug.cgi?id=167097
+
+        Reviewed by Darin Adler.
+
+        Tests: js/dom/modules/import-from-set-interval.html
+               js/dom/modules/import-from-set-timeout.html
+
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::executeScriptInWorld):
+
+2017-01-27  Yusuke Suzuki  <utatane....@gmail.com>
+
         Merge CachedModuleScript and LoadableModuleScript
         https://bugs.webkit.org/show_bug.cgi?id=167500
 

Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (211313 => 211314)


--- trunk/Source/WebCore/bindings/js/ScriptController.cpp	2017-01-28 00:47:30 UTC (rev 211313)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp	2017-01-28 00:49:01 UTC (rev 211314)
@@ -649,7 +649,7 @@
 JSValue ScriptController::executeScriptInWorld(DOMWrapperWorld& world, const String& script, bool forceUserGesture)
 {
     UserGestureIndicator gestureIndicator(forceUserGesture ? std::optional<ProcessingUserGestureState>(ProcessingUserGesture) : std::nullopt);
-    ScriptSourceCode sourceCode(script, m_frame.document()->url());
+    ScriptSourceCode sourceCode(script, m_frame.document()->url(), TextPosition(), JSC::SourceProviderSourceType::Program, CachedScriptFetcher::create(m_frame.document()->charset()));
 
     if (!canExecuteScripts(AboutToExecuteScript) || isPaused())
         return { };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to