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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/VirtualTestSuites ('k') | LayoutTests/fast/workers/worker-sharedarraybuffer-transfer.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/workers/resources/worker-sharedarraybuffer-transfer.js
diff --git a/LayoutTests/fast/workers/resources/worker-sharedarraybuffer-transfer.js b/LayoutTests/fast/workers/resources/worker-sharedarraybuffer-transfer.js
new file mode 100644
index 0000000000000000000000000000000000000000..333c2e46f7b0c5c3b11d356bb211b6e85c98e86b
--- /dev/null
+++ b/LayoutTests/fast/workers/resources/worker-sharedarraybuffer-transfer.js
@@ -0,0 +1,51 @@
+function verifyArray(ta, length) {
+ for (i = 0; i < length; ++i) {
+ if (ta[i] != i) {
+ postMessage("FAIL: Transferred data is incorrect. Expected " +
+ i + " got " + ta[i]);
+ return;
+ }
+ }
+ postMessage("PASS: Transferred data is OK.");
+}
+
+function verifyArrayType(ta, name) {
+ var className = Object.prototype.toString.call(ta);
+ if (className.indexOf(name) != -1)
+ postMessage("PASS: Transferred array type is OK.");
+ else
+ postMessage("FAIL: Expected array type " + name + " got " + className);
+}
+
+self.addEventListener('message', function(e) {
+ var i;
+ var sab;
+ var ta;
+
+ switch (e.data.name) {
+ case 'SharedArrayBuffer':
+ sab = e.data.data;
+ ta = new Uint8Array(sab);
+ verifyArray(ta, e.data.length);
+ break;
+
+ case 'Int8Array':
+ case 'Uint8Array':
+ case 'Uint8ClampedArray':
+ case 'Int16Array':
+ case 'Uint16Array':
+ case 'Int32Array':
+ case 'Uint32Array':
+ case 'Float32Array':
+ case 'Float64Array':
+ ta = e.data.data;
+ verifyArrayType(ta, e.data.name);
+ verifyArray(ta, e.data.length);
+ break;
+
+ default:
+ postMessage("ERROR: unknown command " + e.data.name);
+ break;
+ }
+ postMessage("DONE");
+});
« 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