Diff
Modified: trunk/JSTests/ChangeLog (227467 => 227468)
--- trunk/JSTests/ChangeLog 2018-01-24 02:27:56 UTC (rev 227467)
+++ trunk/JSTests/ChangeLog 2018-01-24 04:35:18 UTC (rev 227468)
@@ -1,3 +1,20 @@
+2018-01-23 Yusuke Suzuki <utatane....@gmail.com>
+
+ Add more module scope related tests with code evaluation by string
+ https://bugs.webkit.org/show_bug.cgi?id=181983
+
+ Reviewed by Sam Weinig.
+
+ Add more module scope related tests. When the original tests are landed,
+ we do not have browser integration. This patch adds more module scope tests
+ with dynamically created script evaluation. We add tests with Function
+ constructor, direct eval, indirect eval, setTimeout, setInterval, and event handlers.
+
+ * modules/scopes-eval.js: Added.
+ (shouldBe):
+ * modules/scopes.js:
+ (shouldBe):
+
2018-01-23 Filip Pizlo <fpi...@apple.com>
Unreviewed, retire some microbenchmarks that are proportionately very slow. Benchmark running time should be proportional to their value. Microbenchmarks have little value, so they should be very fast.
Added: trunk/JSTests/modules/scopes-eval.js (0 => 227468)
--- trunk/JSTests/modules/scopes-eval.js (rev 0)
+++ trunk/JSTests/modules/scopes-eval.js 2018-01-24 04:35:18 UTC (rev 227468)
@@ -0,0 +1,24 @@
+import { Cappuccino } from "./scopes/drink.js"
+import { shouldBe } from "./resources/assert.js";
+
+// Separate test from scopes.js since direct eval can taint variables.
+var global = Function("return this")();
+var globalEval = (0, eval);
+global.Cappuccino = 'Global Scope';
+shouldBe(Cappuccino, 'Cappuccino');
+
+(function () {
+ let Cappuccino = 'Function Scope';
+ shouldBe(Cappuccino, 'Function Scope');
+ {
+ let Cappuccino = 'Block Scope';
+ {
+ (function () {
+ shouldBe(Cappuccino, 'Block Scope');
+ shouldBe(eval(`Cappuccino`), 'Block Scope');
+ }());
+ }
+ }
+ shouldBe(Object, global.Object);
+}());
+shouldBe(Object, global.Object)
Modified: trunk/JSTests/modules/scopes.js (227467 => 227468)
--- trunk/JSTests/modules/scopes.js 2018-01-24 02:27:56 UTC (rev 227467)
+++ trunk/JSTests/modules/scopes.js 2018-01-24 04:35:18 UTC (rev 227468)
@@ -1,26 +1,36 @@
import { Cocoa, Cappuccino, Matcha } from "./scopes/drink.js"
import { shouldBe } from "./resources/assert.js";
+var global = Function("return this")();
+var globalEval = (0, eval);
+global.Cappuccino = 'Global Scope';
+
{
let Cocoa = 42;
shouldBe(Cocoa, 42);
}
shouldBe(Cocoa, 'Cocoa');
-shouldBe(Cappuccino, 'Cappuccino');
+shouldBe(Cappuccino, 'Cappuccino'); // Module Scope.
shouldBe(Matcha, 'Matcha');
-var global = Function("return this")();
-
(function () {
var Cocoa = 42;
- let Cappuccino = 'CPO';
+ let Cappuccino = 'Function Scope';
shouldBe(Cocoa, 42);
- shouldBe(Cappuccino, 'CPO');
+ shouldBe(Cappuccino, 'Function Scope');
shouldBe(Matcha, 'Matcha');
{
+ let Cappuccino = 'Block Scope';
const Matcha = 50;
shouldBe(Matcha, 50);
shouldBe(Object, global.Object);
+ {
+ (function () {
+ shouldBe(Cappuccino, 'Block Scope');
+ shouldBe(globalEval(`Cappuccino`), 'Global Scope');
+ shouldBe(Function(`return Cappuccino`)(), 'Global Scope');
+ }());
+ }
}
shouldBe(Object, global.Object);
}());
Modified: trunk/LayoutTests/ChangeLog (227467 => 227468)
--- trunk/LayoutTests/ChangeLog 2018-01-24 02:27:56 UTC (rev 227467)
+++ trunk/LayoutTests/ChangeLog 2018-01-24 04:35:18 UTC (rev 227468)
@@ -1,3 +1,17 @@
+2018-01-23 Yusuke Suzuki <utatane....@gmail.com>
+
+ Add more module scope related tests with code evaluation by string
+ https://bugs.webkit.org/show_bug.cgi?id=181983
+
+ Reviewed by Sam Weinig.
+
+ * js/dom/modules/module-scope-event-handler-expected.txt: Added.
+ * js/dom/modules/module-scope-event-handler.html: Added.
+ * js/dom/modules/module-scope-set-interval-expected.txt: Added.
+ * js/dom/modules/module-scope-set-interval.html: Added.
+ * js/dom/modules/module-scope-set-timeout-expected.txt: Added.
+ * js/dom/modules/module-scope-set-timeout.html: Added.
+
2018-01-23 Matt Lewis <jlew...@apple.com>
Marked http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html as flaky.
Added: trunk/LayoutTests/js/dom/modules/module-scope-event-handler-expected.txt (0 => 227468)
--- trunk/LayoutTests/js/dom/modules/module-scope-event-handler-expected.txt (rev 0)
+++ trunk/LayoutTests/js/dom/modules/module-scope-event-handler-expected.txt 2018-01-24 04:35:18 UTC (rev 227468)
@@ -0,0 +1,13 @@
+Test relationship between module scope and event handlers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Module is not executed yet.
+PASS visibleAtATime is "Module Scope"
+PASS visibleAtATime is "Module Scope"
+PASS visibleAtATime is "Global Scope"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/dom/modules/module-scope-event-handler.html (0 => 227468)
--- trunk/LayoutTests/js/dom/modules/module-scope-event-handler.html (rev 0)
+++ trunk/LayoutTests/js/dom/modules/module-scope-event-handler.html 2018-01-24 04:35:18 UTC (rev 227468)
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="target"></div>
+<div id="target2" _onclick_="window.visibleAtATime = cocoa; shouldBeEqualToString('visibleAtATime', 'Global Scope'); finishJSTest();"></div>
+<script>
+description("Test relationship between module scope and event handlers");
+
+window.jsTestIsAsync = true;
+debug("Module is not executed yet.");
+window.cocoa = 'Global Scope'
+window.visibleAtATime = null;
+</script>
+<script type="module">
+var cocoa = 'Module Scope';
+window.visibleAtATime = cocoa;
+shouldBeEqualToString("visibleAtATime", "Module Scope");
+var target = document.getElementById('target');
+target._onclick_ = function () {
+ window.visibleAtATime = cocoa;
+ shouldBeEqualToString("visibleAtATime", "Module Scope");
+ var target2 = document.getElementById('target2');
+ target2.click();
+};
+target.click();
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/js/dom/modules/module-scope-set-interval-expected.txt (0 => 227468)
--- trunk/LayoutTests/js/dom/modules/module-scope-set-interval-expected.txt (rev 0)
+++ trunk/LayoutTests/js/dom/modules/module-scope-set-interval-expected.txt 2018-01-24 04:35:18 UTC (rev 227468)
@@ -0,0 +1,13 @@
+Test relationship between module scope and setInterval
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Module is not executed yet.
+PASS visibleAtATime is "Module Scope"
+PASS visibleAtATime is "Module Scope"
+PASS visibleAtATime is "Global Scope"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/dom/modules/module-scope-set-interval.html (0 => 227468)
--- trunk/LayoutTests/js/dom/modules/module-scope-set-interval.html (rev 0)
+++ trunk/LayoutTests/js/dom/modules/module-scope-set-interval.html 2018-01-24 04:35:18 UTC (rev 227468)
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Test relationship between module scope and setInterval");
+
+window.jsTestIsAsync = true;
+debug("Module is not executed yet.");
+window.cocoa = 'Global Scope'
+window.visibleAtATime = null;
+window.token = null;
+</script>
+<script type="module">
+var cocoa = 'Module Scope';
+window.visibleAtATime = cocoa;
+shouldBeEqualToString("visibleAtATime", "Module Scope");
+token = setInterval(function () {
+ clearInterval(token);
+ window.visibleAtATime = cocoa;
+ shouldBeEqualToString("visibleAtATime", "Module Scope");
+ token = setInterval(`
+ clearInterval(token);
+ window.visibleAtATime = cocoa;
+ shouldBeEqualToString("visibleAtATime", "Global Scope");
+ finishJSTest();
+ `, 0);
+}, 0);
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/js/dom/modules/module-scope-set-timeout-expected.txt (0 => 227468)
--- trunk/LayoutTests/js/dom/modules/module-scope-set-timeout-expected.txt (rev 0)
+++ trunk/LayoutTests/js/dom/modules/module-scope-set-timeout-expected.txt 2018-01-24 04:35:18 UTC (rev 227468)
@@ -0,0 +1,13 @@
+Test relationship between module scope and setTimeout
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Module is not executed yet.
+PASS visibleAtATime is "Module Scope"
+PASS visibleAtATime is "Module Scope"
+PASS visibleAtATime is "Global Scope"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/dom/modules/module-scope-set-timeout.html (0 => 227468)
--- trunk/LayoutTests/js/dom/modules/module-scope-set-timeout.html (rev 0)
+++ trunk/LayoutTests/js/dom/modules/module-scope-set-timeout.html 2018-01-24 04:35:18 UTC (rev 227468)
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description("Test relationship between module scope and setTimeout");
+
+window.jsTestIsAsync = true;
+debug("Module is not executed yet.");
+window.cocoa = 'Global Scope'
+window.visibleAtATime = null;
+</script>
+<script type="module">
+var cocoa = 'Module Scope';
+window.visibleAtATime = cocoa;
+shouldBeEqualToString("visibleAtATime", "Module Scope");
+setTimeout(function () {
+ window.visibleAtATime = cocoa;
+ shouldBeEqualToString("visibleAtATime", "Module Scope");
+ setTimeout(`
+ window.visibleAtATime = cocoa;
+ shouldBeEqualToString("visibleAtATime", "Global Scope");
+ finishJSTest();
+ `, 0);
+}, 0);
+</script>
+<script src=""
+</body>
+</html>