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

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

Issue 2400563002: Adds Mojo IDL. (Closed)
Patch Set: uses WebTaskRunner Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/mojo/watch.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Mojo message pipe tests</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script>
6
7 let testData = (() => {
8 let dataIn = new Uint8Array(42);
9 for (let i = 0; i < dataIn.length; ++i)
10 dataIn[i] = i * i;
11
12 return {
13 read(handle) {
14 let {result, buffer, handles} = handle.readMessage();
15 assert_equals(result, Mojo.RESULT_OK);
16 assert_array_equals(new Uint8Array(buffer), dataIn);
17 assert_array_equals(handles, []);
18 },
19 write(handle) {
20 let result = handle.writeMessage(dataIn, []);
21 assert_equals(result, Mojo.RESULT_OK);
22 }
23 };
24 })();
25
26 test(() => {
27 let {result, handle0, handle1} = Mojo.createMessagePipe();
28 assert_equals(result, Mojo.RESULT_OK);
29 assert_true(handle0 instanceof MojoHandle);
30 assert_true(handle1 instanceof MojoHandle);
31 }, "Create pipe");
32
33 test(() => {
34 let {handle0, handle1} = Mojo.createMessagePipe();
35 handle0.close();
36 let {result} = handle0.readMessage();
37 assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT);
38 }, "Read from invalid handle");
39
40 test(() => {
41 let {handle0, handle1} = Mojo.createMessagePipe();
42 let {result} = handle0.readMessage();
43 assert_equals(result, Mojo.RESULT_SHOULD_WAIT);
44 }, "Read from empty pipe");
45
46 test(() => {
47 let {handle0, handle1} = Mojo.createMessagePipe();
48 handle0.close();
49 let result = handle0.writeMessage(new ArrayBuffer(4), []);
50 assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT);
51 }, "Write to invalid handle");
52
53 async_test((test) => {
54 let {handle0, handle1} = Mojo.createMessagePipe();
55
56 handle0.watch({readable: true}, test.step_func_done((result) => {
57 assert_equals(result, Mojo.RESULT_OK);
58 {
59 let {result, buffer, handles} = handle0.readMessage();
60 assert_equals(result, Mojo.RESULT_OK);
61 assert_equals(buffer, undefined);
62 assert_equals(handles, undefined);
63 }
64 }));
65 let result = handle1.writeMessage(new ArrayBuffer(0), []);
66 assert_equals(result, Mojo.RESULT_OK);
67 }, "Send empty message");
68
69 async_test((test) => {
70 let {handle0, handle1} = Mojo.createMessagePipe();
71
72 handle0.watch({readable: true}, test.step_func_done((result) => {
73 assert_equals(result, Mojo.RESULT_OK);
74 testData.read(handle0);
75 }));
76 testData.write(handle1);
77 }, "Send buffer");
78
79 async_test((test) => {
80 let pipe1 = Mojo.createMessagePipe();
81 let pipe2 = Mojo.createMessagePipe();
82 pipe2.handle0.watch({readable: true}, test.step_func_done((result) => {
83 assert_equals(result, Mojo.RESULT_OK);
84 testData.read(pipe2.handle0);
85 }));
86 pipe1.handle0.watch({readable: true}, test.step_func((result) => {
87 assert_equals(result, Mojo.RESULT_OK);
88 {
89 let {result, handles} = pipe1.handle0.readMessage();
90 assert_equals(result, Mojo.RESULT_OK);
91 assert_equals(1, handles.length);
92 testData.write(handles[0]);
93 }
94 }));
95 pipe1.handle1.writeMessage(new ArrayBuffer(0), [pipe2.handle1]);
96 }, "Send handle");
97
98 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/mojo/watch.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698