зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset e7d649603075 (bug 842081) for mochitest-4 bustage on a CLOSED TREE
This commit is contained in:
Родитель
ac2a7d628f
Коммит
1172712d65
|
@ -22,7 +22,7 @@ Tests of DOM Worker transferable objects
|
|||
|
||||
function test1(sizes) {
|
||||
if (!sizes.length) {
|
||||
runTests();
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,15 +32,10 @@ Tests of DOM Worker transferable objects
|
|||
worker.onmessage = function(event) {
|
||||
ok(event.data.status, event.data.event);
|
||||
if (!event.data.status) {
|
||||
runTests();
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if ("notEmpty" in event.data && "byteLength" in event.data.notEmpty) {
|
||||
ok(event.data.notEmpty.byteLength != 0,
|
||||
"P: NotEmpty object received: " + event.data.notEmpty.byteLength);
|
||||
}
|
||||
|
||||
if (!event.data.last)
|
||||
return;
|
||||
|
||||
|
@ -65,57 +60,14 @@ Tests of DOM Worker transferable objects
|
|||
ok(true, "P: PostMessage - Exception for duplicate");
|
||||
}
|
||||
|
||||
var ab = new ArrayBuffer(size);
|
||||
ab = new ArrayBuffer(size);
|
||||
ok(ab.byteLength == size, "P: The size is: " + size + " == " + ab.byteLength);
|
||||
worker.postMessage({ data: 0, timeout: 0, ab: ab, cb: ab, size: size }, [ab]);
|
||||
ok(ab.byteLength == 0, "P: PostMessage - The size is: 0 == " + ab.byteLength)
|
||||
}
|
||||
|
||||
function test2() {
|
||||
var worker = new Worker("transferable_worker.js");
|
||||
worker.onmessage = function(event) {
|
||||
ok(event.data.status, event.data.event);
|
||||
if (!event.data.status) {
|
||||
runTests();
|
||||
return;
|
||||
}
|
||||
|
||||
if ("notEmpty" in event.data && "byteLength" in event.data.notEmpty) {
|
||||
ok(event.data.notEmpty.byteLength != 0,
|
||||
"P: NotEmpty object received: " + event.data.notEmpty.byteLength);
|
||||
}
|
||||
|
||||
if (event.data.last) {
|
||||
runTests();
|
||||
}
|
||||
}
|
||||
worker.onerror = function(event) {
|
||||
ok(false, "No errors!");
|
||||
}
|
||||
|
||||
var f = new Float32Array([0,1,2,3]);
|
||||
ok(f.byteLength != 0, "P: The size is: " + f.byteLength + " is not 0");
|
||||
worker.postMessage({ event: "P: postMessage with Float32Array", status: true,
|
||||
size: 4, notEmpty: f, bc: [ f, f, { dd: f } ] }, [f.buffer]);
|
||||
ok(f.byteLength == 0, "P: The size is: " + f.byteLength + " is 0");
|
||||
}
|
||||
|
||||
var tests = [
|
||||
function() { test1([1024 * 1024 * 32, 128, 4]); },
|
||||
test2
|
||||
];
|
||||
function runTests() {
|
||||
if (!tests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
var test = tests.shift();
|
||||
test();
|
||||
}
|
||||
|
||||
test1([1024 * 1024 * 32, 128, 4]);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
runTests();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
|
@ -4,20 +4,30 @@
|
|||
*/
|
||||
|
||||
onmessage = function(event) {
|
||||
if ("notEmpty" in event.data && "byteLength" in event.data.notEmpty) {
|
||||
postMessage({ event: "W: NotEmpty object received: " + event.data.notEmpty.byteLength,
|
||||
status: event.data.notEmpty.byteLength != 0, last: false });
|
||||
if (event.data.data == 0) {
|
||||
ab = new ArrayBuffer(event.data.size);
|
||||
postMessage({ event: "W: The size is: " + event.data.size + " == " + ab.byteLength,
|
||||
status: ab.byteLength == event.data.size, last: false });
|
||||
|
||||
postMessage({ event: "W: postMessage with arrayBuffer", status: true,
|
||||
ab: ab, bc: [ ab, ab, { dd: ab } ] }, [ab]);
|
||||
|
||||
postMessage({ event: "W: The size is: 0 == " + ab.byteLength,
|
||||
status: ab.byteLength == 0, last: false });
|
||||
|
||||
postMessage({ event: "last one!", status: true, last: true });
|
||||
|
||||
} else {
|
||||
var worker = new Worker('sync_worker.js');
|
||||
worker.onmessage = function(event) {
|
||||
postMessage(event.data);
|
||||
}
|
||||
worker.onsyncmessage = function(event) {
|
||||
var v = postSyncMessage(event.data, null, 500);
|
||||
event.reply(v);
|
||||
}
|
||||
|
||||
--event.data.data;
|
||||
worker.postMessage(event.data);
|
||||
}
|
||||
|
||||
var ab = new ArrayBuffer(event.data.size);
|
||||
postMessage({ event: "W: The size is: " + event.data.size + " == " + ab.byteLength,
|
||||
status: ab.byteLength == event.data.size, last: false });
|
||||
|
||||
postMessage({ event: "W: postMessage with arrayBuffer", status: true,
|
||||
notEmpty: ab, ab: ab, bc: [ ab, ab, { dd: ab } ] }, [ab]);
|
||||
|
||||
postMessage({ event: "W: The size is: 0 == " + ab.byteLength,
|
||||
status: ab.byteLength == 0, last: false });
|
||||
|
||||
postMessage({ event: "W: last one!", status: true, last: true });
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче