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

Unified Diff: third_party/WebKit/LayoutTests/mojo/watch.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
Index: third_party/WebKit/LayoutTests/mojo/watch.html
diff --git a/third_party/WebKit/LayoutTests/mojo/watch.html b/third_party/WebKit/LayoutTests/mojo/watch.html
new file mode 100644
index 0000000000000000000000000000000000000000..3a0eb377d75d7e84bd49eda216920192a0405bb2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/mojo/watch.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<title>mojo watch tests</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ handle0.watch({readable: true}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_OK);
+ }));
+ handle1.writeMessage(new ArrayBuffer(4), []);
+}, "Watch handle readable");
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ handle0.watch({writable: true}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_OK);
+ }));
+}, "Watch handle writable");
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ handle0.watch({peerClosed: true}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_OK);
+ }));
+ handle1.close();
+}, "Watch handle peer closed");
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ handle0.close();
+ handle0.watch({writable: true}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT);
+ }));
+}, "Watch invalid handle");
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ handle0.watch({}, test.step_func_done((result) => {
+ assert_equals(result, Mojo.RESULT_FAILED_PRECONDITION);
+ }));
+}, "Watch with default MojoHandleSignals");
+
+async_test((test) => {
+ let {handle0, handle1} = Mojo.createMessagePipe();
+
+ let watcher = handle0.watch(
+ {writable: true},
+ test.unreached_func("callback triggered after canceling watch"));
+ watcher.cancel();
+ setTimeout(() => { test.done(); });
+}, "Cancel watch");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698