зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 6 changesets (bug 888600) for beta simulation failures: build bustage on Linux and Windows opt (bug 1442036) and devtools failure browser_net_view-source-debugger.js (bug 1441961). a=backout
Backed out changeset 83c87140dc3d (bug 888600) Backed out changeset 2efb9b1753f6 (bug 888600) Backed out changeset af5303781961 (bug 888600) Backed out changeset 79ef59047e63 (bug 888600) Backed out changeset 30d568d628dd (bug 888600) Backed out changeset c7bd4c6c9741 (bug 888600) --HG-- extra : histedit_source : 791b22f6770f4fead2f909478a93d65d85829fe0%2Cbb387309e90f53e1dde45dcf8cf4ebedcc6e5c5e
This commit is contained in:
Родитель
9f2b269354
Коммит
3a10644021
|
@ -168,7 +168,8 @@ function waitForSuggestions(cb) {
|
|||
}
|
||||
|
||||
function waitForContentSearchEvent(messageType, cb) {
|
||||
let mm = content.SpecialPowers.Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
let mm = content.SpecialPowers.Cc["@mozilla.org/globalmessagemanager;1"].
|
||||
getService(content.SpecialPowers.Ci.nsIMessageListenerManager);
|
||||
mm.addMessageListener("ContentSearch", function listener(aMsg) {
|
||||
if (aMsg.data.type != messageType) {
|
||||
return;
|
||||
|
|
|
@ -42,7 +42,10 @@ var gTests = [
|
|||
|
||||
// If we have reached the max process count already, increase it to ensure
|
||||
// our new tab can have its own content process.
|
||||
let childCount = Services.ppmm.childCount;
|
||||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
let childCount = ppmm.childCount;
|
||||
let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
|
||||
// The first check is because if we are on a branch where e10s-multi is
|
||||
// disabled, we want to keep testing e10s with a single content process.
|
||||
|
@ -143,7 +146,10 @@ var gTests = [
|
|||
|
||||
// If we have reached the max process count already, increase it to ensure
|
||||
// our new tab can have its own content process.
|
||||
let childCount = Services.ppmm.childCount;
|
||||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
let childCount = ppmm.childCount;
|
||||
let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
|
||||
// The first check is because if we are on a branch where e10s-multi is
|
||||
// disabled, we want to keep testing e10s with a single content process.
|
||||
|
@ -249,7 +255,10 @@ var gTests = [
|
|||
|
||||
// If we have reached the max process count already, increase it to ensure
|
||||
// our new tab can have its own content process.
|
||||
let childCount = Services.ppmm.childCount;
|
||||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
let childCount = ppmm.childCount;
|
||||
let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
|
||||
// The first check is because if we are on a branch where e10s-multi is
|
||||
// disabled, we want to keep testing e10s with a single content process.
|
||||
|
|
|
@ -19,6 +19,12 @@ add_task(async function testExecuteScript() {
|
|||
Services.ppmm.getChildAt(0),
|
||||
];
|
||||
for (let mm of messageManagerMap.keys()) {
|
||||
// Sanity check: mm is a message manager.
|
||||
try {
|
||||
mm.QueryInterface(Ci.nsIMessageSender);
|
||||
} catch (e) {
|
||||
mm.QueryInterface(Ci.nsIMessageBroadcaster);
|
||||
}
|
||||
if (!globalMMs.includes(mm)) {
|
||||
++count;
|
||||
}
|
||||
|
|
|
@ -3188,13 +3188,14 @@ this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|
|||
// Listen for UITour messages.
|
||||
// Do it here instead of the UITour module itself so that the UITour module is lazy loaded
|
||||
// when the first message is received.
|
||||
Services.mm.addMessageListener("UITour:onPageEvent", function(aMessage) {
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
|
||||
globalMM.addMessageListener("UITour:onPageEvent", function(aMessage) {
|
||||
UITour.onPageEvent(aMessage, aMessage.data);
|
||||
});
|
||||
|
||||
// Listen for HybridContentTelemetry messages.
|
||||
// Do it here instead of HybridContentTelemetry.init() so that
|
||||
// the module can be lazily loaded on the first message.
|
||||
Services.mm.addMessageListener("HybridContentTelemetry:onTelemetryMessage", aMessage => {
|
||||
globalMM.addMessageListener("HybridContentTelemetry:onTelemetryMessage", aMessage => {
|
||||
HybridContentTelemetry.onTelemetryMessage(aMessage, aMessage.data);
|
||||
});
|
||||
|
|
|
@ -15,13 +15,16 @@ const FRAME_SCRIPTS = [
|
|||
ROOT + "content-forms.js"
|
||||
];
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
for (let script of FRAME_SCRIPTS) {
|
||||
Services.mm.loadFrameScript(script, true);
|
||||
globalMM.loadFrameScript(script, true);
|
||||
}
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
for (let script of FRAME_SCRIPTS) {
|
||||
Services.mm.removeDelayedFrameScript(script, true);
|
||||
globalMM.removeDelayedFrameScript(script, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@ var PdfjsChromeUtils = {
|
|||
this._browsers = new WeakSet();
|
||||
if (!this._ppmm) {
|
||||
// global parent process message manager (PPMM)
|
||||
this._ppmm = Services.ppmm;
|
||||
this._ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].
|
||||
getService(Ci.nsIMessageBroadcaster);
|
||||
this._ppmm.addMessageListener("PDFJS:Parent:clearUserPref", this);
|
||||
this._ppmm.addMessageListener("PDFJS:Parent:setIntPref", this);
|
||||
this._ppmm.addMessageListener("PDFJS:Parent:setBoolPref", this);
|
||||
|
@ -77,7 +78,8 @@ var PdfjsChromeUtils = {
|
|||
this._ppmm.addMessageListener("PDFJS:Parent:isDefaultHandlerApp", this);
|
||||
|
||||
// global dom message manager (MMg)
|
||||
this._mmg = Services.mm;
|
||||
this._mmg = Cc["@mozilla.org/globalmessagemanager;1"].
|
||||
getService(Ci.nsIMessageListenerManager);
|
||||
this._mmg.addMessageListener("PDFJS:Parent:displayWarning", this);
|
||||
|
||||
this._mmg.addMessageListener("PDFJS:Parent:addEventListener", this);
|
||||
|
|
|
@ -35,7 +35,8 @@ var PdfjsContentUtils = {
|
|||
// child *process* mm, or when loaded into the parent for in-content
|
||||
// support the psuedo child process mm 'child PPMM'.
|
||||
if (!this._mm) {
|
||||
this._mm = Services.cpmm;
|
||||
this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].
|
||||
getService(Ci.nsISyncMessageSender);
|
||||
this._mm.addMessageListener("PDFJS:Child:updateSettings", this);
|
||||
|
||||
Services.obs.addObserver(this, "quit-application");
|
||||
|
|
|
@ -408,7 +408,9 @@ var PocketOverlay = {
|
|||
}
|
||||
},
|
||||
shutdown(reason) {
|
||||
Services.ppmm.broadcastAsyncMessage("PocketShuttingDown");
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.broadcastAsyncMessage("PocketShuttingDown");
|
||||
Services.obs.removeObserver(this, "browser-delayed-startup-finished");
|
||||
// Although the ppmm loads the scripts into the chrome process as well,
|
||||
// we need to manually unregister here anyway to ensure these aren't part
|
||||
|
|
|
@ -178,7 +178,8 @@ var AboutHome = {
|
|||
if (target && target.messageManager) {
|
||||
target.messageManager.sendAsyncMessage("AboutHome:Update", data);
|
||||
} else {
|
||||
Services.mm.broadcastAsyncMessage("AboutHome:Update", data);
|
||||
let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
|
||||
mm.broadcastAsyncMessage("AboutHome:Update", data);
|
||||
}
|
||||
}).catch(function onError(x) {
|
||||
Cu.reportError("Error in AboutHome.sendAboutHomeData: " + x);
|
||||
|
|
|
@ -995,10 +995,12 @@ var PluginCrashReporter = {
|
|||
// Only the parent process gets the gmp-plugin-crash observer
|
||||
// notification, so we need to inform any content processes that
|
||||
// the GMP has crashed.
|
||||
if (Services.ppmm) {
|
||||
if (Cc["@mozilla.org/parentprocessmessagemanager;1"]) {
|
||||
let pluginName = propertyBag.getPropertyAsAString("pluginName");
|
||||
Services.ppmm.broadcastAsyncMessage("gmp-plugin-crash",
|
||||
{ pluginName, pluginID });
|
||||
let mm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
mm.broadcastAsyncMessage("gmp-plugin-crash",
|
||||
{ pluginName, pluginID });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -489,7 +489,9 @@ var ContentSearch = {
|
|||
},
|
||||
|
||||
_broadcast(type, data) {
|
||||
Services.mm.broadcastAsyncMessage(...this._msgArgs(type, data));
|
||||
Cc["@mozilla.org/globalmessagemanager;1"].
|
||||
getService(Ci.nsIMessageListenerManager).
|
||||
broadcastAsyncMessage(...this._msgArgs(type, data));
|
||||
},
|
||||
|
||||
_msgArgs(type, data) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {Ci, Cu, CC} = require("chrome");
|
||||
const {Cc, Ci, Cu, CC} = require("chrome");
|
||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const Services = require("Services");
|
||||
|
||||
|
@ -17,6 +17,9 @@ loader.lazyGetter(this, "debug", function () {
|
|||
return !!(AppConstants.DEBUG || AppConstants.DEBUG_JS_MODULES);
|
||||
});
|
||||
|
||||
const childProcessMessageManager =
|
||||
Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Ci.nsISyncMessageSender);
|
||||
const BinaryInput = CC("@mozilla.org/binaryinputstream;1",
|
||||
"nsIBinaryInputStream", "setInputStream");
|
||||
const BufferStream = CC("@mozilla.org/io/arraybuffer-input-stream;1",
|
||||
|
@ -301,7 +304,7 @@ function onContentMessage(e) {
|
|||
let value = e.detail.value;
|
||||
switch (e.detail.type) {
|
||||
case "save":
|
||||
Services.cpmm.sendAsyncMessage(
|
||||
childProcessMessageManager.sendAsyncMessage(
|
||||
"devtools:jsonview:save", value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(async function () {
|
|||
await waitForContentRequests;
|
||||
|
||||
info("Clicking stack-trace tab and waiting for stack-trace panel to open");
|
||||
let wait = waitForDOM(document, "#stack-trace-panel .frame-link", 5);
|
||||
let wait = waitForDOM(document, "#stack-trace-panel .frame-link", 4);
|
||||
// Click on the first request
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelector(".request-list-item"));
|
||||
|
|
|
@ -20,10 +20,12 @@ function waitForDeviceClosed() {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = "webrtc:UpdateGlobalIndicators";
|
||||
Services.ppmm.addMessageListener(message, function listener(aMessage) {
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.addMessageListener(message, function listener(aMessage) {
|
||||
info("Received " + message + " message");
|
||||
if (!aMessage.data.showGlobalIndicator) {
|
||||
Services.ppmm.removeMessageListener(message, listener);
|
||||
ppmm.removeMessageListener(message, listener);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var { Cc } = require("chrome");
|
||||
var { Cc, Ci } = require("chrome");
|
||||
|
||||
loader.lazyGetter(this, "ppmm", () => {
|
||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(
|
||||
Ci.nsIMessageBroadcaster);
|
||||
});
|
||||
|
||||
function ProcessActorList() {
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const { Cc, Ci, Cu } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common");
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
|
||||
loader.lazyGetter(this, "ppmm", () => {
|
||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(
|
||||
Ci.nsIMessageBroadcaster);
|
||||
});
|
||||
loader.lazyRequireGetter(this, "WindowActor",
|
||||
"devtools/server/actors/window", true);
|
||||
|
||||
|
@ -543,7 +547,7 @@ RootActor.prototype = {
|
|||
}
|
||||
|
||||
let { id } = request;
|
||||
let mm = Services.ppmm.getChildAt(id);
|
||||
let mm = ppmm.getChildAt(id);
|
||||
if (!mm) {
|
||||
return { error: "noProcess",
|
||||
message: "There is no process with id '" + id + "'." };
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {Ci, Cu, CC} = require("chrome");
|
||||
const {Cc, Ci, Cu, CC} = require("chrome");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {LongStringActor} = require("devtools/server/actors/string");
|
||||
const {DebuggerServer} = require("devtools/server/main");
|
||||
|
@ -1938,14 +1938,20 @@ StorageActors.createActor({
|
|||
|
||||
var indexedDBHelpers = {
|
||||
backToChild(...args) {
|
||||
Services.mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
let mm = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
method: "backToChild",
|
||||
args: args
|
||||
});
|
||||
},
|
||||
|
||||
onItemUpdated(action, host, path) {
|
||||
Services.mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
let mm = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
method: "onItemUpdated",
|
||||
args: [ action, host, path ]
|
||||
});
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
|
@ -34,7 +37,7 @@ const MSG_MGR_CONSOLE_INFO_MAX = 1024;
|
|||
function ContentProcessForward() {
|
||||
Services.obs.addObserver(this, "console-api-log-event");
|
||||
Services.obs.addObserver(this, "xpcom-shutdown");
|
||||
Services.cpmm.addMessageListener("DevTools:StopForwardingContentProcessMessage", this);
|
||||
cpmm.addMessageListener("DevTools:StopForwardingContentProcessMessage", this);
|
||||
}
|
||||
ContentProcessForward.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
|
@ -105,7 +108,7 @@ ContentProcessForward.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
Services.cpmm.sendAsyncMessage("Console:Log", msgData);
|
||||
cpmm.sendAsyncMessage("Console:Log", msgData);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -118,8 +121,7 @@ ContentProcessForward.prototype = {
|
|||
uninit() {
|
||||
Services.obs.removeObserver(this, "console-api-log-event");
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
Services.cpmm.removeMessageListener("DevTools:StopForwardingContentProcessMessage",
|
||||
this);
|
||||
cpmm.removeMessageListener("DevTools:StopForwardingContentProcessMessage", this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ function setupServer(mm) {
|
|||
|
||||
function init(msg) {
|
||||
let mm = msg.target;
|
||||
mm.QueryInterface(Ci.nsISyncMessageSender);
|
||||
let prefix = msg.data.prefix;
|
||||
|
||||
// Using the JS debugger causes problems when we're trying to
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
const {Cc} = require("chrome");
|
||||
const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
|
||||
const {Cc, Ci} = require("chrome");
|
||||
const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
|
||||
exports.setupChild = function (a, b, c) {
|
||||
|
|
|
@ -49,8 +49,10 @@ function runTests() {
|
|||
let client = new DebuggerClient(transport);
|
||||
|
||||
// Wait for a response from setupInChild
|
||||
const ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
let onChild = msg => {
|
||||
Services.ppmm.removeMessageListener("test:setupChild", onChild);
|
||||
ppmm.removeMessageListener("test:setupChild", onChild);
|
||||
let args = msg.json;
|
||||
|
||||
is(args[0], 1, "Got first numeric argument");
|
||||
|
@ -63,7 +65,7 @@ function runTests() {
|
|||
setupChild: "callParent"
|
||||
});
|
||||
};
|
||||
Services.ppmm.addMessageListener("test:setupChild", onChild);
|
||||
ppmm.addMessageListener("test:setupChild", onChild);
|
||||
|
||||
// Wait also for a reponse from setupInParent called from setup-in-child.js
|
||||
let onParent = (_, topic, args) => {
|
||||
|
|
|
@ -649,10 +649,11 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
|
|||
*aSink = GetTabChild().take();
|
||||
return *aSink ? NS_OK : NS_ERROR_FAILURE;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIContentFrameMessageManager))) {
|
||||
RefPtr<TabChild> tabChild = TabChild::GetFrom(this);
|
||||
nsCOMPtr<nsITabChild> tabChild =
|
||||
do_GetInterface(static_cast<nsIDocShell*>(this));
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm;
|
||||
if (tabChild) {
|
||||
mm = tabChild->GetMessageManager();
|
||||
tabChild->GetMessageManager(getter_AddRefs(mm));
|
||||
} else {
|
||||
if (nsPIDOMWindowOuter* win = GetWindow()) {
|
||||
mm = do_QueryInterface(win->GetParentTarget());
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ChildProcessMessageManager_h
|
||||
#define mozilla_dom_ChildProcessMessageManager_h
|
||||
|
||||
#include "mozilla/dom/SyncMessageSender.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ChildProcessMessageManager final : public SyncMessageSender
|
||||
{
|
||||
public:
|
||||
explicit ChildProcessMessageManager(ipc::MessageManagerCallback* aCallback)
|
||||
: SyncMessageSender(aCallback,
|
||||
MessageManagerFlags::MM_PROCESSMANAGER |
|
||||
MessageManagerFlags::MM_OWNSCALLBACK)
|
||||
{
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
return ChildProcessMessageManagerBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~ChildProcessMessageManager()
|
||||
{
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ChildProcessMessageManager_h
|
|
@ -1,47 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
||||
#include "AccessCheck.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
ChromeMessageBroadcaster::ChromeMessageBroadcaster(nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageListenerManager(nullptr, aParentManager,
|
||||
aFlags |
|
||||
MessageManagerFlags::MM_BROADCASTER |
|
||||
MessageManagerFlags::MM_CHROME)
|
||||
{
|
||||
if (mIsProcessManager) {
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
if (aParentManager) {
|
||||
aParentManager->AddChildManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
ChromeMessageBroadcaster::~ChromeMessageBroadcaster()
|
||||
{
|
||||
if (mIsProcessManager) {
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
ChromeMessageBroadcaster::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
|
||||
|
||||
return ChromeMessageBroadcasterBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,95 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ChromeMessageBroadcaster_h
|
||||
#define mozilla_dom_ChromeMessageBroadcaster_h
|
||||
|
||||
#include "mozilla/dom/MessageListenerManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ChromeMessageBroadcaster final : public MessageListenerManager
|
||||
{
|
||||
public:
|
||||
explicit ChromeMessageBroadcaster(MessageManagerFlags aFlags)
|
||||
: ChromeMessageBroadcaster(nullptr, aFlags)
|
||||
{
|
||||
MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
|
||||
MessageManagerFlags::MM_PROCESSMANAGER |
|
||||
MessageManagerFlags::MM_OWNSCALLBACK)));
|
||||
}
|
||||
explicit ChromeMessageBroadcaster(nsFrameMessageManager* aParentManager)
|
||||
: ChromeMessageBroadcaster(aParentManager, MessageManagerFlags::MM_NONE)
|
||||
{}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
using nsFrameMessageManager::BroadcastAsyncMessage;
|
||||
void BroadcastAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, nullptr,
|
||||
JS::UndefinedHandleValue, aError);
|
||||
}
|
||||
uint32_t ChildCount()
|
||||
{
|
||||
return mChildManagers.Length();
|
||||
}
|
||||
using nsFrameMessageManager::GetChildAt;
|
||||
MessageListenerManager* GetChildAt(uint32_t aIndex)
|
||||
{
|
||||
return mChildManagers.SafeElementAt(aIndex);
|
||||
}
|
||||
// XPCOM ReleaseCachedProcesses is OK
|
||||
|
||||
// ProcessScriptLoader
|
||||
using nsFrameMessageManager::LoadProcessScript;
|
||||
void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, false, aError);
|
||||
}
|
||||
// XPCOM RemoveDelayedProcessScript is OK
|
||||
using nsFrameMessageManager::GetDelayedProcessScripts;
|
||||
void GetDelayedProcessScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
|
||||
// GlobalProcessScriptLoader
|
||||
// XPCOM GetInitialProcessData is OK
|
||||
|
||||
// FrameScriptLoader
|
||||
using nsFrameMessageManager::LoadFrameScript;
|
||||
void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope, mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
|
||||
}
|
||||
using nsFrameMessageManager::GetDelayedFrameScripts;
|
||||
void GetDelayedFrameScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
|
||||
private:
|
||||
ChromeMessageBroadcaster(nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags);
|
||||
virtual ~ChromeMessageBroadcaster();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ChromeMessageBroadcaster_h
|
|
@ -1,41 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
ChromeMessageSender::ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageSender(aCallback, aParentManager, aFlags | MessageManagerFlags::MM_CHROME)
|
||||
{
|
||||
MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
|
||||
MessageManagerFlags::MM_PROCESSMANAGER |
|
||||
MessageManagerFlags::MM_OWNSCALLBACK)));
|
||||
|
||||
// This is a bit hackish. We attach to the parent, but only if we have a callback. We
|
||||
// don't have a callback for the frame message manager, and for parent process message
|
||||
// managers (except the parent in-process message manager). In those cases we wait until
|
||||
// the child process is running (see MessageSender::InitWithCallback).
|
||||
if (aParentManager && mCallback) {
|
||||
aParentManager->AddChildManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
ChromeMessageSender::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
|
||||
|
||||
return ChromeMessageSenderBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,60 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ChromeMessageSender_h
|
||||
#define mozilla_dom_ChromeMessageSender_h
|
||||
|
||||
#include "mozilla/dom/MessageSender.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ChromeMessageSender final : public MessageSender
|
||||
{
|
||||
public:
|
||||
ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags=MessageManagerFlags::MM_NONE);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// ProcessScriptLoader
|
||||
using nsFrameMessageManager::LoadProcessScript;
|
||||
void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, false, aError);
|
||||
}
|
||||
// XPCOM RemoveDelayedProcessScript is OK
|
||||
using nsFrameMessageManager::GetDelayedProcessScripts;
|
||||
void GetDelayedProcessScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
|
||||
// FrameScriptLoader
|
||||
using nsFrameMessageManager::LoadFrameScript;
|
||||
void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope, mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
|
||||
}
|
||||
using nsFrameMessageManager::GetDelayedFrameScripts;
|
||||
void GetDelayedFrameScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ChromeMessageSender_h
|
|
@ -1,95 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ContentFrameMessageManager_h
|
||||
#define mozilla_dom_ContentFrameMessageManager_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/MessageManagerGlobal.h"
|
||||
#include "mozilla/dom/ResolveSystemBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* Base class for implementing the WebIDL ContentFrameMessageManager class.
|
||||
*/
|
||||
class ContentFrameMessageManager : public DOMEventTargetHelper,
|
||||
public MessageManagerGlobal
|
||||
{
|
||||
public:
|
||||
using DOMEventTargetHelper::AddRef;
|
||||
using DOMEventTargetHelper::Release;
|
||||
|
||||
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc)
|
||||
{
|
||||
bool found;
|
||||
if (!SystemGlobalResolve(aCx, aObj, aId, &found)) {
|
||||
return false;
|
||||
}
|
||||
if (found) {
|
||||
FillPropertyDescriptor(aDesc, aObj, JS::UndefinedValue(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool MayResolve(jsid aId)
|
||||
{
|
||||
return MayResolveAsSystemBindingName(aId);
|
||||
}
|
||||
void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, mozilla::ErrorResult& aRv)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
GetSystemBindingNames(aCx, thisObj, aNames, aEnumerableOnly, aRv);
|
||||
}
|
||||
|
||||
nsresult AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false, 2);
|
||||
}
|
||||
using DOMEventTargetHelper::AddEventListener;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter> GetContent(ErrorResult& aError) = 0;
|
||||
virtual already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) = 0;
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() = 0;
|
||||
|
||||
nsFrameMessageManager* GetMessageManager()
|
||||
{
|
||||
return mMessageManager;
|
||||
}
|
||||
void DisconnectMessageManager()
|
||||
{
|
||||
mMessageManager->Disconnect();
|
||||
mMessageManager = nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit ContentFrameMessageManager(nsFrameMessageManager* aMessageManager)
|
||||
: MessageManagerGlobal(aMessageManager)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ContentFrameMessageManager_h
|
|
@ -12,10 +12,8 @@
|
|||
#include "mozilla/dom/DOMPointBinding.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/RuleNodeCacheConditions.h"
|
||||
#include "mozilla/ServoCSSParser.h"
|
||||
#include "nsCSSParser.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
#include "nsStyleTransformMatrix.h"
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
@ -21,6 +21,10 @@ var EXPORTED_SYMBOLS = ["DOMRequestIpcHelper"];
|
|||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageListenerManager");
|
||||
|
||||
function DOMRequestIpcHelper() {
|
||||
// _listeners keeps a list of messages for which we added a listener and the
|
||||
// kind of listener that we added (strong or weak). It's an object of this
|
||||
|
@ -85,8 +89,8 @@ DOMRequestIpcHelper.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
aMsg.weakRef ? Services.cpmm.addWeakMessageListener(name, this)
|
||||
: Services.cpmm.addMessageListener(name, this);
|
||||
aMsg.weakRef ? cpmm.addWeakMessageListener(name, this)
|
||||
: cpmm.addMessageListener(name, this);
|
||||
this._listeners[name] = {
|
||||
weakRef: !!aMsg.weakRef,
|
||||
count: 1
|
||||
|
@ -116,8 +120,8 @@ DOMRequestIpcHelper.prototype = {
|
|||
// be waiting on a message.
|
||||
if (!--this._listeners[aName].count) {
|
||||
this._listeners[aName].weakRef ?
|
||||
Services.cpmm.removeWeakMessageListener(aName, this)
|
||||
: Services.cpmm.removeMessageListener(aName, this);
|
||||
cpmm.removeWeakMessageListener(aName, this)
|
||||
: cpmm.removeMessageListener(aName, this);
|
||||
delete this._listeners[aName];
|
||||
}
|
||||
});
|
||||
|
@ -177,9 +181,8 @@ DOMRequestIpcHelper.prototype = {
|
|||
|
||||
if (this._listeners) {
|
||||
Object.keys(this._listeners).forEach((aName) => {
|
||||
this._listeners[aName].weakRef ?
|
||||
Services.cpmm.removeWeakMessageListener(aName, this)
|
||||
: Services.cpmm.removeMessageListener(aName, this);
|
||||
this._listeners[aName].weakRef ? cpmm.removeWeakMessageListener(aName, this)
|
||||
: cpmm.removeMessageListener(aName, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/MessageListenerManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
MessageListenerManager::MessageListenerManager(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
ipc::MessageManagerFlags aFlags)
|
||||
: nsFrameMessageManager(aCallback, aFlags),
|
||||
mParentManager(aParentManager)
|
||||
{
|
||||
}
|
||||
|
||||
MessageListenerManager::~MessageListenerManager()
|
||||
{
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MessageListenerManager)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsFrameMessageManager)
|
||||
NS_IMPL_ADDREF_INHERITED(MessageListenerManager, nsFrameMessageManager)
|
||||
NS_IMPL_RELEASE_INHERITED(MessageListenerManager, nsFrameMessageManager)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MessageListenerManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
void
|
||||
MessageListenerManager::ClearParentManager(bool aRemove)
|
||||
{
|
||||
if (aRemove && mParentManager) {
|
||||
mParentManager->RemoveChildManager(this);
|
||||
}
|
||||
mParentManager = nullptr;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,53 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MessageListenerManager_h
|
||||
#define mozilla_dom_MessageListenerManager_h
|
||||
|
||||
#include "nsCycleCollectionNoteChild.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MessageListenerManager : public nsFrameMessageManager,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
|
||||
nsISupports* GetParentObject()
|
||||
{
|
||||
return ToSupports(mParentManager.get());
|
||||
}
|
||||
|
||||
virtual nsFrameMessageManager* GetParentManager() override
|
||||
{
|
||||
return mParentManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* If aRemove is true then RemoveChildManager(this) will be called on the parent manager
|
||||
* first.
|
||||
*/
|
||||
virtual void ClearParentManager(bool aRemove) override;
|
||||
|
||||
protected:
|
||||
MessageListenerManager(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags);
|
||||
virtual ~MessageListenerManager();
|
||||
|
||||
RefPtr<nsFrameMessageManager> mParentManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MessageListenerManager_h
|
|
@ -1,181 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MessageManagerGlobal_h
|
||||
#define mozilla_dom_MessageManagerGlobal_h
|
||||
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* Base class for implementing the WebIDL MessageManagerGlobal class.
|
||||
*/
|
||||
class MessageManagerGlobal
|
||||
{
|
||||
public:
|
||||
// MessageListenerManager
|
||||
void AddMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
bool aListenWhenClosed,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->AddMessageListener(aMessageName, aListener,
|
||||
aListenWhenClosed, aError);
|
||||
}
|
||||
void RemoveMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->RemoveMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
void AddWeakMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->AddWeakMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
void RemoveWeakMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->RemoveWeakMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
|
||||
// MessageSender
|
||||
void SendAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JS::Handle<JS::Value> aTransfers,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendAsyncMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aTransfers, aError);
|
||||
}
|
||||
already_AddRefed<nsIMessageSender> GetProcessMessageManager(mozilla::ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
return mMessageManager->GetProcessMessageManager(aError);
|
||||
}
|
||||
|
||||
void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->GetRemoteType(aRemoteType, aError);
|
||||
}
|
||||
|
||||
// SyncMessageSender
|
||||
void SendSyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendSyncMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aResult, aError);
|
||||
}
|
||||
void SendRpcMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendRpcMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aResult, aError);
|
||||
}
|
||||
|
||||
// MessageManagerGlobal
|
||||
void Dump(const nsAString& aStr, ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Dump(aStr);
|
||||
}
|
||||
void PrivateNoteIntentionalCrash(ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->PrivateNoteIntentionalCrash();
|
||||
}
|
||||
void Atob(const nsAString& aAsciiString, nsAString& aBase64Data,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Atob(aAsciiString, aBase64Data);
|
||||
}
|
||||
void Btoa(const nsAString& aBase64Data, nsAString& aAsciiString,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Btoa(aBase64Data, aAsciiString);
|
||||
}
|
||||
|
||||
bool MarkForCC()
|
||||
{
|
||||
return mMessageManager && mMessageManager->MarkForCC();
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit MessageManagerGlobal(nsFrameMessageManager* aMessageManager)
|
||||
: mMessageManager(aMessageManager)
|
||||
{}
|
||||
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MessageManagerGlobal_h
|
|
@ -1,33 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/MessageSender.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
void
|
||||
MessageSender::InitWithCallback(ipc::MessageManagerCallback* aCallback)
|
||||
{
|
||||
if (mCallback) {
|
||||
// Initialization should only happen once.
|
||||
return;
|
||||
}
|
||||
|
||||
SetCallback(aCallback);
|
||||
|
||||
// First load parent scripts by adding this to parent manager.
|
||||
if (mParentManager) {
|
||||
mParentManager->AddChildManager(this);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mPendingScripts.Length(); ++i) {
|
||||
LoadFrameScript(mPendingScripts[i], false, mPendingScriptsGlobalStates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,31 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MessageSender_h
|
||||
#define mozilla_dom_MessageSender_h
|
||||
|
||||
#include "mozilla/dom/MessageListenerManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MessageSender : public MessageListenerManager
|
||||
{
|
||||
public:
|
||||
void InitWithCallback(ipc::MessageManagerCallback* aCallback);
|
||||
|
||||
protected:
|
||||
MessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageListenerManager(aCallback, aParentManager, aFlags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MessageSender_h
|
|
@ -7,16 +7,17 @@
|
|||
#include "ProcessGlobal.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/ResolveSystemBinding.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
ProcessGlobal::ProcessGlobal(nsFrameMessageManager* aMessageManager)
|
||||
: MessageManagerGlobal(aMessageManager),
|
||||
mInitialized(false)
|
||||
: mInitialized(false),
|
||||
mMessageManager(aMessageManager)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
|
@ -26,36 +27,6 @@ ProcessGlobal::~ProcessGlobal()
|
|||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessGlobal::DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc)
|
||||
{
|
||||
bool found;
|
||||
if (!SystemGlobalResolve(aCx, aObj, aId, &found)) {
|
||||
return false;
|
||||
}
|
||||
if (found) {
|
||||
FillPropertyDescriptor(aDesc, aObj, JS::UndefinedValue(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
ProcessGlobal::MayResolve(jsid aId)
|
||||
{
|
||||
return MayResolveAsSystemBindingName(aId);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessGlobal::GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, ErrorResult& aRv)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
GetSystemBindingNames(aCx, thisObj, aNames, aEnumerableOnly, aRv);
|
||||
}
|
||||
|
||||
ProcessGlobal*
|
||||
ProcessGlobal::Get()
|
||||
{
|
||||
|
@ -72,7 +43,7 @@ NS_IMETHODIMP_(bool)
|
|||
ProcessGlobal::MarkForCC()
|
||||
{
|
||||
MarkScopesForCC();
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ProcessGlobal)
|
||||
|
@ -104,6 +75,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ProcessGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentProcessMessageManager)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ProcessGlobal)
|
||||
|
@ -117,30 +89,15 @@ ProcessGlobal::Init()
|
|||
}
|
||||
mInitialized = true;
|
||||
|
||||
return InitChildGlobalInternal(NS_LITERAL_CSTRING("processChildGlobal"));
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentProcessMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mPrincipal),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIContentProcessMessageManager*, this);
|
||||
return InitChildGlobalInternal(scopeSupports, NS_LITERAL_CSTRING("processChildGlobal"));
|
||||
}
|
||||
|
||||
void
|
||||
ProcessGlobal::LoadScript(const nsAString& aURL)
|
||||
{
|
||||
Init();
|
||||
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());
|
||||
LoadScriptInternal(global, aURL, false);
|
||||
LoadScriptInternal(aURL, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define mozilla_dom_ProcessGlobal_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/MessageManagerGlobal.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -26,26 +25,18 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
class ProcessGlobal :
|
||||
public nsIContentProcessMessageManager,
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIContentProcessMessageManager,
|
||||
public nsIGlobalObject,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsSupportsWeakReference,
|
||||
public ipc::MessageManagerCallback,
|
||||
public MessageManagerGlobal,
|
||||
public mozilla::dom::ipc::MessageManagerCallback,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
explicit ProcessGlobal(nsFrameMessageManager* aMessageManager);
|
||||
|
||||
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc);
|
||||
static bool MayResolve(jsid aId);
|
||||
void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, ErrorResult& aRv);
|
||||
|
||||
using ipc::MessageManagerCallback::GetProcessMessageManager;
|
||||
using mozilla::dom::ipc::MessageManagerCallback::GetProcessMessageManager;
|
||||
|
||||
bool Init();
|
||||
|
||||
|
@ -54,41 +45,6 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ProcessGlobal, nsIContentProcessMessageManager)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override;
|
||||
|
||||
using MessageManagerGlobal::AddMessageListener;
|
||||
using MessageManagerGlobal::RemoveMessageListener;
|
||||
using MessageManagerGlobal::AddWeakMessageListener;
|
||||
using MessageManagerGlobal::RemoveWeakMessageListener;
|
||||
using MessageManagerGlobal::SendAsyncMessage;
|
||||
using MessageManagerGlobal::GetProcessMessageManager;
|
||||
using MessageManagerGlobal::GetRemoteType;
|
||||
using MessageManagerGlobal::SendSyncMessage;
|
||||
using MessageManagerGlobal::SendRpcMessage;
|
||||
using MessageManagerGlobal::Dump;
|
||||
using MessageManagerGlobal::PrivateNoteIntentionalCrash;
|
||||
using MessageManagerGlobal::Atob;
|
||||
using MessageManagerGlobal::Btoa;
|
||||
|
||||
// ContentProcessMessageManager
|
||||
void GetInitialProcessData(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aInitialProcessData,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->GetInitialProcessData(aCx, aInitialProcessData, aError);
|
||||
}
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager)
|
||||
|
@ -99,10 +55,15 @@ public:
|
|||
|
||||
virtual JSObject* GetGlobalJSObject() override
|
||||
{
|
||||
return GetWrapper();
|
||||
return mGlobal;
|
||||
}
|
||||
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("ProcessGlobal doesn't use DOM bindings!");
|
||||
}
|
||||
|
||||
void SetInitialProcessData(JS::HandleValue aInitialData);
|
||||
|
||||
protected:
|
||||
|
@ -110,6 +71,7 @@ protected:
|
|||
|
||||
private:
|
||||
bool mInitialized;
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_SyncMessageSender_h
|
||||
#define mozilla_dom_SyncMessageSender_h
|
||||
|
||||
#include "mozilla/dom/MessageSender.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class SyncMessageSender : public MessageSender
|
||||
{
|
||||
protected:
|
||||
SyncMessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageSender(aCallback, nullptr, aFlags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_SyncMessageSender_h
|
|
@ -18,7 +18,6 @@
|
|||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPresContext.h"
|
||||
|
||||
using mozilla::dom::KeyboardEvent;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "mozilla/dom/TimeoutManager.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIEventTarget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
class nsIEventTarget;
|
||||
class nsITimeoutHandler;
|
||||
class nsITimer;
|
||||
class nsGlobalWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -156,13 +156,9 @@ EXPORTS.mozilla.dom += [
|
|||
'BodyUtil.h',
|
||||
'BorrowedAttrInfo.h',
|
||||
'ChildIterator.h',
|
||||
'ChildProcessMessageManager.h',
|
||||
'ChromeMessageBroadcaster.h',
|
||||
'ChromeMessageSender.h',
|
||||
'ChromeNodeList.h',
|
||||
'ChromeUtils.h',
|
||||
'Comment.h',
|
||||
'ContentFrameMessageManager.h',
|
||||
'CustomElementRegistry.h',
|
||||
'DirectionalityUtils.h',
|
||||
'DispatcherTrait.h',
|
||||
|
@ -199,9 +195,6 @@ EXPORTS.mozilla.dom += [
|
|||
'IntlUtils.h',
|
||||
'Link.h',
|
||||
'Location.h',
|
||||
'MessageListenerManager.h',
|
||||
'MessageManagerGlobal.h',
|
||||
'MessageSender.h',
|
||||
'NameSpaceConstants.h',
|
||||
'Navigator.h',
|
||||
'NodeInfo.h',
|
||||
|
@ -219,7 +212,6 @@ EXPORTS.mozilla.dom += [
|
|||
'StructuredCloneTags.h',
|
||||
'StyleSheetList.h',
|
||||
'SubtleCrypto.h',
|
||||
'SyncMessageSender.h',
|
||||
'TabGroup.h',
|
||||
'Text.h',
|
||||
'Timeout.h',
|
||||
|
@ -242,8 +234,6 @@ UNIFIED_SOURCES += [
|
|||
'BodyUtil.cpp',
|
||||
'BorrowedAttrInfo.cpp',
|
||||
'ChildIterator.cpp',
|
||||
'ChromeMessageBroadcaster.cpp',
|
||||
'ChromeMessageSender.cpp',
|
||||
'ChromeNodeList.cpp',
|
||||
'ChromeUtils.cpp',
|
||||
'Comment.cpp',
|
||||
|
@ -279,8 +269,6 @@ UNIFIED_SOURCES += [
|
|||
'IntlUtils.cpp',
|
||||
'Link.cpp',
|
||||
'Location.cpp',
|
||||
'MessageListenerManager.cpp',
|
||||
'MessageSender.cpp',
|
||||
'Navigator.cpp',
|
||||
'NodeInfo.cpp',
|
||||
'NodeIterator.cpp',
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "nsISHistory.h"
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsISHContainer.h"
|
||||
#include "nsITabChild.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIXULWindow.h"
|
||||
|
@ -32,7 +33,6 @@
|
|||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ProcessGlobal.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/TimeoutManager.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsObserverService.h"
|
||||
|
@ -311,9 +311,11 @@ MarkWindowList(nsISimpleEnumerator* aWindowList, bool aCleanupJS,
|
|||
|
||||
MarkDocShell(rootDocShell, aCleanupJS, aPrepareForCC);
|
||||
|
||||
RefPtr<TabChild> tabChild = TabChild::GetFrom(rootDocShell);
|
||||
nsCOMPtr<nsITabChild> tabChild =
|
||||
rootDocShell ? rootDocShell->GetTabChild() : nullptr;
|
||||
if (tabChild) {
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm = tabChild->GetMessageManager();
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm;
|
||||
tabChild->GetMessageManager(getter_AddRefs(mm));
|
||||
if (mm) {
|
||||
// MarkForCC ends up calling UnmarkGray on message listeners, which
|
||||
// TraceBlackJS can't do yet.
|
||||
|
@ -531,7 +533,7 @@ mozilla::dom::TraceBlackJS(JSTracer* aTrc, bool aIsShutdownGC)
|
|||
if (ds) {
|
||||
nsCOMPtr<nsITabChild> tabChild = ds->GetTabChild();
|
||||
if (tabChild) {
|
||||
nsCOMPtr<nsISupports> mm;
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm;
|
||||
tabChild->GetMessageManager(getter_AddRefs(mm));
|
||||
nsCOMPtr<EventTarget> et = do_QueryInterface(mm);
|
||||
if (et) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "nsElementTable.h"
|
||||
|
||||
using mozilla::DebugOnly;
|
||||
using mozilla::Move;
|
||||
using mozilla::RawRangeBoundary;
|
||||
|
||||
// couple of utility static functs
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
// includes needed for the prototype chain interfaces
|
||||
|
||||
#include "nsIEventListenerService.h"
|
||||
#include "nsIMessageManager.h"
|
||||
|
||||
#include "mozilla/dom/TouchEvent.h"
|
||||
|
||||
|
@ -130,6 +131,9 @@ using namespace mozilla::dom;
|
|||
#define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, false, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, true)
|
||||
|
||||
|
@ -164,6 +168,22 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
|
||||
// Misc Core related classes
|
||||
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager,
|
||||
nsMessageManagerSH<nsEventTargetSH>,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
XPC_SCRIPTABLE_WANT_ENUMERATE |
|
||||
XPC_SCRIPTABLE_IS_GLOBAL_OBJECT)
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentProcessMessageManager,
|
||||
nsMessageManagerSH<nsDOMGenericSH>,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
XPC_SCRIPTABLE_WANT_ENUMERATE |
|
||||
XPC_SCRIPTABLE_IS_GLOBAL_OBJECT)
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageBroadcaster, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
|
||||
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULControlElement, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULLabeledControlElement, nsDOMGenericSH,
|
||||
|
@ -405,6 +425,36 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIContentFrameMessageManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentProcessMessageManager, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIContentProcessMessageManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeMessageBroadcaster, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIProcessScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIGlobalProcessScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageBroadcaster)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeMessageSender, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIProcessScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(XULControlElement, nsIDOMXULControlElement)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULControlElement)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
@ -1872,3 +1922,41 @@ nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval);
|
||||
}
|
||||
|
||||
// nsContentFrameMessageManagerSH
|
||||
|
||||
template<typename Super>
|
||||
NS_IMETHODIMP
|
||||
nsMessageManagerSH<Super>::Resolve(nsIXPConnectWrappedNative* wrapper,
|
||||
JSContext* cx, JSObject* obj_,
|
||||
jsid id_, bool* resolvedp,
|
||||
bool* _retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, obj_);
|
||||
JS::Rooted<jsid> id(cx, id_);
|
||||
|
||||
*_retval = SystemGlobalResolve(cx, obj, id, resolvedp);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
if (*resolvedp) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return Super::Resolve(wrapper, cx, obj, id, resolvedp, _retval);
|
||||
}
|
||||
|
||||
template<typename Super>
|
||||
NS_IMETHODIMP
|
||||
nsMessageManagerSH<Super>::Enumerate(nsIXPConnectWrappedNative* wrapper,
|
||||
JSContext* cx, JSObject* obj_,
|
||||
bool* _retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, obj_);
|
||||
|
||||
*_retval = SystemGlobalEnumerate(cx, obj);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
// Don't call up to our superclass, since neither nsDOMGenericSH nor
|
||||
// nsEventTargetSH have WANT_ENUMERATE.
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -212,4 +212,29 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
class nsMessageManagerSH : public Super
|
||||
{
|
||||
protected:
|
||||
explicit nsMessageManagerSH(nsDOMClassInfoData* aData)
|
||||
: Super(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsMessageManagerSH()
|
||||
{
|
||||
}
|
||||
public:
|
||||
NS_IMETHOD Resolve(nsIXPConnectWrappedNative* wrapper, JSContext* cx,
|
||||
JSObject* obj_, jsid id_, bool* resolvedp,
|
||||
bool* _retval) override;
|
||||
NS_IMETHOD Enumerate(nsIXPConnectWrappedNative* wrapper, JSContext* cx,
|
||||
JSObject* obj_, bool* _retval) override;
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsMessageManagerSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* nsDOMClassInfo_h___ */
|
||||
|
|
|
@ -19,6 +19,11 @@ enum nsDOMClassInfoID
|
|||
eDOMClassInfo_DOMPrototype_id,
|
||||
eDOMClassInfo_DOMConstructor_id,
|
||||
|
||||
eDOMClassInfo_ContentFrameMessageManager_id,
|
||||
eDOMClassInfo_ContentProcessMessageManager_id,
|
||||
eDOMClassInfo_ChromeMessageBroadcaster_id,
|
||||
eDOMClassInfo_ChromeMessageSender_id,
|
||||
|
||||
eDOMClassInfo_XULControlElement_id,
|
||||
eDOMClassInfo_XULLabeledControlElement_id,
|
||||
eDOMClassInfo_XULButtonElement_id,
|
||||
|
|
|
@ -79,7 +79,6 @@
|
|||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/FrameLoaderBinding.h"
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
|
@ -1643,12 +1642,14 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
|||
RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
|
||||
// Swap pointers in child message managers.
|
||||
if (mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* tabChild = mChildMessageManager;
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
tabChild->SetOwner(otherContent);
|
||||
tabChild->SetChromeMessageManager(otherMessageManager);
|
||||
}
|
||||
if (aOther->mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* otherTabChild = aOther->mChildMessageManager;
|
||||
nsInProcessTabChildGlobal* otherTabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(aOther->mChildMessageManager.get());
|
||||
otherTabChild->SetOwner(ourContent);
|
||||
otherTabChild->SetChromeMessageManager(ourMessageManager);
|
||||
}
|
||||
|
@ -1883,7 +1884,7 @@ nsFrameLoader::DestroyDocShell()
|
|||
|
||||
// Fire the "unload" event if we're in-process.
|
||||
if (mChildMessageManager) {
|
||||
mChildMessageManager->FireUnloadEvent();
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->FireUnloadEvent();
|
||||
}
|
||||
|
||||
// Destroy the docshell.
|
||||
|
@ -1895,7 +1896,7 @@ nsFrameLoader::DestroyDocShell()
|
|||
|
||||
if (mChildMessageManager) {
|
||||
// Stop handling events in the in-process frame script.
|
||||
mChildMessageManager->DisconnectEventListeners();
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->DisconnectEventListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1930,7 +1931,7 @@ nsFrameLoader::DestroyComplete()
|
|||
}
|
||||
|
||||
if (mChildMessageManager) {
|
||||
mChildMessageManager->Disconnect();
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->Disconnect();
|
||||
}
|
||||
|
||||
mMessageManager = nullptr;
|
||||
|
@ -2986,11 +2987,12 @@ public:
|
|||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
nsInProcessTabChildGlobal* tabChild = mFrameLoader->mChildMessageManager;
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mFrameLoader->mChildMessageManager.get());
|
||||
// Since bug 1126089, messages can arrive even when the docShell is destroyed.
|
||||
// Here we make sure that those messages are not delivered.
|
||||
if (tabChild && tabChild->GetInnerManager() && mFrameLoader->GetExistingDocShell()) {
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), tabChild->GetWrapper());
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), tabChild->GetGlobal());
|
||||
ReceiveMessage(static_cast<EventTarget*>(tabChild), mFrameLoader,
|
||||
tabChild->GetInnerManager());
|
||||
}
|
||||
|
@ -3104,8 +3106,9 @@ nsFrameLoader::EnsureMessageManager()
|
|||
parentManager = do_GetService("@mozilla.org/globalmessagemanager;1");
|
||||
}
|
||||
|
||||
mMessageManager = new ChromeMessageSender(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()));
|
||||
mMessageManager = new nsFrameMessageManager(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()),
|
||||
MM_CHROME);
|
||||
if (!IsRemoteFrame()) {
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -3138,7 +3141,7 @@ nsFrameLoader::ReallyLoadFrameScripts()
|
|||
EventTarget*
|
||||
nsFrameLoader::GetTabChildGlobalAsEventTarget()
|
||||
{
|
||||
return mChildMessageManager.get();
|
||||
return static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
class nsIURI;
|
||||
class nsSubDocumentFrame;
|
||||
class nsView;
|
||||
class nsInProcessTabChildGlobal;
|
||||
class nsIInProcessContentFrameMessageManager;
|
||||
class AutoResetInShow;
|
||||
class AutoResetInFrameSwap;
|
||||
class nsITabParent;
|
||||
|
@ -44,7 +44,6 @@ namespace mozilla {
|
|||
class OriginAttributes;
|
||||
|
||||
namespace dom {
|
||||
class ChromeMessageSender;
|
||||
class ContentParent;
|
||||
class PBrowserParent;
|
||||
class Promise;
|
||||
|
@ -269,7 +268,7 @@ public:
|
|||
*/
|
||||
RenderFrameParent* GetCurrentRenderFrame() const;
|
||||
|
||||
mozilla::dom::ChromeMessageSender* GetFrameMessageManager() { return mMessageManager; }
|
||||
nsFrameMessageManager* GetFrameMessageManager() { return mMessageManager; }
|
||||
|
||||
mozilla::dom::Element* GetOwnerContent() { return mOwnerContent; }
|
||||
bool ShouldClipSubdocument() { return mClipSubdocument; }
|
||||
|
@ -320,8 +319,8 @@ public:
|
|||
virtual nsIMessageSender* GetProcessMessageManager() const override;
|
||||
|
||||
// public because a callback needs these.
|
||||
RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager;
|
||||
RefPtr<nsInProcessTabChildGlobal> mChildMessageManager;
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -28,8 +28,6 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "mozilla/dom/CallbackObject.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
||||
#include "mozilla/jsipc/CpowHolder.h"
|
||||
|
@ -41,13 +39,8 @@ namespace dom {
|
|||
|
||||
class nsIContentParent;
|
||||
class nsIContentChild;
|
||||
class ChildProcessMessageManager;
|
||||
class ChromeMessageSender;
|
||||
class ClonedMessageData;
|
||||
class MessageListener;
|
||||
class MessageListenerManager;
|
||||
class MessageManagerReporter;
|
||||
template<typename T> class Optional;
|
||||
|
||||
namespace ipc {
|
||||
|
||||
|
@ -55,15 +48,14 @@ namespace ipc {
|
|||
// of 1 ms actually captures from 500us and above.
|
||||
static const uint32_t kMinTelemetrySyncMessageManagerLatencyMs = 1;
|
||||
|
||||
enum class MessageManagerFlags {
|
||||
MM_NONE = 0,
|
||||
enum MessageManagerFlags {
|
||||
MM_CHILD = 0,
|
||||
MM_CHROME = 1,
|
||||
MM_GLOBAL = 2,
|
||||
MM_PROCESSMANAGER = 4,
|
||||
MM_BROADCASTER = 8,
|
||||
MM_OWNSCALLBACK = 16
|
||||
};
|
||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(MessageManagerFlags);
|
||||
|
||||
class MessageManagerCallback
|
||||
{
|
||||
|
@ -126,10 +118,6 @@ void UnpackClonedMessageDataForChild(const ClonedMessageData& aClonedData,
|
|||
StructuredCloneData& aData);
|
||||
|
||||
} // namespace ipc
|
||||
|
||||
typedef CallbackObjectHolder<mozilla::dom::MessageListener,
|
||||
nsIMessageListener> MessageListenerHolder;
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -140,22 +128,12 @@ struct nsMessageListenerInfo
|
|||
return &aOther == this;
|
||||
}
|
||||
|
||||
// If mWeakListener is null then mStrongListener holds either a MessageListener or an
|
||||
// nsIMessageListener. If mWeakListener is non-null then mStrongListener contains null.
|
||||
mozilla::dom::MessageListenerHolder mStrongListener;
|
||||
// Exactly one of mStrongListener and mWeakListener must be non-null.
|
||||
nsCOMPtr<nsIMessageListener> mStrongListener;
|
||||
nsWeakPtr mWeakListener;
|
||||
bool mListenWhenClosed;
|
||||
};
|
||||
|
||||
inline void
|
||||
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
||||
nsMessageListenerInfo& aField,
|
||||
const char* aName,
|
||||
uint32_t aFlags = 0)
|
||||
{
|
||||
ImplCycleCollectionTraverse(aCallback, aField.mStrongListener, aName, aFlags);
|
||||
ImplCycleCollectionTraverse(aCallback, aField.mWeakListener, aName, aFlags);
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS SameProcessCpowHolder : public mozilla::jsipc::CpowHolder
|
||||
{
|
||||
|
@ -172,86 +150,25 @@ private:
|
|||
JS::Rooted<JSObject*> mObj;
|
||||
};
|
||||
|
||||
class nsFrameMessageManager : public nsIContentFrameMessageManager,
|
||||
public nsIMessageBroadcaster,
|
||||
public nsIFrameScriptLoader,
|
||||
public nsIGlobalProcessScriptLoader
|
||||
class nsFrameMessageManager final : public nsIContentFrameMessageManager,
|
||||
public nsIMessageBroadcaster,
|
||||
public nsIFrameScriptLoader,
|
||||
public nsIGlobalProcessScriptLoader
|
||||
{
|
||||
friend class mozilla::dom::MessageManagerReporter;
|
||||
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
|
||||
|
||||
protected:
|
||||
typedef mozilla::dom::ipc::MessageManagerFlags MessageManagerFlags;
|
||||
|
||||
public:
|
||||
nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback,
|
||||
MessageManagerFlags aFlags);
|
||||
nsFrameMessageManager* aParentManager,
|
||||
/* mozilla::dom::ipc::MessageManagerFlags */ uint32_t aFlags);
|
||||
|
||||
virtual ~nsFrameMessageManager();
|
||||
private:
|
||||
~nsFrameMessageManager();
|
||||
|
||||
public:
|
||||
explicit nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback)
|
||||
: nsFrameMessageManager(aCallback, MessageManagerFlags::MM_NONE)
|
||||
{}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFrameMessageManager,
|
||||
nsIContentFrameMessageManager)
|
||||
|
||||
// MessageListenerManager
|
||||
void AddMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
bool aListenWhenClosed,
|
||||
mozilla::ErrorResult& aError);
|
||||
void RemoveMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
mozilla::ErrorResult& aError);
|
||||
void AddWeakMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
mozilla::ErrorResult& aError);
|
||||
void RemoveWeakMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
// MessageSender
|
||||
void SendAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JS::Handle<JS::Value> aTransfers,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, aPrincipal, aTransfers,
|
||||
aError);
|
||||
}
|
||||
already_AddRefed<nsIMessageSender>
|
||||
GetProcessMessageManager(mozilla::ErrorResult& aError);
|
||||
void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError) const;
|
||||
|
||||
// SyncMessageSender
|
||||
void SendSyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
SendMessage(aCx, aMessageName, aObj, aObjects, aPrincipal, true, aResult, aError);
|
||||
}
|
||||
void SendRpcMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
SendMessage(aCx, aMessageName, aObj, aObjects, aPrincipal, false, aResult, aError);
|
||||
}
|
||||
|
||||
// GlobalProcessScriptLoader
|
||||
void GetInitialProcessData(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aInitialProcessData,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
NS_DECL_NSIMESSAGELISTENERMANAGER
|
||||
NS_DECL_NSIMESSAGESENDER
|
||||
NS_DECL_NSIMESSAGEBROADCASTER
|
||||
|
@ -262,7 +179,7 @@ public:
|
|||
NS_DECL_NSIPROCESSSCRIPTLOADER
|
||||
NS_DECL_NSIGLOBALPROCESSSCRIPTLOADER
|
||||
|
||||
static mozilla::dom::ChromeMessageSender*
|
||||
static nsFrameMessageManager*
|
||||
NewProcessMessageManager(bool aIsRemote);
|
||||
|
||||
nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
|
||||
|
@ -271,11 +188,15 @@ public:
|
|||
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
|
||||
nsTArray<StructuredCloneData>* aRetVal);
|
||||
|
||||
void AddChildManager(mozilla::dom::MessageListenerManager* aManager);
|
||||
void RemoveChildManager(mozilla::dom::MessageListenerManager* aManager);
|
||||
void AddChildManager(nsFrameMessageManager* aManager);
|
||||
void RemoveChildManager(nsFrameMessageManager* aManager)
|
||||
{
|
||||
mChildManagers.RemoveObject(aManager);
|
||||
}
|
||||
void Disconnect(bool aRemoveFromParent = true);
|
||||
void Close();
|
||||
|
||||
void InitWithCallback(mozilla::dom::ipc::MessageManagerCallback* aCallback);
|
||||
void SetCallback(mozilla::dom::ipc::MessageManagerCallback* aCallback);
|
||||
|
||||
mozilla::dom::ipc::MessageManagerCallback* GetCallback()
|
||||
|
@ -296,6 +217,14 @@ public:
|
|||
StructuredCloneData& aData,
|
||||
JS::Handle<JSObject*> aCpows,
|
||||
nsIPrincipal* aPrincipal);
|
||||
void RemoveFromParent();
|
||||
nsFrameMessageManager* GetParentManager() { return mParentManager; }
|
||||
void SetParentManager(nsFrameMessageManager* aParent)
|
||||
{
|
||||
NS_ASSERTION(!mParentManager, "We have parent manager already!");
|
||||
NS_ASSERTION(mChrome, "Should not set parent manager!");
|
||||
mParentManager = aParent;
|
||||
}
|
||||
bool IsGlobal() { return mGlobal; }
|
||||
bool IsBroadcaster() { return mIsBroadcaster; }
|
||||
|
||||
|
@ -303,11 +232,11 @@ public:
|
|||
{
|
||||
return sParentProcessManager;
|
||||
}
|
||||
static mozilla::dom::ChildProcessMessageManager* GetChildProcessManager()
|
||||
static nsFrameMessageManager* GetChildProcessManager()
|
||||
{
|
||||
return sChildProcessManager;
|
||||
}
|
||||
static void SetChildProcessManager(mozilla::dom::ChildProcessMessageManager* aManager)
|
||||
static void SetChildProcessManager(nsFrameMessageManager* aManager)
|
||||
{
|
||||
sChildProcessManager = aManager;
|
||||
}
|
||||
|
@ -316,24 +245,7 @@ public:
|
|||
|
||||
void LoadPendingScripts();
|
||||
|
||||
protected:
|
||||
friend class MMListenerRemover;
|
||||
|
||||
virtual nsFrameMessageManager* GetParentManager()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
virtual void ClearParentManager(bool aRemove)
|
||||
{
|
||||
}
|
||||
|
||||
void DispatchAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JS::Handle<JS::Value> aTransfers,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
private:
|
||||
nsresult SendMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aJSON,
|
||||
JS::Handle<JS::Value> aObjects,
|
||||
|
@ -342,14 +254,6 @@ protected:
|
|||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
bool aIsSync);
|
||||
void SendMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj, JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal, bool aIsSync, nsTArray<JS::Value>& aResult,
|
||||
mozilla::ErrorResult& aError);
|
||||
void SendMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
StructuredCloneData& aData, JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal, bool aIsSync,
|
||||
nsTArray<JS::Value>& aResult, mozilla::ErrorResult& aError);
|
||||
|
||||
nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
|
||||
bool aTargetClosed, const nsAString& aMessage,
|
||||
|
@ -357,28 +261,19 @@ protected:
|
|||
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
|
||||
nsTArray<StructuredCloneData>* aRetVal);
|
||||
|
||||
void LoadScript(const nsAString& aURL, bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope, mozilla::ErrorResult& aError);
|
||||
void RemoveDelayedScript(const nsAString& aURL);
|
||||
nsresult GetDelayedScripts(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aList);
|
||||
void GetDelayedScripts(JSContext* aCx, nsTArray<nsTArray<JS::Value>>& aList,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
enum ProcessCheckerType {
|
||||
PROCESS_CHECKER_PERMISSION,
|
||||
PROCESS_CHECKER_MANIFEST_URL,
|
||||
ASSERT_APP_HAS_PERMISSION
|
||||
};
|
||||
bool AssertProcessInternal(ProcessCheckerType aType,
|
||||
const nsAString& aCapability,
|
||||
mozilla::ErrorResult& aError);
|
||||
NS_IMETHOD LoadScript(const nsAString& aURL,
|
||||
bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope);
|
||||
NS_IMETHOD RemoveDelayedScript(const nsAString& aURL);
|
||||
NS_IMETHOD GetDelayedScripts(JSContext* aCx, JS::MutableHandle<JS::Value> aList);
|
||||
|
||||
protected:
|
||||
friend class MMListenerRemover;
|
||||
// We keep the message listeners as arrays in a hastable indexed by the
|
||||
// message name. That gives us fast lookups in ReceiveMessage().
|
||||
nsClassHashtable<nsStringHashKey,
|
||||
nsAutoTObserverArray<nsMessageListenerInfo, 1>> mListeners;
|
||||
nsTArray<RefPtr<mozilla::dom::MessageListenerManager>> mChildManagers;
|
||||
nsCOMArray<nsIContentFrameMessageManager> mChildManagers;
|
||||
bool mChrome; // true if we're in the chrome process
|
||||
bool mGlobal; // true if we're the global frame message manager
|
||||
bool mIsProcessManager; // true if the message manager belongs to the process realm
|
||||
|
@ -389,6 +284,7 @@ protected:
|
|||
bool mDisconnected;
|
||||
mozilla::dom::ipc::MessageManagerCallback* mCallback;
|
||||
nsAutoPtr<mozilla::dom::ipc::MessageManagerCallback> mOwnedCallback;
|
||||
RefPtr<nsFrameMessageManager> mParentManager;
|
||||
nsTArray<nsString> mPendingScripts;
|
||||
nsTArray<bool> mPendingScriptsGlobalStates;
|
||||
JS::Heap<JS::Value> mInitialProcessData;
|
||||
|
@ -400,13 +296,15 @@ public:
|
|||
static nsFrameMessageManager* sSameProcessParentManager;
|
||||
static nsTArray<nsCOMPtr<nsIRunnable> >* sPendingSameProcessAsyncMessages;
|
||||
private:
|
||||
void AddMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListenerHolder&& aListener,
|
||||
bool aListenWhenClosed);
|
||||
void RemoveMessageListener(const nsAString& aMessageName,
|
||||
const mozilla::dom::MessageListenerHolder& aListener);
|
||||
|
||||
static mozilla::dom::ChildProcessMessageManager* sChildProcessManager;
|
||||
static nsFrameMessageManager* sChildProcessManager;
|
||||
enum ProcessCheckerType {
|
||||
PROCESS_CHECKER_PERMISSION,
|
||||
PROCESS_CHECKER_MANIFEST_URL,
|
||||
ASSERT_APP_HAS_PERMISSION
|
||||
};
|
||||
nsresult AssertProcessInternal(ProcessCheckerType aType,
|
||||
const nsAString& aCapability,
|
||||
bool* aValid);
|
||||
};
|
||||
|
||||
/* A helper class for taking care of many details for async message sending
|
||||
|
@ -476,6 +374,10 @@ class nsMessageManagerScriptExecutor
|
|||
public:
|
||||
static void PurgeCache();
|
||||
static void Shutdown();
|
||||
JSObject* GetGlobal()
|
||||
{
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
void MarkScopesForCC();
|
||||
protected:
|
||||
|
@ -484,20 +386,17 @@ protected:
|
|||
~nsMessageManagerScriptExecutor() { MOZ_COUNT_DTOR(nsMessageManagerScriptExecutor); }
|
||||
|
||||
void DidCreateGlobal();
|
||||
void LoadScriptInternal(JS::Handle<JSObject*> aGlobal, const nsAString& aURL,
|
||||
bool aRunInGlobalScope);
|
||||
void LoadScriptInternal(const nsAString& aURL, bool aRunInGlobalScope);
|
||||
void TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
bool aRunInGlobalScope,
|
||||
bool aShouldCache,
|
||||
JS::MutableHandle<JSScript*> aScriptp);
|
||||
void TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
bool aRunInGlobalScope);
|
||||
bool InitChildGlobalInternal(const nsACString& aID);
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) = 0;
|
||||
bool InitChildGlobalInternal(nsISupports* aScope, const nsACString& aID);
|
||||
void Trace(const TraceCallbacks& aCallbacks, void* aClosure);
|
||||
void Unlink();
|
||||
JS::TenuredHeap<JSObject*> mGlobal;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
AutoTArray<JS::Heap<JSObject*>, 2> mAnonymousGlobalScopes;
|
||||
|
||||
|
|
|
@ -1246,7 +1246,8 @@ nsGlobalWindowInner::CleanUp()
|
|||
if (mCleanMessageManager) {
|
||||
MOZ_ASSERT(mIsChrome, "only chrome should have msg manager cleaned");
|
||||
if (mChromeFields.mMessageManager) {
|
||||
mChromeFields.mMessageManager->Disconnect();
|
||||
static_cast<nsFrameMessageManager*>(
|
||||
mChromeFields.mMessageManager.get())->Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7592,7 +7593,7 @@ nsGlobalWindowInner::GetMessageManager(nsIMessageBroadcaster** aManager)
|
|||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
ChromeMessageBroadcaster*
|
||||
nsIMessageBroadcaster*
|
||||
nsGlobalWindowInner::GetMessageManager(ErrorResult& aError)
|
||||
{
|
||||
MOZ_ASSERT(IsChromeWindow());
|
||||
|
@ -7600,7 +7601,9 @@ nsGlobalWindowInner::GetMessageManager(ErrorResult& aError)
|
|||
nsCOMPtr<nsIMessageBroadcaster> globalMM =
|
||||
do_GetService("@mozilla.org/globalmessagemanager;1");
|
||||
mChromeFields.mMessageManager =
|
||||
new ChromeMessageBroadcaster(static_cast<nsFrameMessageManager*>(globalMM.get()));
|
||||
new nsFrameMessageManager(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(globalMM.get()),
|
||||
MM_CHROME | MM_BROADCASTER);
|
||||
}
|
||||
return mChromeFields.mMessageManager;
|
||||
}
|
||||
|
@ -7615,18 +7618,21 @@ nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
|
|||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
ChromeMessageBroadcaster*
|
||||
nsIMessageBroadcaster*
|
||||
nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
MOZ_ASSERT(IsChromeWindow());
|
||||
|
||||
RefPtr<ChromeMessageBroadcaster> messageManager =
|
||||
nsCOMPtr<nsIMessageBroadcaster> messageManager =
|
||||
mChromeFields.mGroupMessageManagers.LookupForAdd(aGroup).OrInsert(
|
||||
[this, &aError] () {
|
||||
nsFrameMessageManager* parent = GetMessageManager(aError);
|
||||
nsFrameMessageManager* parent =
|
||||
static_cast<nsFrameMessageManager*>(GetMessageManager(aError));
|
||||
|
||||
return new ChromeMessageBroadcaster(parent);
|
||||
return new nsFrameMessageManager(nullptr,
|
||||
parent,
|
||||
MM_CHROME | MM_BROADCASTER);
|
||||
});
|
||||
return messageManager;
|
||||
}
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "prclist.h"
|
||||
#include "mozilla/dom/DOMPrefs.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
|
@ -941,11 +941,9 @@ public:
|
|||
void Restore();
|
||||
void NotifyDefaultButtonLoaded(mozilla::dom::Element& aDefaultButton,
|
||||
mozilla::ErrorResult& aError);
|
||||
mozilla::dom::ChromeMessageBroadcaster*
|
||||
GetMessageManager(mozilla::ErrorResult& aError);
|
||||
mozilla::dom::ChromeMessageBroadcaster*
|
||||
GetGroupMessageManager(const nsAString& aGroup,
|
||||
mozilla::ErrorResult& aError);
|
||||
nsIMessageBroadcaster* GetMessageManager(mozilla::ErrorResult& aError);
|
||||
nsIMessageBroadcaster* GetGroupMessageManager(const nsAString& aGroup,
|
||||
mozilla::ErrorResult& aError);
|
||||
void BeginWindowMove(mozilla::dom::Event& aMouseDownEvent,
|
||||
mozilla::dom::Element* aPanel,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
@ -1273,9 +1271,9 @@ private:
|
|||
{
|
||||
MOZ_RELEASE_ASSERT(IsChromeWindow());
|
||||
for (auto iter = mChromeFields.mGroupMessageManagers.Iter(); !iter.Done(); iter.Next()) {
|
||||
mozilla::dom::ChromeMessageBroadcaster* mm = iter.UserData();
|
||||
nsIMessageBroadcaster* mm = iter.UserData();
|
||||
if (mm) {
|
||||
mm->Disconnect();
|
||||
static_cast<nsFrameMessageManager*>(mm)->Disconnect();
|
||||
}
|
||||
}
|
||||
mChromeFields.mGroupMessageManagers.Clear();
|
||||
|
@ -1475,9 +1473,8 @@ protected:
|
|||
: mGroupMessageManagers(1)
|
||||
{}
|
||||
|
||||
RefPtr<mozilla::dom::ChromeMessageBroadcaster> mMessageManager;
|
||||
nsRefPtrHashtable<nsStringHashKey,
|
||||
mozilla::dom::ChromeMessageBroadcaster> mGroupMessageManagers;
|
||||
nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
|
||||
nsInterfaceHashtable<nsStringHashKey, nsIMessageBroadcaster> mGroupMessageManagers;
|
||||
} mChromeFields;
|
||||
|
||||
// These fields are used by the inner and outer windows to prevent
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "mozilla/FlushType.h"
|
||||
#include "prclist.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
|
|
|
@ -203,7 +203,7 @@ interface nsIMessageListener : nsISupports
|
|||
void receiveMessage();
|
||||
};
|
||||
|
||||
[uuid(b949bfec-bb7d-47bc-b387-ac6a9b655072)]
|
||||
[scriptable, builtinclass, uuid(b949bfec-bb7d-47bc-b387-ac6a9b655072)]
|
||||
interface nsIMessageListenerManager : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -261,7 +261,7 @@ interface nsIMessageListenerManager : nsISupports
|
|||
* messages that are only delivered to its one parent-process message
|
||||
* manager.
|
||||
*/
|
||||
[uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)]
|
||||
[scriptable, builtinclass, uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)]
|
||||
interface nsIMessageSender : nsIMessageListenerManager
|
||||
{
|
||||
/**
|
||||
|
@ -309,7 +309,7 @@ interface nsIMessageSender : nsIMessageListenerManager
|
|||
* manager will broadcast the message to all frame message managers
|
||||
* within its window.
|
||||
*/
|
||||
[uuid(4d7d62ad-4725-4f39-86cf-8fb22bf9c1d8)]
|
||||
[scriptable, builtinclass, uuid(4d7d62ad-4725-4f39-86cf-8fb22bf9c1d8)]
|
||||
interface nsIMessageBroadcaster : nsIMessageListenerManager
|
||||
{
|
||||
/**
|
||||
|
@ -342,7 +342,7 @@ interface nsIMessageBroadcaster : nsIMessageListenerManager
|
|||
void releaseCachedProcesses();
|
||||
};
|
||||
|
||||
[uuid(0e602c9e-1977-422a-a8e4-fe0d4a4f78d0)]
|
||||
[scriptable, builtinclass, uuid(0e602c9e-1977-422a-a8e4-fe0d4a4f78d0)]
|
||||
interface nsISyncMessageSender : nsIMessageSender
|
||||
{
|
||||
/**
|
||||
|
@ -372,7 +372,7 @@ interface nsISyncMessageSender : nsIMessageSender
|
|||
[optional] in nsIPrincipal principal);
|
||||
};
|
||||
|
||||
[uuid(13f3555f-769e-44ea-b607-5239230c3162)]
|
||||
[scriptable, builtinclass, uuid(13f3555f-769e-44ea-b607-5239230c3162)]
|
||||
interface nsIMessageManagerGlobal : nsISyncMessageSender
|
||||
{
|
||||
/**
|
||||
|
@ -393,7 +393,7 @@ interface nsIMessageManagerGlobal : nsISyncMessageSender
|
|||
DOMString btoa(in DOMString aBase64Data);
|
||||
};
|
||||
|
||||
[uuid(694e367c-aa25-4446-8499-2c527c4bd838)]
|
||||
[scriptable, builtinclass, uuid(694e367c-aa25-4446-8499-2c527c4bd838)]
|
||||
interface nsIContentFrameMessageManager : nsIMessageManagerGlobal
|
||||
{
|
||||
/**
|
||||
|
@ -420,7 +420,7 @@ interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
|
|||
[notxpcom] void cacheFrameLoader(in nsIFrameLoader aFrameLoader);
|
||||
};
|
||||
|
||||
[uuid(6d12e467-2446-46db-9965-e4e93cb87ca5)]
|
||||
[scriptable, builtinclass, uuid(6d12e467-2446-46db-9965-e4e93cb87ca5)]
|
||||
interface nsIContentProcessMessageManager : nsIMessageManagerGlobal
|
||||
{
|
||||
/**
|
||||
|
@ -431,7 +431,7 @@ interface nsIContentProcessMessageManager : nsIMessageManagerGlobal
|
|||
readonly attribute jsval initialProcessData;
|
||||
};
|
||||
|
||||
[uuid(bf61446b-ba24-4b1d-88c7-4f94724b9ce1)]
|
||||
[scriptable, builtinclass, uuid(bf61446b-ba24-4b1d-88c7-4f94724b9ce1)]
|
||||
interface nsIFrameScriptLoader : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -458,7 +458,7 @@ interface nsIFrameScriptLoader : nsISupports
|
|||
jsval getDelayedFrameScripts();
|
||||
};
|
||||
|
||||
[uuid(7e1e1a20-b24f-11e4-ab27-0800200c9a66)]
|
||||
[scriptable, builtinclass, uuid(7e1e1a20-b24f-11e4-ab27-0800200c9a66)]
|
||||
interface nsIProcessScriptLoader : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -483,7 +483,7 @@ interface nsIProcessScriptLoader : nsISupports
|
|||
jsval getDelayedProcessScripts();
|
||||
};
|
||||
|
||||
[uuid(5b390753-abb3-49b0-ae3b-b803dab58144)]
|
||||
[scriptable, builtinclass, uuid(5b390753-abb3-49b0-ae3b-b803dab58144)]
|
||||
interface nsIGlobalProcessScriptLoader : nsIProcessScriptLoader
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
#include "nsFrameLoader.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsIMozBrowserFrame.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
|
||||
|
@ -90,11 +89,11 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
|
|||
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
|
||||
nsIContent* aOwner,
|
||||
nsFrameMessageManager* aChrome)
|
||||
: ContentFrameMessageManager(aChrome),
|
||||
mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
||||
: mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
||||
mPreventEventsEscaping(false),
|
||||
mOwner(aOwner), mChromeMessageManager(aChrome)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
|
||||
|
@ -120,7 +119,7 @@ NS_IMETHODIMP_(bool)
|
|||
nsInProcessTabChildGlobal::MarkForCC()
|
||||
{
|
||||
MarkScopesForCC();
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -132,7 +131,9 @@ nsInProcessTabChildGlobal::Init()
|
|||
InitTabChildGlobal();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Couldn't initialize nsInProcessTabChildGlobal");
|
||||
mMessageManager = new nsFrameMessageManager(this);
|
||||
mMessageManager = new nsFrameMessageManager(this,
|
||||
nullptr,
|
||||
dom::ipc::MM_CHILD);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -168,69 +169,43 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
bool
|
||||
nsInProcessTabChildGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentFrameMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mPrincipal),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
nsInProcessTabChildGlobal::CacheFrameLoader(nsIFrameLoader* aFrameLoader)
|
||||
{
|
||||
mFrameLoader = aFrameLoader;
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter>
|
||||
nsInProcessTabChildGlobal::GetContent(ErrorResult& aError)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowOuter> content;
|
||||
if (mDocShell) {
|
||||
content = mDocShell->GetWindow();
|
||||
}
|
||||
return content.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetContent(mozIDOMWindowProxy** aContent)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aContent = GetContent(rv).take();
|
||||
return rv.StealNSResult();
|
||||
*aContent = nullptr;
|
||||
if (!mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = mDocShell->GetWindow();
|
||||
window.forget(aContent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aDocShell = GetDocShell(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsInProcessTabChildGlobal::GetTabEventTarget()
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
|
||||
return target.forget();
|
||||
NS_IF_ADDREF(*aDocShell = mDocShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget)
|
||||
{
|
||||
*aTarget = GetTabEventTarget().take();
|
||||
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
|
||||
target.forget(aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -337,7 +312,8 @@ nsInProcessTabChildGlobal::InitTabChildGlobal()
|
|||
id.AppendLiteral("?ownedBy=");
|
||||
id.Append(u);
|
||||
}
|
||||
NS_ENSURE_STATE(InitChildGlobalInternal(id));
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, this);
|
||||
NS_ENSURE_STATE(InitChildGlobalInternal(scopeSupports, id));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -377,8 +353,7 @@ nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL, bool aRunInGlo
|
|||
}
|
||||
bool tmp = mLoadingScript;
|
||||
mLoadingScript = true;
|
||||
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());
|
||||
LoadScriptInternal(global, aURL, aRunInGlobalScope);
|
||||
LoadScriptInternal(aURL, aRunInGlobalScope);
|
||||
mLoadingScript = tmp;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -28,7 +27,7 @@ namespace mozilla {
|
|||
class EventChainPreVisitor;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsInProcessTabChildGlobal : public mozilla::dom::ContentFrameMessageManager,
|
||||
class nsInProcessTabChildGlobal : public mozilla::DOMEventTargetHelper,
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIInProcessContentFrameMessageManager,
|
||||
public nsIGlobalObject,
|
||||
|
@ -47,30 +46,38 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal,
|
||||
mozilla::DOMEventTargetHelper)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override;
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter>
|
||||
GetContent(mozilla::ErrorResult& aError) override;
|
||||
virtual already_AddRefed<nsIDocShell>
|
||||
GetDocShell(mozilla::ErrorResult& aError) override
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell(mDocShell);
|
||||
return docShell.forget();
|
||||
}
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager);
|
||||
NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
|
||||
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
|
||||
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override;
|
||||
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override;
|
||||
NS_IMETHOD GetTabEventTarget(nsIEventTarget** aTarget) override;
|
||||
|
||||
NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
|
||||
|
||||
|
@ -92,6 +99,26 @@ public:
|
|||
|
||||
virtual nsresult GetEventTargetParent(
|
||||
mozilla::EventChainPreVisitor& aVisitor) override;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false,
|
||||
2);
|
||||
}
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
using mozilla::DOMEventTargetHelper::AddEventListener;
|
||||
|
||||
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
|
||||
void LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope);
|
||||
|
@ -116,9 +143,12 @@ public:
|
|||
mChromeMessageManager = aParent;
|
||||
}
|
||||
|
||||
virtual JSObject* GetGlobalJSObject() override
|
||||
virtual JSObject* GetGlobalJSObject() override {
|
||||
return mGlobal;
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
return GetWrapper();
|
||||
MOZ_CRASH("nsInProcessTabChildGlobal doesn't use DOM bindings!");
|
||||
}
|
||||
|
||||
already_AddRefed<nsIFrameLoader> GetFrameLoader();
|
||||
|
@ -128,6 +158,7 @@ protected:
|
|||
|
||||
nsresult Init();
|
||||
nsresult InitTabChildGlobal();
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
bool mInitialized;
|
||||
bool mLoadingScript;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptElement.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
|
@ -344,7 +344,11 @@ private:
|
|||
// Friend declarations for things that need to be able to call
|
||||
// SetIsNotDOMBinding(). The goal is to get rid of all of these, and
|
||||
// SetIsNotDOMBinding() too.
|
||||
friend class mozilla::dom::TabChildGlobal;
|
||||
friend class mozilla::dom::ProcessGlobal;
|
||||
friend class SandboxPrivate;
|
||||
friend class nsInProcessTabChildGlobal;
|
||||
friend class nsWindowRoot;
|
||||
void SetIsNotDOMBinding()
|
||||
{
|
||||
MOZ_ASSERT(!mWrapper && !(GetWrapperFlags() & ~WRAPPER_IS_NOT_DOM_BINDING),
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
|
||||
const BASE_NUMBER_OF_PROCESSES = 3;
|
||||
function checkBaseProcessCount(description) {
|
||||
const {childCount} = Services.ppmm;
|
||||
const {childCount} = ppmm;
|
||||
// With preloaded activity-stream, process count is a bit undeterministic, so
|
||||
// allow for some variation
|
||||
const extraCount = BASE_NUMBER_OF_PROCESSES + 1;
|
||||
|
@ -8,12 +12,14 @@ function checkBaseProcessCount(description) {
|
|||
}
|
||||
|
||||
function processScript() {
|
||||
if (Services.cpmm !== this) {
|
||||
let cpmm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsISyncMessageSender);
|
||||
if (cpmm !== this) {
|
||||
dump("Test failed: wrong global object\n");
|
||||
return;
|
||||
}
|
||||
|
||||
this.cpmm = Services.cpmm;
|
||||
this.cpmm = cpmm;
|
||||
|
||||
addMessageListener("ProcessTest:Reply", function listener(msg) {
|
||||
removeMessageListener("ProcessTest:Reply", listener);
|
||||
|
@ -64,7 +70,7 @@ add_task(async function(){
|
|||
if (!gMultiProcessBrowser)
|
||||
return;
|
||||
|
||||
Services.ppmm.releaseCachedProcesses();
|
||||
ppmm.releaseCachedProcesses();
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 5]]})
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.keepProcessesAlive.web", 5]]})
|
||||
|
@ -78,17 +84,17 @@ add_task(async function(){
|
|||
await BrowserTestUtils.removeTab(tabs[i]);
|
||||
}
|
||||
|
||||
Services.ppmm.releaseCachedProcesses();
|
||||
ppmm.releaseCachedProcesses();
|
||||
checkBaseProcessCount("Should get back to the base number of processes at this point");
|
||||
})
|
||||
|
||||
// Test that loading a process script loads in all existing processes
|
||||
add_task(async function() {
|
||||
let checks = [];
|
||||
for (let i = 0; i < Services.ppmm.childCount; i++)
|
||||
checks.push(checkProcess(Services.ppmm.getChildAt(i)));
|
||||
for (let i = 0; i < ppmm.childCount; i++)
|
||||
checks.push(checkProcess(ppmm.getChildAt(i)));
|
||||
|
||||
Services.ppmm.loadProcessScript(processScriptURL, false);
|
||||
ppmm.loadProcessScript(processScriptURL, false);
|
||||
await Promise.all(checks);
|
||||
});
|
||||
|
||||
|
@ -104,7 +110,7 @@ add_task(async function() {
|
|||
gBrowser.selectedBrowser.loadURI("about:robots");
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
let init = Services.ppmm.initialProcessData;
|
||||
let init = ppmm.initialProcessData;
|
||||
init.test123 = "hello";
|
||||
init.test456 = new Map();
|
||||
init.test456.set("hi", "bye");
|
||||
|
@ -113,16 +119,16 @@ add_task(async function() {
|
|||
// However, stuff like remote thumbnails can cause a content
|
||||
// process to exist nonetheless. This should be rare, though,
|
||||
// so the test is useful most of the time.
|
||||
if (Services.ppmm.childCount == 2) {
|
||||
let mainMM = Services.ppmm.getChildAt(0);
|
||||
if (ppmm.childCount == 2) {
|
||||
let mainMM = ppmm.getChildAt(0);
|
||||
|
||||
let check = checkProcess(Services.ppmm);
|
||||
Services.ppmm.loadProcessScript(processScriptURL, true);
|
||||
let check = checkProcess(ppmm);
|
||||
ppmm.loadProcessScript(processScriptURL, true);
|
||||
|
||||
// The main process should respond
|
||||
await check;
|
||||
|
||||
check = checkProcess(Services.ppmm);
|
||||
check = checkProcess(ppmm);
|
||||
// Reset the default browser to start a new child process
|
||||
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
|
||||
gBrowser.selectedBrowser.loadURI("about:blank");
|
||||
|
@ -133,10 +139,10 @@ add_task(async function() {
|
|||
// The new process should have responded
|
||||
await check;
|
||||
|
||||
Services.ppmm.removeDelayedProcessScript(processScriptURL);
|
||||
ppmm.removeDelayedProcessScript(processScriptURL);
|
||||
|
||||
let childMM;
|
||||
childMM = Services.ppmm.getChildAt(2);
|
||||
childMM = ppmm.getChildAt(2);
|
||||
|
||||
childMM.loadProcessScript(initTestScriptURL, false);
|
||||
let msg = await promiseMessage(childMM, "ProcessTest:InitGood");
|
||||
|
|
|
@ -11,7 +11,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1139964
|
|||
<label value="Mozilla Bug 1139964"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
|
||||
function ok(cond, msg) {
|
||||
opener.wrappedJSObject.ok(cond, msg);
|
||||
|
|
|
@ -14,9 +14,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
|
|||
var didRunAsync = false;
|
||||
var didRunLocal = false;
|
||||
|
||||
var global = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
|
||||
var global = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsIMessageBroadcaster);
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsIMessageBroadcaster);
|
||||
var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsISyncMessageSender);
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
|
||||
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -15,7 +15,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT = "data:,sendAsyncMessage('test')";
|
||||
var order = ["group", "window", "global"];
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -15,7 +15,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT = "data:,addMessageListener('test', function (msg) {" +
|
||||
"sendSyncMessage('test', msg.data)})";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -17,7 +17,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'frame2')})";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -17,7 +17,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'group2')})";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -16,7 +16,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
|
||||
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -21,7 +21,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098074
|
|||
// with SimpleTest.finish as a continuation function.
|
||||
SimpleTest.monitorConsole(SimpleTest.finish, [{errorMessage: new RegExp('acopia')}]);
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
globalMM.addMessageListener("flimfniffle", function onMessage(msg) {
|
||||
globalMM.removeMessageListener("flimfniffle", onMessage);
|
||||
is(msg.data, "teufeltor", "correct message");
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
ChromeUtils.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
let obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].
|
||||
getService(Ci.nsIMessageBroadcaster);
|
||||
|
||||
function DummyHelperSubclass() {
|
||||
this.onuninit = null;
|
||||
|
|
|
@ -3127,22 +3127,11 @@ ConvertExceptionToPromise(JSContext* cx,
|
|||
|
||||
/* static */
|
||||
void
|
||||
CreateGlobalOptionsWithXPConnect::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
CreateGlobalOptions<nsGlobalWindowInner>::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
{
|
||||
xpc::TraceXPCGlobal(aTrc, aObj);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
CreateGlobalOptionsWithXPConnect::PostCreateGlobal(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGlobal)
|
||||
{
|
||||
// Invoking the XPCWrappedNativeScope constructor automatically hooks it
|
||||
// up to the compartment of aGlobal.
|
||||
(void) new XPCWrappedNativeScope(aCx, aGlobal);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sRegisteredDOMNames = false;
|
||||
|
||||
nsresult
|
||||
|
@ -3176,7 +3165,10 @@ CreateGlobalOptions<nsGlobalWindowInner>::PostCreateGlobal(JSContext* aCx,
|
|||
return Throw(aCx, rv);
|
||||
}
|
||||
|
||||
return CreateGlobalOptionsWithXPConnect::PostCreateGlobal(aCx, aGlobal);
|
||||
// Invoking the XPCWrappedNativeScope constructor automatically hooks it
|
||||
// up to the compartment of aGlobal.
|
||||
(void) new XPCWrappedNativeScope(aCx, aGlobal);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -50,7 +50,6 @@ enum UseCounter : int16_t;
|
|||
|
||||
namespace dom {
|
||||
class CustomElementReactionsStack;
|
||||
class MessageManagerGlobal;
|
||||
template<typename KeyType, typename ValueType> class Record;
|
||||
|
||||
nsresult
|
||||
|
@ -3101,9 +3100,11 @@ bool
|
|||
EnumerateGlobal(JSContext* aCx, JS::HandleObject aObj,
|
||||
JS::AutoIdVector& aProperties, bool aEnumerableOnly);
|
||||
|
||||
|
||||
struct CreateGlobalOptionsGeneric
|
||||
template <class T>
|
||||
struct CreateGlobalOptions
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::NonWindowLike;
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
{
|
||||
mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj);
|
||||
|
@ -3116,34 +3117,12 @@ struct CreateGlobalOptionsGeneric
|
|||
}
|
||||
};
|
||||
|
||||
struct CreateGlobalOptionsWithXPConnect
|
||||
{
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
|
||||
static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
using IsGlobalWithXPConnect =
|
||||
IntegralConstant<bool,
|
||||
IsBaseOf<nsGlobalWindowInner, T>::value ||
|
||||
IsBaseOf<MessageManagerGlobal, T>::value>;
|
||||
|
||||
template <class T>
|
||||
struct CreateGlobalOptions
|
||||
: Conditional<IsGlobalWithXPConnect<T>::value,
|
||||
CreateGlobalOptionsWithXPConnect,
|
||||
CreateGlobalOptionsGeneric>::Type
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::NonWindowLike;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CreateGlobalOptions<nsGlobalWindowInner>
|
||||
: public CreateGlobalOptionsWithXPConnect
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::WindowLike;
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
|
||||
static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
};
|
||||
|
||||
|
@ -3234,11 +3213,11 @@ class PinnedStringId
|
|||
return true;
|
||||
}
|
||||
|
||||
operator const jsid& () const {
|
||||
operator const jsid& () {
|
||||
return id;
|
||||
}
|
||||
|
||||
operator JS::Handle<jsid> () const {
|
||||
operator JS::Handle<jsid> () {
|
||||
/* This is safe because we have pinned the string. */
|
||||
return JS::Handle<jsid>::fromMarkedLocation(&id);
|
||||
}
|
||||
|
|
|
@ -152,10 +152,6 @@ DOMInterfaces = {
|
|||
'implicitJSContext': ['clear', 'count', 'groupEnd', 'time', 'timeEnd'],
|
||||
},
|
||||
|
||||
'ContentProcessMessageManager': {
|
||||
'nativeType': 'mozilla::dom::ProcessGlobal'
|
||||
},
|
||||
|
||||
'ConvolverNode': {
|
||||
'implicitJSContext': [ 'buffer' ],
|
||||
},
|
||||
|
@ -574,18 +570,6 @@ DOMInterfaces = {
|
|||
'headerFile': 'MediaRecorder.h',
|
||||
},
|
||||
|
||||
'MessageBroadcaster': {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'MessageListenerManager': {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'MessageSender': {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'MimeType': {
|
||||
'headerFile' : 'nsMimeTypeArray.h',
|
||||
'nativeType': 'nsMimeType',
|
||||
|
@ -1031,10 +1015,6 @@ DOMInterfaces = {
|
|||
'concrete': False,
|
||||
},
|
||||
|
||||
'SyncMessageSender' : {
|
||||
'concrete': False,
|
||||
},
|
||||
|
||||
'TestFunctions': {
|
||||
'wrapperCache': False
|
||||
},
|
||||
|
@ -1731,10 +1711,13 @@ addExternalIface('MozTreeView', nativeType='nsITreeView',
|
|||
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
|
||||
addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow',
|
||||
notflattened=True)
|
||||
addExternalIface('nsIEventTarget', nativeType='nsIEventTarget', notflattened=True)
|
||||
addExternalIface('nsIFile', nativeType='nsIFile', notflattened=True)
|
||||
addExternalIface('nsILoadGroup', nativeType='nsILoadGroup',
|
||||
headerFile='nsILoadGroup.h', notflattened=True)
|
||||
addExternalIface('nsIMessageBroadcaster', nativeType='nsIMessageBroadcaster',
|
||||
headerFile='nsIMessageManager.h', notflattened=True)
|
||||
addExternalIface('nsIMessageSender', nativeType='nsIMessageSender',
|
||||
headerFile='nsIMessageManager.h', notflattened=True)
|
||||
addExternalIface('nsIPrintSettings', nativeType='nsIPrintSettings',
|
||||
notflattened=True)
|
||||
addExternalIface('nsISelectionListener', nativeType='nsISelectionListener')
|
||||
|
|
|
@ -281,15 +281,12 @@ class CGStringTable(CGThing):
|
|||
The uint16_t indices are smaller than the pointer equivalents, and the
|
||||
string table requires no runtime relocations.
|
||||
"""
|
||||
def __init__(self, accessorName, strings, static=False):
|
||||
def __init__(self, accessorName, strings):
|
||||
CGThing.__init__(self)
|
||||
self.accessorName = accessorName
|
||||
self.strings = strings
|
||||
self.static = static
|
||||
|
||||
def declare(self):
|
||||
if self.static:
|
||||
return ""
|
||||
return "extern const char *%s(unsigned int aIndex);\n" % self.accessorName
|
||||
|
||||
def define(self):
|
||||
|
@ -301,7 +298,7 @@ class CGStringTable(CGThing):
|
|||
currentIndex += len(s) + 1 # for the null terminator
|
||||
return fill(
|
||||
"""
|
||||
${static}const char *${name}(unsigned int aIndex)
|
||||
const char *${name}(unsigned int aIndex)
|
||||
{
|
||||
static const char table[] = ${table};
|
||||
static const uint16_t indices[] = { ${indices} };
|
||||
|
@ -309,7 +306,6 @@ class CGStringTable(CGThing):
|
|||
return &table[indices[aIndex]];
|
||||
}
|
||||
""",
|
||||
static="static " if self.static else "",
|
||||
name=self.accessorName,
|
||||
table=table,
|
||||
indices=", ".join("%d" % index for index in indices),
|
||||
|
@ -1107,7 +1103,7 @@ class CGHeaders(CGWrapper):
|
|||
interfacesImplementingSelf)
|
||||
|
||||
# Grab the includes for the things that involve XPCOM interfaces
|
||||
hasInstanceIncludes = set(self.getDeclarationFilename(d.interface) for d
|
||||
hasInstanceIncludes = set("nsIDOM" + d.interface.identifier.name + ".h" for d
|
||||
in descriptors if
|
||||
d.interface.hasInterfaceObject() and
|
||||
NeedsGeneratedHasInstance(d) and
|
||||
|
@ -13953,120 +13949,58 @@ class CGRegisterWorkletBindings(CGAbstractMethod):
|
|||
lines.append(CGGeneric("return true;\n"))
|
||||
return CGList(lines, "\n").define()
|
||||
|
||||
|
||||
class CGSystemBindingInitIds(CGAbstractMethod):
|
||||
def __init__(self):
|
||||
CGAbstractMethod.__init__(self, None, 'SystemBindingInitIds', 'bool',
|
||||
[Argument('JSContext*', 'aCx')])
|
||||
|
||||
def definition_body(self):
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!idsInited) {
|
||||
// We can't use range-based for because we need the index to call IdString.
|
||||
for (uint32_t i = 0; i < ArrayLength(properties); ++i) {
|
||||
if (!properties[i].id.init(aCx, IdString(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
idsInited = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
""")
|
||||
|
||||
|
||||
class CGResolveSystemBinding(CGAbstractMethod):
|
||||
def __init__(self):
|
||||
def __init__(self, config):
|
||||
CGAbstractMethod.__init__(self, None, 'ResolveSystemBinding', 'bool',
|
||||
[Argument('JSContext*', 'aCx'),
|
||||
Argument('JS::Handle<JSObject*>', 'aObj'),
|
||||
Argument('JS::Handle<jsid>', 'aId'),
|
||||
Argument('bool*', 'aResolvedp')])
|
||||
self.config = config
|
||||
|
||||
def definition_body(self):
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(idsInited);
|
||||
descriptors = self.config.getDescriptors(hasInterfaceObject=True,
|
||||
isExposedInSystemGlobals=True,
|
||||
register=True)
|
||||
|
||||
if (JSID_IS_VOID(aId)) {
|
||||
for (const auto& property : properties) {
|
||||
if (!property.enabled || property.enabled(aCx, aObj)) {
|
||||
if (!property.define(aCx)) {
|
||||
return false;
|
||||
}
|
||||
*aResolvedp = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
def descNameToId(name):
|
||||
return "s%s_id" % name
|
||||
jsidNames = [descNameToId(desc.name) for desc in descriptors]
|
||||
jsidDecls = CGList(CGGeneric("static jsid %s;\n" % name)
|
||||
for name in jsidNames)
|
||||
|
||||
for (const auto& property : properties) {
|
||||
if (property.id == aId) {
|
||||
if (!property.enabled || property.enabled(aCx, aObj)) {
|
||||
if (!property.define(aCx)) {
|
||||
return false;
|
||||
}
|
||||
*aResolvedp = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
""")
|
||||
jsidInits = CGList(
|
||||
(CGIfWrapper(
|
||||
CGGeneric("return false;\n"),
|
||||
'!AtomizeAndPinJSString(aCx, %s, "%s")' %
|
||||
(descNameToId(desc.name), desc.interface.identifier.name))
|
||||
for desc in descriptors),
|
||||
"\n")
|
||||
jsidInits.append(CGGeneric("idsInited = true;\n"))
|
||||
jsidInits = CGIfWrapper(jsidInits, "!idsInited")
|
||||
jsidInits = CGList([CGGeneric("static bool idsInited = false;\n"),
|
||||
jsidInits])
|
||||
|
||||
definitions = CGList([], "\n")
|
||||
for desc in descriptors:
|
||||
bindingNS = toBindingNamespace(desc.name)
|
||||
defineCode = "!%s::GetConstructorObject(aCx)" % bindingNS
|
||||
defineCode = CGIfWrapper(CGGeneric("return false;\n"), defineCode)
|
||||
defineCode = CGList([defineCode,
|
||||
CGGeneric("*aResolvedp = true;\n")])
|
||||
|
||||
class CGMayResolveAsSystemBindingName(CGAbstractMethod):
|
||||
def __init__(self):
|
||||
CGAbstractMethod.__init__(self, None, 'MayResolveAsSystemBindingName', 'bool',
|
||||
[Argument('jsid', 'aId')])
|
||||
condition = "JSID_IS_VOID(aId) || aId == %s" % descNameToId(desc.name)
|
||||
if desc.isExposedConditionally():
|
||||
condition = "(%s) && %s::ConstructorEnabled(aCx, aObj)" % (condition, bindingNS)
|
||||
|
||||
def definition_body(self):
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(idsInited);
|
||||
definitions.append(CGIfWrapper(defineCode, condition))
|
||||
|
||||
for (const auto& property : properties) {
|
||||
if (aId == property.id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
""")
|
||||
|
||||
|
||||
class CGGetSystemBindingNames(CGAbstractMethod):
|
||||
def __init__(self):
|
||||
CGAbstractMethod.__init__(self, None, 'GetSystemBindingNames', 'void',
|
||||
[Argument('JSContext*', 'aCx'),
|
||||
Argument('JS::Handle<JSObject*>', 'aObj'),
|
||||
Argument('JS::AutoIdVector&', 'aNames'),
|
||||
Argument('bool', 'aEnumerableOnly'),
|
||||
Argument('mozilla::ErrorResult&', 'aRv')])
|
||||
|
||||
def definition_body(self):
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aEnumerableOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SystemBindingInitIds(aCx)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& property : properties) {
|
||||
if (!property.enabled || property.enabled(aCx, aObj)) {
|
||||
if (!aNames.append(property.id)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
return CGList([CGGeneric("MOZ_ASSERT(NS_IsMainThread());\n"),
|
||||
jsidDecls,
|
||||
jsidInits,
|
||||
definitions,
|
||||
CGGeneric("return true;\n")],
|
||||
"\n").define()
|
||||
|
||||
|
||||
def getGlobalNames(config):
|
||||
|
@ -17562,44 +17496,8 @@ class GlobalGenRoots():
|
|||
|
||||
@staticmethod
|
||||
def ResolveSystemBinding(config):
|
||||
curr = CGList([], "\n")
|
||||
|
||||
descriptors = config.getDescriptors(hasInterfaceObject=True,
|
||||
isExposedInSystemGlobals=True,
|
||||
register=True)
|
||||
properties = [desc.name for desc in descriptors]
|
||||
|
||||
curr.append(CGStringTable("IdString", properties, static=True))
|
||||
|
||||
initValues = []
|
||||
for desc in descriptors:
|
||||
bindingNS = toBindingNamespace(desc.name)
|
||||
if desc.isExposedConditionally():
|
||||
enabled = "%s::ConstructorEnabled" % bindingNS
|
||||
else:
|
||||
enabled = "nullptr"
|
||||
define = "%s::GetConstructorObject" % bindingNS
|
||||
initValues.append("{ %s, %s },\n" % (enabled, define))
|
||||
curr.append(CGGeneric(fill("""
|
||||
struct SystemProperty
|
||||
{
|
||||
WebIDLGlobalNameHash::ConstructorEnabled enabled;
|
||||
ProtoGetter define;
|
||||
PinnedStringId id;
|
||||
};
|
||||
|
||||
static SystemProperty properties[] = {
|
||||
$*{init}
|
||||
};
|
||||
|
||||
static bool idsInited = false;
|
||||
""",
|
||||
init="".join(initValues))))
|
||||
|
||||
curr.append(CGSystemBindingInitIds())
|
||||
curr.append(CGResolveSystemBinding())
|
||||
curr.append(CGMayResolveAsSystemBindingName())
|
||||
curr.append(CGGetSystemBindingNames())
|
||||
curr = CGResolveSystemBinding(config)
|
||||
|
||||
# Wrap all of that in our namespaces.
|
||||
curr = CGNamespace.build(['mozilla', 'dom'],
|
||||
|
@ -17613,7 +17511,7 @@ class GlobalGenRoots():
|
|||
isExposedInSystemGlobals=True)]
|
||||
defineIncludes.append("nsThreadUtils.h") # For NS_IsMainThread
|
||||
defineIncludes.append("js/Id.h") # For jsid
|
||||
defineIncludes.append("mozilla/dom/WebIDLGlobalNameHash.h")
|
||||
defineIncludes.append("mozilla/dom/BindingUtils.h") # AtomizeAndPinJSString
|
||||
|
||||
curr = CGHeaders([], [], [], [], [], defineIncludes,
|
||||
'ResolveSystemBinding', curr)
|
||||
|
|
|
@ -233,13 +233,6 @@ ToJSValue(JSContext* aCx,
|
|||
|
||||
// Accept existing JS values (which may not be same-compartment with us
|
||||
MOZ_MUST_USE inline bool
|
||||
ToJSValue(JSContext* aCx, const JS::Value& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
aValue.set(aArgument);
|
||||
return MaybeWrapValue(aCx, aValue);
|
||||
}
|
||||
MOZ_MUST_USE inline bool
|
||||
ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
|
@ -319,13 +312,33 @@ ToJSValue(JSContext* aCx,
|
|||
Promise& aArgument,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
|
||||
// Accept arrays (and nested arrays) of other things we accept
|
||||
// Accept arrays of other things we accept
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
T* aArguments,
|
||||
size_t aLength,
|
||||
JS::MutableHandle<JS::Value> aValue);
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
// Make sure we're called in a compartment
|
||||
MOZ_ASSERT(JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
JS::AutoValueVector v(aCx);
|
||||
if (!v.resize(aLength)) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < aLength; ++i) {
|
||||
if (!ToJSValue(aCx, aArguments[i], v[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
JSObject* arrayObj = JS_NewArrayObject(aCx, v);
|
||||
if (!arrayObj) {
|
||||
return false;
|
||||
}
|
||||
aValue.setObject(*arrayObj);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
|
@ -356,34 +369,6 @@ ToJSValue(JSContext* aCx,
|
|||
return ToJSValue(aCx, aArgument, N, aValue);
|
||||
}
|
||||
|
||||
// Accept arrays of other things we accept
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool
|
||||
ToJSValue(JSContext* aCx,
|
||||
T* aArguments,
|
||||
size_t aLength,
|
||||
JS::MutableHandle<JS::Value> aValue)
|
||||
{
|
||||
// Make sure we're called in a compartment
|
||||
MOZ_ASSERT(JS::CurrentGlobalOrNull(aCx));
|
||||
|
||||
JS::AutoValueVector v(aCx);
|
||||
if (!v.resize(aLength)) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < aLength; ++i) {
|
||||
if (!ToJSValue(aCx, aArguments[i], v[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
JSObject* arrayObj = JS_NewArrayObject(aCx, v);
|
||||
if (!arrayObj) {
|
||||
return false;
|
||||
}
|
||||
aValue.setObject(*arrayObj);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ struct WebIDLNameTableEntry : public PLDHashEntryHdr
|
|||
constructors::id::ID mConstructorId;
|
||||
WebIDLGlobalNameHash::DefineGlobalName mDefine;
|
||||
// May be null if enabled unconditionally
|
||||
WebIDLGlobalNameHash::ConstructorEnabled mEnabled;
|
||||
WebIDLGlobalNameHash::ConstructorEnabled* mEnabled;
|
||||
};
|
||||
|
||||
static nsTHashtable<WebIDLNameTableEntry>* sWebIDLGlobalNames;
|
||||
|
@ -163,7 +163,7 @@ WebIDLGlobalNameHash::Shutdown()
|
|||
void
|
||||
WebIDLGlobalNameHash::Register(uint16_t aNameOffset, uint16_t aNameLength,
|
||||
DefineGlobalName aDefine,
|
||||
ConstructorEnabled aEnabled,
|
||||
ConstructorEnabled* aEnabled,
|
||||
constructors::id::ID aConstructorId)
|
||||
{
|
||||
const char* name = sNames + aNameOffset;
|
||||
|
@ -211,7 +211,7 @@ WebIDLGlobalNameHash::DefineIfEnabled(JSContext* aCx,
|
|||
|
||||
*aFound = true;
|
||||
|
||||
ConstructorEnabled checkEnabledForScope = entry->mEnabled;
|
||||
ConstructorEnabled* checkEnabledForScope = entry->mEnabled;
|
||||
// We do the enabled check on the current compartment of aCx, but for the
|
||||
// actual object we pass in the underlying object in the Xray case. That
|
||||
// way the callee can decide whether to allow access based on the caller
|
||||
|
|
|
@ -38,10 +38,10 @@ public:
|
|||
// pointer, so it's more obvious that pointers to a ConstructorEnabled
|
||||
// can be null.
|
||||
typedef bool
|
||||
(*ConstructorEnabled)(JSContext* cx, JS::Handle<JSObject*> obj);
|
||||
(ConstructorEnabled)(JSContext* cx, JS::Handle<JSObject*> obj);
|
||||
|
||||
static void Register(uint16_t aNameOffset, uint16_t aNameLength,
|
||||
DefineGlobalName aDefine, ConstructorEnabled aEnabled,
|
||||
DefineGlobalName aDefine, ConstructorEnabled* aEnabled,
|
||||
constructors::id::ID aConstructorId);
|
||||
|
||||
static void Remove(const char* aName, uint32_t aLength);
|
||||
|
|
|
@ -72,10 +72,10 @@
|
|||
let receivedMessageIndex = 0;
|
||||
|
||||
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||
mm.addMessageListener("test:ipcClonedMessage", SpecialPowers.wrapCallback(function(message) {
|
||||
mm.addMessageListener("test:ipcClonedMessage", function(message) {
|
||||
let data = message.json;
|
||||
|
||||
if (SpecialPowers.call_Instanceof(data, Blob)) {
|
||||
if (data instanceof Blob) {
|
||||
is(receivedMessageIndex, messages.length - 1, "Blob is last");
|
||||
is (data.size,
|
||||
messages[receivedMessageIndex].size,
|
||||
|
@ -104,7 +104,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
SpecialPowers.wrap(reader1).readAsText(data);
|
||||
reader1.readAsText(data);
|
||||
reader2.readAsText(messages[receivedMessageIndex]);
|
||||
return;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@
|
|||
is(message.json,
|
||||
messages[receivedMessageIndex++],
|
||||
"Got correct round-tripped response");
|
||||
}));
|
||||
});
|
||||
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
|
||||
false);
|
||||
|
||||
|
|
|
@ -80,14 +80,11 @@ function waitForMessage(aMessage, browser)
|
|||
{
|
||||
return new Promise((resolve, reject) => {
|
||||
/* eslint-disable no-undef */
|
||||
// When contentScript runs, "this" is a ContentFrameMessageManager (so that's where
|
||||
// addEventListener will add the listener), but the non-bubbling "message" event is
|
||||
// sent to the Window involved, so we need a capturing listener.
|
||||
function contentScript() {
|
||||
addEventListener("message", function(event) {
|
||||
sendAsyncMessage("testLocal:message",
|
||||
{message: event.data});
|
||||
}, {once: true, capture: true}, true);
|
||||
}, {once: true}, true);
|
||||
}
|
||||
/* eslint-enable no-undef */
|
||||
|
||||
|
|
|
@ -214,16 +214,16 @@ function parentFrameScript(mm) {
|
|||
function* testSteps() {
|
||||
let result = yield undefined;
|
||||
|
||||
is(SpecialPowers.Cu.getClassName(result, true), "Array", "Child delivered an array of results");
|
||||
is(Array.isArray(result), true, "Child delivered an array of results");
|
||||
is(result.length, 2, "Child delivered two results");
|
||||
|
||||
let blob = result[0];
|
||||
is(SpecialPowers.call_Instanceof(blob, Blob), true, "Child delivered a blob");
|
||||
is(blob instanceof Blob, true, "Child delivered a blob");
|
||||
is(blob.size, blobText.length, "Blob has correct size");
|
||||
is(blob.type, blobType, "Blob has correct type");
|
||||
|
||||
let slice = result[1];
|
||||
is(SpecialPowers.call_Instanceof(slice, Blob), true, "Child delivered a slice");
|
||||
is(slice instanceof Blob, true, "Child delivered a slice");
|
||||
is(slice.size, blobData[0].length, "Slice has correct size");
|
||||
is(slice.type, blobType, "Slice has correct type");
|
||||
|
||||
|
@ -231,7 +231,7 @@ function parentFrameScript(mm) {
|
|||
|
||||
let reader = new FileReader();
|
||||
reader.onload = grabAndContinue;
|
||||
SpecialPowers.wrap(reader).readAsText(blob);
|
||||
reader.readAsText(blob);
|
||||
yield undefined;
|
||||
|
||||
is(reader.result, blobText, "Blob has correct data");
|
||||
|
@ -240,14 +240,14 @@ function parentFrameScript(mm) {
|
|||
|
||||
reader = new FileReader();
|
||||
reader.onload = grabAndContinue;
|
||||
SpecialPowers.wrap(reader).readAsText(slice);
|
||||
reader.readAsText(slice);
|
||||
yield undefined;
|
||||
|
||||
is(reader.result, blobData[0], "Slice has correct data");
|
||||
|
||||
slice = blob.slice(0, blobData[0].length, blobType);
|
||||
|
||||
is(SpecialPowers.call_Instanceof(slice, Blob), true, "Child delivered a slice");
|
||||
is(slice instanceof Blob, true, "Made a new slice from blob");
|
||||
is(slice.size, blobData[0].length, "Second slice has correct size");
|
||||
is(slice.type, blobType, "Second slice has correct type");
|
||||
|
||||
|
@ -255,7 +255,7 @@ function parentFrameScript(mm) {
|
|||
|
||||
reader = new FileReader();
|
||||
reader.onload = grabAndContinue;
|
||||
SpecialPowers.wrap(reader).readAsText(slice);
|
||||
reader.readAsText(slice);
|
||||
yield undefined;
|
||||
|
||||
is(reader.result, blobData[0], "Second slice has correct data");
|
||||
|
@ -266,7 +266,7 @@ function parentFrameScript(mm) {
|
|||
let testGenerator = testSteps();
|
||||
testGenerator.next();
|
||||
|
||||
mm.addMessageListener(messageName, SpecialPowers.wrapCallback(function(message) {
|
||||
mm.addMessageListener(messageName, function(message) {
|
||||
let data = message.data;
|
||||
switch (data.op) {
|
||||
case "info": {
|
||||
|
@ -289,7 +289,7 @@ function parentFrameScript(mm) {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
|
||||
false);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMElement;
|
||||
interface nsIMessageSender;
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, builtinclass, uuid(456f58be-29dd-4973-885b-95aece1c9a8a)]
|
||||
|
@ -35,7 +36,7 @@ interface nsIContentProcessInfo : nsISupports
|
|||
* The process manager for this ContentParent (so a process message manager
|
||||
* as opposed to a frame message manager.
|
||||
*/
|
||||
readonly attribute nsISupports messageManager;
|
||||
readonly attribute nsIMessageSender messageManager;
|
||||
};
|
||||
|
||||
[scriptable, uuid(83ffb063-5f65-4c45-ae07-3f553e0809bb)]
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "domstubs.idl"
|
||||
#include "nsIDroppedLinkHandler.idl"
|
||||
|
||||
interface nsIContentFrameMessageManager;
|
||||
interface nsIWebBrowserChrome3;
|
||||
|
||||
native CommandsArray(nsTArray<nsCString>);
|
||||
|
@ -14,7 +15,7 @@ native CommandsArray(nsTArray<nsCString>);
|
|||
[scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)]
|
||||
interface nsITabChild : nsISupports
|
||||
{
|
||||
readonly attribute nsISupports messageManager;
|
||||
readonly attribute nsIContentFrameMessageManager messageManager;
|
||||
|
||||
attribute nsIWebBrowserChrome3 webBrowserChrome;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/ContentBridgeParent.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/TabParent.h"
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "mozilla/docshell/OfflineCacheUpdateChild.h"
|
||||
#include "mozilla/dom/ClientManager.h"
|
||||
#include "mozilla/dom/ClientOpenWindowOpActors.h"
|
||||
#include "mozilla/dom/ChildProcessMessageManager.h"
|
||||
#include "mozilla/dom/ContentBridgeChild.h"
|
||||
#include "mozilla/dom/ContentBridgeParent.h"
|
||||
#include "mozilla/dom/DOMPrefs.h"
|
||||
|
|
|
@ -526,7 +526,7 @@ ScriptableCPInfo::GetTabCount(int32_t* aTabCount)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ScriptableCPInfo::GetMessageManager(nsISupports** aMessenger)
|
||||
ScriptableCPInfo::GetMessageManager(nsIMessageSender** aMessenger)
|
||||
{
|
||||
*aMessenger = nullptr;
|
||||
if (!mContentParent) {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "mozilla/BrowserElementParent.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
|
||||
#include "mozilla/dom/PaymentRequestChild.h"
|
||||
#include "mozilla/dom/TelemetryScrollProbe.h"
|
||||
|
@ -105,6 +104,7 @@
|
|||
#include "UnitTransforms.h"
|
||||
#include "ClientLayerManager.h"
|
||||
#include "LayersLogging.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsColorPickerProxy.h"
|
||||
#include "nsContentPermissionHelper.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
@ -236,10 +236,11 @@ TabChildBase::DispatchMessageManagerMessage(const nsAString& aMessageName,
|
|||
}
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(cx, mTabChildGlobal->GetWrapper());
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(cx, GetGlobal());
|
||||
// Let the BrowserElementScrolling helper (if it exists) for this
|
||||
// content manipulate the frame state.
|
||||
RefPtr<nsFrameMessageManager> mm = mTabChildGlobal->GetMessageManager();
|
||||
RefPtr<nsFrameMessageManager> mm =
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
||||
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
|
||||
aMessageName, false, &data, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
@ -271,7 +272,7 @@ TabChildBase::UpdateFrameHandler(const FrameMetrics& aFrameMetrics)
|
|||
void
|
||||
TabChildBase::ProcessUpdateFrame(const FrameMetrics& aFrameMetrics)
|
||||
{
|
||||
if (!mTabChildGlobal) {
|
||||
if (!mGlobal || !mTabChildGlobal) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1108,11 +1109,13 @@ TabChild::ActorDestroy(ActorDestroyReason why)
|
|||
// We should have a message manager if the global is alive, but it
|
||||
// seems sometimes we don't. Assert in aurora/nightly, but don't
|
||||
// crash in release builds.
|
||||
MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->GetMessageManager());
|
||||
if (mTabChildGlobal->GetMessageManager()) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->mMessageManager);
|
||||
if (mTabChildGlobal->mMessageManager) {
|
||||
// The messageManager relays messages via the TabChild which
|
||||
// no longer exists.
|
||||
mTabChildGlobal->DisconnectMessageManager();
|
||||
static_cast<nsFrameMessageManager*>
|
||||
(mTabChildGlobal->mMessageManager.get())->Disconnect();
|
||||
mTabChildGlobal->mMessageManager = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1359,11 +1362,9 @@ TabChild::HandleDoubleTap(const CSSPoint& aPoint, const Modifiers& aModifiers,
|
|||
const ScrollableLayerGuid& aGuid)
|
||||
{
|
||||
TABC_LOG("Handling double tap at %s with %p %p\n",
|
||||
Stringify(aPoint).c_str(),
|
||||
mTabChildGlobal ? mTabChildGlobal->GetWrapper() : nullptr,
|
||||
mTabChildGlobal.get());
|
||||
Stringify(aPoint).c_str(), mGlobal.get(), mTabChildGlobal.get());
|
||||
|
||||
if (!mTabChildGlobal || !mTabChildGlobal->GetWrapper()) {
|
||||
if (!mGlobal || !mTabChildGlobal) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1405,7 @@ TabChild::RecvHandleTap(const GeckoContentController::TapType& aType,
|
|||
|
||||
switch (aType) {
|
||||
case GeckoContentController::TapType::eSingleTap:
|
||||
if (mTabChildGlobal) {
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 1);
|
||||
}
|
||||
break;
|
||||
|
@ -1412,18 +1413,18 @@ TabChild::RecvHandleTap(const GeckoContentController::TapType& aType,
|
|||
HandleDoubleTap(point, aModifiers, aGuid);
|
||||
break;
|
||||
case GeckoContentController::TapType::eSecondTap:
|
||||
if (mTabChildGlobal) {
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 2);
|
||||
}
|
||||
break;
|
||||
case GeckoContentController::TapType::eLongTap:
|
||||
if (mTabChildGlobal) {
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
mAPZEventState->ProcessLongTap(presShell, point, scale, aModifiers, aGuid,
|
||||
aInputBlockId);
|
||||
}
|
||||
break;
|
||||
case GeckoContentController::TapType::eLongTapUp:
|
||||
if (mTabChildGlobal) {
|
||||
if (mGlobal && mTabChildGlobal) {
|
||||
mAPZEventState->ProcessLongTapUp(presShell, point, scale, aModifiers);
|
||||
}
|
||||
break;
|
||||
|
@ -2275,18 +2276,12 @@ TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture)
|
|||
mozilla::ipc::IPCResult
|
||||
TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalScope)
|
||||
{
|
||||
if (!InitTabChildGlobal())
|
||||
if (!mGlobal && !InitTabChildGlobal())
|
||||
// This can happen if we're half-destroyed. It's not a fatal
|
||||
// error.
|
||||
return IPC_OK();
|
||||
|
||||
JS::Rooted<JSObject*> global(RootingCx(), mTabChildGlobal->GetWrapper());
|
||||
if (!global) {
|
||||
// This can happen if we're half-destroyed. It's not a fatal error.
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
LoadScriptInternal(global, aURL, aRunInGlobalScope);
|
||||
LoadScriptInternal(aURL, aRunInGlobalScope);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
@ -2304,19 +2299,19 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
RefPtr<nsFrameMessageManager> mm = mTabChildGlobal->GetMessageManager();
|
||||
|
||||
// We should have a message manager if the global is alive, but it
|
||||
// seems sometimes we don't. Assert in aurora/nightly, but don't
|
||||
// crash in release builds.
|
||||
MOZ_DIAGNOSTIC_ASSERT(mm);
|
||||
if (!mm) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->mMessageManager);
|
||||
if (!mTabChildGlobal->mMessageManager) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), mTabChildGlobal->GetWrapper());
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), GetGlobal());
|
||||
StructuredCloneData data;
|
||||
UnpackClonedMessageDataForChild(aData, data);
|
||||
RefPtr<nsFrameMessageManager> mm =
|
||||
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
|
||||
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
|
||||
aMessage, false, &data, &cpows, aPrincipal, nullptr);
|
||||
return IPC_OK();
|
||||
|
@ -2722,29 +2717,27 @@ TabChild::DeallocPRenderFrameChild(PRenderFrameChild* aFrame)
|
|||
bool
|
||||
TabChild::InitTabChildGlobal()
|
||||
{
|
||||
if (!mTabChildGlobal) {
|
||||
if (!mGlobal && !mTabChildGlobal) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
|
||||
NS_ENSURE_TRUE(window, false);
|
||||
nsCOMPtr<EventTarget> chromeHandler =
|
||||
do_QueryInterface(window->GetChromeEventHandler());
|
||||
NS_ENSURE_TRUE(chromeHandler, false);
|
||||
|
||||
RefPtr<TabChildGlobal> scope = mTabChildGlobal = new TabChildGlobal(this);
|
||||
RefPtr<TabChildGlobal> scope = new TabChildGlobal(this);
|
||||
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, scope);
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(globalId, "outOfProcessTabChildGlobal");
|
||||
if (NS_WARN_IF(!InitChildGlobalInternal(globalId))) {
|
||||
mTabChildGlobal = nullptr;
|
||||
return false;
|
||||
}
|
||||
NS_ENSURE_TRUE(InitChildGlobalInternal(scopeSupports, globalId), false);
|
||||
|
||||
scope->Init();
|
||||
|
||||
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
|
||||
if (NS_WARN_IF(!root)) {
|
||||
mTabChildGlobal = nullptr;
|
||||
return false;
|
||||
}
|
||||
NS_ENSURE_TRUE(root, false);
|
||||
root->SetParentTarget(scope);
|
||||
|
||||
mTabChildGlobal = scope.forget();;
|
||||
}
|
||||
|
||||
if (!mTriedBrowserInit) {
|
||||
|
@ -2965,11 +2958,14 @@ TabChild::IsVisible()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChild::GetMessageManager(nsISupports** aResult)
|
||||
TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm(mTabChildGlobal);
|
||||
mm.forget(aResult);
|
||||
return *aResult ? NS_OK : NS_ERROR_FAILURE;
|
||||
if (mTabChildGlobal) {
|
||||
NS_ADDREF(*aResult = mTabChildGlobal);
|
||||
return NS_OK;
|
||||
}
|
||||
*aResult = nullptr;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3477,9 +3473,9 @@ TabChild::TabGroup()
|
|||
}
|
||||
|
||||
TabChildGlobal::TabChildGlobal(TabChild* aTabChild)
|
||||
: ContentFrameMessageManager(new nsFrameMessageManager(aTabChild)),
|
||||
mTabChild(aTabChild)
|
||||
: mTabChild(aTabChild)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
}
|
||||
|
||||
TabChildGlobal::~TabChildGlobal()
|
||||
|
@ -3489,6 +3485,11 @@ TabChildGlobal::~TabChildGlobal()
|
|||
void
|
||||
TabChildGlobal::Init()
|
||||
{
|
||||
NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
|
||||
mMessageManager = new nsFrameMessageManager(mTabChild,
|
||||
nullptr,
|
||||
MM_CHILD);
|
||||
|
||||
TelemetryScrollProbe::Create(this);
|
||||
}
|
||||
|
||||
|
@ -3516,26 +3517,12 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
bool
|
||||
TabChildGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentFrameMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mTabChild->GetPrincipal()),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
// This method isn't automatically forwarded safely because it's notxpcom, so
|
||||
// the IDL binding doesn't know what value to return.
|
||||
NS_IMETHODIMP_(bool)
|
||||
|
@ -3548,59 +3535,36 @@ TabChildGlobal::MarkForCC()
|
|||
if (elm) {
|
||||
elm->MarkForCC();
|
||||
}
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter>
|
||||
TabChildGlobal::GetContent(ErrorResult& aError)
|
||||
{
|
||||
if (!mTabChild) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window =
|
||||
do_GetInterface(mTabChild->WebNavigation());
|
||||
return window.forget();
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChildGlobal::GetContent(mozIDOMWindowProxy** aContent)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aContent = GetContent(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDocShell>
|
||||
TabChildGlobal::GetDocShell(ErrorResult& aError)
|
||||
{
|
||||
if (!mTabChild) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsIDocShell> window = do_GetInterface(mTabChild->WebNavigation());
|
||||
return window.forget();
|
||||
*aContent = nullptr;
|
||||
if (!mTabChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(mTabChild->WebNavigation());
|
||||
window.forget(aContent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
||||
{
|
||||
ErrorResult rv;
|
||||
*aDocShell = GetDocShell(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
TabChildGlobal::GetTabEventTarget()
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = EventTargetFor(TaskCategory::Other);
|
||||
return target.forget();
|
||||
*aDocShell = nullptr;
|
||||
if (!mTabChild)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mTabChild->WebNavigation());
|
||||
docShell.swap(*aDocShell);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget)
|
||||
{
|
||||
*aTarget = GetTabEventTarget().take();
|
||||
nsCOMPtr<nsIEventTarget> target = EventTargetFor(TaskCategory::Other);
|
||||
target.forget(aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3616,7 +3580,7 @@ JSObject*
|
|||
TabChildGlobal::GetGlobalJSObject()
|
||||
{
|
||||
NS_ENSURE_TRUE(mTabChild, nullptr);
|
||||
return GetWrapper();
|
||||
return mTabChild->GetGlobal();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#ifndef mozilla_dom_TabChild_h
|
||||
#define mozilla_dom_TabChild_h
|
||||
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -79,7 +78,7 @@ class ClonedMessageData;
|
|||
class CoalescedMouseData;
|
||||
class CoalescedWheelData;
|
||||
|
||||
class TabChildGlobal : public ContentFrameMessageManager,
|
||||
class TabChildGlobal : public DOMEventTargetHelper,
|
||||
public nsIContentFrameMessageManager,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsIGlobalObject,
|
||||
|
@ -90,25 +89,58 @@ public:
|
|||
void Init();
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector);
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter> GetContent(ErrorResult& aError) override;
|
||||
virtual already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) override;
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager);
|
||||
NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
|
||||
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
|
||||
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override;
|
||||
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override;
|
||||
NS_IMETHOD GetTabEventTarget(nsIEventTarget** aTarget) override;
|
||||
|
||||
nsresult AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false, 2);
|
||||
}
|
||||
using DOMEventTargetHelper::AddEventListener;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetEventTargetParent(EventChainPreVisitor& aVisitor) override
|
||||
|
@ -120,6 +152,11 @@ public:
|
|||
virtual nsIPrincipal* GetPrincipal() override;
|
||||
virtual JSObject* GetGlobalJSObject() override;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("TabChildGlobal doesn't use DOM bindings!");
|
||||
}
|
||||
|
||||
// Dispatch a runnable related to the global.
|
||||
virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
|
||||
already_AddRefed<nsIRunnable>&& aRunnable) override;
|
||||
|
@ -130,6 +167,7 @@ public:
|
|||
virtual AbstractThread*
|
||||
AbstractMainThreadFor(mozilla::TaskCategory aCategory) override;
|
||||
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
||||
RefPtr<TabChild> mTabChild;
|
||||
|
||||
protected:
|
||||
|
@ -164,13 +202,6 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TabChildBase)
|
||||
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override
|
||||
{
|
||||
return mTabChildGlobal->WrapGlobalObject(aCx, aOptions, aReflector);
|
||||
}
|
||||
|
||||
virtual nsIWebNavigation* WebNavigation() const = 0;
|
||||
virtual PuppetWidget* WebWidget() = 0;
|
||||
nsIPrincipal* GetPrincipal() { return mPrincipal; }
|
||||
|
@ -279,11 +310,6 @@ public:
|
|||
|
||||
FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild)
|
||||
|
||||
nsIContentFrameMessageManager* GetMessageManager()
|
||||
{
|
||||
return mTabChildGlobal;
|
||||
}
|
||||
|
||||
/**
|
||||
* MessageManagerCallback methods that we override.
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "nsAccessibilityService.h"
|
||||
#endif
|
||||
#include "mozilla/BrowserElementParent.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/ContentBridgeParent.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/DataTransfer.h"
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "nsIContentChild.h"
|
||||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ChildProcessMessageManager.h"
|
||||
#include "mozilla/dom/DOMTypes.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/ContentBridgeParent.h"
|
||||
#include "mozilla/dom/ContentProcessManager.h"
|
||||
|
@ -25,6 +24,7 @@
|
|||
#include "mozilla/ipc/IPCStreamSource.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "xpcpublic.h"
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace dom {
|
|||
class Blob;
|
||||
class BlobConstructorParams;
|
||||
class BlobImpl;
|
||||
class ChromeMessageSender;
|
||||
class ContentParent;
|
||||
class ContentBridgeParent;
|
||||
class IPCTabContext;
|
||||
|
@ -89,7 +88,7 @@ public:
|
|||
|
||||
ContentBridgeParent* AsContentBridgeParent();
|
||||
|
||||
mozilla::dom::ChromeMessageSender* GetMessageManager() const { return mMessageManager; }
|
||||
nsFrameMessageManager* GetMessageManager() const { return mMessageManager; }
|
||||
|
||||
virtual bool SendActivate(PBrowserParent* aTab) = 0;
|
||||
|
||||
|
@ -162,7 +161,7 @@ protected: // IPDL methods
|
|||
const ClonedMessageData& aData);
|
||||
|
||||
protected: // members
|
||||
RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager;
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentParent, NS_ICONTENTPARENT_IID)
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
dump("Loading remote script!\n");
|
||||
dump(content + "\n");
|
||||
|
||||
var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
|
||||
var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsISyncMessageSender);
|
||||
cpm.addMessageListener("cpm-async",
|
||||
function(m) {
|
||||
cpm.sendSyncMessage("ppm-sync");
|
||||
|
|
|
@ -85,11 +85,11 @@
|
|||
// 1. Test that loading a script works, and that accessing process level mm and
|
||||
// global mm works.
|
||||
var ppm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService();
|
||||
.getService(Components.interfaces.nsIMessageBroadcaster);
|
||||
var gm = Components.classes["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService();
|
||||
.getService(Components.interfaces.nsIMessageBroadcaster);
|
||||
var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService();
|
||||
.getService(Components.interfaces.nsISyncMessageSender);
|
||||
|
||||
if (ppm.childCount != 2) {
|
||||
alert("Should have two child processes!");
|
||||
|
|
|
@ -53,7 +53,7 @@ function parentFrameScript(mm) {
|
|||
let finishedTestingBlob = false;
|
||||
let finishedTestingSlice = false;
|
||||
|
||||
mm.addMessageListener(messageName, SpecialPowers.wrapCallback(function(message) {
|
||||
mm.addMessageListener(messageName, function(message) {
|
||||
if ("blob" in message.data) {
|
||||
is(receivedBlob, false, "Have not yet received Blob");
|
||||
is(receivedSlice, false, "Have not yet received Slice");
|
||||
|
@ -64,7 +64,7 @@ function parentFrameScript(mm) {
|
|||
|
||||
let blob = message.data.blob;
|
||||
|
||||
ok(SpecialPowers.call_Instanceof(blob, Blob), "Received a Blob");
|
||||
ok(blob instanceof Blob, "Received a Blob");
|
||||
is(blob.size, blobText.length, "Blob has correct size");
|
||||
is(blob.type, blobType, "Blob has correct type");
|
||||
|
||||
|
@ -73,7 +73,7 @@ function parentFrameScript(mm) {
|
|||
blob.size,
|
||||
blobType);
|
||||
|
||||
ok(SpecialPowers.call_Instanceof(slice, Blob), "Slice returned a Blob");
|
||||
ok(slice instanceof Blob, "Slice returned a Blob");
|
||||
is(slice.size,
|
||||
blobData[blobData.length - 1].length,
|
||||
"Slice has correct size");
|
||||
|
@ -91,7 +91,7 @@ function parentFrameScript(mm) {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
SpecialPowers.wrap(reader).readAsText(slice);
|
||||
reader.readAsText(slice);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ function parentFrameScript(mm) {
|
|||
|
||||
let slice = message.data.slice;
|
||||
|
||||
ok(SpecialPowers.call_Instanceof(slice, Blob), "Received a Blob for slice");
|
||||
ok(slice instanceof Blob, "Received a Blob for slice");
|
||||
is(slice.size, sliceText.length, "Slice has correct size");
|
||||
is(slice.type, blobType, "Slice has correct type");
|
||||
|
||||
|
@ -115,7 +115,7 @@ function parentFrameScript(mm) {
|
|||
|
||||
let slice2 = slice.slice(1, 2, blobType);
|
||||
|
||||
ok(SpecialPowers.call_Instanceof(slice2, Blob), "Slice returned a Blob");
|
||||
ok(slice2 instanceof Blob, "Slice returned a Blob");
|
||||
is(slice2.size, 1, "Slice has correct size");
|
||||
is(slice2.type, blobType, "Slice has correct type");
|
||||
|
||||
|
@ -129,15 +129,15 @@ function parentFrameScript(mm) {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
};
|
||||
SpecialPowers.wrap(reader2).readAsText(slice2);
|
||||
reader2.readAsText(slice2);
|
||||
};
|
||||
SpecialPowers.wrap(reader).readAsText(slice);
|
||||
reader.readAsText(slice);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Received a bad message: " + JSON.stringify(message.data));
|
||||
}));
|
||||
});
|
||||
|
||||
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
|
||||
false);
|
||||
|
|
|
@ -117,13 +117,13 @@ function parentFrameScript(mm) {
|
|||
function* testSteps() {
|
||||
let slice = yield undefined;
|
||||
|
||||
ok(SpecialPowers.call_Instanceof(slice, Blob), "Received a Blob");
|
||||
ok(slice instanceof Blob, "Received a Blob");
|
||||
is(slice.size, sliceText.length, "Slice has correct size");
|
||||
is(slice.type, blobType, "Slice has correct type");
|
||||
|
||||
let reader = new FileReader();
|
||||
reader.onload = grabAndContinue;
|
||||
SpecialPowers.wrap(reader).readAsText(slice);
|
||||
reader.readAsText(slice);
|
||||
yield undefined;
|
||||
|
||||
is(reader.result, sliceText, "Slice has correct data");
|
||||
|
@ -133,7 +133,7 @@ function parentFrameScript(mm) {
|
|||
let testGenerator = testSteps();
|
||||
testGenerator.next();
|
||||
|
||||
mm.addMessageListener(messageName, SpecialPowers.wrapCallback(function(message) {
|
||||
mm.addMessageListener(messageName, function(message) {
|
||||
let data = message.data;
|
||||
switch (data.op) {
|
||||
case "info": {
|
||||
|
@ -156,7 +156,7 @@ function parentFrameScript(mm) {
|
|||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
|
||||
false);
|
||||
|
|
|
@ -52,8 +52,7 @@
|
|||
test.next(msg.data.value);
|
||||
}
|
||||
|
||||
mm.addMessageListener("testBug1086684:childDone",
|
||||
SpecialPowers.wrapCallback(testDone));
|
||||
mm.addMessageListener("testBug1086684:childDone", testDone);
|
||||
|
||||
let blob = new Blob([]);
|
||||
let file = new File([blob], "helloworld.txt", { type: "text/plain" });
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
test.next(msg.data);
|
||||
}
|
||||
|
||||
mm.addMessageListener("testCPOWCookies:test1Finished",
|
||||
SpecialPowers.wrapCallback(testDone));
|
||||
mm.addMessageListener("testCPOWCookies:test1Finished", testDone);
|
||||
|
||||
mm.sendAsyncMessage("testCPOWCookies:test1", {});
|
||||
lastResult = yield;
|
||||
|
|
|
@ -68,8 +68,9 @@ class GlobalPCList {
|
|||
Services.obs.addObserver(this, "gmp-plugin-crash", true);
|
||||
Services.obs.addObserver(this, "PeerConnection:response:allow", true);
|
||||
Services.obs.addObserver(this, "PeerConnection:response:deny", true);
|
||||
if (Services.cpmm) {
|
||||
Services.cpmm.addMessageListener("gmp-plugin-crash", this);
|
||||
if (Cc["@mozilla.org/childprocessmessagemanager;1"]) {
|
||||
let mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
|
||||
mm.addMessageListener("gmp-plugin-crash", this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@ ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
|||
ChromeUtils.defineModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
||||
"@mozilla.org/parentprocessmessagemanager;1",
|
||||
"nsIMessageListenerManager");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "notificationStorage",
|
||||
"@mozilla.org/notificationStorage;1",
|
||||
"nsINotificationStorage");
|
||||
|
@ -52,13 +56,13 @@ var NotificationDB = {
|
|||
|
||||
registerListeners: function() {
|
||||
for (let message of kMessages) {
|
||||
Services.ppmm.addMessageListener(message, this);
|
||||
ppmm.addMessageListener(message, this);
|
||||
}
|
||||
},
|
||||
|
||||
unregisterListeners: function() {
|
||||
for (let message of kMessages) {
|
||||
Services.ppmm.removeMessageListener(message, this);
|
||||
ppmm.removeMessageListener(message, this);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@ const NOTIFICATIONSTORAGE_CONTRACTID = "@mozilla.org/notificationStorage;1";
|
|||
ChromeUtils.defineModuleGetter(this, "Services",
|
||||
"resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
|
||||
const kMessageNotificationGetAllOk = "Notification:GetAll:Return:OK";
|
||||
const kMessageNotificationGetAllKo = "Notification:GetAll:Return:KO";
|
||||
const kMessageNotificationSaveKo = "Notification:Save:Return:KO";
|
||||
|
@ -46,13 +50,13 @@ NotificationStorage.prototype = {
|
|||
|
||||
registerListeners: function() {
|
||||
for (let message of kMessages) {
|
||||
Services.cpmm.addMessageListener(message, this);
|
||||
cpmm.addMessageListener(message, this);
|
||||
}
|
||||
},
|
||||
|
||||
unregisterListeners: function() {
|
||||
for (let message of kMessages) {
|
||||
Services.cpmm.removeMessageListener(message, this);
|
||||
cpmm.removeMessageListener(message, this);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -100,7 +104,7 @@ NotificationStorage.prototype = {
|
|||
};
|
||||
|
||||
if (serviceWorkerRegistrationScope) {
|
||||
Services.cpmm.sendAsyncMessage("Notification:Save", {
|
||||
cpmm.sendAsyncMessage("Notification:Save", {
|
||||
origin: origin,
|
||||
notification: notification
|
||||
});
|
||||
|
@ -145,7 +149,7 @@ NotificationStorage.prototype = {
|
|||
delete this._notifications[id];
|
||||
}
|
||||
|
||||
Services.cpmm.sendAsyncMessage("Notification:Delete", {
|
||||
cpmm.sendAsyncMessage("Notification:Delete", {
|
||||
origin: origin,
|
||||
id: id
|
||||
});
|
||||
|
@ -190,7 +194,7 @@ NotificationStorage.prototype = {
|
|||
};
|
||||
var requestID = this._requestCount++;
|
||||
this._requests[requestID] = request;
|
||||
Services.cpmm.sendAsyncMessage("Notification:GetAll", {
|
||||
cpmm.sendAsyncMessage("Notification:GetAll", {
|
||||
origin: origin,
|
||||
requestID: requestID
|
||||
});
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче