mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Refactor structured clone JSAPI to prevent mismatched scopes.
Roll-up of bugs 1442722, 1455071, 1433642, 1456604 and 1458320.
This commit is contained in:
parent
1b173ad9e4
commit
0795e50d87
15 changed files with 447 additions and 311 deletions
|
|
@ -63,15 +63,18 @@ struct null_t {
|
|||
|
||||
struct SerializedStructuredCloneBuffer final
|
||||
{
|
||||
SerializedStructuredCloneBuffer()
|
||||
: data(JS::StructuredCloneScope::Unassigned)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
SerializedStructuredCloneBuffer&
|
||||
operator=(const SerializedStructuredCloneBuffer& aOther)
|
||||
{
|
||||
data.Clear();
|
||||
auto iter = aOther.data.Iter();
|
||||
while (!iter.Done()) {
|
||||
data.WriteBytes(iter.Data(), iter.RemainingInSegment());
|
||||
iter.Advance(aOther.data, iter.RemainingInSegment());
|
||||
}
|
||||
data.initScope(aOther.data.scope());
|
||||
data.Append(aOther.data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -712,11 +715,9 @@ struct ParamTraits<JSStructuredCloneData>
|
|||
{
|
||||
MOZ_ASSERT(!(aParam.Size() % sizeof(uint64_t)));
|
||||
WriteParam(aMsg, aParam.Size());
|
||||
auto iter = aParam.Iter();
|
||||
while (!iter.Done()) {
|
||||
aMsg->WriteBytes(iter.Data(), iter.RemainingInSegment(), sizeof(uint64_t));
|
||||
iter.Advance(aParam, iter.RemainingInSegment());
|
||||
}
|
||||
aParam.ForEachDataChunk([&](const char* aData, size_t aSize) {
|
||||
return aMsg->WriteBytes(aData, aSize, sizeof(uint64_t));
|
||||
});
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
|
|
@ -746,7 +747,7 @@ struct ParamTraits<JSStructuredCloneData>
|
|||
return false;
|
||||
}
|
||||
|
||||
*aResult = JSStructuredCloneData(Move(out));
|
||||
*aResult = JSStructuredCloneData(Move(out), JS::StructuredCloneScope::DifferentProcess);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue