Bug 1562663 - P5 - Fix try failures; r=nika,lth

Differential Revision: https://phabricator.services.mozilla.com/D46492

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Tung 2019-09-26 13:28:21 +00:00
Родитель 27676f6b0d
Коммит 05f490fe48
6 изменённых файлов: 13 добавлений и 10 удалений

Просмотреть файл

@ -6627,7 +6627,7 @@ gc::ZealModeHelpText),
"serialize(data, [transferables, [policy]])",
" Serialize 'data' using JS_WriteStructuredClone. Returns a structured\n"
" clone buffer object. 'policy' may be an options hash. Valid keys:\n"
" 'SharedArrayBuffer' - either 'allow' (the default) or 'deny'\n"
" 'SharedArrayBuffer' - either 'allow' or 'deny' (the default)\n"
" to specify whether SharedArrayBuffers may be serialized.\n"
" 'scope' - SameProcessSameThread, SameProcessDifferentThread,\n"
" DifferentProcess, or DifferentProcessForIndexedDB. Determines how some\n"

Просмотреть файл

@ -24,7 +24,7 @@
// Serialization and deserialization of shared memories work:
let mem2 = deserialize(serialize(mem1));
let mem2 = deserialize(serialize(mem1, [], {SharedArrayBuffer: 'allow'}));
assertEq(mem2 instanceof WebAssembly.Memory, true);
let buf2 = mem2.buffer;
assertEq(buf2 instanceof SharedArrayBuffer, true);
@ -79,7 +79,7 @@
{
let mem = new WebAssembly.Memory({initial: 2, maximum: 4, shared: true});
let buf = mem.buffer;
let clonedbuf = serialize(buf);
let clonedbuf = serialize(buf, [], {SharedArrayBuffer: 'allow'});
mem.grow(1);
let buf2 = deserialize(clonedbuf);
assertEq(buf.byteLength, buf2.byteLength);

Просмотреть файл

@ -18,7 +18,7 @@ let x = new SharedArrayBuffer(1);
// Initially the reference count is 1.
assertEq(sharedArrayRawBufferRefcount(x), 1);
let y = serialize(x);
let y = serialize(x, [], {SharedArrayBuffer: 'allow'});
// Serializing it successfully increments the reference count.
assertEq(sharedArrayRawBufferRefcount(x), 2);

Просмотреть файл

@ -28,7 +28,7 @@ if (sharedArrayRawBufferCount() == 0) {
assertEq(sharedArrayRawBufferCount(), 1+k);
// Capture the buffer in a serialization object.
var y = serialize(sab)
var y = serialize(sab, [], {SharedArrayBuffer: 'allow'})
// Serializing it did not increase the number of buffers.
assertEq(sharedArrayRawBufferCount(), 1+k);

Просмотреть файл

@ -15,7 +15,7 @@ if (!this.SharedArrayBuffer) {
}
let x = new SharedArrayBuffer(1);
let y = serialize(x);
let y = serialize(x, [], {SharedArrayBuffer: 'allow'});
x = null;
// If the bug is present this loop usually crashes quickly during

Просмотреть файл

@ -169,7 +169,7 @@ function testSharedTypedArrayMethods() {
function testClone1() {
var sab1 = b;
var blob = serialize(sab1, []);
var blob = serialize(sab1, [], {SharedArrayBuffer: 'allow'});
var sab2 = deserialize(blob);
if (typeof sharedAddress != "undefined")
assertEq(sharedAddress(sab1), sharedAddress(sab2));
@ -178,7 +178,7 @@ function testClone1() {
function testClone2() {
var sab = b;
var ia1 = new Int32Array(sab);
var blob = serialize(ia1, []);
var blob = serialize(ia1, [], {SharedArrayBuffer: 'allow'});
var ia2 = deserialize(blob);
assertEq(ia1.length, ia2.length);
assertEq(ia1.buffer instanceof SharedArrayBuffer, true);
@ -189,7 +189,7 @@ function testClone2() {
}
// Serializing a SharedArrayBuffer should fail if we've set its flag to 'deny' or if
// the flag is bogus.
// the flag is bogus or if the flag is not set to 'allow' explicitly
function testNoClone() {
// This just tests the API in serialize()
@ -198,6 +198,9 @@ function testNoClone() {
// This tests the actual cloning functionality - should fail
assertThrowsInstanceOf(() => serialize(b, [], {SharedArrayBuffer: 'deny'}), TypeError);
// This tests that cloning a SharedArrayBuffer is not allowed by default
assertThrowsInstanceOf(() => serialize(b), TypeError);
// Ditto - should succeed
assertEq(typeof serialize(b, [], {SharedArrayBuffer: 'allow'}), "object");
}
@ -206,7 +209,7 @@ function testRedundantTransfer() {
// Throws TypeError in the shell, DataCloneError in the browser.
assertThrowsInstanceOf(() => {
var sab1 = b;
var blob = serialize(sab1, [sab1]);
var blob = serialize(sab1, [sab1], {SharedArrayBuffer: 'allow'});
}, TypeError);
}