Backed out changeset 6b886fbb3e48 (bug 1148032) for mochitest-chrome orange on b2g emulators

This commit is contained in:
Wes Kocher 2015-03-31 15:48:25 -07:00
parent 38060d4f00
commit 5f7c650df1
17 changed files with 35 additions and 192 deletions

View File

@ -126,13 +126,11 @@ class InitializeRunnable final : public WorkerMainThreadRunnable
{
public:
InitializeRunnable(WorkerPrivate* aWorkerPrivate, nsAString& aOrigin,
PrincipalInfo& aPrincipalInfo, bool& aPrivateBrowsing,
ErrorResult& aRv)
PrincipalInfo& aPrincipalInfo, ErrorResult& aRv)
: WorkerMainThreadRunnable(aWorkerPrivate)
, mWorkerPrivate(GetCurrentThreadWorkerPrivate())
, mOrigin(aOrigin)
, mPrincipalInfo(aPrincipalInfo)
, mPrivateBrowsing(aPrivateBrowsing)
, mRv(aRv)
{
MOZ_ASSERT(mWorkerPrivate);
@ -182,10 +180,8 @@ public:
}
nsIDocument* doc = window->GetExtantDoc();
// No bfcache when BroadcastChannel is used.
if (doc) {
mPrivateBrowsing = nsContentUtils::IsInPrivateBrowsing(doc);
// No bfcache when BroadcastChannel is used.
doc->DisallowBFCaching();
}
@ -196,7 +192,6 @@ private:
WorkerPrivate* mWorkerPrivate;
nsAString& mOrigin;
PrincipalInfo& mPrincipalInfo;
bool& mPrivateBrowsing;
ErrorResult& mRv;
};
@ -401,14 +396,12 @@ BroadcastChannel::IsEnabled(JSContext* aCx, JSObject* aGlobal)
BroadcastChannel::BroadcastChannel(nsPIDOMWindow* aWindow,
const PrincipalInfo& aPrincipalInfo,
const nsAString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing)
const nsAString& aChannel)
: DOMEventTargetHelper(aWindow)
, mWorkerFeature(nullptr)
, mPrincipalInfo(new PrincipalInfo(aPrincipalInfo))
, mOrigin(aOrigin)
, mChannel(aChannel)
, mPrivateBrowsing(aPrivateBrowsing)
, mIsKeptAlive(false)
, mInnerID(0)
, mState(StateActive)
@ -438,7 +431,6 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
nsAutoString origin;
PrincipalInfo principalInfo;
bool privateBrowsing = false;
WorkerPrivate* workerPrivate = nullptr;
if (NS_IsMainThread()) {
@ -477,10 +469,8 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
}
nsIDocument* doc = window->GetExtantDoc();
// No bfcache when BroadcastChannel is used.
if (doc) {
privateBrowsing = nsContentUtils::IsInPrivateBrowsing(doc);
// No bfcache when BroadcastChannel is used.
doc->DisallowBFCaching();
}
} else {
@ -489,8 +479,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
MOZ_ASSERT(workerPrivate);
nsRefPtr<InitializeRunnable> runnable =
new InitializeRunnable(workerPrivate, origin, principalInfo,
privateBrowsing, aRv);
new InitializeRunnable(workerPrivate, origin, principalInfo, aRv);
runnable->Dispatch(cx);
}
@ -499,8 +488,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
}
nsRefPtr<BroadcastChannel> bc =
new BroadcastChannel(window, principalInfo, origin, aChannel,
privateBrowsing);
new BroadcastChannel(window, principalInfo, origin, aChannel);
// Register this component to PBackground.
PBackgroundChild* actor = BackgroundChild::GetForCurrentThread();
@ -626,8 +614,7 @@ BroadcastChannel::ActorCreated(PBackgroundChild* aActor)
}
PBroadcastChannelChild* actor =
aActor->SendPBroadcastChannelConstructor(*mPrincipalInfo, mOrigin, mChannel,
mPrivateBrowsing);
aActor->SendPBroadcastChannelConstructor(*mPrincipalInfo, mOrigin, mChannel);
mActor = static_cast<BroadcastChannelChild*>(actor);
MOZ_ASSERT(mActor);

View File

@ -92,8 +92,7 @@ private:
BroadcastChannel(nsPIDOMWindow* aWindow,
const PrincipalInfo& aPrincipalInfo,
const nsAString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing);
const nsAString& aChannel);
~BroadcastChannel();
@ -113,7 +112,6 @@ private:
nsString mOrigin;
nsString mChannel;
bool mPrivateBrowsing;
bool mIsKeptAlive;

View File

@ -25,8 +25,10 @@ namespace dom {
using namespace workers;
BroadcastChannelChild::BroadcastChannelChild(const nsAString& aOrigin)
BroadcastChannelChild::BroadcastChannelChild(const nsAString& aOrigin,
const nsAString& aChannel)
: mOrigin(aOrigin)
, mChannel(aChannel)
, mActorDestroyed(false)
{
}

View File

@ -37,7 +37,9 @@ public:
}
private:
explicit BroadcastChannelChild(const nsAString& aOrigin);
BroadcastChannelChild(const nsAString& aOrigin,
const nsAString& aChannel);
~BroadcastChannelChild();
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
@ -47,6 +49,7 @@ private:
BroadcastChannel* mBC;
nsString mOrigin;
nsString mChannel;
bool mActorDestroyed;
};

