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

Side by Side 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: Addressed a review comment. 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <script> 2 <script>
3
4 // When both timeouts finish, the counter will be 2. 3 // When both timeouts finish, the counter will be 2.
5 window.completionCounter = 0; 4 window.completionCounter = 0;
6 function test() 5 function test()
7 { 6 {
8 if (window.testRunner) { 7 if (window.testRunner) {
9 testRunner.dumpAsText(); 8 testRunner.dumpAsText();
10 testRunner.waitUntilDone(); 9 testRunner.waitUntilDone();
11 } 10 }
11
12 // Get the iframe's window. 12 // Get the iframe's window.
13 var mainWindow = window;
13 var iframeWindow = window.frames["testIframe"]; 14 var iframeWindow = window.frames["testIframe"];
15
14 // setTimeout with a callback specified as a JS closure. 16 // setTimeout with a callback specified as a JS closure.
15 // This one should run in the context of the main page. 17 // This one should run in the context of the main page.
16 iframeWindow.setTimeout( 18 iframeWindow.setTimeout(
17 function() { 19 function() {
18 document.getElementById("closureResult").innerText = (window == pare nt ? "PASS" : "FAIL"); 20 document.getElementById("closureResult").innerText = (window == main Window ? "PASS" : "FAIL");
19 completionCounter++; 21 completionCounter++;
20 }, 1); 22 }, 0);
23
21 // setTimeout with a JS string containing similar code. 24 // setTimeout with a JS string containing similar code.
22 // This one should run 'inside' iframe. 25 // This one should run 'inside' iframe.
23 iframeWindow.setTimeout( 26 mainWindow.setTimeout.call(
27 iframeWindow,
24 "parent.document.getElementById('stringResult').innerText = (window != p arent ? 'PASS' : 'FAIL');" + 28 "parent.document.getElementById('stringResult').innerText = (window != p arent ? 'PASS' : 'FAIL');" +
25 "parent.completionCounter++;" 29 "parent.completionCounter++;",
26 , 1); 30 0);
31
32 // The callback this value must be the context object.
33 iframeWindow.setTimeout.call(window, function() {
34 document.getElementById("contextResult").innerText = (this == mainWindow ? "PASS" : "FAIL");
35 completionCounter++;
36 }, 0);
37
27 window.setInterval(checkResult, 10); 38 window.setInterval(checkResult, 10);
28 } 39 }
29 function checkResult() { 40 function checkResult() {
30 if (completionCounter < 2) 41 if (completionCounter < 3)
31 return; 42 return;
32 if (window.testRunner) 43 if (window.testRunner)
33 testRunner.notifyDone(); 44 testRunner.notifyDone();
34 } 45 }
35 </script> 46 </script>
36 <body onload="test()"> 47 <body onload="test()">
37 <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 execut e in the main page, 'string' callback should execute in the iframe. Test passes if you see 2 lines 'PASS' below.</p> 48 <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:
38 <div id=closureResult>FAIL</div> 49 <a href="https://html.spec.whatwg.org/multipage/webappapis.html#timer-initialisa tion-steps">https://html.spec.whatwg.org/multipage/webappapis.html#timer-initial isation-steps</a></p>
39 <div id=stringResult>FAIL</div> 50
40 <iframe style="display:none" src="about:blank" name=testIframe></iframe> 51 <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 rele vant realm for that function object.</div>
52 <div><span id="stringResult">FAIL: Test didn't run.</span> -- string argument: i f the argument is a string, then it must be compiled in the relevant realm for t he context object, hence must run in the relevant realm for the context object.< /div>
53 <div><span id="contextResult">FAIL: Test didn't run.</span> -- callback this val ue: the callback this value must be the context object.</div>
54 <iframe style="display:none" src="about:blank" name="testIframe"></iframe>
41 </body> 55 </body>
42 </html> 56 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/Window/timeout-callback-scope-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698