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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/mojo/watch.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/mojo/message-pipe.html
diff --git a/third_party/WebKit/LayoutTests/mojo/message-pipe.html b/third_party/WebKit/LayoutTests/mojo/message-pipe.html
new file mode 100644
index 0000000000000000000000000000000000000000..a8e51b7fdb5167a002d92ec19fc2da2ecb222ae6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/mojo/message-pipe.html
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<title>Mojo message pipe tests</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+
+let testData = (() => {
+ let dataIn = new Uint8Array(42);
+ for (let i = 0; i < dataIn.length; ++i)
+ dataIn[i] = i * i;
+
+ return {
+ read(handle) {
+ let {result, buffer, handles} = handle.readMessage();
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_array_equals(new Uint8Array(buffer), dataIn);
+ assert_array_equals(handles, []);
+ },
+ write(handle) {
+ let result = handle.writeMessage(dataIn, []);
+ assert_equals(result, Mojo.RESULT_OK);
+ }
+ };
+})();
+
+test(() => {
+ let {result, handle0, handle1} = Mojo.createMessagePipe();
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_true(handle0 instanceof MojoHandle);
+ assert_true(handle1 instanceof MojoHandle);
+}, "Create pipe");
+
+test(() => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+ handle0.close();
+ let {result} = handle0.readMessage();
+ assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT);
+}, "Read from invalid handle");
+
+test(() => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+ let {result} = handle0.readMessage();
+ assert_equals(result, Mojo.RESULT_SHOULD_WAIT);
+}, "Read from empty pipe");
+
+test(() => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+ handle0.close();
+ let result = handle0.writeMessage(new ArrayBuffer(4), []);
+ assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT);
+}, "Write to invalid handle");
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ handle0.watch({readable: true}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_OK);
+ {
+ let {result, buffer, handles} = handle0.readMessage();
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_equals(buffer, undefined);
+ assert_equals(handles, undefined);
+ }
+ }));
+ let result = handle1.writeMessage(new ArrayBuffer(0), []);
+ assert_equals(result, Mojo.RESULT_OK);
+}, "Send empty message");
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ handle0.watch({readable: true}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_OK);
+ testData.read(handle0);
+ }));
+ testData.write(handle1);
+}, "Send buffer");
+
+async_test((test) => {
+ let pipe1 = Mojo.createMessagePipe();
+ let pipe2 = Mojo.createMessagePipe();
+ pipe2.handle0.watch({readable: true}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_OK);
+ testData.read(pipe2.handle0);
+ }));
+ pipe1.handle0.watch({readable: true}, test.step_func((result) => {
+ assert_equals(result, Mojo.RESULT_OK);
+ {
+ let {result, handles} = pipe1.handle0.readMessage();
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_equals(1, handles.length);
+ testData.write(handles[0]);
+ }
+ }));
+ pipe1.handle1.writeMessage(new ArrayBuffer(0), [pipe2.handle1]);
+}, "Send handle");
+
+</script>
« 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