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

Unified Diff: third_party/WebKit/LayoutTests/mojo/shared-buffer.html

Issue 2720873002: Implements JS bindings for mojo shared buffer. (Closed)
Patch Set: rebaseline2 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/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/mojo/shared-buffer.html
diff --git a/third_party/WebKit/LayoutTests/mojo/shared-buffer.html b/third_party/WebKit/LayoutTests/mojo/shared-buffer.html
new file mode 100644
index 0000000000000000000000000000000000000000..fa95f9246ca54a9cf5f25b7988a3febc9f19b278
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/mojo/shared-buffer.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<title>Mojo shared buffer tests</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+
+let kBufferSize = 32;
+
+test(() => {
+ let {result, handle} = Mojo.createSharedBuffer(kBufferSize);
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_true(handle instanceof MojoHandle);
+}, "Create shared buffer");
+
+test(() => {
+ let {handle} = Mojo.createSharedBuffer(kBufferSize);
+ let {result, buffer} = handle.mapBuffer(0, kBufferSize);
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_true(buffer instanceof ArrayBuffer);
+}, "Map shared buffer");
+
+test(() => {
+ let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
+ let {result, handle: handle1} = handle0.duplicateBufferHandle();
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_true(handle1 instanceof MojoHandle);
+ assert_not_equals(handle1, handle0);
+}, "Duplicate RW shared buffer handle");
+
+test(() => {
+ let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
+ let {result, handle: handle1} = handle0.duplicateBufferHandle({readOnly: true});
+ assert_equals(result, Mojo.RESULT_OK);
+ assert_true(handle1 instanceof MojoHandle);
+ assert_not_equals(handle1, handle0);
+}, "Duplicate RO shared buffer handle");
+
+test(() => {
+ let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
+ let {buffer: buffer0} = handle0.mapBuffer(0, kBufferSize);
+ let array0 = new Uint8Array(buffer0);
+
+ let {handle: handle1} = handle0.duplicateBufferHandle({readOnly: true});
+ let {buffer: buffer1} = handle1.mapBuffer(0, kBufferSize);
+ let array1 = new Uint8Array(buffer1);
+
+ assert_not_equals(buffer1, buffer0);
+ for (let i = 0; i < kBufferSize; ++i) {
+ array0[i] = i;
+ assert_equals(array1[i], i);
+ }
+}, "Read from RO shared buffer handle");
+
+test(() => {
+ let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
+ let {buffer: buffer0} = handle0.mapBuffer(0, kBufferSize);
+ let array0 = new Uint8Array(buffer0);
+
+ let {handle: handle1} = handle0.duplicateBufferHandle();
+ let {buffer: buffer1} = handle1.mapBuffer(0, kBufferSize);
+ let array1 = new Uint8Array(buffer1);
+
+ assert_not_equals(buffer1, buffer0);
+ for (let i = 0; i < kBufferSize; ++i) {
+ array1[i] = i;
+ assert_equals(array0[i], i);
+ }
+}, "Write to RW shared buffer handle");
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698