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

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

Issue 2720873002: Implements JS bindings for mojo shared buffer. (Closed)
Patch Set: adds layout tests 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
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.clone();
yzshen1 2017/03/01 23:11:46 Clone is not a great name in that it sounds like a
alokp 2017/03/01 23:58:34 I was following the C++ API: https://cs.chromium.o
yzshen1 2017/03/02 17:41:07 I would vote for "duplicate" to be consistent with
25 assert_equals(result, Mojo.RESULT_OK);
26 assert_true(handle1 instanceof MojoHandle);
27 }, "Clone RW shared buffer handle");
28
29 test(() => {
30 let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
31 let {result, handle: handle1} = handle0.clone({readOnly: true});
32 assert_equals(result, Mojo.RESULT_OK);
33 assert_true(handle1 instanceof MojoHandle);
34 }, "Clone RO shared buffer handle");
35
36 test(() => {
37 let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
38 let {buffer: buffer0} = handle0.mapBuffer(0, kBufferSize);
39 let array0 = new Uint8Array(buffer0);
40
41 let {handle: handle1} = handle0.clone({readOnly: true});
42 let {buffer: buffer1} = handle1.mapBuffer(0, kBufferSize);
jbroman 2017/03/01 23:29:37 nit: Consider verifying that handle1 != handle0 an
alokp 2017/03/01 23:58:34 Done. Added "handle1 != handle0" checks to clone t
43 let array1 = new Uint8Array(buffer1);
44
45 for (let i = 0; i < kBufferSize; ++i) {
46 array0[i] = i;
47 assert_equals(array1[i], i);
48 }
49 }, "Read from RO shared buffer handle");
50
51 test(() => {
52 let {handle: handle0} = Mojo.createSharedBuffer(kBufferSize);
53 let {buffer: buffer0} = handle0.mapBuffer(0, kBufferSize);
54 let array0 = new Uint8Array(buffer0);
55
56 let {handle: handle1} = handle0.clone();
57 let {buffer: buffer1} = handle1.mapBuffer(0, kBufferSize);
58 let array1 = new Uint8Array(buffer1);
59
60 for (let i = 0; i < kBufferSize; ++i) {
61 array1[i] = i;
62 assert_equals(array0[i], i);
63 }
64 }, "Write to RW shared buffer handle");
65
66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698