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

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

Issue 2521843002: Fix flakyness in broadcastchannel/blobs.html test. (Closed)
Patch Set: address comments 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..041d8022ac4240a78bb2242e94b1a66233702014 100644
--- a/third_party/WebKit/LayoutTests/broadcastchannel/blobs.html
+++ b/third_party/WebKit/LayoutTests/broadcastchannel/blobs.html
@@ -5,9 +5,9 @@
<script>
async_test(t => {
- let c1 = new BroadcastChannel('blob');
- let c2 = new BroadcastChannel('blob');
- let c3 = new BroadcastChannel('blob');
+ const c1 = new BroadcastChannel('blob');
+ const c2 = new BroadcastChannel('blob');
+ const c3 = new BroadcastChannel('blob');
let readCount = 0;
c2.onmessage = t.step_func(e => {
@@ -15,7 +15,7 @@ async_test(t => {
assert_true('blob' in e.data);
assert_true(e.data.blob instanceof Blob);
assert_equals(e.data.blob.size, 6);
- let reader = new FileReader();
+ const reader = new FileReader();
reader.onerror = t.unreached_func();
reader.onload = t.step_func(() => {
assert_equals(reader.result, 'foobar');
@@ -29,19 +29,11 @@ async_test(t => {
}, 'Blobs work on BroadcastChannel');
async_test(t => {
- let c1 = new BroadcastChannel('blobworker');
- let c2 = new BroadcastChannel('blobworker');
- let events = [];
+ const c1 = new BroadcastChannel('blobworker');
+ const c2 = new BroadcastChannel('blobworker');
+ const 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 => {
+ const verifyEvents = function() {
assert_equals(events.length, 5);
assert_equals(events[0], 'from worker');
assert_equals(events[1], 'from worker');
@@ -50,13 +42,34 @@ async_test(t => {
assert_true(events[3].blob instanceof Blob);
assert_equals(events[3].blob.size, 11);
assert_equals(events[4], 'done');
- let reader = new FileReader();
+ const reader = new FileReader();
reader.onerror = t.unreached_func();
reader.onload = t.step_func(() => {
assert_equals(reader.result, 'hello-world');
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', t.step_func(e => {
+ if (e.data.blob)
+ c1.postMessage('done');
+ if (e.data === 'done')
+ receivedDone = true;
+ if (receivedDone && receivedWorkerDone)
+ verifyEvents();
+ }));
+
+ const worker = new Worker('resources/worker.js');
+ 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