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

Unified Diff: third_party/WebKit/LayoutTests/mojo/data-pipe.html

Issue 2732163002: Implements JS bindings for mojo data pipe. (Closed)
Patch Set: optional args Created 3 years, 9 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/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>
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/BUILD.gn » ('j') | third_party/WebKit/Source/core/mojo/MojoHandle.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698