Bug 765075 - Load BrowserElementChild.js before returning the result of window.open from <iframe mozbrowser> to the opener. r=smaug

This commit is contained in:
Justin Lebar 2012-06-21 21:17:52 -04:00
Родитель b6c0a2f287
Коммит b5919daf01
9 изменённых файлов: 54 добавлений и 23 удалений

Просмотреть файл

@ -1505,13 +1505,6 @@ nsFrameLoader::MaybeCreateDocShell()
mDocShell->SetChromeEventHandler(chromeEventHandler);
}
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (OwnerIsBrowserFrame() && os) {
mDocShell->SetIsBrowserFrame(true);
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
"in-process-browser-frame-shown", NULL);
}
// This is nasty, this code (the do_GetInterface(mDocShell) below)
// *must* come *after* the above call to
// mDocShell->SetChromeEventHandler() for the global window to get
@ -1538,6 +1531,22 @@ nsFrameLoader::MaybeCreateDocShell()
EnsureMessageManager();
if (OwnerIsBrowserFrame()) {
mDocShell->SetIsBrowserFrame(true);
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
os->NotifyObservers(NS_ISUPPORTS_CAST(nsIFrameLoader*, this),
"in-process-browser-frame-shown", NULL);
}
if (mMessageManager) {
mMessageManager->LoadFrameScript(
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"),
/* allowDelayedLoad = */ true);
}
}
return NS_OK;
}
@ -1899,7 +1908,8 @@ nsFrameLoader::TryRemoteBrowser()
ContentParent* parent = ContentParent::GetNewOrUsed();
NS_ASSERTION(parent->IsAlive(), "Process parent should be alive; something is very wrong!");
mRemoteBrowser = parent->CreateTab(chromeFlags);
mRemoteBrowser = parent->CreateTab(chromeFlags,
/* aIsBrowserFrame = */ OwnerIsBrowserFrame());
if (mRemoteBrowser) {
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(mOwnerContent);
mRemoteBrowser->SetOwnerElement(element);

Просмотреть файл

@ -169,9 +169,6 @@ function BrowserElementParent(frameLoader) {
defineDOMRequestMethod('getScreenshot', 'get-screenshot');
defineDOMRequestMethod('getCanGoBack', 'get-can-go-back');
defineDOMRequestMethod('getCanGoForward', 'get-can-go-forward');
this._mm.loadFrameScript("chrome://global/content/BrowserElementChild.js",
/* allowDelayedLoad = */ true);
}
BrowserElementParent.prototype = {

Просмотреть файл

@ -382,9 +382,9 @@ ContentChild::DeallocPMemoryReportRequest(PMemoryReportRequestChild* actor)
}
PBrowserChild*
ContentChild::AllocPBrowser(const PRUint32& aChromeFlags)
ContentChild::AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserFrame)
{
nsRefPtr<TabChild> iframe = new TabChild(aChromeFlags);
nsRefPtr<TabChild> iframe = new TabChild(aChromeFlags, aIsBrowserFrame);
return NS_SUCCEEDED(iframe->Init()) ? iframe.forget().get() : NULL;
}

Просмотреть файл

@ -55,7 +55,8 @@ public:
/* if you remove this, please talk to cjones or dougt */
virtual bool RecvDummy(Shmem& foo) { return true; }
virtual PBrowserChild* AllocPBrowser(const PRUint32& aChromeFlags);
virtual PBrowserChild* AllocPBrowser(const PRUint32& aChromeFlags,
const bool& aIsBrowserFrame);
virtual bool DeallocPBrowser(PBrowserChild*);
virtual PCrashReporterChild*

Просмотреть файл

