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

Side by Side Diff: third_party/WebKit/LayoutTests/mojo/data-pipe.html

Issue 2732163002: Implements JS bindings for mojo data pipe. (Closed)
Patch Set: optional args Created 3 years, 9 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 <title>Mojo data pipe tests</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script>
6
7 let kElementNumBytes = 1;
8 let kCapacityNumBytes = 64;
9
10 function createDataPipe() {
11 return Mojo.createDataPipe({
12 elementNumBytes: kElementNumBytes,
13 capacityNumBytes: kCapacityNumBytes
14 });
15 };
16
17 test(() => {
18 let {result, producer, consumer} = createDataPipe();
19 assert_equals(result, Mojo.RESULT_OK);
20 assert_true(producer instanceof MojoHandle);
21 assert_true(consumer instanceof MojoHandle);
22 }, "Create data pipe");
23
24 async_test((test) => {
25 let {producer, consumer} = createDataPipe();
26
27 let data = new Uint8Array(kCapacityNumBytes);
28 for (let i = 0; i < data.length; ++i)
29 data[i] = i;
30
31 consumer.watch({readable: true}, test.step_func_done((result) => {
32 assert_equals(result, Mojo.RESULT_OK);
33
34 var {result, numBytes} = consumer.readData({query: true});
35 assert_equals(result, Mojo.RESULT_OK);
36 assert_equals(numBytes, data.length);
37 }));
38
39 let {result, numBytes} = producer.writeData(data);
40 assert_equals(result, Mojo.RESULT_OK);
41 assert_equals(numBytes, data.length);
42 }, "Send data");
43
44 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/BUILD.gn » ('j') | third_party/WebKit/Source/core/mojo/MojoHandle.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698