forked from mirrors/gecko-dev
Bug 1842713 - Pass CloneDataPolicy to readTransfer r=smaug,sfink
In this patch, readTransfer() takes `CloneDataPolicy` as a parameter like what read() does. As a result, not only read() but also readTransfer() can take the given `CloneDataPolicy` into account when reading the serialized/transferred data. In the next patch, `areIntraClusterClonableSharedObjectsAllowed()` in the `CloneDataPolicy` will be checked before reading the data passed through postMessage(). Depends on D183227 Differential Revision: https://phabricator.services.mozilla.com/D183598
This commit is contained in:
parent
c0e4b94724
commit
3912474237
5 changed files with 20 additions and 15 deletions
|
|
@ -111,14 +111,15 @@ bool StructuredCloneCallbacksWrite(JSContext* aCx,
|
|||
}
|
||||
|
||||
bool StructuredCloneCallbacksReadTransfer(
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||
void* aContent, uint64_t aExtraData, void* aClosure,
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader,
|
||||
const JS::CloneDataPolicy& aCloneDataPolicy, uint32_t aTag, void* aContent,
|
||||
uint64_t aExtraData, void* aClosure,
|
||||
JS::MutableHandle<JSObject*> aReturnObject) {
|
||||
StructuredCloneHolderBase* holder =
|
||||
static_cast<StructuredCloneHolderBase*>(aClosure);
|
||||
MOZ_ASSERT(holder);
|
||||
return holder->CustomReadTransferHandler(aCx, aReader, aTag, aContent,
|
||||
aExtraData, aReturnObject);
|
||||
return holder->CustomReadTransferHandler(aCx, aReader, aCloneDataPolicy, aTag,
|
||||
aContent, aExtraData, aReturnObject);
|
||||
}
|
||||
|
||||
bool StructuredCloneCallbacksWriteTransfer(
|
||||
|
|
@ -303,9 +304,9 @@ bool StructuredCloneHolderBase::Read(
|
|||
}
|
||||
|
||||
bool StructuredCloneHolderBase::CustomReadTransferHandler(
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||
void* aContent, uint64_t aExtraData,
|
||||
JS::MutableHandle<JSObject*> aReturnObject) {
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader,
|
||||
const JS::CloneDataPolicy& aCloneDataPolicy, uint32_t aTag, void* aContent,
|
||||
uint64_t aExtraData, JS::MutableHandle<JSObject*> aReturnObject) {
|
||||
MOZ_CRASH("Nothing to read.");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1250,9 +1251,9 @@ already_AddRefed<MessagePort> StructuredCloneHolder::ReceiveMessagePort(
|
|||
// TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230)
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY bool
|
||||
StructuredCloneHolder::CustomReadTransferHandler(
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||
void* aContent, uint64_t aExtraData,
|
||||
JS::MutableHandle<JSObject*> aReturnObject) {
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader,
|
||||
const JS::CloneDataPolicy& aCloneDataPolicy, uint32_t aTag, void* aContent,
|
||||
uint64_t aExtraData, JS::MutableHandle<JSObject*> aReturnObject) {
|
||||
MOZ_ASSERT(mSupportsTransferring);
|
||||
|
||||
if (aTag == SCTAG_DOM_MAP_MESSAGEPORT) {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ class StructuredCloneHolderBase {
|
|||
// allowed. Otherwise only arrayBuffers will be transferred.
|
||||
|
||||
virtual bool CustomReadTransferHandler(
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader,
|
||||
const JS::CloneDataPolicy& aCloneDataPolicy, uint32_t aTag,
|
||||
void* aContent, uint64_t aExtraData,
|
||||
JS::MutableHandle<JSObject*> aReturnObject);
|
||||
|
||||
|
|
@ -282,7 +283,8 @@ class StructuredCloneHolder : public StructuredCloneHolderBase {
|
|||
bool* aSameProcessScopeRequired) override;
|
||||
|
||||
virtual bool CustomReadTransferHandler(
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||
JSContext* aCx, JSStructuredCloneReader* aReader,
|
||||
const JS::CloneDataPolicy& aCloneDataPolicy, uint32_t aTag,
|
||||
void* aContent, uint64_t aExtraData,
|
||||
JS::MutableHandle<JSObject*> aReturnObject) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -313,7 +313,8 @@ typedef void (*StructuredCloneErrorOp)(JSContext* cx, uint32_t errorid,
|
|||
* will only contain a backreference to the already-read object.
|
||||
*/
|
||||
typedef bool (*ReadTransferStructuredCloneOp)(
|
||||
JSContext* cx, JSStructuredCloneReader* r, uint32_t tag, void* content,
|
||||
JSContext* cx, JSStructuredCloneReader* r,
|
||||
const JS::CloneDataPolicy& aCloneDataPolicy, uint32_t tag, void* content,
|
||||
uint64_t extraData, void* closure, JS::MutableHandleObject returnObject);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5277,6 +5277,7 @@ class CustomSerializableObject : public NativeObject {
|
|||
}
|
||||
|
||||
static bool ReadTransfer(JSContext* cx, JSStructuredCloneReader* r,
|
||||
const JS::CloneDataPolicy& cloneDataPolicy,
|
||||
uint32_t tag, void* content, uint64_t extraData,
|
||||
void* closure,
|
||||
JS::MutableHandleObject returnObject) {
|
||||
|
|
|
|||
|
|
@ -3301,8 +3301,8 @@ bool JSStructuredCloneReader::readTransferMap() {
|
|||
ReportDataCloneError(cx, callbacks, JS_SCERR_TRANSFERABLE, closure);
|
||||
return false;
|
||||
}
|
||||
if (!callbacks->readTransfer(cx, this, tag, content, extraData, closure,
|
||||
&obj)) {
|
||||
if (!callbacks->readTransfer(cx, this, cloneDataPolicy, tag, content,
|
||||
extraData, closure, &obj)) {
|
||||
if (!cx->isExceptionPending()) {
|
||||
ReportDataCloneError(cx, callbacks, JS_SCERR_TRANSFERABLE, closure);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue