Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(930)

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope.html

Issue 2049493005: binding: Uses the relevant realm instead of the current realm (1 of ?) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated layout tests. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope.html b/third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope.html
index c33aba8afe9b8d6f401ebc413abba08aa8d22221..be0da7702193dce571a62582e8b4f29fd225bf72 100644
--- a/third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope.html
+++ b/third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope.html
@@ -1,6 +1,5 @@
<html>
<script>
-
// When both timeouts finish, the counter will be 2.
window.completionCounter = 0;
function test()
@@ -9,34 +8,49 @@ function test()
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
+
// Get the iframe's window.
+ var mainWindow = window;
var iframeWindow = window.frames["testIframe"];
+
// setTimeout with a callback specified as a JS closure.
// This one should run in the context of the main page.
iframeWindow.setTimeout(
- function() {
- document.getElementById("closureResult").innerText = (window == parent ? "PASS" : "FAIL");
+ function() {
+ document.getElementById("closureResult").innerText = (window == mainWindow ? "PASS" : "FAIL");
completionCounter++;
- }, 1);
+ }, 0);
+
// setTimeout with a JS string containing similar code.
// This one should run 'inside' iframe.
- iframeWindow.setTimeout(
+ mainWindow.setTimeout.call(
+ iframeWindow,
"parent.document.getElementById('stringResult').innerText = (window != parent ? 'PASS' : 'FAIL');" +
- "parent.completionCounter++;"
- , 1);
+ "parent.completionCounter++;",
+ 0);
+
+ // The callback this value must be the context object.
+ iframeWindow.setTimeout.call(window, function() {
+ document.getElementById("contextResult").innerText = (this == mainWindow ? "PASS" : "FAIL");
+ completionCounter++;
+ }, 0);
+
window.setInterval(checkResult, 10);
}
function checkResult() {
- if (completionCounter < 2)
+ if (completionCounter < 3)
return;
if (window.testRunner)
testRunner.notifyDone();
}
</script>
<body onload="test()">
-<p>Test verifies that a timeout callback is run in the proper execution context. 2 timeouts are set on a child iframe's window. 'Closure' callback should execute in the main page, 'string' callback should execute in the iframe. Test passes if you see 2 lines 'PASS' below.</p>
-<div id=closureResult>FAIL</div>
-<div id=stringResult>FAIL</div>
-<iframe style="display:none" src="about:blank" name=testIframe></iframe>
+<p>Test verifies that a timeout callback is run in the proper execution context. 3 timeouts are set on a child iframe's window. Test passes if you see 3 lines 'PASS' below. See also:
+<a href="https://html.spec.whatwg.org/multipage/webappapis.html#timer-initialisation-steps">https://html.spec.whatwg.org/multipage/webappapis.html#timer-initialisation-steps</a></p>
+
+<div><span id="closureResult">FAIL: Test didn't run.</span> -- function argument: if the argument is a function, then the callback function must run in the relevant realm for that function object.</div>
+<div><span id="stringResult">FAIL: Test didn't run.</span> -- string argument: if the argument is a string, then it must be compiled in the relevant realm for the context object, hence must run in the relevant realm for the context object.</div>
+<div><span id="contextResult">FAIL: Test didn't run.</span> -- callback this value: the callback this value must be the context object.</div>
+<iframe style="display:none" src="about:blank" name="testIframe"></iframe>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698