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

Side by Side Diff: LayoutTests/fast/workers/resources/worker-sharedarraybuffer-transfer.js

Issue 1097773004: Sharing of SharedArrayBuffer via PostMessage transfer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: additional flag in virtual test suite Created 5 years, 5 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 function verifyArray(ta, length) {
2 for (i = 0; i < length; ++i) {
3 if (ta[i] != i) {
4 postMessage("FAIL: Transferred data is incorrect. Expected " +
5 i + " got " + ta[i]);
6 return;
7 }
8 }
9 postMessage("PASS: Transferred data is OK.");
10 }
11
12 function verifyArrayType(ta, name) {
13 var className = Object.prototype.toString.call(ta);
14 if (className.indexOf(name) != -1)
15 postMessage("PASS: Transferred array type is OK.");
16 else
17 postMessage("FAIL: Expected array type " + name + " got " + className);
18 }
19
20 self.addEventListener('message', function(e) {
21 var i;
22 var sab;
23 var ta;
24
25 switch (e.data.name) {
26 case 'SharedArrayBuffer':
27 sab = e.data.data;
28 ta = new Uint8Array(sab);
29 verifyArray(ta, e.data.length);
30 break;
31
32 case 'Int8Array':
33 case 'Uint8Array':
34 case 'Uint8ClampedArray':
35 case 'Int16Array':
36 case 'Uint16Array':
37 case 'Int32Array':
38 case 'Uint32Array':
39 case 'Float32Array':
40 case 'Float64Array':
41 ta = e.data.data;
42 verifyArrayType(ta, e.data.name);
43 verifyArray(ta, e.data.length);
44 break;
45
46 default:
47 postMessage("ERROR: unknown command " + e.data.name);
48 break;
49 }
50 postMessage("DONE");
51 });
OLDNEW
« no previous file with comments | « LayoutTests/VirtualTestSuites ('k') | LayoutTests/fast/workers/worker-sharedarraybuffer-transfer.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698