summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
Diffstat (limited to 'dom')
-rw-r--r--dom/base/StructuredCloneHolder.cpp34
-rw-r--r--dom/base/nsFrameMessageManager.cpp5
-rw-r--r--dom/base/nsStructuredCloneContainer.cpp2
-rw-r--r--dom/broadcastchannel/BroadcastChannel.cpp4
-rw-r--r--dom/canvas/CanvasRenderingContext2D.cpp14
-rw-r--r--dom/canvas/CanvasRenderingContext2D.h5
-rw-r--r--dom/filesystem/tests/test_webkitdirectory.html1
-rw-r--r--dom/indexedDB/ActorsParent.cpp35
-rw-r--r--dom/indexedDB/IDBObjectStore.cpp8
-rw-r--r--dom/indexedDB/IndexedDatabase.h4
-rw-r--r--dom/indexedDB/IndexedDatabaseInlines.h11
-rw-r--r--dom/ipc/ContentParent.cpp8
-rw-r--r--dom/ipc/StructuredCloneData.cpp4
-rw-r--r--dom/ipc/StructuredCloneData.h23
-rw-r--r--dom/xbl/nsXBLBinding.cpp12
15 files changed, 101 insertions, 69 deletions
diff --git a/dom/base/StructuredCloneHolder.cpp b/dom/base/StructuredCloneHolder.cpp
index 1c27c632e0..8e7cee340f 100644
--- a/dom/base/StructuredCloneHolder.cpp
+++ b/dom/base/StructuredCloneHolder.cpp
@@ -1075,9 +1075,9 @@ StructuredCloneHolder::CustomReadHandler(JSContext* aCx,
return ReadFormData(aCx, aReader, aIndex, this);
}
- if (aTag == SCTAG_DOM_IMAGEBITMAP) {
- MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
- mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
+ if (aTag == SCTAG_DOM_IMAGEBITMAP &&
+ (mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
+ mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
// Get the current global object.
// This can be null.
@@ -1087,7 +1087,9 @@ StructuredCloneHolder::CustomReadHandler(JSContext* aCx,
parent, GetSurfaces(), aIndex);
}
- if (aTag == SCTAG_DOM_WASM) {
+ if (aTag == SCTAG_DOM_WASM &&
+ (mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
+ mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
return ReadWasmModule(aCx, aIndex, this);
}
@@ -1202,9 +1204,9 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
return true;
}
- if (aTag == SCTAG_DOM_CANVAS) {
- MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
- mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
+ if (aTag == SCTAG_DOM_CANVAS &&
+ (mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
+ mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
OffscreenCanvasCloneData* data =
static_cast<OffscreenCanvasCloneData*>(aContent);
@@ -1222,9 +1224,9 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
return true;
}
- if (aTag == SCTAG_DOM_IMAGEBITMAP) {
- MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
- mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
+ if (aTag == SCTAG_DOM_IMAGEBITMAP &&
+ (mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
+ mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
ImageBitmapCloneData* data =
static_cast<ImageBitmapCloneData*>(aContent);
@@ -1328,9 +1330,9 @@ StructuredCloneHolder::CustomFreeTransferHandler(uint32_t aTag,
return;
}
- if (aTag == SCTAG_DOM_CANVAS) {
- MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
- mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
+ if (aTag == SCTAG_DOM_CANVAS &&
+ (mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
+ mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
OffscreenCanvasCloneData* data =
static_cast<OffscreenCanvasCloneData*>(aContent);
@@ -1338,9 +1340,9 @@ StructuredCloneHolder::CustomFreeTransferHandler(uint32_t aTag,
return;
}
- if (aTag == SCTAG_DOM_IMAGEBITMAP) {
- MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
- mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
+ if (aTag == SCTAG_DOM_IMAGEBITMAP &&
+ (mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
+ mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
ImageBitmapCloneData* data =
static_cast<ImageBitmapCloneData*>(aContent);
diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp
index 049bc0a1ae..6fffd376b2 100644
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -271,10 +271,10 @@ BuildClonedMessageData(typename BlobTraits<Flavor>::ConcreteContentManagerType*
ClonedMessageData& aClonedData)
{
SerializedStructuredCloneBuffer& buffer = aClonedData.data();
- auto iter = aData.Data().Iter();
+ auto iter = aData.Data().Start();
size_t size = aData.Data().Size();
bool success;
- buffer.data = aData.Data().Borrow<js::SystemAllocPolicy>(iter, size, &success);
+ buffer.data = aData.Data().Borrow(iter, size, &success);
if (NS_WARN_IF(!success)) {
return false;
}
@@ -1286,6 +1286,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
if (aRetVal) {
ErrorResult rv;
StructuredCloneData* data = aRetVal->AppendElement();
+ data->InitScope(JS::StructuredCloneScope::DifferentProcess);
data->Write(cx, rval, rv);
if (NS_WARN_IF(rv.Failed())) {
aRetVal->RemoveElementAt(aRetVal->Length() - 1);
diff --git a/dom/base/nsStructuredCloneContainer.cpp b/dom/base/nsStructuredCloneContainer.cpp
index 8c2cdc0911..ea2d38bc8e 100644
--- a/dom/base/nsStructuredCloneContainer.cpp
+++ b/dom/base/nsStructuredCloneContainer.cpp
@@ -137,7 +137,7 @@ nsStructuredCloneContainer::GetDataAsBase64(nsAString &aOut)
return NS_ERROR_FAILURE;
}
- auto iter = Data().Iter();
+ auto iter = Data().Start();
size_t size = Data().Size();
nsAutoCString binaryData;
binaryData.SetLength(size);
diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp
index c3c2d448b1..874212db7a 100644
--- a/dom/broadcastchannel/BroadcastChannel.cpp
+++ b/dom/broadcastchannel/BroadcastChannel.cpp
@@ -154,8 +154,8 @@ public:
bool success;
SerializedStructuredCloneBuffer& buffer = message.data();
- auto iter = mData->BufferData().Iter();
- buffer.data = mData->BufferData().Borrow<js::SystemAllocPolicy>(iter, mData->BufferData().Size(), &success);
+ auto iter = mData->BufferData().Start();
+ buffer.data = mData->BufferData().Borrow(iter, mData->BufferData().Size(), &success);
if (NS_WARN_IF(!success)) {
return NS_OK;
}
diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp
index f4c4259f68..18af28e9f7 100644
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -1862,8 +1862,6 @@ CanvasRenderingContext2D::GetHeight() const
NS_IMETHODIMP
CanvasRenderingContext2D::SetDimensions(int32_t aWidth, int32_t aHeight)
{
- ClearTarget();
-
// Zero sized surfaces can cause problems.
mZero = false;
if (aHeight == 0) {
@@ -1874,14 +1872,14 @@ CanvasRenderingContext2D::SetDimensions(int32_t aWidth, int32_t aHeight)
aWidth = 1;
mZero = true;
}
- mWidth = aWidth;
- mHeight = aHeight;
+
+ ClearTarget(aWidth, aHeight);
return NS_OK;
}
void
-CanvasRenderingContext2D::ClearTarget()
+CanvasRenderingContext2D::ClearTarget(int32_t aWidth, int32_t aHeight)
{
Reset();
@@ -1889,6 +1887,12 @@ CanvasRenderingContext2D::ClearTarget()
SetInitialState();
+ // Update dimensions only if new (strictly positive) values were passed.
+ if (aWidth > 0 && aHeight > 0) {
+ mWidth = aWidth;
+ mHeight = aHeight;
+ }
+
// For vertical writing-mode, unless text-orientation is sideways,
// we'll modify the initial value of textBaseline to 'middle'.
RefPtr<nsStyleContext> canvasStyle;
diff --git a/dom/canvas/CanvasRenderingContext2D.h b/dom/canvas/CanvasRenderingContext2D.h
index d5dff8f3b0..848b3ee083 100644
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -669,8 +669,11 @@ protected:
/**
* Disposes an old target and prepares to lazily create a new target.
+ *
+ * Parameters are the new dimensions to be used, or if either is negative,
+ * existing dimensions will be left unchanged.
*/
- void ClearTarget();
+ void ClearTarget(int32_t aWidth = -1, int32_t aHeight = -1);
/*
* Returns the target to the buffer provider. i.e. this will queue a frame for
diff --git a/dom/filesystem/tests/test_webkitdirectory.html b/dom/filesystem/tests/test_webkitdirectory.html
index 825f5e8fba..591619e45b 100644
--- a/dom/filesystem/tests/test_webkitdirectory.html
+++ b/dom/filesystem/tests/test_webkitdirectory.html
@@ -152,6 +152,7 @@ function test_changeDataWhileWorking() {
function test_setup() {
SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true],
+ ["dom.filesystem.pathcheck.disabled", true],
["dom.webkitBlink.dirPicker.enabled", true]]}, next);
}
diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp
index 4e1b9f7af4..e6fe9e2a82 100644
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -8440,12 +8440,12 @@ class ObjectStoreAddOrPutRequestOp::SCInputStream final
: public nsIInputStream
{
const JSStructuredCloneData& mData;
- JSStructuredCloneData::IterImpl mIter;
+ JSStructuredCloneData::Iterator mIter;
public:
explicit SCInputStream(const JSStructuredCloneData& aData)
: mData(aData)
- , mIter(aData.Iter())
+ , mIter(aData.Start())
{ }
private:
@@ -19687,7 +19687,7 @@ UpgradeFileIdsFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
return NS_ERROR_UNEXPECTED;
}
- StructuredCloneReadInfo cloneInfo;
+ StructuredCloneReadInfo cloneInfo(JS::StructuredCloneScope::DifferentProcess);
DatabaseOperationBase::GetStructuredCloneReadInfoFromValueArray(aArguments,
1,
0,
@@ -19892,7 +19892,7 @@ DatabaseOperationBase::GetStructuredCloneReadInfoFromBlob(
return NS_ERROR_FILE_CORRUPTED;
}
- if (!aInfo->mData.WriteBytes(uncompressedBuffer, uncompressed.Length())) {
+ if (!aInfo->mData.AppendBytes(uncompressedBuffer, uncompressed.Length())) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -19978,7 +19978,7 @@ DatabaseOperationBase::GetStructuredCloneReadInfoFromExternalBlob(
break;
}
- if (NS_WARN_IF(!aInfo->mData.WriteBytes(buffer, numRead))) {
+ if (NS_WARN_IF(!aInfo->mData.AppendBytes(buffer, numRead))) {
rv = NS_ERROR_OUT_OF_MEMORY;
break;
}
@@ -25337,7 +25337,7 @@ UpdateIndexDataValuesFunction::OnFunctionCall(mozIStorageValueArray* aValues,
}
#endif
- StructuredCloneReadInfo cloneInfo;
+ StructuredCloneReadInfo cloneInfo(JS::StructuredCloneScope::DifferentProcess);
nsresult rv =
GetStructuredCloneReadInfoFromValueArray(aValues,
/* aDataIndex */ 3,
@@ -26546,18 +26546,9 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
char keyPropBuffer[keyPropSize];
LittleEndian::writeUint64(keyPropBuffer, keyPropValue);
- auto iter = cloneData.Iter();
- DebugOnly<bool> result =
- iter.AdvanceAcrossSegments(cloneData, cloneInfo.offsetToKeyProp());
- MOZ_ASSERT(result);
-
- for (uint32_t index = 0; index < keyPropSize; index++) {
- char* keyPropPointer = iter.Data();
- *keyPropPointer = keyPropBuffer[index];
-
- result = iter.AdvanceAcrossSegments(cloneData, 1);
- MOZ_ASSERT(result);
- }
+ auto iter = cloneData.Start();
+ MOZ_ALWAYS_TRUE(cloneData.Advance(iter, cloneInfo.offsetToKeyProp()));
+ MOZ_ALWAYS_TRUE(cloneData.UpdateBytes(iter, keyPropBuffer, keyPropSize));
}
}
@@ -26583,7 +26574,7 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
} else {
nsCString flatCloneData;
flatCloneData.SetLength(cloneDataSize);
- auto iter = cloneData.Iter();
+ auto iter = cloneData.Start();
cloneData.ReadBytes(iter, flatCloneData.BeginWriting(), cloneDataSize);
// Compress the bytes before adding into the database.
@@ -26840,7 +26831,7 @@ SCInputStream::ReadSegments(nsWriteSegmentFun aWriter,
*_retval += count;
aCount -= count;
- mIter.Advance(mData, count);
+ mData.Advance(mIter, count);
}
return NS_OK;
@@ -28029,7 +28020,7 @@ CursorOpBase::PopulateResponseFromStatement(
switch (mCursor->mType) {
case OpenCursorParams::TObjectStoreOpenCursorParams: {
- StructuredCloneReadInfo cloneInfo;
+ StructuredCloneReadInfo cloneInfo(JS::StructuredCloneScope::DifferentProcess);
rv = GetStructuredCloneReadInfoFromStatement(aStmt,
2,
1,
@@ -28077,7 +28068,7 @@ CursorOpBase::PopulateResponseFromStatement(
return rv;
}
- StructuredCloneReadInfo cloneInfo;
+ StructuredCloneReadInfo cloneInfo(JS::StructuredCloneScope::DifferentProcess);
rv = GetStructuredCloneReadInfoFromStatement(aStmt,
4,
3,
diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp
index a6d6c5f064..8a0b292ade 100644
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -67,7 +67,7 @@ struct IDBObjectStore::StructuredCloneWriteInfo
uint64_t mOffsetToKeyProp;
explicit StructuredCloneWriteInfo(IDBDatabase* aDatabase)
- : mCloneBuffer(JS::StructuredCloneScope::SameProcessSameThread, nullptr,
+ : mCloneBuffer(JS::StructuredCloneScope::DifferentProcessForIndexedDB, nullptr,
nullptr)
, mDatabase(aDatabase)
, mOffsetToKeyProp(0)
@@ -1216,7 +1216,7 @@ IDBObjectStore::DeserializeValue(JSContext* aCx,
// FIXME: Consider to use StructuredCloneHolder here and in other
// deserializing methods.
if (!JS_ReadStructuredClone(aCx, aCloneReadInfo.mData, JS_STRUCTURED_CLONE_VERSION,
- JS::StructuredCloneScope::SameProcessSameThread,
+ JS::StructuredCloneScope::DifferentProcessForIndexedDB,
aValue, &callbacks, &aCloneReadInfo)) {
return false;
}
@@ -1249,7 +1249,7 @@ IDBObjectStore::DeserializeIndexValue(JSContext* aCx,
};
if (!JS_ReadStructuredClone(aCx, aCloneReadInfo.mData, JS_STRUCTURED_CLONE_VERSION,
- JS::StructuredCloneScope::SameProcessSameThread,
+ JS::StructuredCloneScope::DifferentProcessForIndexedDB,
aValue, &callbacks, &aCloneReadInfo)) {
return false;
}
@@ -1285,7 +1285,7 @@ IDBObjectStore::DeserializeUpgradeValue(JSContext* aCx,
};
if (!JS_ReadStructuredClone(aCx, aCloneReadInfo.mData, JS_STRUCTURED_CLONE_VERSION,
- JS::StructuredCloneScope::SameProcessSameThread,
+ JS::StructuredCloneScope::DifferentProcessForIndexedDB,
aValue, &callbacks, &aCloneReadInfo)) {
return false;
}
diff --git a/dom/indexedDB/IndexedDatabase.h b/dom/indexedDB/IndexedDatabase.h
index b0c4cb877a..b3c6ab7258 100644
--- a/dom/indexedDB/IndexedDatabase.h
+++ b/dom/indexedDB/IndexedDatabase.h
@@ -65,6 +65,10 @@ struct StructuredCloneReadInfo
bool mHasPreprocessInfo;
// In IndexedDatabaseInlines.h
+ inline explicit
+ StructuredCloneReadInfo(JS::StructuredCloneScope aScope);
+
+ // In IndexedDatabaseInlines.h
inline
StructuredCloneReadInfo();
diff --git a/dom/indexedDB/IndexedDatabaseInlines.h b/dom/indexedDB/IndexedDatabaseInlines.h
index 830c2f1100..8c34a81dd9 100644
--- a/dom/indexedDB/IndexedDatabaseInlines.h
+++ b/dom/indexedDB/IndexedDatabaseInlines.h
@@ -45,14 +45,21 @@ StructuredCloneFile::operator==(const StructuredCloneFile& aOther) const
}
inline
-StructuredCloneReadInfo::StructuredCloneReadInfo()
- : mDatabase(nullptr)
+StructuredCloneReadInfo::StructuredCloneReadInfo(JS::StructuredCloneScope aScope)
+ : mData(aScope)
+ , mDatabase(nullptr)
, mHasPreprocessInfo(false)
{
MOZ_COUNT_CTOR(StructuredCloneReadInfo);
}
inline
+StructuredCloneReadInfo::StructuredCloneReadInfo()
+ : StructuredCloneReadInfo(JS::StructuredCloneScope::DifferentProcessForIndexedDB)
+{
+}
+
+inline
StructuredCloneReadInfo::StructuredCloneReadInfo(
StructuredCloneReadInfo&& aCloneReadInfo)
: mData(Move(aCloneReadInfo.mData))
diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
index 3488e26bd8..0a07147bf0 100644
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4721,6 +4721,14 @@ ContentParent::RecvGetFilesRequest(const nsID& aUUID,
{
MOZ_ASSERT(!mGetFilesPendingRequests.GetWeak(aUUID));
+ if (!mozilla::Preferences::GetBool("dom.filesystem.pathcheck.disabled", false)) {
+ RefPtr<FileSystemSecurity> fss = FileSystemSecurity::Get();
+ if (NS_WARN_IF(!fss ||
+ !fss->ContentProcessHasAccessTo(ChildID(), aDirectoryPath))) {
+ return false;
+ }
+ }
+
ErrorResult rv;
RefPtr<GetFilesHelper> helper =
GetFilesHelperParent::Create(aUUID, aDirectoryPath, aRecursiveFlag, this,
diff --git a/dom/ipc/StructuredCloneData.cpp b/dom/ipc/StructuredCloneData.cpp
index 98f56904fa..2c1fff2ac3 100644
--- a/dom/ipc/StructuredCloneData.cpp
+++ b/dom/ipc/StructuredCloneData.cpp
@@ -88,7 +88,7 @@ StructuredCloneData::Write(JSContext* aCx,
return;
}
- JSStructuredCloneData data;
+ JSStructuredCloneData data(mBuffer->scope());
mBuffer->abandon();
mBuffer->steal(&data);
mBuffer = nullptr;
@@ -107,7 +107,7 @@ StructuredCloneData::ReadIPCParams(const IPC::Message* aMsg,
PickleIterator* aIter)
{
MOZ_ASSERT(!mInitialized);
- JSStructuredCloneData data;
+ JSStructuredCloneData data(JS::StructuredCloneScope::DifferentProcess);
if (!ReadParam(aMsg, aIter, &data)) {
return false;
}
diff --git a/dom/ipc/StructuredCloneData.h b/dom/ipc/StructuredCloneData.h
index 9e427e938c..64cfd19355 100644
--- a/dom/ipc/StructuredCloneData.h
+++ b/dom/ipc/StructuredCloneData.h
@@ -31,8 +31,8 @@ public:
static already_AddRefed<SharedJSAllocatedData>
CreateFromExternalData(const char* aData, size_t aDataLength)
{
- JSStructuredCloneData buf;
- buf.WriteBytes(aData, aDataLength);
+ JSStructuredCloneData buf(JS::StructuredCloneScope::DifferentProcess);
+ buf.AppendBytes(aData, aDataLength);
RefPtr<SharedJSAllocatedData> sharedData =
new SharedJSAllocatedData(Move(buf));
return sharedData.forget();
@@ -41,12 +41,8 @@ public:
static already_AddRefed<SharedJSAllocatedData>
CreateFromExternalData(const JSStructuredCloneData& aData)
{
- JSStructuredCloneData buf;
- auto iter = aData.Iter();
- while (!iter.Done()) {
- buf.WriteBytes(iter.Data(), iter.RemainingInSegment());
- iter.Advance(aData, iter.RemainingInSegment());
- }
+ JSStructuredCloneData buf(aData.scope());
+ buf.Append(aData);
RefPtr<SharedJSAllocatedData> sharedData =
new SharedJSAllocatedData(Move(buf));
return sharedData.forget();
@@ -70,6 +66,7 @@ public:
: StructuredCloneHolder(StructuredCloneHolder::CloningSupported,
StructuredCloneHolder::TransferringSupported,
StructuredCloneHolder::StructuredCloneScope::DifferentProcess)
+ , mExternalData(StructuredCloneHolder::StructuredCloneScope::DifferentProcess)
, mInitialized(false)
{}
@@ -113,10 +110,9 @@ public:
bool UseExternalData(const JSStructuredCloneData& aData)
{
- auto iter = aData.Iter();
+ auto iter = aData.Start();
bool success = false;
- mExternalData =
- aData.Borrow<js::SystemAllocPolicy>(iter, aData.Size(), &success);
+ mExternalData = aData.Borrow(iter, aData.Size(), &success);
mInitialized = true;
return success;
}
@@ -133,6 +129,11 @@ public:
return mSharedData ? mSharedData->Data() : mExternalData;
}
+ void InitScope(JS::StructuredCloneScope aScope)
+ {
+ Data().initScope(aScope);
+ }
+
size_t DataLength() const
{
return mSharedData ? mSharedData->DataLength() : mExternalData.Size();
diff --git a/dom/xbl/nsXBLBinding.cpp b/dom/xbl/nsXBLBinding.cpp
index 6ae17c4c02..d9a2aacc5a 100644
--- a/dom/xbl/nsXBLBinding.cpp
+++ b/dom/xbl/nsXBLBinding.cpp
@@ -1014,7 +1014,17 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
NS_ENSURE_TRUE(xblScope, NS_ERROR_UNEXPECTED);
JS::Rooted<JSObject*> parent_proto(cx);
- if (!JS_GetPrototype(cx, obj, &parent_proto)) {
+ {
+ JS::RootedObject wrapped(cx, obj);
+ JSAutoCompartment ac(cx, xblScope);
+ if (!JS_WrapObject(cx, &wrapped)) {
+ return NS_ERROR_FAILURE;
+ }
+ if (!JS_GetPrototype(cx, wrapped, &parent_proto)) {
+ return NS_ERROR_FAILURE;
+ }
+ }
+ if (!JS_WrapObject(cx, &parent_proto)) {
return NS_ERROR_FAILURE;
}