View File

@ -18,12 +18,10 @@ namespace dom {
BroadcastChannelParent::BroadcastChannelParent(
const nsAString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing)
const nsAString& aChannel)
: mService(BroadcastChannelService::GetOrCreate())
, mOrigin(aOrigin)
, mChannel(aChannel)
, mPrivateBrowsing(aPrivateBrowsing)
{
AssertIsOnBackgroundThread();
mService->RegisterActor(this);
@ -43,7 +41,7 @@ BroadcastChannelParent::RecvPostMessage(const ClonedMessageData& aData)
return false;
}
mService->PostMessage(this, aData, mOrigin, mChannel, mPrivateBrowsing);
mService->PostMessage(this, aData, mOrigin, mChannel);
return true;
}
@ -79,14 +77,11 @@ BroadcastChannelParent::ActorDestroy(ActorDestroyReason aWhy)
void
BroadcastChannelParent::CheckAndDeliver(const ClonedMessageData& aData,
const nsString& aOrigin,
const nsString& aChannel,
bool aPrivateBrowsing)
const nsString& aChannel)
{
AssertIsOnBackgroundThread();
if (aOrigin == mOrigin &&
aChannel == mChannel &&
aPrivateBrowsing == mPrivateBrowsing) {
if (aOrigin == mOrigin && aChannel == mChannel) {
// 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() ||

View File

@ -24,13 +24,11 @@ class BroadcastChannelParent final : public PBroadcastChannelParent
public:
void CheckAndDeliver(const ClonedMessageData& aData,
const nsString& aOrigin,
const nsString& aChannel,
bool aPrivateBrowsing);
const nsString& aChannel);
private:
BroadcastChannelParent(const nsAString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing);
const nsAString& aChannel);
~BroadcastChannelParent();
virtual bool
@ -43,7 +41,6 @@ private:
nsRefPtr<BroadcastChannelService> mService;
nsString mOrigin;
nsString mChannel;
bool mPrivateBrowsing;
};
} // dom namespace

View File

@ -83,13 +83,11 @@ struct MOZ_STACK_CLASS PostMessageData final
PostMessageData(BroadcastChannelParent* aParent,
const ClonedMessageData& aData,
const nsAString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing)
const nsAString& aChannel)
: mParent(aParent)
, mData(aData)
, mOrigin(aOrigin)
, mChannel(aChannel)
, mPrivateBrowsing(aPrivateBrowsing)
{
MOZ_ASSERT(aParent);
MOZ_COUNT_CTOR(PostMessageData);
@ -118,7 +116,6 @@ struct MOZ_STACK_CLASS PostMessageData final
nsTArray<nsRefPtr<FileImpl>> mFiles;
const nsString mOrigin;
const nsString mChannel;
bool mPrivateBrowsing;
};
PLDHashOperator
@ -131,8 +128,7 @@ PostMessageEnumerator(nsPtrHashKey<BroadcastChannelParent>* aKey, void* aPtr)
MOZ_ASSERT(parent);
if (parent != data->mParent) {
parent->CheckAndDeliver(data->mData, data->mOrigin, data->mChannel,
data->mPrivateBrowsing);
parent->CheckAndDeliver(data->mData, data->mOrigin, data->mChannel);
}
return PL_DHASH_NEXT;
@ -144,14 +140,13 @@ void
BroadcastChannelService::PostMessage(BroadcastChannelParent* aParent,
const ClonedMessageData& aData,
const nsAString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing)
const nsAString& aChannel)
{
AssertIsOnBackgroundThread();
MOZ_ASSERT(aParent);
MOZ_ASSERT(mAgents.Contains(aParent));
PostMessageData data(aParent, aData, aOrigin, aChannel, aPrivateBrowsing);
PostMessageData data(aParent, aData, aOrigin, aChannel);
mAgents.EnumerateEntries(PostMessageEnumerator, &data);
}

View File

@ -32,8 +32,7 @@ public:
void PostMessage(BroadcastChannelParent* aParent,
const ClonedMessageData& aData,
const nsAString& aOrigin,
const nsAString& aChannel,
bool aPrivateBrowsing);
const nsAString& aChannel);
private:
BroadcastChannelService();

View File

@ -24,7 +24,6 @@ LOCAL_INCLUDES += [
]
MOCHITEST_MANIFESTS += ['tests/mochitest.ini']
MOCHITEST_CHROME_MANIFESTS += ['tests/chrome.ini']
include('/ipc/chromium/chromium-config.mozbuild')

View File

@ -1,2 +0,0 @@
<!DOCTYPE HTML>
<html><body></body></html>

View File

@ -1,5 +0,0 @@
[DEFAULT]
support-files =
blank.html
[test_broadcastchannel_private_browsing.html]

View File

@ -1,118 +0,0 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test for BroadcastChannel - Private Browsing</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
</head>
<body>
<script type="application/javascript">
const Ci = Components.interfaces;
var mainWindow;
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefBranch.setIntPref("browser.startup.page", 0);
prefBranch.setCharPref("browser.startup.homepage_override.mstone", "ignore");
var contentPage = "http://mochi.test:8888/chrome/dom/broadcastchannel/tests/blank.html";
function testOnWindow(aIsPrivate, aCallback) {
var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
win.gBrowser.loadURI(contentPage);
return;
}
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
SimpleTest.executeSoon(function() { aCallback(win); });
}, true);
if (!aIsPrivate) {
win.gBrowser.loadURI(contentPage);
}
}, true);
}
function setupWindow() {
mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
runTest();
}
var gCounter = 0;
function check(msg, private) {
is(msg, private ? "private" : "public", "Correct context!");
gCounter++;
if (gCounter > 1) {
runTest();
}
}
var wN;
var wP;
function doTests() {
testOnWindow(false, function(aWin) {
wN = aWin;
testOnWindow(true, function(aWin) {
wP = aWin;
var bcP = new wP.content.BroadcastChannel('foobar');
bcP.onmessage = function(e) { ok(false, "This should not be called!"); }
var bc = new wP.content.BroadcastChannel('foobar');
bc.onmessage = function(e) { check(e.data, true); }
var bcN = new wN.content.BroadcastChannel('foobar');
bcN.onmessage = function(e) { ok(false, "This should not be called!"); }
var bc = new wN.content.BroadcastChannel('foobar');
bc.onmessage = function(e) { check(e.data, false); }
bcP.postMessage('private');
bcN.postMessage('public');
});
});
}
var steps = [
setupWindow,
doTests
];
function runTest() {
if (!steps.length) {
wN.close();
wP.close();
prefBranch.clearUserPref("browser.startup.page")
prefBranch.clearUserPref("browser.startup.homepage_override.mstone");
SimpleTest.finish();
return;
}
var step = steps.shift();
step();
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.broadcastChannel.enabled", true]]}, runTest);
</script>
</body>
</html>

View File

@ -220,11 +220,10 @@ BackgroundChildImpl::DeallocPVsyncChild(PVsyncChild* aActor)
dom::PBroadcastChannelChild*
BackgroundChildImpl::AllocPBroadcastChannelChild(const PrincipalInfo& aPrincipalInfo,
const nsString& aOrigin,
const nsString& aChannel,
const bool& aPrivateBrowsing)
const nsString& aChannel)
{
nsRefPtr<dom::BroadcastChannelChild> agent =
new dom::BroadcastChannelChild(aOrigin);
new dom::BroadcastChannelChild(aOrigin, aChannel);
return agent.forget().take();
}

View File

@ -86,8 +86,7 @@ protected:
virtual PBroadcastChannelChild*
AllocPBroadcastChannelChild(const PrincipalInfo& aPrincipalInfo,
const nsString& aOrigin,
const nsString& aChannel,
const bool& aPrivateBrowsing) override;
const nsString& aChannel) override;
virtual bool
DeallocPBroadcastChannelChild(PBroadcastChannelChild* aActor) override;

View File

@ -255,13 +255,12 @@ mozilla::dom::PBroadcastChannelParent*
BackgroundParentImpl::AllocPBroadcastChannelParent(
const PrincipalInfo& aPrincipalInfo,
const nsString& aOrigin,
const nsString& aChannel,
const bool& aPrivateBrowsing)
const nsString& aChannel)
{
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
return new BroadcastChannelParent(aOrigin, aChannel, aPrivateBrowsing);
return new BroadcastChannelParent(aOrigin, aChannel);
}
namespace {
@ -329,8 +328,7 @@ BackgroundParentImpl::RecvPBroadcastChannelConstructor(
PBroadcastChannelParent* actor,
const PrincipalInfo& aPrincipalInfo,
const nsString& aOrigin,
const nsString& aChannel,
const bool& aPrivateBrowsing)
const nsString& aChannel)
{
AssertIsInMainProcess();
AssertIsOnBackgroundThread();

View File

@ -73,15 +73,13 @@ protected:
virtual PBroadcastChannelParent*
AllocPBroadcastChannelParent(const PrincipalInfo& aPrincipalInfo,
const nsString& aOrigin,
const nsString& aChannel,
const bool& aPrivateBrowsing) override;
const nsString& aChannel) override;
virtual bool
RecvPBroadcastChannelConstructor(PBroadcastChannelParent* actor,
const PrincipalInfo& aPrincipalInfo,
const nsString& origin,
const nsString& channel,
const bool& aPrivateBrowsing) override;
const nsString& channel) override;
virtual bool
DeallocPBroadcastChannelParent(PBroadcastChannelParent* aActor) override;

View File

@ -46,8 +46,7 @@ parent:
PVsync();
PMedia();
PBroadcastChannel(PrincipalInfo pInfo, nsString origin, nsString channel,
bool privateBrowsing);
PBroadcastChannel(PrincipalInfo pInfo, nsString origin, nsString channel);
RegisterServiceWorker(ServiceWorkerRegistrationData data);
UnregisterServiceWorker(PrincipalInfo principalInfo,