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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Mojo shared buffer tests</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script>
6
7 let kBufferSize = 32;
8
9 test(() => {
10 let {result, handle} = Mojo.createSharedBuffer(kBufferSize);
11 assert_equals(result, Mojo.RESULT_OK);
12 assert_true(handle instanceof MojoHandle);
13 }, "Create shared buffer");
14
15 test(() => {
16 let {handle} = Mojo.createSharedBuffer(kBufferSize);
17 let {result, buffer} = handle.mapBuffer(0, kBufferSize);
18 assert_equals(result, Mojo.RESULT_OK);
19 assert_true(buffer instanceof ArrayBuffer);
20 }, "Map shared buffer");
21
22 test(() => {
23 let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
24 let {result, handle: handle1} = handle0.duplicateBufferHandle();
25 assert_equals(result, Mojo.RESULT_OK);
26 assert_true(handle1 instanceof MojoHandle);
27 assert_not_equals(handle1, handle0);
28 }, "Duplicate RW shared buffer handle");
29
30 test(() => {
31 let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
32 let {result, handle: handle1} = handle0.duplicateBufferHandle({readOnly: true} );
33 assert_equals(result, Mojo.RESULT_OK);
34 assert_true(handle1 instanceof MojoHandle);
35 assert_not_equals(handle1, handle0);
36 }, "Duplicate RO shared buffer handle");
37
38 test(() => {
39 let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
40 let {buffer: buffer0} = handle0.mapBuffer(0, kBufferSize);
41 let array0 = new Uint8Array(buffer0);
42
43 let {handle: handle1} = handle0.duplicateBufferHandle({readOnly: true});
44 let {buffer: buffer1} = handle1.mapBuffer(0, kBufferSize);
45 let array1 = new Uint8Array(buffer1);
46
47 assert_not_equals(buffer1, buffer0);
48 for (let i = 0; i < kBufferSize; ++i) {
49 array0[i] = i;
50 assert_equals(array1[i], i);
51 }
52 }, "Read from RO shared buffer handle");
53
54 test(() => {
55 let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
56 let {buffer: buffer0} = handle0.mapBuffer(0, kBufferSize);
57 let array0 = new Uint8Array(buffer0);
58
59 let {handle: handle1} = handle0.duplicateBufferHandle();
60 let {buffer: buffer1} = handle1.mapBuffer(0, kBufferSize);
61 let array1 = new Uint8Array(buffer1);
62
63 assert_not_equals(buffer1, buffer0);
64 for (let i = 0; i < kBufferSize; ++i) {
65 array1[i] = i;
66 assert_equals(array0[i], i);
67 }
68 }, "Write to RW shared buffer handle");
69
70 </script>
OLDNEW
« 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