| Index: third_party/WebKit/LayoutTests/mojo/data-pipe.html
|
| diff --git a/third_party/WebKit/LayoutTests/mojo/data-pipe.html b/third_party/WebKit/LayoutTests/mojo/data-pipe.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..857c2b513f0a1e7af84f7c2944b071c59f948895
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/mojo/data-pipe.html
|
| @@ -0,0 +1,44 @@
|
| +<!DOCTYPE html>
|
| +<title>Mojo data pipe tests</title>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +<script>
|
| +
|
| +let kElementNumBytes = 1;
|
| +let kCapacityNumBytes = 64;
|
| +
|
| +function createDataPipe() {
|
| + return Mojo.createDataPipe({
|
| + elementNumBytes: kElementNumBytes,
|
| + capacityNumBytes: kCapacityNumBytes
|
| + });
|
| +};
|
| +
|
| +test(() => {
|
| + let {result, producer, consumer} = createDataPipe();
|
| + assert_equals(result, Mojo.RESULT_OK);
|
| + assert_true(producer instanceof MojoHandle);
|
| + assert_true(consumer instanceof MojoHandle);
|
| +}, "Create data pipe");
|
| +
|
| +async_test((test) => {
|
| + let {producer, consumer} = createDataPipe();
|
| +
|
| + let data = new Uint8Array(kCapacityNumBytes);
|
| + for (let i = 0; i < data.length; ++i)
|
| + data[i] = i;
|
| +
|
| + consumer.watch({readable: true}, test.step_func_done((result) => {
|
| + assert_equals(result, Mojo.RESULT_OK);
|
| +
|
| + var {result, numBytes} = consumer.readData({query: true});
|
| + assert_equals(result, Mojo.RESULT_OK);
|
| + assert_equals(numBytes, data.length);
|
| + }));
|
| +
|
| + let {result, numBytes} = producer.writeData(data);
|
| + assert_equals(result, Mojo.RESULT_OK);
|
| + assert_equals(numBytes, data.length);
|
| +}, "Send data");
|
| +
|
| +</script>
|
|
|