Backed out 3 changesets (bug 1479569) for devtools/client/responsive.html failures. CLOSED TREE

Backed out changeset e123d0aa911c (bug 1479569)
Backed out changeset b828a58404e5 (bug 1479569)
Backed out changeset 97041ef8f311 (bug 1479569)
This commit is contained in:
Csoregi Natalia
2018-08-03 10:39:12 +03:00
parent 56069dc7d1
commit 5bd0ca7b64
57 changed files with 266 additions and 167 deletions

View File

@@ -75,8 +75,10 @@ function FeedWriter() {
Services.telemetry.scalarAdd("browser.feeds.preview_loaded", 1); Services.telemetry.scalarAdd("browser.feeds.preview_loaded", 1);
XPCOMUtils.defineLazyGetter(this, "_mm", XPCOMUtils.defineLazyGetter(this, "_mm", () =>
() => this._window.docShell.messageManager); this._window.docShell.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIContentFrameMessageManager));
} }
FeedWriter.prototype = { FeedWriter.prototype = {

View File

@@ -18,7 +18,10 @@ add_task(async function init() {
function frameScript() { function frameScript() {
// Make send[A]syncMessage("SessionStore:update", ...) simulate OOM. // Make send[A]syncMessage("SessionStore:update", ...) simulate OOM.
// Other operations are unaffected. // Other operations are unaffected.
let mm = docShell.messageManager; let mm = docShell.sameTypeRootTreeItem.
QueryInterface(Ci.nsIDocShell).
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIContentFrameMessageManager);
let wrap = function(original) { let wrap = function(original) {
return function(name, ...args) { return function(name, ...args) {

View File

@@ -266,7 +266,9 @@ let ProfileAutocomplete = {
}, },
_frameMMFromWindow(contentWindow) { _frameMMFromWindow(contentWindow) {
return contentWindow.docShell.messageManager; return contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}, },
_getSelectedIndex(contentWindow) { _getSelectedIndex(contentWindow) {
@@ -628,7 +630,9 @@ var FormAutofillContent = {
}, },
_messageManagerFromWindow(win) { _messageManagerFromWindow(win) {
return win.docShell.messageManager; return win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}, },
_onKeyDown(e) { _onKeyDown(e) {

View File

@@ -412,7 +412,9 @@ class ChromeActions {
getLocalizedString(strings, "open_with_different_viewer"), getLocalizedString(strings, "open_with_different_viewer"),
getLocalizedString(strings, "open_with_different_viewer", "accessKey")); getLocalizedString(strings, "open_with_different_viewer", "accessKey"));
let winmm = domWindow.docShell.messageManager; let winmm = domWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.addMessageListener("PDFJS:Child:fallbackDownload", winmm.addMessageListener("PDFJS:Child:fallbackDownload",
function fallbackDownload(msg) { function fallbackDownload(msg) {
@@ -437,7 +439,9 @@ class ChromeActions {
return; return;
} }
var winmm = this.domWindow.docShell.messageManager; var winmm = this.domWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage("PDFJS:Parent:updateControlState", data); winmm.sendAsyncMessage("PDFJS:Parent:updateControlState", data);
} }
@@ -751,7 +755,9 @@ class RequestListener {
class FindEventManager { class FindEventManager {
constructor(contentWindow) { constructor(contentWindow) {
this.contentWindow = contentWindow; this.contentWindow = contentWindow;
this.winmm = contentWindow.docShell.messageManager; this.winmm = contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} }
bind() { bind() {

View File

@@ -72,7 +72,9 @@ var PdfjsContentUtils = {
*/ */
displayWarning(aWindow, aMessage, aLabel, aAccessKey) { displayWarning(aWindow, aMessage, aLabel, aAccessKey) {
// the child's dom frame mm associated with the window. // the child's dom frame mm associated with the window.
let winmm = aWindow.docShell.messageManager; let winmm = aWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
winmm.sendAsyncMessage("PDFJS:Parent:displayWarning", { winmm.sendAsyncMessage("PDFJS:Parent:displayWarning", {
message: aMessage, message: aMessage,
label: aLabel, label: aLabel,

View File

@@ -37,7 +37,18 @@ var gDecoderDoctorObserver = function(subject, topic, data) {
}; };
function getMessageManagerForWindow(aContentWindow) { function getMessageManagerForWindow(aContentWindow) {
return aContentWindow.docShell.messageManager; let ir = aContentWindow.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
return ir.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
if (e.result == Cr.NS_NOINTERFACE) {
return null;
}
throw e;
}
} }
Services.obs.addObserver(gEMEUIObserver, "mediakeys-request"); Services.obs.addObserver(gEMEUIObserver, "mediakeys-request");

View File

@@ -425,5 +425,15 @@ function getMessageManagerForWindow(aContentWindow) {
return null; return null;
} }
return docShell.messageManager; let ir = docShell.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor);
try {
// This throws NS_NOINTERFACE for closed tabs (only with e10s enabled).
return ir.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
if (e.result == Cr.NS_NOINTERFACE) {
return null;
}
throw e;
}
} }

View File

@@ -36,7 +36,10 @@ FormSubmitObserver.prototype =
this._content = aWindow; this._content = aWindow;
this._tab = aTabChildGlobal; this._tab = aTabChildGlobal;
this._mm = this._mm =
this._content.docShell.messageManager; this._content.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
this._tab.addEventListener("pageshow", this); this._tab.addEventListener("pageshow", this);
this._tab.addEventListener("unload", this); this._tab.addEventListener("unload", this);

View File

@@ -51,5 +51,8 @@ var LightWeightThemeWebInstallListener = {
}; };
function getMessageManagerForContent(content) { function getMessageManagerForContent(content) {
return content.docShell.messageManager; return content.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} }

View File

@@ -41,7 +41,10 @@ var LightweightThemeChildHelper = {
const windowEnumerator = Services.ww.getWindowEnumerator(); const windowEnumerator = Services.ww.getWindowEnumerator();
while (windowEnumerator.hasMoreElements()) { while (windowEnumerator.hasMoreElements()) {
const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow); const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
const tabChildGlobal = window.docShell.messageManager; const tabChildGlobal = window.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
const {chromeOuterWindowID, content} = tabChildGlobal; const {chromeOuterWindowID, content} = tabChildGlobal;
if (changedKeys.includes(`theme/${chromeOuterWindowID}`) && if (changedKeys.includes(`theme/${chromeOuterWindowID}`) &&
content && this.whitelist.has(content.document.documentURI)) { content && this.whitelist.has(content.document.documentURI)) {

View File

@@ -50,7 +50,9 @@ var PageStyleHandler = {
return; return;
} }
let mm = win.docShell.messageManager; let mm = win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
this.sendStyleSheetInfo(mm); this.sendStyleSheetInfo(mm);
}, },

View File

@@ -472,7 +472,8 @@ MessageManagerTunnel.prototype = {
// non-remote, so we're able to reach into its window and use the child // non-remote, so we're able to reach into its window and use the child
// side message manager there. // side message manager there.
const docShell = this.outer[FRAME_LOADER].docShell; const docShell = this.outer[FRAME_LOADER].docShell;
return docShell.messageManager; return docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}, },
get inner() { get inner() {

View File

@@ -314,7 +314,13 @@ const browsingContextTargetPrototype = {
* Getter for the nsIMessageManager associated to the browsing context. * Getter for the nsIMessageManager associated to the browsing context.
*/ */
get messageManager() { get messageManager() {
return this.docShell.messageManager; try {
return this.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
return null;
}
}, },
/** /**

View File

@@ -42,7 +42,10 @@ function ContentProcessTargetActor(connection) {
const windowEnumerator = Services.ww.getWindowEnumerator(); const windowEnumerator = Services.ww.getWindowEnumerator();
while (windowEnumerator.hasMoreElements()) { while (windowEnumerator.hasMoreElements()) {
const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow); const window = windowEnumerator.getNext().QueryInterface(Ci.nsIDOMWindow);
const tabChildGlobal = window.docShell.messageManager; const tabChildGlobal = window.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
tabs.push(tabChildGlobal); tabs.push(tabChildGlobal);
} }
return tabs; return tabs;

View File

@@ -39,7 +39,6 @@
#include "mozilla/dom/ClientManager.h" #include "mozilla/dom/ClientManager.h"
#include "mozilla/dom/ClientSource.h" #include "mozilla/dom/ClientSource.h"
#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/DocGroup.h" #include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLAnchorElement.h" #include "mozilla/dom/HTMLAnchorElement.h"
@@ -639,6 +638,17 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
} else if (aIID.Equals(NS_GET_IID(nsITabChild))) { } else if (aIID.Equals(NS_GET_IID(nsITabChild))) {
*aSink = GetTabChild().take(); *aSink = GetTabChild().take();
return *aSink ? NS_OK : NS_ERROR_FAILURE; return *aSink ? NS_OK : NS_ERROR_FAILURE;
} else if (aIID.Equals(NS_GET_IID(nsIContentFrameMessageManager))) {
RefPtr<TabChild> tabChild = TabChild::GetFrom(this);
nsCOMPtr<nsIContentFrameMessageManager> mm;
if (tabChild) {
mm = tabChild->GetMessageManager();
} else {
if (nsPIDOMWindowOuter* win = GetWindow()) {
mm = do_QueryInterface(win->GetParentTarget());
}
}
*aSink = mm.get();
} else { } else {
return nsDocLoader::GetInterface(aIID, aSink); return nsDocLoader::GetInterface(aIID, aSink);
} }
@@ -3966,19 +3976,6 @@ nsDocShell::GetDomWindow(mozIDOMWindowProxy** aWindow)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager)
{
RefPtr<ContentFrameMessageManager> mm;
if (RefPtr<TabChild> tabChild = TabChild::GetFrom(this)) {
mm = tabChild->GetMessageManager();
} else if (nsPIDOMWindowOuter* win = GetWindow()) {
mm = win->GetMessageManager();
}
mm.forget(aMessageManager);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::SetDeviceSizeIsPageSize(bool aValue) nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
{ {

View File

@@ -65,7 +65,6 @@ interface nsILoadURIDelegate;
native TabChildRef(already_AddRefed<nsITabChild>); native TabChildRef(already_AddRefed<nsITabChild>);
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*); native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
webidl ContentFrameMessageManager;
webidl EventTarget; webidl EventTarget;
[scriptable, builtinclass, uuid(049234fe-da10-478b-bc5d-bc6f9a1ba63d)] [scriptable, builtinclass, uuid(049234fe-da10-478b-bc5d-bc6f9a1ba63d)]
@@ -1201,10 +1200,4 @@ interface nsIDocShell : nsIDocShellTreeItem
* Media queries only look at the value in the top-most docshell. * Media queries only look at the value in the top-most docshell.
*/ */
attribute unsigned long displayMode; attribute unsigned long displayMode;
/**
* The message manager for this docshell. This does not throw, but
* can return null if the docshell has no message manager.
*/
[infallible] readonly attribute ContentFrameMessageManager messageManager;
}; };

View File

@@ -6,7 +6,6 @@
#include "mozilla/dom/ChildSHistory.h" #include "mozilla/dom/ChildSHistory.h"
#include "mozilla/dom/ChildSHistoryBinding.h" #include "mozilla/dom/ChildSHistoryBinding.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "nsIMessageManager.h" #include "nsIMessageManager.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsSHistory.h" #include "nsSHistory.h"
@@ -21,7 +20,6 @@ ChildSHistory::ChildSHistory(nsDocShell* aDocShell)
: mDocShell(aDocShell) : mDocShell(aDocShell)
, mHistory(new nsSHistory()) , mHistory(new nsSHistory())
{ {
MOZ_ASSERT(mDocShell);
mHistory->SetRootDocShell(mDocShell); mHistory->SetRootDocShell(mDocShell);
} }
@@ -133,13 +131,10 @@ nsISupports*
ChildSHistory::GetParentObject() const ChildSHistory::GetParentObject() const
{ {
// We want to get the TabChildGlobal, which is the // We want to get the TabChildGlobal, which is the
// messageManager on mDocShell. // nsIContentFrameMessageManager on mDocShell.
RefPtr<ContentFrameMessageManager> mm; nsCOMPtr<nsIContentFrameMessageManager> mm =
if (mDocShell) { do_GetInterface(static_cast<nsIDocShell*>(mDocShell));
mm = mDocShell->GetMessageManager(); return mm;
}
// else we must be unlinked... can that happen here?
return ToSupports(mm);
} }
} // namespace dom } // namespace dom

View File

@@ -31,7 +31,6 @@
#include "mozilla/CycleCollectedJSRuntime.h" #include "mozilla/CycleCollectedJSRuntime.h"
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h" #include "mozilla/dom/ChromeMessageBroadcaster.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/ParentProcessMessageManager.h" #include "mozilla/dom/ParentProcessMessageManager.h"
#include "mozilla/dom/ProcessGlobal.h" #include "mozilla/dom/ProcessGlobal.h"
@@ -120,11 +119,11 @@ MarkChildMessageManagers(MessageBroadcaster* aMM)
mozilla::dom::ipc::MessageManagerCallback* cb = tabMM->GetCallback(); mozilla::dom::ipc::MessageManagerCallback* cb = tabMM->GetCallback();
if (cb) { if (cb) {
nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb); nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
nsInProcessTabChildGlobal* et = fl->GetTabChildGlobal(); EventTarget* et = fl->GetTabChildGlobalAsEventTarget();
if (!et) { if (!et) {
continue; continue;
} }
et->MarkForCC(); static_cast<nsInProcessTabChildGlobal*>(et)->MarkForCC();
EventListenerManager* elm = et->GetExistingListenerManager(); EventListenerManager* elm = et->GetExistingListenerManager();
if (elm) { if (elm) {
elm->MarkForCC(); elm->MarkForCC();
@@ -509,13 +508,14 @@ mozilla::dom::TraceBlackJS(JSTracer* aTrc, bool aIsShutdownGC)
if (ds) { if (ds) {
nsCOMPtr<nsITabChild> tabChild = ds->GetTabChild(); nsCOMPtr<nsITabChild> tabChild = ds->GetTabChild();
if (tabChild) { if (tabChild) {
RefPtr<ContentFrameMessageManager> mm; nsCOMPtr<nsISupports> mm;
tabChild->GetMessageManager(getter_AddRefs(mm)); tabChild->GetMessageManager(getter_AddRefs(mm));
if (mm) { nsCOMPtr<EventTarget> et = do_QueryInterface(mm);
if (et) {
nsCOMPtr<nsISupports> tabChildAsSupports = nsCOMPtr<nsISupports> tabChildAsSupports =
do_QueryInterface(tabChild); do_QueryInterface(tabChild);
mozilla::TraceScriptHolder(tabChildAsSupports, aTrc); mozilla::TraceScriptHolder(tabChildAsSupports, aTrc);
EventListenerManager* elm = mm->GetExistingListenerManager(); EventListenerManager* elm = et->GetExistingListenerManager();
if (elm) { if (elm) {
elm->TraceListeners(aTrc); elm->TraceListeners(aTrc);
} }

View File

@@ -121,7 +121,6 @@
#include "nsHtml5StringParser.h" #include "nsHtml5StringParser.h"
#include "nsHTMLDocument.h" #include "nsHTMLDocument.h"
#include "nsHTMLTags.h" #include "nsHTMLTags.h"
#include "nsInProcessTabChildGlobal.h"
#include "nsIAddonPolicyService.h" #include "nsIAddonPolicyService.h"
#include "nsIAnonymousContentCreator.h" #include "nsIAnonymousContentCreator.h"
#include "nsIAsyncVerifyRedirectCallback.h" #include "nsIAsyncVerifyRedirectCallback.h"
@@ -11088,8 +11087,8 @@ nsContentUtils::ContentIsLink(nsIContent* aContent)
kNameSpaceID_XLink, nsGkAtoms::type, nsGkAtoms::simple, eCaseMatters); kNameSpaceID_XLink, nsGkAtoms::type, nsGkAtoms::simple, eCaseMatters);
} }
/* static */ already_AddRefed<ContentFrameMessageManager> /* static */ already_AddRefed<EventTarget>
nsContentUtils::TryGetTabChildGlobal(nsISupports* aFrom) nsContentUtils::TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom)
{ {
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(aFrom); nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(aFrom);
if (!frameLoaderOwner) { if (!frameLoaderOwner) {
@@ -11101,8 +11100,8 @@ nsContentUtils::TryGetTabChildGlobal(nsISupports* aFrom)
return nullptr; return nullptr;
} }
RefPtr<ContentFrameMessageManager> manager = frameLoader->GetTabChildGlobal(); nsCOMPtr<EventTarget> target = frameLoader->GetTabChildGlobalAsEventTarget();
return manager.forget(); return target.forget();
} }
/* static */ uint32_t /* static */ uint32_t

View File

@@ -124,7 +124,6 @@ class EventListenerManager;
class HTMLEditor; class HTMLEditor;
namespace dom { namespace dom {
class ContentFrameMessageManager;
struct CustomElementDefinition; struct CustomElementDefinition;
class DocumentFragment; class DocumentFragment;
class Element; class Element;
@@ -3243,8 +3242,8 @@ public:
static bool ContentIsLink(nsIContent* aContent); static bool ContentIsLink(nsIContent* aContent);
static already_AddRefed<mozilla::dom::ContentFrameMessageManager> static already_AddRefed<mozilla::dom::EventTarget>
TryGetTabChildGlobal(nsISupports* aFrom); TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom);
static PopupControlState static PopupControlState
PushPopupControlState(PopupControlState aState, bool aForce) PushPopupControlState(PopupControlState aState, bool aForce)

View File

@@ -2820,7 +2820,8 @@ nsFrameLoader::DoLoadMessageManagerScript(const nsAString& aURL, bool aRunInGlob
if (tabParent) { if (tabParent) {
return tabParent->SendLoadRemoteScript(nsString(aURL), aRunInGlobalScope); return tabParent->SendLoadRemoteScript(nsString(aURL), aRunInGlobalScope);
} }
RefPtr<nsInProcessTabChildGlobal> tabChild = GetTabChildGlobal(); RefPtr<nsInProcessTabChildGlobal> tabChild =
static_cast<nsInProcessTabChildGlobal*>(GetTabChildGlobalAsEventTarget());
if (tabChild) { if (tabChild) {
tabChild->LoadFrameScript(aURL, aRunInGlobalScope); tabChild->LoadFrameScript(aURL, aRunInGlobalScope);
} }
@@ -2978,6 +2979,12 @@ nsFrameLoader::ReallyLoadFrameScripts()
return NS_OK; return NS_OK;
} }
EventTarget*
nsFrameLoader::GetTabChildGlobalAsEventTarget()
{
return mChildMessageManager.get();
}
already_AddRefed<Element> already_AddRefed<Element>
nsFrameLoader::GetOwnerElement() nsFrameLoader::GetOwnerElement()
{ {

View File

@@ -106,10 +106,7 @@ public:
void DestroyDocShell(); void DestroyDocShell();
void DestroyComplete(); void DestroyComplete();
nsIDocShell* GetExistingDocShell() { return mDocShell; } nsIDocShell* GetExistingDocShell() { return mDocShell; }
nsInProcessTabChildGlobal* GetTabChildGlobal() const mozilla::dom::EventTarget* GetTabChildGlobalAsEventTarget();
{
return mChildMessageManager;
}
nsresult CreateStaticClone(nsFrameLoader* aDest); nsresult CreateStaticClone(nsFrameLoader* aDest);
nsresult UpdatePositionAndSize(nsSubDocumentFrame *aIFrame); nsresult UpdatePositionAndSize(nsSubDocumentFrame *aIFrame);

View File

@@ -145,7 +145,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentFrameMessageManager)
/* Message managers in child process implement nsIMessageSender. /* Message managers in child process implement nsIMessageSender.
Message managers in the chrome process are Message managers in the chrome process are
@@ -153,6 +153,9 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
managers) or they're simple message senders. */ managers) or they're simple message senders. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIMessageSender, !mChrome || !mIsBroadcaster) NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIMessageSender, !mChrome || !mIsBroadcaster)
/* nsIContentFrameMessageManager is accessible only in TabChildGlobal. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIContentFrameMessageManager,
!mChrome && !mIsProcessManager)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameMessageManager) NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameMessageManager)

View File

@@ -161,7 +161,7 @@ private:
JS::Rooted<JSObject*> mObj; JS::Rooted<JSObject*> mObj;
}; };
class nsFrameMessageManager : public nsIMessageSender class nsFrameMessageManager : public nsIContentFrameMessageManager
{ {
friend class mozilla::dom::MessageManagerReporter; friend class mozilla::dom::MessageManagerReporter;
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData; typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
@@ -180,7 +180,8 @@ public:
{} {}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsFrameMessageManager) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFrameMessageManager,
nsIContentFrameMessageManager)
void MarkForCC(); void MarkForCC();
@@ -242,6 +243,7 @@ public:
mozilla::dom::ipc::WritableSharedMap* SharedData(); mozilla::dom::ipc::WritableSharedMap* SharedData();
NS_DECL_NSIMESSAGESENDER NS_DECL_NSIMESSAGESENDER
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
static mozilla::dom::ProcessMessageManager* NewProcessMessageManager(bool aIsRemote); static mozilla::dom::ProcessMessageManager* NewProcessMessageManager(bool aIsRemote);

View File

@@ -18,7 +18,6 @@
#include "nsDOMNavigationTiming.h" #include "nsDOMNavigationTiming.h"
#include "nsIDOMStorageManager.h" #include "nsIDOMStorageManager.h"
#include "mozilla/AutoplayPermissionManager.h" #include "mozilla/AutoplayPermissionManager.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/DOMJSProxyHandler.h" #include "mozilla/dom/DOMJSProxyHandler.h"
#include "mozilla/dom/DOMPrefs.h" #include "mozilla/dom/DOMPrefs.h"
#include "mozilla/dom/EventTarget.h" #include "mozilla/dom/EventTarget.h"
@@ -1911,18 +1910,20 @@ nsGlobalWindowInner::UpdateParentTarget()
nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal(); nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
nsCOMPtr<EventTarget> eventTarget = nsCOMPtr<EventTarget> eventTarget =
nsContentUtils::TryGetTabChildGlobal(frameElement); nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
if (!eventTarget) { if (!eventTarget) {
nsGlobalWindowOuter* topWin = GetScriptableTopInternal(); nsGlobalWindowOuter* topWin = GetScriptableTopInternal();
if (topWin) { if (topWin) {
frameElement = topWin->AsOuter()->GetFrameElementInternal(); frameElement = topWin->AsOuter()->GetFrameElementInternal();
eventTarget = nsContentUtils::TryGetTabChildGlobal(frameElement); eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
} }
} }
if (!eventTarget) { if (!eventTarget) {
eventTarget = nsContentUtils::TryGetTabChildGlobal(mChromeEventHandler); eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(mChromeEventHandler);
} }
if (!eventTarget) { if (!eventTarget) {

View File

@@ -20,7 +20,6 @@
#include "nsISecureBrowserUI.h" #include "nsISecureBrowserUI.h"
#include "nsIWebProgressListener.h" #include "nsIWebProgressListener.h"
#include "mozilla/AntiTrackingCommon.h" #include "mozilla/AntiTrackingCommon.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/EventTarget.h" #include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/LocalStorage.h" #include "mozilla/dom/LocalStorage.h"
#include "mozilla/dom/Storage.h" #include "mozilla/dom/Storage.h"
@@ -1039,7 +1038,6 @@ nsGlobalWindowOuter::CleanUp()
} }
mChromeEventHandler = nullptr; // Forces Release mChromeEventHandler = nullptr; // Forces Release
mParentTarget = nullptr; mParentTarget = nullptr;
mMessageManager = nullptr;
mArguments = nullptr; mArguments = nullptr;
@@ -1146,7 +1144,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowOuter)
// Traverse stuff from nsPIDOMWindow // Traverse stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFrameElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOpenerForInitialContentBrowser) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOpenerForInitialContentBrowser)
@@ -1173,7 +1170,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowOuter)
// Unlink stuff from nsPIDOMWindow // Unlink stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget) NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement) NS_IMPL_CYCLE_COLLECTION_UNLINK(mFrameElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOpenerForInitialContentBrowser) NS_IMPL_CYCLE_COLLECTION_UNLINK(mOpenerForInitialContentBrowser)
@@ -2240,10 +2236,9 @@ nsGlobalWindowOuter::SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
void void
nsGlobalWindowOuter::UpdateParentTarget() nsGlobalWindowOuter::UpdateParentTarget()
{ {
// NOTE: This method is nearly identical to // NOTE: This method is identical to
// nsGlobalWindowInner::UpdateParentTarget(). IF YOU UPDATE THIS METHOD, // nsGlobalWindowInner::UpdateParentTarget(). IF YOU UPDATE THIS METHOD,
// UPDATE THE OTHER ONE TOO! The one difference is that this method updates // UPDATE THE OTHER ONE TOO!
// mMessageManager as well, which inner windows don't have.
// Try to get our frame element's tab child global (its in-process message // Try to get our frame element's tab child global (its in-process message
// manager). If that fails, fall back to the chrome event handler's tab // manager). If that fails, fall back to the chrome event handler's tab
@@ -2251,25 +2246,28 @@ nsGlobalWindowOuter::UpdateParentTarget()
// handler itself. // handler itself.
nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal(); nsCOMPtr<Element> frameElement = GetOuterWindow()->GetFrameElementInternal();
mMessageManager = nsContentUtils::TryGetTabChildGlobal(frameElement); nsCOMPtr<EventTarget> eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
if (!mMessageManager) { if (!eventTarget) {
nsGlobalWindowOuter* topWin = GetScriptableTopInternal(); nsGlobalWindowOuter* topWin = GetScriptableTopInternal();
if (topWin) { if (topWin) {
frameElement = topWin->GetFrameElementInternal(); frameElement = topWin->GetFrameElementInternal();
mMessageManager = nsContentUtils::TryGetTabChildGlobal(frameElement); eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(frameElement);
} }
} }
if (!mMessageManager) { if (!eventTarget) {
mMessageManager = nsContentUtils::TryGetTabChildGlobal(mChromeEventHandler); eventTarget =
nsContentUtils::TryGetTabChildGlobalAsEventTarget(mChromeEventHandler);
} }
if (mMessageManager) { if (!eventTarget) {
mParentTarget = mMessageManager; eventTarget = mChromeEventHandler;
} else {
mParentTarget = mChromeEventHandler;
} }
mParentTarget = eventTarget;
} }
EventTarget* EventTarget*
@@ -7629,19 +7627,6 @@ nsPIDOMWindowOuter::MaybeCreateDoc()
} }
} }
void
nsPIDOMWindowOuter::SetChromeEventHandlerInternal(EventTarget* aChromeEventHandler)
{
// Out-of-line so we don't need to include ContentFrameMessageManager.h in
// nsPIDOMWindow.h.
mChromeEventHandler = aChromeEventHandler;
// mParentTarget and mMessageManager will be set when the next event is
// dispatched or someone asks for our message manager.
mParentTarget = nullptr;
mMessageManager = nullptr;
}
mozilla::dom::DocGroup* mozilla::dom::DocGroup*
nsPIDOMWindowOuter::GetDocGroup() const nsPIDOMWindowOuter::GetDocGroup() const
{ {

View File

@@ -13,8 +13,14 @@ interface nsIMessageSender : nsISupports
{ {
}; };
// NOTE: Only scriptable for Ci.nsIContentFrameMessageManager
[scriptable, builtinclass, uuid(694e367c-aa25-4446-8499-2c527c4bd838)]
interface nsIContentFrameMessageManager : nsIMessageSender
{
};
[uuid(b39a3324-b574-4f85-8cdb-274d04f807ef)] [uuid(b39a3324-b574-4f85-8cdb-274d04f807ef)]
interface nsIInProcessContentFrameMessageManager : nsIMessageSender interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
{ {
[notxpcom] nsIContent getOwnerContent(); [notxpcom] nsIContent getOwnerContent();
}; };

View File

@@ -166,6 +166,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIMessageSender) NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager) NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
@@ -294,7 +295,7 @@ nsInProcessTabChildGlobal::GetEventTargetParent(EventChainPreVisitor& aVisitor)
nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner); nsCOMPtr<nsIFrameLoaderOwner> owner = do_QueryInterface(mOwner);
RefPtr<nsFrameLoader> fl = owner->GetFrameLoader(); RefPtr<nsFrameLoader> fl = owner->GetFrameLoader();
if (fl) { if (fl) {
NS_ASSERTION(this == fl->GetTabChildGlobal(), NS_ASSERTION(this == fl->GetTabChildGlobalAsEventTarget(),
"Wrong event target!"); "Wrong event target!");
NS_ASSERTION(fl->mMessageManager == mChromeMessageManager, NS_ASSERTION(fl->mMessageManager == mChromeMessageManager,
"Wrong message manager!"); "Wrong message manager!");

View File

@@ -84,6 +84,7 @@ public:
virtual uint64_t ChromeOuterWindowID() override; virtual uint64_t ChromeOuterWindowID() override;
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER

View File

@@ -51,7 +51,6 @@ namespace dom {
class AudioContext; class AudioContext;
class ClientInfo; class ClientInfo;
class ClientState; class ClientState;
class ContentFrameMessageManager;
class DocGroup; class DocGroup;
class TabGroup; class TabGroup;
class Element; class Element;
@@ -873,15 +872,6 @@ public:
return mParentTarget; return mParentTarget;
} }
mozilla::dom::ContentFrameMessageManager* GetMessageManager()
{
// We maintain our mMessageManager state alongside mParentTarget.
if (!mParentTarget) {
UpdateParentTarget();
}
return mMessageManager;
}
nsIDocument* GetExtantDoc() const nsIDocument* GetExtantDoc() const
{ {
return mDoc; return mDoc;
@@ -1170,7 +1160,11 @@ protected:
// we have what it takes to do so. // we have what it takes to do so.
void MaybeCreateDoc(); void MaybeCreateDoc();
void SetChromeEventHandlerInternal(mozilla::dom::EventTarget* aChromeEventHandler); void SetChromeEventHandlerInternal(mozilla::dom::EventTarget* aChromeEventHandler) {
mChromeEventHandler = aChromeEventHandler;
// mParentTarget will be set when the next event is dispatched.
mParentTarget = nullptr;
}
virtual void UpdateParentTarget() = 0; virtual void UpdateParentTarget() = 0;
@@ -1183,7 +1177,6 @@ protected:
nsCOMPtr<nsIURI> mDocumentURI; // strong nsCOMPtr<nsIURI> mDocumentURI; // strong
nsCOMPtr<mozilla::dom::EventTarget> mParentTarget; // strong nsCOMPtr<mozilla::dom::EventTarget> mParentTarget; // strong
RefPtr<mozilla::dom::ContentFrameMessageManager> mMessageManager; // strong
nsCOMPtr<mozilla::dom::Element> mFrameElement; nsCOMPtr<mozilla::dom::Element> mFrameElement;

View File

@@ -142,7 +142,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
var docShell = document.getElementById('ifr').contentWindow.docShell; var docShell = document.getElementById('ifr').contentWindow.docShell;
ok(docShell, "Should have docshell"); ok(docShell, "Should have docshell");
var cfmm = docShell.messageManager; var cfmm = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIContentFrameMessageManager);
ok(cfmm, "Should have content messageManager"); ok(cfmm, "Should have content messageManager");
var didGetSyncMessage = false; var didGetSyncMessage = false;

View File

@@ -30,7 +30,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1412775
b.addEventListener("foo", function(e) { b.addEventListener("foo", function(e) {
didCallChromeSide = true; didCallChromeSide = true;
var path = e.composedPath(); var path = e.composedPath();
var mm = d.defaultView.docShell.messageManager; var mm = d.defaultView.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
is(path.length, 5, "Should have 5 items in composedPath in chrome."); is(path.length, 5, "Should have 5 items in composedPath in chrome.");
is(path[0], mm, "TabChildGlobal is the chrome handler."); is(path[0], mm, "TabChildGlobal is the chrome handler.");
is(path[1], b, "browser element should be in the path."); is(path[1], b, "browser element should be in the path.");

View File

@@ -8,15 +8,13 @@
interface nsIWebBrowserChrome3; interface nsIWebBrowserChrome3;
webidl ContentFrameMessageManager;
native CommandsArray(nsTArray<nsCString>); native CommandsArray(nsTArray<nsCString>);
[ref] native CommandsArrayRef(nsTArray<nsCString>); [ref] native CommandsArrayRef(nsTArray<nsCString>);
[scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)] [scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)]
interface nsITabChild : nsISupports interface nsITabChild : nsISupports
{ {
readonly attribute ContentFrameMessageManager messageManager; readonly attribute nsISupports messageManager;
attribute nsIWebBrowserChrome3 webBrowserChrome; attribute nsIWebBrowserChrome3 webBrowserChrome;

View File

@@ -2993,9 +2993,9 @@ TabChild::IsVisible()
} }
NS_IMETHODIMP NS_IMETHODIMP
TabChild::GetMessageManager(ContentFrameMessageManager** aResult) TabChild::GetMessageManager(nsISupports** aResult)
{ {
RefPtr<ContentFrameMessageManager> mm(mTabChildGlobal); nsCOMPtr<nsIContentFrameMessageManager> mm(mTabChildGlobal);
mm.forget(aResult); mm.forget(aResult);
return *aResult ? NS_OK : NS_ERROR_FAILURE; return *aResult ? NS_OK : NS_ERROR_FAILURE;
} }
@@ -3551,6 +3551,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildGlobal) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIMessageSender) NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)

View File

@@ -80,7 +80,7 @@ class CoalescedMouseData;
class CoalescedWheelData; class CoalescedWheelData;
class TabChildGlobal : public ContentFrameMessageManager, class TabChildGlobal : public ContentFrameMessageManager,
public nsIMessageSender, public nsIContentFrameMessageManager,
public nsIScriptObjectPrincipal, public nsIScriptObjectPrincipal,
public nsIGlobalObject, public nsIGlobalObject,
public nsSupportsWeakReference public nsSupportsWeakReference
@@ -108,6 +108,7 @@ public:
virtual uint64_t ChromeOuterWindowID() override; virtual uint64_t ChromeOuterWindowID() override;
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
void void
GetEventTargetParent(EventChainPreVisitor& aVisitor) override GetEventTargetParent(EventChainPreVisitor& aVisitor) override

View File

@@ -21,8 +21,9 @@ addEventListener("click",
dump(e.target + "\n"); dump(e.target + "\n");
if (ChromeUtils.getClassName(e.target) === "HTMLAnchorElement" && if (ChromeUtils.getClassName(e.target) === "HTMLAnchorElement" &&
dshell == docShell) { dshell == docShell) {
var retval = docShell.messageManager var retval = docShell.QueryInterface(Ci.nsIInterfaceRequestor).
.sendSyncMessage("linkclick", { href: e.target.href }); getInterface(Ci.nsIContentFrameMessageManager).
sendSyncMessage("linkclick", { href: e.target.href });
dump(uneval(retval[0]) + "\n"); dump(uneval(retval[0]) + "\n");
// Test here also that both retvals are the same // Test here also that both retvals are the same
sendAsyncMessage("linkclick-reply-object", uneval(retval[0]) == uneval(retval[1]) ? retval[0] : ""); sendAsyncMessage("linkclick-reply-object", uneval(retval[0]) == uneval(retval[1]) ? retval[0] : "");

View File

@@ -196,9 +196,9 @@ this.FxAccountsWebChannel.prototype = {
switch (command) { switch (command) {
case COMMAND_LOADED: case COMMAND_LOADED:
// Note: we want the child side of the message manager here, not the let mm = sendingContext.browser.docShell
// parent, so get it from the docshell, not the browser. .QueryInterface(Ci.nsIInterfaceRequestor)
let mm = sendingContext.browser.docShell.messageManager; .getInterface(Ci.nsIContentFrameMessageManager);
mm.sendAsyncMessage(COMMAND_LOADED); mm.sendAsyncMessage(COMMAND_LOADED);
break; break;

View File

@@ -1754,14 +1754,14 @@ SpecialPowersAPI.prototype = {
aWindow.focus(); aWindow.focus();
var mm = global; var mm = global;
if (aWindow) { if (aWindow) {
let windowMM = aWindow.docShell.messageManager; try {
if (windowMM) { mm = aWindow.docShell
mm = windowMM; .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} catch (ex) {
/* Ignore exceptions for e.g. XUL chrome windows from mochitest-chrome
* which won't have a message manager */
} }
/*
* Otherwise (e.g. XUL chrome windows from mochitest-chrome which won't
* have a message manager) just stick with "global".
*/
} }
mm.sendAsyncMessage("SpecialPowers.Focus", {}); mm.sendAsyncMessage("SpecialPowers.Focus", {});
}, },

View File

@@ -4,7 +4,9 @@
function init() { function init() {
if (document.location.hash.indexOf("#auto") == 0) { if (document.location.hash.indexOf("#auto") == 0) {
let mm = window.docShell.messageManager; let mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
mm.addMessageListener("CPStartup:FinalResults", function onResults(msg) { mm.addMessageListener("CPStartup:FinalResults", function onResults(msg) {
mm.removeMessageListener("CPStartup:FinalResults", onResults); mm.removeMessageListener("CPStartup:FinalResults", onResults);

View File

@@ -4,7 +4,9 @@
function init() { function init() {
if (document.location.hash.indexOf("#auto") == 0) { if (document.location.hash.indexOf("#auto") == 0) {
let mm = window.docShell.messageManager; let mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
mm.addMessageListener("TabPaint:FinalResults", function onResults(msg) { mm.addMessageListener("TabPaint:FinalResults", function onResults(msg) {
mm.removeMessageListener("TabPaint:FinalResults", onResults); mm.removeMessageListener("TabPaint:FinalResults", onResults);

View File

@@ -52,7 +52,9 @@
let opened = parseInt(location.search.substring(1), 10); let opened = parseInt(location.search.substring(1), 10);
let delta = presented - opened; let delta = presented - opened;
let mm = window.docShell.messageManager; let mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
mm.sendAsyncMessage("TabPaint:Painted", { delta }); mm.sendAsyncMessage("TabPaint:Painted", { delta });
}); });

View File

@@ -371,7 +371,8 @@ class BaseContext {
let {document, docShell} = contentWindow; let {document, docShell} = contentWindow;
this.innerWindowID = getInnerWindowID(contentWindow); this.innerWindowID = getInnerWindowID(contentWindow);
this.messageManager = docShell.messageManager; this.messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
if (this.incognito == null) { if (this.incognito == null) {
this.incognito = PrivateBrowsingUtils.isContentWindowPrivate(contentWindow); this.incognito = PrivateBrowsingUtils.isContentWindowPrivate(contentWindow);

View File

@@ -399,7 +399,9 @@ ExtensionPageChild = {
throw new Error("An extension context was already initialized for this frame"); throw new Error("An extension context was already initialized for this frame");
} }
let mm = contentWindow.docShell.messageManager; let mm = contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let {viewType, tabId, devtoolsToolboxInfo} = getFrameData(mm) || {}; let {viewType, tabId, devtoolsToolboxInfo} = getFrameData(mm) || {};

View File

@@ -25,7 +25,7 @@
* A basic setup works something like this: * A basic setup works something like this:
* *
* A content script adds a message listener to its global * A content script adds a message listener to its global
* ContentFrameMessageManager, with an appropriate set of filters: * nsIContentFrameMessageManager, with an appropriate set of filters:
* *
* { * {
* init(messageManager, window, extensionID) { * init(messageManager, window, extensionID) {

View File

@@ -88,6 +88,16 @@ var contentScripts = new DefaultWeakMap(matcher => {
matcher); matcher);
}); });
function getMessageManager(window) {
let docShell = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
try {
return docShell.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
// Some windows don't support this interface (hidden window).
return null;
}
}
var DocumentManager; var DocumentManager;
var ExtensionManager; var ExtensionManager;
@@ -480,7 +490,7 @@ ExtensionProcessScript.prototype = {
}, },
initExtensionDocument(policy, doc) { initExtensionDocument(policy, doc) {
if (DocumentManager.globals.has(doc.defaultView.docShell.messageManager)) { if (DocumentManager.globals.has(getMessageManager(doc.defaultView))) {
DocumentManager.loadInto(policy, doc.defaultView); DocumentManager.loadInto(policy, doc.defaultView);
} }
}, },
@@ -497,7 +507,7 @@ ExtensionProcessScript.prototype = {
}, },
loadContentScript(contentScript, window) { loadContentScript(contentScript, window) {
if (DocumentManager.globals.has(window.docShell.messageManager)) { if (DocumentManager.globals.has(getMessageManager(window))) {
contentScripts.get(contentScript).injectInto(window); contentScripts.get(contentScript).injectInto(window);
} }
}, },

View File

@@ -153,6 +153,12 @@ prefBranch.addObserver("", observer.onPrefChange);
observer.onPrefChange(); // read initial values observer.onPrefChange(); // read initial values
function messageManagerFromWindow(win) {
return win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}
// This object maps to the "child" process (even in the single-process case). // This object maps to the "child" process (even in the single-process case).
var LoginManagerContent = { var LoginManagerContent = {
__formFillService: null, // FormFillController, for username autocompleting __formFillService: null, // FormFillController, for username autocompleting
@@ -295,7 +301,7 @@ var LoginManagerContent = {
} }
let actionOrigin = LoginUtils._getActionOrigin(form); let actionOrigin = LoginUtils._getActionOrigin(form);
let messageManager = win.docShell.messageManager; let messageManager = messageManagerFromWindow(win);
// XXX Weak?? // XXX Weak??
let requestData = { form }; let requestData = { form };
@@ -317,7 +323,7 @@ var LoginManagerContent = {
let formOrigin = LoginUtils._getPasswordOrigin(doc.documentURI); let formOrigin = LoginUtils._getPasswordOrigin(doc.documentURI);
let actionOrigin = LoginUtils._getActionOrigin(form); let actionOrigin = LoginUtils._getActionOrigin(form);
let messageManager = win.docShell.messageManager; let messageManager = messageManagerFromWindow(win);
let previousResult = aPreviousResult ? let previousResult = aPreviousResult ?
{ searchString: aPreviousResult.searchString, { searchString: aPreviousResult.searchString,
@@ -438,7 +444,7 @@ var LoginManagerContent = {
const isPrivateWindow = PrivateBrowsingUtils.isContentWindowPrivate(window); const isPrivateWindow = PrivateBrowsingUtils.isContentWindowPrivate(window);
let messageManager = window.docShell.messageManager; let messageManager = messageManagerFromWindow(window);
messageManager.sendAsyncMessage("LoginStats:LoginEncountered", messageManager.sendAsyncMessage("LoginStats:LoginEncountered",
{ {
isPrivateWindow, isPrivateWindow,
@@ -501,7 +507,7 @@ var LoginManagerContent = {
frame => hasInsecureLoginForms(frame)); frame => hasInsecureLoginForms(frame));
}; };
let messageManager = topWindow.docShell.messageManager; let messageManager = messageManagerFromWindow(topWindow);
messageManager.sendAsyncMessage("RemoteLogins:insecureLoginFormPresent", { messageManager.sendAsyncMessage("RemoteLogins:insecureLoginFormPresent", {
hasInsecureLoginForms: hasInsecureLoginForms(topWindow), hasInsecureLoginForms: hasInsecureLoginForms(topWindow),
}); });
@@ -939,7 +945,7 @@ var LoginManagerContent = {
} }
let formSubmitURL = LoginUtils._getActionOrigin(form); let formSubmitURL = LoginUtils._getActionOrigin(form);
let messageManager = win.docShell.messageManager; let messageManager = messageManagerFromWindow(win);
let recipes = LoginRecipesContent.getRecipes(hostname, win); let recipes = LoginRecipesContent.getRecipes(hostname, win);
@@ -1257,7 +1263,7 @@ var LoginManagerContent = {
autofillResult = AUTOFILL_RESULT.FILLED; autofillResult = AUTOFILL_RESULT.FILLED;
let win = doc.defaultView; let win = doc.defaultView;
let messageManager = win.docShell.messageManager; let messageManager = messageManagerFromWindow(win);
messageManager.sendAsyncMessage("LoginStats:LoginFillSuccessful"); messageManager.sendAsyncMessage("LoginStats:LoginFillSuccessful");
} finally { } finally {
if (autofillResult == -1) { if (autofillResult == -1) {

View File

@@ -234,7 +234,9 @@ var LoginRecipesContent = {
} }
} }
let mm = win.docShell.messageManager; let mm = win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
log.warn("getRecipes: falling back to a synchronous message for:", aHost); log.warn("getRecipes: falling back to a synchronous message for:", aHost);
recipes = mm.sendSyncMessage("RemoteLogins:findRecipes", { formOrigin: aHost })[0]; recipes = mm.sendSyncMessage("RemoteLogins:findRecipes", { formOrigin: aHost })[0];

View File

@@ -359,7 +359,8 @@ function openTabPrompt(domWin, tabPrompt, args) {
let winUtils = domWin.windowUtils; let winUtils = domWin.windowUtils;
winUtils.enterModalState(); winUtils.enterModalState();
let frameMM = docShell.messageManager; let frameMM = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
// We provide a callback so the prompt can close itself. We don't want to // We provide a callback so the prompt can close itself. We don't want to
// wait for this event loop to return... Otherwise the presence of other // wait for this event loop to return... Otherwise the presence of other
@@ -442,7 +443,7 @@ function openRemotePrompt(domWin, args, tabPrompt) {
winUtils.enterModalState(); winUtils.enterModalState();
let closed = false; let closed = false;
let frameMM = docShell.messageManager; let frameMM = docShell.getInterface(Ci.nsIContentFrameMessageManager);
// It should be hard or impossible to cause a window to create multiple // It should be hard or impossible to cause a window to create multiple
// prompts, but just in case, give our prompt an ID. // prompts, but just in case, give our prompt an ID.

View File

@@ -40,7 +40,11 @@ function isAutocompleteDisabled(aField) {
function FormHistoryClient({ formField, inputName }) { function FormHistoryClient({ formField, inputName }) {
if (formField && inputName != this.SEARCHBAR_ID) { if (formField && inputName != this.SEARCHBAR_ID) {
let window = formField.ownerGlobal; let window = formField.ownerGlobal;
this.mm = window.docShell.messageManager; let topDocShell = window.docShell
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIDocShell);
this.mm = topDocShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} else { } else {
if (inputName == this.SEARCHBAR_ID && formField) { if (inputName == this.SEARCHBAR_ID && formField) {
throw new Error("FormHistoryClient constructed with both a " + throw new Error("FormHistoryClient constructed with both a " +

View File

@@ -11,7 +11,13 @@ function nsSidebar() {
nsSidebar.prototype = { nsSidebar.prototype = {
init(window) { init(window) {
this.window = window; this.window = window;
this.mm = window.docShell.messageManager; try {
this.mm = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
Cu.reportError(e);
}
}, },
// This function implements window.external.AddSearchProvider(). // This function implements window.external.AddSearchProvider().

View File

@@ -57,7 +57,9 @@ let ProcessObserver = {
// Get the frame message manager for this window so we can associate this // Get the frame message manager for this window so we can associate this
// page with a browser element // page with a browser element
let messageManager = window.docShell.messageManager; let messageManager = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let { ChildMessagePort } = let { ChildMessagePort } =
ChromeUtils.import("resource://gre/modules/remotepagemanager/RemotePageManagerChild.jsm", {}); ChromeUtils.import("resource://gre/modules/remotepagemanager/RemotePageManagerChild.jsm", {});

View File

@@ -306,8 +306,9 @@ var E10SUtils = {
redirectLoad(aDocShell, aURI, aReferrer, aTriggeringPrincipal, aFreshProcess, aFlags) { redirectLoad(aDocShell, aURI, aReferrer, aTriggeringPrincipal, aFreshProcess, aFlags) {
// Retarget the load to the correct process // Retarget the load to the correct process
let messageManager = aDocShell.messageManager; let messageManager = aDocShell.QueryInterface(Ci.nsIInterfaceRequestor)
let sessionHistory = aDocShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory; .getInterface(Ci.nsIContentFrameMessageManager);
let sessionHistory = aDocShell.getInterface(Ci.nsIWebNavigation).sessionHistory;
messageManager.sendAsyncMessage("Browser:LoadURI", { messageManager.sendAsyncMessage("Browser:LoadURI", {
loadOptions: { loadOptions: {

View File

@@ -12,7 +12,9 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
function getMessageManager(event) { function getMessageManager(event) {
let window = Cu.getGlobalForObject(event.target); let window = Cu.getGlobalForObject(event.target);
return window.docShell.messageManager; return window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} }
var WebChannelContent = { var WebChannelContent = {

View File

@@ -165,9 +165,14 @@ var ContentPolicy = {
} }
} }
let windowMM = window.docShell.messageManager; let ir = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
if (windowMM) { try {
mm = windowMM; // If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
mm = ir.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
if (e.result != Cr.NS_NOINTERFACE) {
throw e;
}
} }
} }

View File

@@ -73,7 +73,9 @@ amContentHandler.prototype = {
} }
// Fall back to sending through the message manager // Fall back to sending through the message manager
let messageManager = window.docShell.messageManager; let messageManager = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
messageManager.sendAsyncMessage(MSG_INSTALL_ADDON, install); messageManager.sendAsyncMessage(MSG_INSTALL_ADDON, install);
}, },

View File

@@ -37,7 +37,10 @@ function RemoteMediator(window) {
let utils = window.windowUtils; let utils = window.windowUtils;
this._windowID = utils.currentInnerWindowID; this._windowID = utils.currentInnerWindowID;
this.mm = window.docShell.messageManager; this.mm = window
.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this); this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this);
this._lastCallbackID = 0; this._lastCallbackID = 0;
@@ -89,7 +92,9 @@ RemoteMediator.prototype = {
} }
// Fall back to sending through the message manager // Fall back to sending through the message manager
let messageManager = window.docShell.messageManager; let messageManager = window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
return messageManager.sendSyncMessage(MSG_INSTALL_ADDON, install)[0]; return messageManager.sendSyncMessage(MSG_INSTALL_ADDON, install)[0];
}, },

View File

@@ -203,7 +203,10 @@ class WebAPI extends APIObject {
} }
init(window) { init(window) {
let mm = window.docShell.messageManager; let mm = window
.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
let broker = new APIBroker(mm); let broker = new APIBroker(mm);
super.init(window, broker, {}); super.init(window, broker, {});