зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 19e79becc540 (bug 1312817) for failures in own test on android
This commit is contained in:
Родитель
865eb293ab
Коммит
fa86fa4b7f
|
@ -997,41 +997,6 @@ WriteFormData(JSStructuredCloneWriter* aWriter,
|
|||
return aFormData->ForEach(Closure::Write, &closure);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
ReadWasmModule(JSContext* aCx,
|
||||
uint32_t aIndex,
|
||||
StructuredCloneHolder* aHolder)
|
||||
{
|
||||
MOZ_ASSERT(aHolder);
|
||||
MOZ_ASSERT(aIndex < aHolder->WasmModules().Length());
|
||||
MOZ_ASSERT(aHolder->CloneScope() == StructuredCloneHolder::StructuredCloneScope::SameProcessSameThread ||
|
||||
aHolder->CloneScope() == StructuredCloneHolder::StructuredCloneScope::SameProcessDifferentThread);
|
||||
|
||||
RefPtr<JS::WasmModule> wasmModule = aHolder->WasmModules()[aIndex];
|
||||
return wasmModule->createObject(aCx);
|
||||
}
|
||||
|
||||
bool
|
||||
WriteWasmModule(JSStructuredCloneWriter* aWriter,
|
||||
JS::WasmModule* aWasmModule,
|
||||
StructuredCloneHolder* aHolder)
|
||||
{
|
||||
MOZ_ASSERT(aWriter);
|
||||
MOZ_ASSERT(aWasmModule);
|
||||
MOZ_ASSERT(aHolder);
|
||||
MOZ_ASSERT(aHolder->CloneScope() == StructuredCloneHolder::StructuredCloneScope::SameProcessSameThread ||
|
||||
aHolder->CloneScope() == StructuredCloneHolder::StructuredCloneScope::SameProcessDifferentThread);
|
||||
|
||||
// We store the position of the wasmModule in the array as index.
|
||||
if (JS_WriteUint32Pair(aWriter, SCTAG_DOM_WASM,
|
||||
aHolder->WasmModules().Length())) {
|
||||
aHolder->WasmModules().AppendElement(aWasmModule);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
JSObject*
|
||||
|
@ -1068,11 +1033,7 @@ StructuredCloneHolder::CustomReadHandler(JSContext* aCx,
|
|||
// aIndex is the index of the cloned image.
|
||||
return ImageBitmap::ReadStructuredClone(aCx, aReader,
|
||||
parent, GetSurfaces(), aIndex);
|
||||
}
|
||||
|
||||
if (aTag == SCTAG_DOM_WASM) {
|
||||
return ReadWasmModule(aCx, aIndex, this);
|
||||
}
|
||||
}
|
||||
|
||||
return ReadFullySerializableObjects(aCx, aReader, aTag);
|
||||
}
|
||||
|
@ -1134,16 +1095,6 @@ StructuredCloneHolder::CustomWriteHandler(JSContext* aCx,
|
|||
}
|
||||
}
|
||||
|
||||
// See if this is a WasmModule.
|
||||
if ((mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
|
||||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread) &&
|
||||
JS::IsWasmModuleObject(aObj)) {
|
||||
RefPtr<JS::WasmModule> module = JS::GetWasmModule(aObj);
|
||||
MOZ_ASSERT(module);
|
||||
|
||||
return WriteWasmModule(aWriter, module, this);
|
||||
}
|
||||
|
||||
return WriteFullySerializableObjects(aCx, aWriter, aObj);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#ifndef mozilla_dom_StructuredCloneHolder_h
|
||||
#define mozilla_dom_StructuredCloneHolder_h
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "js/StructuredClone.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
@ -179,7 +178,6 @@ public:
|
|||
bool HasClonedDOMObjects() const
|
||||
{
|
||||
return !mBlobImplArray.IsEmpty() ||
|
||||
!mWasmModuleArray.IsEmpty() ||
|
||||
!mClonedSurfaces.IsEmpty();
|
||||
}
|
||||
|
||||
|
@ -189,12 +187,6 @@ public:
|
|||
return mBlobImplArray;
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<JS::WasmModule>>& WasmModules()
|
||||
{
|
||||
MOZ_ASSERT(mSupportsCloning, "WasmModules cannot be taken/set if cloning is not supported.");
|
||||
return mWasmModuleArray;
|
||||
}
|
||||
|
||||
StructuredCloneScope CloneScope() const
|
||||
{
|
||||
return mStructuredCloneScope;
|
||||
|
@ -300,9 +292,6 @@ protected:
|
|||
// Used for cloning blobs in the structured cloning algorithm.
|
||||
nsTArray<RefPtr<BlobImpl>> mBlobImplArray;
|
||||
|
||||
// Used for cloning JS::WasmModules in the structured cloning algorithm.
|
||||
nsTArray<RefPtr<JS::WasmModule>> mWasmModuleArray;
|
||||
|
||||
// This is used for sharing the backend of ImageBitmaps.
|
||||
// The DataSourceSurface object must be thread-safely reference-counted.
|
||||
// The DataSourceSurface object will not be written ever via any ImageBitmap
|
||||
|
|
|
@ -11,17 +11,13 @@
|
|||
<script type="application/javascript;version=1.7">
|
||||
|
||||
function setup_tests() {
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true],
|
||||
["javascript.options.wasm", true]]}, next);
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true]]}, next);
|
||||
}
|
||||
|
||||
function getType(a) {
|
||||
if (a === null || a === undefined)
|
||||
return 'null';
|
||||
|
||||
if (a instanceof WebAssembly.Module)
|
||||
return "wasm";
|
||||
|
||||
if (Array.isArray(a))
|
||||
return 'array';
|
||||
|
||||
|
@ -63,32 +59,21 @@ function compare(a, b) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == 'wasm') {
|
||||
var wasmA = new WebAssembly.Instance(a);
|
||||
ok(wasmA instanceof WebAssembly.Instance, "got an instance");
|
||||
|
||||
var wasmB = new WebAssembly.Instance(b);
|
||||
ok(wasmB instanceof WebAssembly.Instance, "got an instance");
|
||||
|
||||
ok(wasmA.exports.foo() === wasmB.exports.foo(), "Same result!");
|
||||
ok(wasmB.exports.foo() === 42, "We want 42");
|
||||
}
|
||||
|
||||
if (type != 'null') {
|
||||
is (a.toSource(), b.toSource(), 'Matching using toSource()');
|
||||
}
|
||||
}
|
||||
|
||||
var clonableObjects = [
|
||||
{ target: 'all', data: 'hello world' },
|
||||
{ target: 'all', data: 123 },
|
||||
{ target: 'all', data: null },
|
||||
{ target: 'all', data: true },
|
||||
{ target: 'all', data: new Date() },
|
||||
{ target: 'all', data: [ 1, 'test', true, new Date() ] },
|
||||
{ target: 'all', data: { a: true, b: null, c: new Date(), d: [ true, false, {} ] } },
|
||||
{ target: 'all', data: new Blob([123], { type: 'plain/text' }) },
|
||||
{ target: 'all', data: new ImageData(2, 2) },
|
||||
'hello world',
|
||||
123,
|
||||
null,
|
||||
true,
|
||||
new Date(),
|
||||
[ 1, 'test', true, new Date() ],
|
||||
{ a: true, b: null, c: new Date(), d: [ true, false, {} ] },
|
||||
new Blob([123], { type: 'plain/text' }),
|
||||
new ImageData(2, 2),
|
||||
];
|
||||
|
||||
function create_fileList() {
|
||||
|
@ -103,7 +88,7 @@ function create_fileList() {
|
|||
var domFile = fileList.files[0];
|
||||
is(domFile.name, "prefs.js", "fileName should be prefs.js");
|
||||
|
||||
clonableObjects.push({ target: 'all', data: fileList.files });
|
||||
clonableObjects.push(fileList.files);
|
||||
script.destroy();
|
||||
next();
|
||||
}
|
||||
|
@ -130,7 +115,7 @@ function create_directory() {
|
|||
is(list.length, 1, "This list has 1 element");
|
||||
ok(list[0] instanceof Directory, "We have a directory.");
|
||||
|
||||
clonableObjects.push({ target: 'all', data: list[0] });
|
||||
clonableObjects.push(list[0]);
|
||||
script.destroy();
|
||||
next();
|
||||
});
|
||||
|
@ -140,41 +125,14 @@ function create_directory() {
|
|||
script.sendAsyncMessage("dir.open");
|
||||
}
|
||||
|
||||
function create_wasmModule() {
|
||||
info("Checking if we can play with WebAssembly...");
|
||||
|
||||
if (!SpecialPowers.Cu.getJSTestingFunctions().wasmIsSupported()) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
ok(WebAssembly, "WebAssembly object should exist");
|
||||
ok(WebAssembly.compile, "WebAssembly.compile function should exist");
|
||||
|
||||
const wasmTextToBinary = SpecialPowers.unwrap(SpecialPowers.Cu.getJSTestingFunctions().wasmTextToBinary);
|
||||
const fooModuleCode = wasmTextToBinary(`(module
|
||||
(func $foo (result i32) (i32.const 42))
|
||||
(export "foo" $foo)
|
||||
)`, 'new-format');
|
||||
|
||||
WebAssembly.compile(fooModuleCode).then((m) => {
|
||||
ok(m instanceof WebAssembly.Module, "The WasmModule has been compiled.");
|
||||
clonableObjects.push({ target: 'sameProcess', data: m });
|
||||
next();
|
||||
}, () => {
|
||||
ok(false, "The compilation of the wasmModule failed.");
|
||||
});
|
||||
}
|
||||
|
||||
function runTests(obj) {
|
||||
ok(('clonableObjectsEveryWhere' in obj) &&
|
||||
('clonableObjectsSameProcess' in obj) &&
|
||||
ok(('clonableObjects' in obj) &&
|
||||
('transferableObjects' in obj) &&
|
||||
(obj.clonableObjectsEveryWhere || obj.clonableObjectsSameProcess || obj.transferableObjects), "We must run some test!");
|
||||
(obj.clonableObjects || obj.transferableObjects), "We must run some test!");
|
||||
|
||||
// cloning tests - everyWhere
|
||||
// cloning tests
|
||||
new Promise(function(resolve, reject) {
|
||||
if (!obj.clonableObjectsEveryWhere) {
|
||||
if (!obj.clonableObjects) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
@ -188,13 +146,8 @@ function runTests(obj) {
|
|||
|
||||
var object = clonableObjects[clonableObjectsId++];
|
||||
|
||||
if (object.target != 'all') {
|
||||
runClonableTest();
|
||||
return;
|
||||
}
|
||||
|
||||
obj.send(object.data, []).then(function(received) {
|
||||
compare(received.data, object.data);
|
||||
obj.send(object, []).then(function(received) {
|
||||
compare(received.data, object);
|
||||
runClonableTest();
|
||||
});
|
||||
}
|
||||
|
@ -202,38 +155,6 @@ function runTests(obj) {
|
|||
runClonableTest();
|
||||
})
|
||||
|
||||
// clonable same process
|
||||
.then(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!obj.clonableObjectsSameProcess) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
var clonableObjectsId = 0;
|
||||
function runClonableTest() {
|
||||
if (clonableObjectsId >= clonableObjects.length) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
var object = clonableObjects[clonableObjectsId++];
|
||||
|
||||
if (object.target != 'sameProcess') {
|
||||
runClonableTest();
|
||||
return;
|
||||
}
|
||||
|
||||
obj.send(object.data, []).then(function(received) {
|
||||
compare(received.data, object.data);
|
||||
runClonableTest();
|
||||
});
|
||||
}
|
||||
|
||||
runClonableTest();
|
||||
});
|
||||
})
|
||||
|
||||
// transfering tests
|
||||
.then(function() {
|
||||
if (!obj.transferableObjects) {
|
||||
|
@ -313,8 +234,7 @@ function test_windowToWindow() {
|
|||
}
|
||||
|
||||
runTests({
|
||||
clonableObjectsEveryWhere: true,
|
||||
clonableObjectsSameProcess: true,
|
||||
clonableObjects: true,
|
||||
transferableObjects: true,
|
||||
send: function(what, ports) {
|
||||
return new Promise(function(r, rr) {
|
||||
|
@ -367,8 +287,7 @@ function test_windowToIframeURL(url) {
|
|||
ifr.src = url;
|
||||
ifr.onload = function() {
|
||||
runTests({
|
||||
clonableObjectsEveryWhere: true,
|
||||
clonableObjectsSameProcess: false,
|
||||
clonableObjects: true,
|
||||
transferableObjects: true,
|
||||
send: function(what, ports) {
|
||||
return new Promise(function(r, rr) {
|
||||
|
@ -415,8 +334,7 @@ function test_workers() {
|
|||
}
|
||||
|
||||
runTests({
|
||||
clonableObjectsEveryWhere: true,
|
||||
clonableObjectsSameProcess: true,
|
||||
clonableObjects: true,
|
||||
transferableObjects: true,
|
||||
send: function(what, ports) {
|
||||
return new Promise(function(r, rr) {
|
||||
|
@ -459,8 +377,7 @@ function test_broadcastChannel() {
|
|||
}
|
||||
|
||||
runTests({
|
||||
clonableObjectsEveryWhere: true,
|
||||
clonableObjectsSameProcess: false,
|
||||
clonableObjects: true,
|
||||
transferableObjects: false,
|
||||
send: function(what, ports) {
|
||||
return new Promise(function(r, rr) {
|
||||
|
@ -505,8 +422,7 @@ function test_broadcastChannel_inWorkers() {
|
|||
}
|
||||
|
||||
runTests({
|
||||
clonableObjectsEveryWhere: true,
|
||||
clonableObjectsSameProcess: false,
|
||||
clonableObjects: true,
|
||||
transferableObjects: false,
|
||||
send: function(what, ports) {
|
||||
return new Promise(function(r, rr) {
|
||||
|
@ -547,8 +463,7 @@ function test_messagePort() {
|
|||
}
|
||||
|
||||
runTests({
|
||||
clonableObjectsEveryWhere: true,
|
||||
clonableObjectsSameProcess: false,
|
||||
clonableObjects: true,
|
||||
transferableObjects: true,
|
||||
send: function(what, ports) {
|
||||
return new Promise(function(r, rr) {
|
||||
|
@ -593,8 +508,7 @@ function test_messagePort_inWorkers() {
|
|||
}
|
||||
|
||||
runTests({
|
||||
clonableObjectsEveryWhere: true,
|
||||
clonableObjectsSameProcess: false,
|
||||
clonableObjects: true,
|
||||
transferableObjects: true,
|
||||
send: function(what, ports) {
|
||||
return new Promise(function(r, rr) {
|
||||
|
@ -621,7 +535,6 @@ var tests = [
|
|||
|
||||
create_fileList,
|
||||
create_directory,
|
||||
create_wasmModule,
|
||||
|
||||
test_windowToWindow,
|
||||
test_windowToIframe,
|
||||
|
|
|
@ -46,7 +46,6 @@ StructuredCloneData::Copy(const StructuredCloneData& aData)
|
|||
BlobImpls().AppendElements(aData.BlobImpls());
|
||||
|
||||
MOZ_ASSERT(GetSurfaces().IsEmpty());
|
||||
MOZ_ASSERT(WasmModules().IsEmpty());
|
||||
|
||||
mInitialized = true;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче