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

Side by Side Diff: third_party/WebKit/LayoutTests/broadcastchannel/blobs.html

Issue 2004643002: Implement BroadcastChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address dcheng's comments 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script>
6
7 async_test(t => {
8 let c1 = new BroadcastChannel('blob');
9 let c2 = new BroadcastChannel('blob');
10 let c3 = new BroadcastChannel('blob');
11
12 let readCount = 0;
13 c2.onmessage = t.step_func(e => {
14 // check blob
15 assert_true('blob' in e.data);
16 assert_true(e.data.blob instanceof Blob);
17 assert_equals(e.data.blob.size, 6);
18 let reader = new FileReader();
19 reader.onerror = t.unreached_func();
20 reader.onload = t.step_func(() => {
21 assert_equals(reader.result, 'foobar');
22 if (++readCount == 2)
23 t.done();
24 });
25 reader.readAsText(e.data.blob);
26 });
27 c3.onmessage = c2.onmessage;
28 c1.postMessage({blob: new Blob(['foo', 'bar'])});
29 }, 'Blobs work on BroadcastChannel');
30
31 async_test(t => {
32 let c1 = new BroadcastChannel('blobworker');
33 let c2 = new BroadcastChannel('blobworker');
34 let events = [];
35
36 c1.onmessage = e => events.push(e.data);
37 c2.onmessage = e => events.push(e.data);
38 c2.addEventListener('message', e => {
39 if (e.data.blob)
40 c1.postMessage('done');
41 });
42
43 let worker = new Worker('resources/worker.js');
44 worker.onmessage = t.step_func(e => {
45 assert_equals(events.length, 5);
46 assert_equals(events[0], 'from worker');
47 assert_equals(events[1], 'from worker');
48 assert_true(events[2].blob instanceof Blob);
49 assert_equals(events[2].blob.size, 11);
50 assert_true(events[3].blob instanceof Blob);
51 assert_equals(events[3].blob.size, 11);
52 assert_equals(events[4], 'done');
53 let reader = new FileReader();
54 reader.onerror = t.unreached_func();
55 reader.onload = t.step_func(() => {
56 assert_equals(reader.result, 'hello-world');
57 t.done();
58 });
59 reader.readAsText(events[3].blob);
60 });
61 worker.postMessage({channel: 'blobworker'});
62 worker.postMessage({blob: ['hello-world']});
63
64 }, 'Blobs work with workers on BroadcastChannel');
65
66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698