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

Unified Diff: third_party/WebKit/LayoutTests/broadcastchannel/blobs.html

Issue 2521843002: Fix flakyness in broadcastchannel/blobs.html test. (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/broadcastchannel/blobs.html
diff --git a/third_party/WebKit/LayoutTests/broadcastchannel/blobs.html b/third_party/WebKit/LayoutTests/broadcastchannel/blobs.html
index a75be5e0e897501ed0ba2d62b9c54373502dab98..19f63bbad7f37e37186869e961737cb765b4d68b 100644
--- a/third_party/WebKit/LayoutTests/broadcastchannel/blobs.html
+++ b/third_party/WebKit/LayoutTests/broadcastchannel/blobs.html
@@ -33,15 +33,7 @@ async_test(t => {
let c2 = new BroadcastChannel('blobworker');
let events = [];
- c1.onmessage = e => events.push(e.data);
- c2.onmessage = e => events.push(e.data);
- c2.addEventListener('message', e => {
- if (e.data.blob)
- c1.postMessage('done');
- });
-
- let worker = new Worker('resources/worker.js');
- worker.onmessage = t.step_func(e => {
+ let verifyEvents = function() {
jsbell 2016/11/22 17:13:22 nit: could be const, but using let for consistency
Marijn Kruisselbrink 2016/11/22 17:51:28 Ah yes, good point. Changed all the lets that coul
assert_equals(events.length, 5);
assert_equals(events[0], 'from worker');
assert_equals(events[1], 'from worker');
@@ -57,6 +49,27 @@ async_test(t => {
t.done();
});
reader.readAsText(events[3].blob);
+ };
+
+ let receivedDone = false;
+ let receivedWorkerDone = false;
+
+ c1.onmessage = e => events.push(e.data);
+ c2.onmessage = e => events.push(e.data);
+ c2.addEventListener('message', e => {
jsbell 2016/11/22 17:13:22 Wrap in t.step_func()
Marijn Kruisselbrink 2016/11/22 17:51:28 Done
+ if (e.data.blob)
+ c1.postMessage('done');
+ if (e.data === 'done')
+ receivedDone = true;
+ if (receivedDone && receivedWorkerDone)
+ verifyEvents();
+ });
+
+ let worker = new Worker('resources/worker.js');
jsbell 2016/11/22 17:13:23 could be const, but let is okay.
+ worker.onmessage = t.step_func(e => {
+ receivedWorkerDone = true;
+ if (receivedDone && receivedWorkerDone)
+ verifyEvents();
});
worker.postMessage({channel: 'blobworker'});
worker.postMessage({blob: ['hello-world']});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698