mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1122553 - BroadcastChannel should keep FileImpl alive when sent to the PBackground actors, r=bent
This commit is contained in:
parent
633dc9fccf
commit
15c180d225
@ -82,8 +82,10 @@ BroadcastChannelParent::CheckAndDeliver(const ClonedMessageData& aData,
|
||||
AssertIsOnBackgroundThread();
|
||||
|
||||
if (aOrigin == mOrigin && aChannel == mChannel) {
|
||||
// We need to duplicate data only if we have blobs.
|
||||
if (aData.blobsParent().IsEmpty()) {
|
||||
// We need to duplicate data only if we have blobs or if the manager of
|
||||
// them is different than the manager of this parent actor.
|
||||
if (aData.blobsParent().IsEmpty() ||
|
||||
static_cast<BlobParent*>(aData.blobsParent()[0])->GetBackgroundManager() == Manager()) {
|
||||
unused << SendNotify(aData);
|
||||
return;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "BroadcastChannelService.h"
|
||||
#include "BroadcastChannelParent.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/ipc/BlobParent.h"
|
||||
#include "mozilla/ipc/BackgroundParent.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
@ -89,6 +91,19 @@ struct MOZ_STACK_CLASS PostMessageData MOZ_FINAL
|
||||
{
|
||||
MOZ_ASSERT(aParent);
|
||||
MOZ_COUNT_CTOR(PostMessageData);
|
||||
|
||||
// We need to keep the array alive for the life-time of this
|
||||
// PostMessageData.
|
||||
if (!aData.blobsParent().IsEmpty()) {
|
||||
mFiles.SetCapacity(aData.blobsParent().Length());
|
||||
|
||||
for (uint32_t i = 0, len = aData.blobsParent().Length(); i < len; ++i) {
|
||||
nsRefPtr<FileImpl> impl =
|
||||
static_cast<BlobParent*>(aData.blobsParent()[i])->GetBlobImpl();
|
||||
MOZ_ASSERT(impl);
|
||||
mFiles.AppendElement(impl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~PostMessageData()
|
||||
@ -98,6 +113,7 @@ struct MOZ_STACK_CLASS PostMessageData MOZ_FINAL
|
||||
|
||||
BroadcastChannelParent* mParent;
|
||||
const ClonedMessageData& mData;
|
||||
nsTArray<nsRefPtr<FileImpl>> mFiles;
|
||||
const nsString mOrigin;
|
||||
const nsString mChannel;
|
||||
};
|
||||
|
@ -75,15 +75,42 @@ function compare(a, b) {
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
var count = 2;
|
||||
|
||||
var bc = new BroadcastChannel("foobar");
|
||||
ok(bc, "BroadcastChannel can be created");
|
||||
|
||||
bc.onmessage = function(event) {
|
||||
ok(count < 2, "Still comparing...");
|
||||
info("bc: " + currentTest);
|
||||
compare(event.data, currentTest);
|
||||
++count;
|
||||
next();
|
||||
}
|
||||
|
||||
var bc2 = new BroadcastChannel("foobar");
|
||||
ok(bc2, "BroadcastChannel can be created");
|
||||
|
||||
var toSkip = true;
|
||||
bc2.onmessage = function(event) {
|
||||
toSkip = !toSkip;
|
||||
if (toSkip) return;
|
||||
|
||||
ok(count < 2, "Still comparing...");
|
||||
info("bc2: " + currentTest);
|
||||
compare(event.data, currentTest);
|
||||
++count;
|
||||
next();
|
||||
}
|
||||
|
||||
function next() {
|
||||
if (count < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
is(count, 2, "Just 2 comparations");
|
||||
count = 0;
|
||||
|
||||
if (!tests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
@ -91,6 +118,7 @@ function runTest() {
|
||||
|
||||
currentTest = tests.shift();
|
||||
bc.postMessage(currentTest);
|
||||
info("Posted: " + currentTest);
|
||||
}
|
||||
|
||||
var worker = new Worker("broadcastchannel_worker_any.js");
|
||||
|
Loading…
Reference in New Issue
Block a user