зеркало из https://github.com/mozilla/gecko-dev.git
Bug 758401 - Add a way to get message manager from docshell, r=jst
This commit is contained in:
Родитель
4b9fdeaa2b
Коммит
66c92d82af
|
@ -91,6 +91,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
var localmm = document.getElementById('ifr').messageManager;
|
var localmm = document.getElementById('ifr').messageManager;
|
||||||
|
|
||||||
|
var wn = document.getElementById('ifr').contentWindow
|
||||||
|
.getInterface(Components.interfaces.nsIWebNavigation);
|
||||||
|
opener.wrappedJSObject.ok(wn, "Should have webnavigation");
|
||||||
|
var cfmm = wn.getInterface(Components.interfaces.nsIContentFrameMessageManager);
|
||||||
|
opener.wrappedJSObject.ok(cfmm, "Should have content messageManager");
|
||||||
|
|
||||||
|
var didGetSyncMessage = false;
|
||||||
|
function syncContinueTestFn() {
|
||||||
|
didGetSyncMessage = true;
|
||||||
|
}
|
||||||
|
localmm.addMessageListener("syncContinueTest", syncContinueTestFn);
|
||||||
|
cfmm.sendSyncMessage("syncContinueTest", {});
|
||||||
|
localmm.removeMessageListener("syncContinueTest", syncContinueTestFn);
|
||||||
|
opener.wrappedJSObject.ok(didGetSyncMessage, "Should have got sync message!");
|
||||||
|
|
||||||
localmm.addMessageListener("lasync", localL);
|
localmm.addMessageListener("lasync", localL);
|
||||||
localmm.loadFrameScript("data:,sendAsyncMessage('lasync', { data: 2345 })", false);
|
localmm.loadFrameScript("data:,sendAsyncMessage('lasync', { data: 2345 })", false);
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,7 @@
|
||||||
#include "nsDOMNavigationTiming.h"
|
#include "nsDOMNavigationTiming.h"
|
||||||
#include "nsITimedChannel.h"
|
#include "nsITimedChannel.h"
|
||||||
#include "mozilla/StartupTimeline.h"
|
#include "mozilla/StartupTimeline.h"
|
||||||
|
#include "nsIFrameMessageManager.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||||
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||||
|
@ -1057,6 +1058,22 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink)
|
||||||
return ir->GetInterface(aIID, aSink);
|
return ir->GetInterface(aIID, aSink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (aIID.Equals(NS_GET_IID(nsIContentFrameMessageManager))) {
|
||||||
|
nsCOMPtr<nsITabChild> tabChild =
|
||||||
|
do_GetInterface(static_cast<nsIDocShell*>(this));
|
||||||
|
nsCOMPtr<nsIContentFrameMessageManager> mm;
|
||||||
|
if (tabChild) {
|
||||||
|
tabChild->
|
||||||
|
GetMessageManager(getter_AddRefs(mm));
|
||||||
|
} else {
|
||||||
|
nsCOMPtr<nsPIDOMWindow> win =
|
||||||
|
do_GetInterface(static_cast<nsIDocShell*>(this));
|
||||||
|
if (win) {
|
||||||
|
mm = do_QueryInterface(win->GetParentTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*aSink = mm.get();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return nsDocLoader::GetInterface(aIID, aSink);
|
return nsDocLoader::GetInterface(aIID, aSink);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
|
|
||||||
|
|
||||||
#include "domstubs.idl"
|
#include "domstubs.idl"
|
||||||
|
interface nsIContentFrameMessageManager;
|
||||||
|
|
||||||
// Sole purpose is to be able to identify the concrete class nsTabChild
|
// Sole purpose is to be able to identify the concrete class nsTabChild
|
||||||
[uuid(a89f8ab5-ff71-492a-8ed5-71185446fa66)]
|
[uuid(bf1eddf9-731b-4a4b-bd65-9a712a892832)]
|
||||||
interface nsITabChild : nsISupports
|
interface nsITabChild : nsISupports
|
||||||
{
|
{
|
||||||
|
readonly attribute nsIContentFrameMessageManager messageManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -939,6 +939,17 @@ TabChild::SetBackgroundColor(const nscolor& aColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult)
|
||||||
|
{
|
||||||
|
if (mTabChildGlobal) {
|
||||||
|
NS_ADDREF(*aResult = mTabChildGlobal);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
*aResult = nsnull;
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
SendSyncMessageToParent(void* aCallbackData,
|
SendSyncMessageToParent(void* aCallbackData,
|
||||||
const nsAString& aMessage,
|
const nsAString& aMessage,
|
||||||
|
|
|
@ -152,6 +152,7 @@ public:
|
||||||
NS_DECL_NSIINTERFACEREQUESTOR
|
NS_DECL_NSIINTERFACEREQUESTOR
|
||||||
NS_DECL_NSIWINDOWPROVIDER
|
NS_DECL_NSIWINDOWPROVIDER
|
||||||
NS_DECL_NSIDIALOGCREATOR
|
NS_DECL_NSIDIALOGCREATOR
|
||||||
|
NS_DECL_NSITABCHILD
|
||||||
|
|
||||||
virtual bool RecvLoadURL(const nsCString& uri);
|
virtual bool RecvLoadURL(const nsCString& uri);
|
||||||
virtual bool RecvShow(const nsIntSize& size);
|
virtual bool RecvShow(const nsIntSize& size);
|
||||||
|
|
|
@ -28,7 +28,9 @@ addEventListener("click",
|
||||||
dump(e.target + "\n");
|
dump(e.target + "\n");
|
||||||
if (e.target instanceof Components.interfaces.nsIDOMHTMLAnchorElement &&
|
if (e.target instanceof Components.interfaces.nsIDOMHTMLAnchorElement &&
|
||||||
dshell == docShell) {
|
dshell == docShell) {
|
||||||
var retval = sendSyncMessage("linkclick", { href: e.target.href });
|
var retval = docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||||
|
getInterface(Components.interfaces.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] : "");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче