OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>mojo watch tests</title> |
| 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 |
| 7 async_test((test) => { |
| 8 let {handle0, handle1} = Mojo.createMessagePipe(); |
| 9 |
| 10 handle0.watch({readable: true}, test.step_func_done((result) => { |
| 11 assert_equals(result, Mojo.RESULT_OK); |
| 12 })); |
| 13 handle1.writeMessage(new ArrayBuffer(4), []); |
| 14 }, "Watch handle readable"); |
| 15 |
| 16 async_test((test) => { |
| 17 let {handle0, handle1} = Mojo.createMessagePipe(); |
| 18 |
| 19 handle0.watch({writable: true}, test.step_func_done((result) => { |
| 20 assert_equals(result, Mojo.RESULT_OK); |
| 21 })); |
| 22 }, "Watch handle writable"); |
| 23 |
| 24 async_test((test) => { |
| 25 let {handle0, handle1} = Mojo.createMessagePipe(); |
| 26 |
| 27 handle0.watch({peerClosed: true}, test.step_func_done((result) => { |
| 28 assert_equals(result, Mojo.RESULT_OK); |
| 29 })); |
| 30 handle1.close(); |
| 31 }, "Watch handle peer closed"); |
| 32 |
| 33 async_test((test) => { |
| 34 let {handle0, handle1} = Mojo.createMessagePipe(); |
| 35 |
| 36 handle0.close(); |
| 37 handle0.watch({writable: true}, test.step_func_done((result) => { |
| 38 assert_equals(result, Mojo.RESULT_INVALID_ARGUMENT); |
| 39 })); |
| 40 }, "Watch invalid handle"); |
| 41 |
| 42 async_test((test) => { |
| 43 let {handle0, handle1} = Mojo.createMessagePipe(); |
| 44 |
| 45 handle0.watch({}, test.step_func_done((result) => { |
| 46 assert_equals(result, Mojo.RESULT_FAILED_PRECONDITION); |
| 47 })); |
| 48 }, "Watch with default MojoHandleSignals"); |
| 49 |
| 50 async_test((test) => { |
| 51 let {handle0, handle1} = Mojo.createMessagePipe(); |
| 52 |
| 53 let watcher = handle0.watch( |
| 54 {writable: true}, |
| 55 test.unreached_func("callback triggered after canceling watch")); |
| 56 watcher.cancel(); |
| 57 setTimeout(() => { test.done(); }); |
| 58 }, "Cancel watch"); |
| 59 |
| 60 </script> |
OLD | NEW |