@ -356,9 +356,9 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
}
TabParent*
ContentParent::CreateTab(PRUint32 aChromeFlags)
ContentParent::CreateTab(PRUint32 aChromeFlags, bool aIsBrowserFrame)
{
return static_cast<TabParent*>(SendPBrowserConstructor(aChromeFlags));
return static_cast<TabParent*>(SendPBrowserConstructor(aChromeFlags, aIsBrowserFrame));
}
TestShellParent*
@ -698,7 +698,7 @@ ContentParent::Observe(nsISupports* aSubject,
}
PBrowserParent*
ContentParent::AllocPBrowser(const PRUint32& aChromeFlags)
ContentParent::AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserFrame)
{
TabParent* parent = new TabParent();
if (parent){

Просмотреть файл

@ -51,7 +51,13 @@ public:
NS_DECL_NSITHREADOBSERVER
NS_DECL_NSIDOMGEOPOSITIONCALLBACK
TabParent* CreateTab(PRUint32 aChromeFlags);
/**
* Create a new tab.
*
* |aIsBrowserFrame| indicates whether this tab is part of an
* <iframe mozbrowser>.
*/
TabParent* CreateTab(PRUint32 aChromeFlags, bool aIsBrowserFrame);
TestShellParent* CreateTestShell();
bool DestroyTestShell(TestShellParent* aTestShell);
@ -90,7 +96,7 @@ private:
void Init();
virtual PBrowserParent* AllocPBrowser(const PRUint32& aChromeFlags);
virtual PBrowserParent* AllocPBrowser(const PRUint32& aChromeFlags, const bool& aIsBrowserFrame);
virtual bool DeallocPBrowser(PBrowserParent* frame);
virtual PCrashReporterParent* AllocPCrashReporter(const NativeThreadId& tid,

Просмотреть файл

@ -84,7 +84,7 @@ both:
// The child creates the PBrowser as part of
// TabChild::BrowserFrameProvideWindow, and the parent creates the PBrowser
// as part of ContentParent::CreateTab.
async PBrowser(PRUint32 chromeFlags);
async PBrowser(PRUint32 chromeFlags, bool isBrowserFrame);
child:
PMemoryReportRequest();

Просмотреть файл

@ -87,13 +87,14 @@ public:
};
TabChild::TabChild(PRUint32 aChromeFlags)
TabChild::TabChild(PRUint32 aChromeFlags, bool aIsBrowserFrame)
: mRemoteFrame(nsnull)
, mTabChildGlobal(nsnull)
, mChromeFlags(aChromeFlags)
, mOuterRect(0, 0, 0, 0)
, mLastBackgroundColor(NS_RGB(255, 255, 255))
, mDidFakeShow(false)
, mIsBrowserFrame(aIsBrowserFrame)
{
printf("creating %d!\n", NS_IsMainThread());
}
@ -377,7 +378,9 @@ TabChild::BrowserFrameProvideWindow(nsIDOMWindow* aOpener,
*aReturn = nsnull;
nsRefPtr<TabChild> newChild =
static_cast<TabChild*>(Manager()->SendPBrowserConstructor(0));
static_cast<TabChild*>(Manager()->SendPBrowserConstructor(
/* aChromeFlags = */ 0,
/* aIsBrowserFrame = */ true));
nsCAutoString spec;
aURI->GetSpec(spec);
@ -948,6 +951,13 @@ TabChild::InitTabChildGlobal()
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
NS_ENSURE_TRUE(root, false);
root->SetParentTarget(scope);
// Initialize the child side of the browser element machinery, if appropriate.
if (mIsBrowserFrame) {
RecvLoadRemoteScript(
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js"));
}
return true;
}

Просмотреть файл

@ -140,7 +140,13 @@ class TabChild : public PBrowserChild,
typedef mozilla::layout::RenderFrameChild RenderFrameChild;
public:
TabChild(PRUint32 aChromeFlags);
/**
* Create a new TabChild object.
*
* |aIsBrowserFrame| indicates whether the TabChild is inside an
* <iframe mozbrowser>.
*/
TabChild(PRUint32 aChromeFlags, bool aIsBrowserFrame);
virtual ~TabChild();
nsresult Init();
@ -266,6 +272,7 @@ private:
nsIntRect mOuterRect;
nscolor mLastBackgroundColor;
bool mDidFakeShow;
bool mIsBrowserFrame;
DISALLOW_EVIL_CONSTRUCTORS(TabChild);
};