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

Side by Side Diff: LayoutTests/fast/events/message-port-start-and-close-different-microtask.html

Issue 720543005: Fix MessagePort race exposed by blink scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding the tests too :) Created 6 years, 1 month 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
OLDNEW
1 <body> 1 <body>
2 <p>Test Closed MessagePort Whether Receive Message Or Not.</p> 2 <p>Test whether opening and closing a messageport in the same microtask correctl y discards an in-flight message.</p>
Sami 2014/11/12 16:45:50 Looks like the test descriptions got swapped.
alex clarke (OOO till 29th) 2014/11/12 18:23:21 Fixed now.
3 <p>Should be a START message, followed with DONE.</p> 3 <p>Should be a START message, followed by a HELLO message then DONE.</p>
4 <pre id=log></pre> 4 <pre id=log></pre>
5 <script> 5 <script>
6 function log(message) 6 function log(message)
7 { 7 {
8 document.getElementById("log").innerHTML += message + "<br>"; 8 document.getElementById("log").innerHTML += message + "<br>";
9 } 9 }
10 10
11 if (window.testRunner) { 11 if (window.testRunner) {
12 testRunner.dumpAsText(); 12 testRunner.dumpAsText();
13 testRunner.waitUntilDone(); 13 testRunner.waitUntilDone();
14 } 14 }
15 15
16 log("START"); 16 log("START");
17 17
18 var channel = new MessageChannel; 18 var channel = new MessageChannel;
19 channel.port1.onmessage = function(evt) { 19 channel.port2.postMessage("HELLO");
20 log("Closed port receiving: FAIL. Got Message: " + evt.data + " after close "); 20 openThenClose();
21 done();
22
23 function openThenClose() {
24 setTimeout(function() {
25 channel.port1.onmessage = function(evt) {
26 log("PASS. Got Message: " + evt.data + " before close");
27 }
28 setTimeout(function() {
29 channel.port1.close();
30 }, 0);
31 }, 0);
21 } 32 }
22 channel.port1.close();
23 channel.port2.postMessage("This message can't be received");
24 done();
25 33
26 function done() { 34 function done() {
27 // Wait a short period of time to ensure no messages come in from previous t ests. 35 // Wait a short period of time to ensure no messages come in from previous t ests.
28 setTimeout(function() { 36 setTimeout(function() {
29 log("DONE"); 37 log("DONE");
30 if (window.testRunner) 38 if (window.testRunner)
31 testRunner.notifyDone(); 39 testRunner.notifyDone();
32 }, 100); 40 }, 100);
33 } 41 }
34 42
35 </script> 43 </script>
36 </body> 44 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698