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)
This commit is contained in:
Sebastian Hengst
2018-03-01 11:51:09 +02:00
parent bac13fdc6d
commit 500c4f7ad2
137 changed files with 1270 additions and 2652 deletions

View File

@@ -168,7 +168,8 @@ function waitForSuggestions(cb) {
} }
function waitForContentSearchEvent(messageType, 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) { mm.addMessageListener("ContentSearch", function listener(aMsg) {
if (aMsg.data.type != messageType) { if (aMsg.data.type != messageType) {
return; return;

View File

@@ -42,7 +42,10 @@ var gTests = [
// If we have reached the max process count already, increase it to ensure // If we have reached the max process count already, increase it to ensure
// our new tab can have its own content process. // 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"); let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
// The first check is because if we are on a branch where e10s-multi is // 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. // 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 // If we have reached the max process count already, increase it to ensure
// our new tab can have its own content process. // 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"); let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
// The first check is because if we are on a branch where e10s-multi is // 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. // 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 // If we have reached the max process count already, increase it to ensure
// our new tab can have its own content process. // 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"); let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
// The first check is because if we are on a branch where e10s-multi is // 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. // disabled, we want to keep testing e10s with a single content process.

View File

@@ -19,6 +19,12 @@ add_task(async function testExecuteScript() {
Services.ppmm.getChildAt(0), Services.ppmm.getChildAt(0),
]; ];
for (let mm of messageManagerMap.keys()) { 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)) { if (!globalMMs.includes(mm)) {
++count; ++count;
} }

View File

@@ -3188,13 +3188,14 @@ this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
// Listen for UITour messages. // Listen for UITour messages.
// Do it here instead of the UITour module itself so that the UITour module is lazy loaded // Do it here instead of the UITour module itself so that the UITour module is lazy loaded
// when the first message is received. // 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); UITour.onPageEvent(aMessage, aMessage.data);
}); });
// Listen for HybridContentTelemetry messages. // Listen for HybridContentTelemetry messages.
// Do it here instead of HybridContentTelemetry.init() so that // Do it here instead of HybridContentTelemetry.init() so that
// the module can be lazily loaded on the first message. // 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); HybridContentTelemetry.onTelemetryMessage(aMessage, aMessage.data);
}); });

View File

@@ -15,13 +15,16 @@ const FRAME_SCRIPTS = [
ROOT + "content-forms.js" ROOT + "content-forms.js"
]; ];
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
.getService(Ci.nsIMessageListenerManager);
for (let script of FRAME_SCRIPTS) { for (let script of FRAME_SCRIPTS) {
Services.mm.loadFrameScript(script, true); globalMM.loadFrameScript(script, true);
} }
registerCleanupFunction(() => { registerCleanupFunction(() => {
for (let script of FRAME_SCRIPTS) { for (let script of FRAME_SCRIPTS) {
Services.mm.removeDelayedFrameScript(script, true); globalMM.removeDelayedFrameScript(script, true);
} }
}); });

View File

@@ -68,7 +68,8 @@ var PdfjsChromeUtils = {
this._browsers = new WeakSet(); this._browsers = new WeakSet();
if (!this._ppmm) { if (!this._ppmm) {
// global parent process message manager (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:clearUserPref", this);
this._ppmm.addMessageListener("PDFJS:Parent:setIntPref", this); this._ppmm.addMessageListener("PDFJS:Parent:setIntPref", this);
this._ppmm.addMessageListener("PDFJS:Parent:setBoolPref", this); this._ppmm.addMessageListener("PDFJS:Parent:setBoolPref", this);
@@ -77,7 +78,8 @@ var PdfjsChromeUtils = {
this._ppmm.addMessageListener("PDFJS:Parent:isDefaultHandlerApp", this); this._ppmm.addMessageListener("PDFJS:Parent:isDefaultHandlerApp", this);
// global dom message manager (MMg) // 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:displayWarning", this);
this._mmg.addMessageListener("PDFJS:Parent:addEventListener", this); this._mmg.addMessageListener("PDFJS:Parent:addEventListener", this);

View File

@@ -35,7 +35,8 @@ var PdfjsContentUtils = {
// child *process* mm, or when loaded into the parent for in-content // child *process* mm, or when loaded into the parent for in-content
// support the psuedo child process mm 'child PPMM'. // support the psuedo child process mm 'child PPMM'.
if (!this._mm) { if (!this._mm) {
this._mm = Services.cpmm; this._mm = Cc["@mozilla.org/childprocessmessagemanager;1"].
getService(Ci.nsISyncMessageSender);
this._mm.addMessageListener("PDFJS:Child:updateSettings", this); this._mm.addMessageListener("PDFJS:Child:updateSettings", this);
Services.obs.addObserver(this, "quit-application"); Services.obs.addObserver(this, "quit-application");

View File

@@ -408,7 +408,9 @@ var PocketOverlay = {
} }
}, },
shutdown(reason) { 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"); Services.obs.removeObserver(this, "browser-delayed-startup-finished");
// Although the ppmm loads the scripts into the chrome process as well, // 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 // we need to manually unregister here anyway to ensure these aren't part

View File

@@ -178,7 +178,8 @@ var AboutHome = {
if (target && target.messageManager) { if (target && target.messageManager) {
target.messageManager.sendAsyncMessage("AboutHome:Update", data); target.messageManager.sendAsyncMessage("AboutHome:Update", data);
} else { } 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) { }).catch(function onError(x) {
Cu.reportError("Error in AboutHome.sendAboutHomeData: " + x); Cu.reportError("Error in AboutHome.sendAboutHomeData: " + x);

View File

@@ -995,10 +995,12 @@ var PluginCrashReporter = {
// Only the parent process gets the gmp-plugin-crash observer // Only the parent process gets the gmp-plugin-crash observer
// notification, so we need to inform any content processes that // notification, so we need to inform any content processes that
// the GMP has crashed. // the GMP has crashed.
if (Services.ppmm) { if (Cc["@mozilla.org/parentprocessmessagemanager;1"]) {
let pluginName = propertyBag.getPropertyAsAString("pluginName"); let pluginName = propertyBag.getPropertyAsAString("pluginName");
Services.ppmm.broadcastAsyncMessage("gmp-plugin-crash", let mm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
{ pluginName, pluginID }); .getService(Ci.nsIMessageListenerManager);
mm.broadcastAsyncMessage("gmp-plugin-crash",
{ pluginName, pluginID });
} }
break; break;
} }

View File

@@ -489,7 +489,9 @@ var ContentSearch = {
}, },
_broadcast(type, data) { _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) { _msgArgs(type, data) {

View File

@@ -6,7 +6,7 @@
"use strict"; "use strict";
const {Ci, Cu, CC} = require("chrome"); const {Cc, Ci, Cu, CC} = require("chrome");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm"); const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const Services = require("Services"); const Services = require("Services");
@@ -17,6 +17,9 @@ loader.lazyGetter(this, "debug", function () {
return !!(AppConstants.DEBUG || AppConstants.DEBUG_JS_MODULES); return !!(AppConstants.DEBUG || AppConstants.DEBUG_JS_MODULES);
}); });
const childProcessMessageManager =
Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsISyncMessageSender);
const BinaryInput = CC("@mozilla.org/binaryinputstream;1", const BinaryInput = CC("@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream", "setInputStream"); "nsIBinaryInputStream", "setInputStream");
const BufferStream = CC("@mozilla.org/io/arraybuffer-input-stream;1", const BufferStream = CC("@mozilla.org/io/arraybuffer-input-stream;1",
@@ -301,7 +304,7 @@ function onContentMessage(e) {
let value = e.detail.value; let value = e.detail.value;
switch (e.detail.type) { switch (e.detail.type) {
case "save": case "save":
Services.cpmm.sendAsyncMessage( childProcessMessageManager.sendAsyncMessage(
"devtools:jsonview:save", value); "devtools:jsonview:save", value);
} }
} }

View File

@@ -23,7 +23,7 @@ add_task(async function () {
await waitForContentRequests; await waitForContentRequests;
info("Clicking stack-trace tab and waiting for stack-trace panel to open"); 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 // Click on the first request
EventUtils.sendMouseEvent({ type: "mousedown" }, EventUtils.sendMouseEvent({ type: "mousedown" },
document.querySelector(".request-list-item")); document.querySelector(".request-list-item"));

View File

@@ -20,10 +20,12 @@ function waitForDeviceClosed() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const message = "webrtc:UpdateGlobalIndicators"; 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"); info("Received " + message + " message");
if (!aMessage.data.showGlobalIndicator) { if (!aMessage.data.showGlobalIndicator) {
Services.ppmm.removeMessageListener(message, listener); ppmm.removeMessageListener(message, listener);
resolve(); resolve();
} }
}); });

View File

@@ -4,10 +4,11 @@
"use strict"; "use strict";
var { Cc } = require("chrome"); var { Cc, Ci } = require("chrome");
loader.lazyGetter(this, "ppmm", () => { loader.lazyGetter(this, "ppmm", () => {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(); return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(
Ci.nsIMessageBroadcaster);
}); });
function ProcessActorList() { function ProcessActorList() {

View File

@@ -6,11 +6,15 @@
"use strict"; "use strict";
const { Cu } = require("chrome"); const { Cc, Ci, Cu } = require("chrome");
const Services = require("Services"); const Services = require("Services");
const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common"); const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common");
const { DebuggerServer } = require("devtools/server/main"); const { DebuggerServer } = require("devtools/server/main");
loader.lazyGetter(this, "ppmm", () => {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(
Ci.nsIMessageBroadcaster);
});
loader.lazyRequireGetter(this, "WindowActor", loader.lazyRequireGetter(this, "WindowActor",
"devtools/server/actors/window", true); "devtools/server/actors/window", true);
@@ -543,7 +547,7 @@ RootActor.prototype = {
} }
let { id } = request; let { id } = request;
let mm = Services.ppmm.getChildAt(id); let mm = ppmm.getChildAt(id);
if (!mm) { if (!mm) {
return { error: "noProcess", return { error: "noProcess",
message: "There is no process with id '" + id + "'." }; message: "There is no process with id '" + id + "'." };

View File

@@ -4,7 +4,7 @@
"use strict"; "use strict";
const {Ci, Cu, CC} = require("chrome"); const {Cc, Ci, Cu, CC} = require("chrome");
const protocol = require("devtools/shared/protocol"); const protocol = require("devtools/shared/protocol");
const {LongStringActor} = require("devtools/server/actors/string"); const {LongStringActor} = require("devtools/server/actors/string");
const {DebuggerServer} = require("devtools/server/main"); const {DebuggerServer} = require("devtools/server/main");
@@ -1938,14 +1938,20 @@ StorageActors.createActor({
var indexedDBHelpers = { var indexedDBHelpers = {
backToChild(...args) { 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", method: "backToChild",
args: args args: args
}); });
}, },
onItemUpdated(action, host, path) { 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", method: "onItemUpdated",
args: [ action, host, path ] args: [ action, host, path ]
}); });

View File

@@ -7,6 +7,9 @@
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {}); const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {}); const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
ChromeUtils.defineModuleGetter(this, "E10SUtils", ChromeUtils.defineModuleGetter(this, "E10SUtils",
"resource://gre/modules/E10SUtils.jsm"); "resource://gre/modules/E10SUtils.jsm");
@@ -34,7 +37,7 @@ const MSG_MGR_CONSOLE_INFO_MAX = 1024;
function ContentProcessForward() { function ContentProcessForward() {
Services.obs.addObserver(this, "console-api-log-event"); Services.obs.addObserver(this, "console-api-log-event");
Services.obs.addObserver(this, "xpcom-shutdown"); Services.obs.addObserver(this, "xpcom-shutdown");
Services.cpmm.addMessageListener("DevTools:StopForwardingContentProcessMessage", this); cpmm.addMessageListener("DevTools:StopForwardingContentProcessMessage", this);
} }
ContentProcessForward.prototype = { ContentProcessForward.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
@@ -105,7 +108,7 @@ ContentProcessForward.prototype = {
} }
} }
Services.cpmm.sendAsyncMessage("Console:Log", msgData); cpmm.sendAsyncMessage("Console:Log", msgData);
break; break;
} }
@@ -118,8 +121,7 @@ ContentProcessForward.prototype = {
uninit() { uninit() {
Services.obs.removeObserver(this, "console-api-log-event"); Services.obs.removeObserver(this, "console-api-log-event");
Services.obs.removeObserver(this, "xpcom-shutdown"); Services.obs.removeObserver(this, "xpcom-shutdown");
Services.cpmm.removeMessageListener("DevTools:StopForwardingContentProcessMessage", cpmm.removeMessageListener("DevTools:StopForwardingContentProcessMessage", this);
this);
} }
}; };

View File

@@ -49,6 +49,7 @@ function setupServer(mm) {
function init(msg) { function init(msg) {
let mm = msg.target; let mm = msg.target;
mm.QueryInterface(Ci.nsISyncMessageSender);
let prefix = msg.data.prefix; let prefix = msg.data.prefix;
// Using the JS debugger causes problems when we're trying to // Using the JS debugger causes problems when we're trying to

View File

@@ -1,7 +1,8 @@
"use strict"; "use strict";
const {Cc} = require("chrome"); const {Cc, Ci} = require("chrome");
const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(); const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsIMessageListenerManager);
const { DebuggerServer } = require("devtools/server/main"); const { DebuggerServer } = require("devtools/server/main");
exports.setupChild = function (a, b, c) { exports.setupChild = function (a, b, c) {

View File

@@ -49,8 +49,10 @@ function runTests() {
let client = new DebuggerClient(transport); let client = new DebuggerClient(transport);
// Wait for a response from setupInChild // Wait for a response from setupInChild
const ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageListenerManager);
let onChild = msg => { let onChild = msg => {
Services.ppmm.removeMessageListener("test:setupChild", onChild); ppmm.removeMessageListener("test:setupChild", onChild);
let args = msg.json; let args = msg.json;
is(args[0], 1, "Got first numeric argument"); is(args[0], 1, "Got first numeric argument");
@@ -63,7 +65,7 @@ function runTests() {
setupChild: "callParent" 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 // Wait also for a reponse from setupInParent called from setup-in-child.js
let onParent = (_, topic, args) => { let onParent = (_, topic, args) => {

View File

@@ -649,10 +649,11 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
*aSink = GetTabChild().take(); *aSink = GetTabChild().take();
return *aSink ? NS_OK : NS_ERROR_FAILURE; return *aSink ? NS_OK : NS_ERROR_FAILURE;
} else if (aIID.Equals(NS_GET_IID(nsIContentFrameMessageManager))) { } 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; nsCOMPtr<nsIContentFrameMessageManager> mm;
if (tabChild) { if (tabChild) {
mm = tabChild->GetMessageManager(); tabChild->GetMessageManager(getter_AddRefs(mm));
} else { } else {
if (nsPIDOMWindowOuter* win = GetWindow()) { if (nsPIDOMWindowOuter* win = GetWindow()) {
mm = do_QueryInterface(win->GetParentTarget()); mm = do_QueryInterface(win->GetParentTarget());

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -12,10 +12,8 @@
#include "mozilla/dom/DOMPointBinding.h" #include "mozilla/dom/DOMPointBinding.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ToJSValue.h" #include "mozilla/dom/ToJSValue.h"
#include "mozilla/RuleNodeCacheConditions.h"
#include "mozilla/ServoCSSParser.h" #include "mozilla/ServoCSSParser.h"
#include "nsCSSParser.h" #include "nsCSSParser.h"
#include "nsGlobalWindowInner.h"
#include "nsStyleTransformMatrix.h" #include "nsStyleTransformMatrix.h"
#include <math.h> #include <math.h>

View File

@@ -21,6 +21,10 @@ var EXPORTED_SYMBOLS = ["DOMRequestIpcHelper"];
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageListenerManager");
function DOMRequestIpcHelper() { function DOMRequestIpcHelper() {
// _listeners keeps a list of messages for which we added a listener and the // _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 // 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) aMsg.weakRef ? cpmm.addWeakMessageListener(name, this)
: Services.cpmm.addMessageListener(name, this); : cpmm.addMessageListener(name, this);
this._listeners[name] = { this._listeners[name] = {
weakRef: !!aMsg.weakRef, weakRef: !!aMsg.weakRef,
count: 1 count: 1
@@ -116,8 +120,8 @@ DOMRequestIpcHelper.prototype = {
// be waiting on a message. // be waiting on a message.
if (!--this._listeners[aName].count) { if (!--this._listeners[aName].count) {
this._listeners[aName].weakRef ? this._listeners[aName].weakRef ?
Services.cpmm.removeWeakMessageListener(aName, this) cpmm.removeWeakMessageListener(aName, this)
: Services.cpmm.removeMessageListener(aName, this); : cpmm.removeMessageListener(aName, this);
delete this._listeners[aName]; delete this._listeners[aName];
} }
}); });
@@ -177,9 +181,8 @@ DOMRequestIpcHelper.prototype = {
if (this._listeners) { if (this._listeners) {
Object.keys(this._listeners).forEach((aName) => { Object.keys(this._listeners).forEach((aName) => {
this._listeners[aName].weakRef ? this._listeners[aName].weakRef ? cpmm.removeWeakMessageListener(aName, this)
Services.cpmm.removeWeakMessageListener(aName, this) : cpmm.removeMessageListener(aName, this);
: Services.cpmm.removeMessageListener(aName, this);
}); });
} }

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -7,16 +7,17 @@
#include "ProcessGlobal.h" #include "ProcessGlobal.h"
#include "nsContentCID.h" #include "nsContentCID.h"
#include "mozilla/dom/MessageManagerBinding.h" #include "nsDOMClassInfoID.h"
#include "mozilla/dom/ResolveSystemBinding.h" #include "mozilla/HoldDropJSObjects.h"
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
ProcessGlobal::ProcessGlobal(nsFrameMessageManager* aMessageManager) ProcessGlobal::ProcessGlobal(nsFrameMessageManager* aMessageManager)
: MessageManagerGlobal(aMessageManager), : mInitialized(false),
mInitialized(false) mMessageManager(aMessageManager)
{ {
SetIsNotDOMBinding();
mozilla::HoldJSObjects(this); mozilla::HoldJSObjects(this);
} }
@@ -26,36 +27,6 @@ ProcessGlobal::~ProcessGlobal()
mozilla::DropJSObjects(this); 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*
ProcessGlobal::Get() ProcessGlobal::Get()
{ {
@@ -72,7 +43,7 @@ NS_IMETHODIMP_(bool)
ProcessGlobal::MarkForCC() ProcessGlobal::MarkForCC()
{ {
MarkScopesForCC(); MarkScopesForCC();
return MessageManagerGlobal::MarkForCC(); return mMessageManager ? mMessageManager->MarkForCC() : false;
} }
NS_IMPL_CYCLE_COLLECTION_CLASS(ProcessGlobal) 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(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentProcessMessageManager)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(ProcessGlobal) NS_IMPL_CYCLE_COLLECTING_ADDREF(ProcessGlobal)
@@ -117,30 +89,15 @@ ProcessGlobal::Init()
} }
mInitialized = true; mInitialized = true;
return InitChildGlobalInternal(NS_LITERAL_CSTRING("processChildGlobal")); nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIContentProcessMessageManager*, this);
} return InitChildGlobalInternal(scopeSupports, 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;
} }
void void
ProcessGlobal::LoadScript(const nsAString& aURL) ProcessGlobal::LoadScript(const nsAString& aURL)
{ {
Init(); Init();
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper()); LoadScriptInternal(aURL, false);
LoadScriptInternal(global, aURL, false);
} }
void void

View File

@@ -8,7 +8,6 @@
#define mozilla_dom_ProcessGlobal_h #define mozilla_dom_ProcessGlobal_h
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/dom/MessageManagerGlobal.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsFrameMessageManager.h" #include "nsFrameMessageManager.h"
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
@@ -26,26 +25,18 @@ namespace mozilla {
namespace dom { namespace dom {
class ProcessGlobal : class ProcessGlobal :
public nsIContentProcessMessageManager,
public nsMessageManagerScriptExecutor, public nsMessageManagerScriptExecutor,
public nsIContentProcessMessageManager,
public nsIGlobalObject, public nsIGlobalObject,
public nsIScriptObjectPrincipal, public nsIScriptObjectPrincipal,
public nsSupportsWeakReference, public nsSupportsWeakReference,
public ipc::MessageManagerCallback, public mozilla::dom::ipc::MessageManagerCallback,
public MessageManagerGlobal,
public nsWrapperCache public nsWrapperCache
{ {
public: public:
explicit ProcessGlobal(nsFrameMessageManager* aMessageManager); explicit ProcessGlobal(nsFrameMessageManager* aMessageManager);
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj, using mozilla::dom::ipc::MessageManagerCallback::GetProcessMessageManager;
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;
bool Init(); bool Init();
@@ -54,41 +45,6 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ProcessGlobal, nsIContentProcessMessageManager) 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_NSIMESSAGELISTENERMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager) NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager)
@@ -99,10 +55,15 @@ public:
virtual JSObject* GetGlobalJSObject() override virtual JSObject* GetGlobalJSObject() override
{ {
return GetWrapper(); return mGlobal;
} }
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; } 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); void SetInitialProcessData(JS::HandleValue aInitialData);
protected: protected:
@@ -110,6 +71,7 @@ protected:
private: private:
bool mInitialized; bool mInitialized;
RefPtr<nsFrameMessageManager> mMessageManager;
}; };
} // namespace dom } // namespace dom

View File

@@ -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

View File

@@ -18,7 +18,6 @@
#include "nsPIDOMWindow.h" #include "nsPIDOMWindow.h"
#include "nsPresContext.h" #include "nsPresContext.h"
using mozilla::dom::KeyboardEvent;
using namespace mozilla::widget; using namespace mozilla::widget;
namespace mozilla { namespace mozilla {

View File

@@ -8,7 +8,6 @@
#include "mozilla/dom/TimeoutManager.h" #include "mozilla/dom/TimeoutManager.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsIEventTarget.h"
#include "nsString.h" #include "nsString.h"
namespace mozilla { namespace mozilla {

View File

@@ -12,7 +12,6 @@
class nsIEventTarget; class nsIEventTarget;
class nsITimeoutHandler; class nsITimeoutHandler;
class nsITimer;
class nsGlobalWindowInner; class nsGlobalWindowInner;
namespace mozilla { namespace mozilla {

View File

@@ -156,13 +156,9 @@ EXPORTS.mozilla.dom += [
'BodyUtil.h', 'BodyUtil.h',
'BorrowedAttrInfo.h', 'BorrowedAttrInfo.h',
'ChildIterator.h', 'ChildIterator.h',
'ChildProcessMessageManager.h',
'ChromeMessageBroadcaster.h',
'ChromeMessageSender.h',
'ChromeNodeList.h', 'ChromeNodeList.h',
'ChromeUtils.h', 'ChromeUtils.h',
'Comment.h', 'Comment.h',
'ContentFrameMessageManager.h',
'CustomElementRegistry.h', 'CustomElementRegistry.h',
'DirectionalityUtils.h', 'DirectionalityUtils.h',
'DispatcherTrait.h', 'DispatcherTrait.h',
@@ -199,9 +195,6 @@ EXPORTS.mozilla.dom += [
'IntlUtils.h', 'IntlUtils.h',
'Link.h', 'Link.h',
'Location.h', 'Location.h',
'MessageListenerManager.h',
'MessageManagerGlobal.h',
'MessageSender.h',
'NameSpaceConstants.h', 'NameSpaceConstants.h',
'Navigator.h', 'Navigator.h',
'NodeInfo.h', 'NodeInfo.h',
@@ -219,7 +212,6 @@ EXPORTS.mozilla.dom += [
'StructuredCloneTags.h', 'StructuredCloneTags.h',
'StyleSheetList.h', 'StyleSheetList.h',
'SubtleCrypto.h', 'SubtleCrypto.h',
'SyncMessageSender.h',
'TabGroup.h', 'TabGroup.h',
'Text.h', 'Text.h',
'Timeout.h', 'Timeout.h',
@@ -242,8 +234,6 @@ UNIFIED_SOURCES += [
'BodyUtil.cpp', 'BodyUtil.cpp',
'BorrowedAttrInfo.cpp', 'BorrowedAttrInfo.cpp',
'ChildIterator.cpp', 'ChildIterator.cpp',
'ChromeMessageBroadcaster.cpp',
'ChromeMessageSender.cpp',
'ChromeNodeList.cpp', 'ChromeNodeList.cpp',
'ChromeUtils.cpp', 'ChromeUtils.cpp',
'Comment.cpp', 'Comment.cpp',
@@ -279,8 +269,6 @@ UNIFIED_SOURCES += [
'IntlUtils.cpp', 'IntlUtils.cpp',
'Link.cpp', 'Link.cpp',
'Location.cpp', 'Location.cpp',
'MessageListenerManager.cpp',
'MessageSender.cpp',
'Navigator.cpp', 'Navigator.cpp',
'NodeInfo.cpp', 'NodeInfo.cpp',
'NodeIterator.cpp', 'NodeIterator.cpp',

View File

@@ -17,6 +17,7 @@
#include "nsISHistory.h" #include "nsISHistory.h"
#include "nsISHEntry.h" #include "nsISHEntry.h"
#include "nsISHContainer.h" #include "nsISHContainer.h"
#include "nsITabChild.h"
#include "nsIWindowWatcher.h" #include "nsIWindowWatcher.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "nsIXULWindow.h" #include "nsIXULWindow.h"
@@ -32,7 +33,6 @@
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/ProcessGlobal.h" #include "mozilla/dom/ProcessGlobal.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/dom/TimeoutManager.h" #include "mozilla/dom/TimeoutManager.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "nsObserverService.h" #include "nsObserverService.h"
@@ -311,9 +311,11 @@ MarkWindowList(nsISimpleEnumerator* aWindowList, bool aCleanupJS,
MarkDocShell(rootDocShell, aCleanupJS, aPrepareForCC); MarkDocShell(rootDocShell, aCleanupJS, aPrepareForCC);
RefPtr<TabChild> tabChild = TabChild::GetFrom(rootDocShell); nsCOMPtr<nsITabChild> tabChild =
rootDocShell ? rootDocShell->GetTabChild() : nullptr;
if (tabChild) { if (tabChild) {
nsCOMPtr<nsIContentFrameMessageManager> mm = tabChild->GetMessageManager(); nsCOMPtr<nsIContentFrameMessageManager> mm;
tabChild->GetMessageManager(getter_AddRefs(mm));
if (mm) { if (mm) {
// MarkForCC ends up calling UnmarkGray on message listeners, which // MarkForCC ends up calling UnmarkGray on message listeners, which
// TraceBlackJS can't do yet. // TraceBlackJS can't do yet.
@@ -531,7 +533,7 @@ mozilla::dom::TraceBlackJS(JSTracer* aTrc, bool aIsShutdownGC)
if (ds) { if (ds) {
nsCOMPtr<nsITabChild> tabChild = ds->GetTabChild(); nsCOMPtr<nsITabChild> tabChild = ds->GetTabChild();
if (tabChild) { if (tabChild) {
nsCOMPtr<nsISupports> mm; nsCOMPtr<nsIContentFrameMessageManager> mm;
tabChild->GetMessageManager(getter_AddRefs(mm)); tabChild->GetMessageManager(getter_AddRefs(mm));
nsCOMPtr<EventTarget> et = do_QueryInterface(mm); nsCOMPtr<EventTarget> et = do_QueryInterface(mm);
if (et) { if (et) {

View File

@@ -18,7 +18,6 @@
#include "nsElementTable.h" #include "nsElementTable.h"
using mozilla::DebugOnly; using mozilla::DebugOnly;
using mozilla::Move;
using mozilla::RawRangeBoundary; using mozilla::RawRangeBoundary;
// couple of utility static functs // couple of utility static functs

View File

@@ -73,6 +73,7 @@
// includes needed for the prototype chain interfaces // includes needed for the prototype chain interfaces
#include "nsIEventListenerService.h" #include "nsIEventListenerService.h"
#include "nsIMessageManager.h"
#include "mozilla/dom/TouchEvent.h" #include "mozilla/dom/TouchEvent.h"
@@ -130,6 +131,9 @@ using namespace mozilla::dom;
#define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \ #define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, false, false) 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) \ #define NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(_class, _helper, _flags) \
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, true) NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, true)
@@ -164,6 +168,22 @@ static nsDOMClassInfoData sClassInfoData[] = {
// Misc Core related classes // 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, NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULControlElement, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS) DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULLabeledControlElement, nsDOMGenericSH, NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULLabeledControlElement, nsDOMGenericSH,
@@ -405,6 +425,36 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor) DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
DOM_CLASSINFO_MAP_END 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_BEGIN_NO_CLASS_IF(XULControlElement, nsIDOMXULControlElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULControlElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMXULControlElement)
DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_END
@@ -1872,3 +1922,41 @@ nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval); 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;
}

View File

@@ -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___ */ #endif /* nsDOMClassInfo_h___ */

View File

@@ -19,6 +19,11 @@ enum nsDOMClassInfoID
eDOMClassInfo_DOMPrototype_id, eDOMClassInfo_DOMPrototype_id,
eDOMClassInfo_DOMConstructor_id, eDOMClassInfo_DOMConstructor_id,
eDOMClassInfo_ContentFrameMessageManager_id,
eDOMClassInfo_ContentProcessMessageManager_id,
eDOMClassInfo_ChromeMessageBroadcaster_id,
eDOMClassInfo_ChromeMessageSender_id,
eDOMClassInfo_XULControlElement_id, eDOMClassInfo_XULControlElement_id,
eDOMClassInfo_XULLabeledControlElement_id, eDOMClassInfo_XULLabeledControlElement_id,
eDOMClassInfo_XULButtonElement_id, eDOMClassInfo_XULButtonElement_id,

View File

@@ -79,7 +79,6 @@
#include "mozilla/HTMLEditor.h" #include "mozilla/HTMLEditor.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/dom/ChromeMessageSender.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/FrameLoaderBinding.h" #include "mozilla/dom/FrameLoaderBinding.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
@@ -1643,12 +1642,14 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager; RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
// Swap pointers in child message managers. // Swap pointers in child message managers.
if (mChildMessageManager) { if (mChildMessageManager) {
nsInProcessTabChildGlobal* tabChild = mChildMessageManager; nsInProcessTabChildGlobal* tabChild =
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
tabChild->SetOwner(otherContent); tabChild->SetOwner(otherContent);
tabChild->SetChromeMessageManager(otherMessageManager); tabChild->SetChromeMessageManager(otherMessageManager);
} }
if (aOther->mChildMessageManager) { if (aOther->mChildMessageManager) {
nsInProcessTabChildGlobal* otherTabChild = aOther->mChildMessageManager; nsInProcessTabChildGlobal* otherTabChild =
static_cast<nsInProcessTabChildGlobal*>(aOther->mChildMessageManager.get());
otherTabChild->SetOwner(ourContent); otherTabChild->SetOwner(ourContent);
otherTabChild->SetChromeMessageManager(ourMessageManager); otherTabChild->SetChromeMessageManager(ourMessageManager);
} }
@@ -1883,7 +1884,7 @@ nsFrameLoader::DestroyDocShell()
// Fire the "unload" event if we're in-process. // Fire the "unload" event if we're in-process.
if (mChildMessageManager) { if (mChildMessageManager) {
mChildMessageManager->FireUnloadEvent(); static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->FireUnloadEvent();
} }
// Destroy the docshell. // Destroy the docshell.
@@ -1895,7 +1896,7 @@ nsFrameLoader::DestroyDocShell()
if (mChildMessageManager) { if (mChildMessageManager) {
// Stop handling events in the in-process frame script. // 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) { if (mChildMessageManager) {
mChildMessageManager->Disconnect(); static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->Disconnect();
} }
mMessageManager = nullptr; mMessageManager = nullptr;
@@ -2986,11 +2987,12 @@ public:
NS_IMETHOD Run() override 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. // Since bug 1126089, messages can arrive even when the docShell is destroyed.
// Here we make sure that those messages are not delivered. // Here we make sure that those messages are not delivered.
if (tabChild && tabChild->GetInnerManager() && mFrameLoader->GetExistingDocShell()) { 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, ReceiveMessage(static_cast<EventTarget*>(tabChild), mFrameLoader,
tabChild->GetInnerManager()); tabChild->GetInnerManager());
} }
@@ -3104,8 +3106,9 @@ nsFrameLoader::EnsureMessageManager()
parentManager = do_GetService("@mozilla.org/globalmessagemanager;1"); parentManager = do_GetService("@mozilla.org/globalmessagemanager;1");
} }
mMessageManager = new ChromeMessageSender(nullptr, mMessageManager = new nsFrameMessageManager(nullptr,
static_cast<nsFrameMessageManager*>(parentManager.get())); static_cast<nsFrameMessageManager*>(parentManager.get()),
MM_CHROME);
if (!IsRemoteFrame()) { if (!IsRemoteFrame()) {
nsresult rv = MaybeCreateDocShell(); nsresult rv = MaybeCreateDocShell();
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
@@ -3138,7 +3141,7 @@ nsFrameLoader::ReallyLoadFrameScripts()
EventTarget* EventTarget*
nsFrameLoader::GetTabChildGlobalAsEventTarget() nsFrameLoader::GetTabChildGlobalAsEventTarget()
{ {
return mChildMessageManager.get(); return static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
} }
already_AddRefed<Element> already_AddRefed<Element>

View File

@@ -32,7 +32,7 @@
class nsIURI; class nsIURI;
class nsSubDocumentFrame; class nsSubDocumentFrame;
class nsView; class nsView;
class nsInProcessTabChildGlobal; class nsIInProcessContentFrameMessageManager;
class AutoResetInShow; class AutoResetInShow;
class AutoResetInFrameSwap; class AutoResetInFrameSwap;
class nsITabParent; class nsITabParent;
@@ -44,7 +44,6 @@ namespace mozilla {
class OriginAttributes; class OriginAttributes;
namespace dom { namespace dom {
class ChromeMessageSender;
class ContentParent; class ContentParent;
class PBrowserParent; class PBrowserParent;
class Promise; class Promise;
@@ -269,7 +268,7 @@ public:
*/ */
RenderFrameParent* GetCurrentRenderFrame() const; RenderFrameParent* GetCurrentRenderFrame() const;
mozilla::dom::ChromeMessageSender* GetFrameMessageManager() { return mMessageManager; } nsFrameMessageManager* GetFrameMessageManager() { return mMessageManager; }
mozilla::dom::Element* GetOwnerContent() { return mOwnerContent; } mozilla::dom::Element* GetOwnerContent() { return mOwnerContent; }
bool ShouldClipSubdocument() { return mClipSubdocument; } bool ShouldClipSubdocument() { return mClipSubdocument; }
@@ -320,8 +319,8 @@ public:
virtual nsIMessageSender* GetProcessMessageManager() const override; virtual nsIMessageSender* GetProcessMessageManager() const override;
// public because a callback needs these. // public because a callback needs these.
RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager; RefPtr<nsFrameMessageManager> mMessageManager;
RefPtr<nsInProcessTabChildGlobal> mChildMessageManager; nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override; virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;

File diff suppressed because it is too large Load Diff

View File

@@ -28,8 +28,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "js/RootingAPI.h" #include "js/RootingAPI.h"
#include "nsTObserverArray.h" #include "nsTObserverArray.h"
#include "mozilla/TypedEnumBits.h"
#include "mozilla/dom/CallbackObject.h"
#include "mozilla/dom/SameProcessMessageQueue.h" #include "mozilla/dom/SameProcessMessageQueue.h"
#include "mozilla/dom/ipc/StructuredCloneData.h" #include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/jsipc/CpowHolder.h" #include "mozilla/jsipc/CpowHolder.h"
@@ -41,13 +39,8 @@ namespace dom {
class nsIContentParent; class nsIContentParent;
class nsIContentChild; class nsIContentChild;
class ChildProcessMessageManager;
class ChromeMessageSender;
class ClonedMessageData; class ClonedMessageData;
class MessageListener;
class MessageListenerManager;
class MessageManagerReporter; class MessageManagerReporter;
template<typename T> class Optional;
namespace ipc { namespace ipc {
@@ -55,15 +48,14 @@ namespace ipc {
// of 1 ms actually captures from 500us and above. // of 1 ms actually captures from 500us and above.
static const uint32_t kMinTelemetrySyncMessageManagerLatencyMs = 1; static const uint32_t kMinTelemetrySyncMessageManagerLatencyMs = 1;
enum class MessageManagerFlags { enum MessageManagerFlags {
MM_NONE = 0, MM_CHILD = 0,
MM_CHROME = 1, MM_CHROME = 1,
MM_GLOBAL = 2, MM_GLOBAL = 2,
MM_PROCESSMANAGER = 4, MM_PROCESSMANAGER = 4,
MM_BROADCASTER = 8, MM_BROADCASTER = 8,
MM_OWNSCALLBACK = 16 MM_OWNSCALLBACK = 16
}; };
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(MessageManagerFlags);
class MessageManagerCallback class MessageManagerCallback
{ {
@@ -126,10 +118,6 @@ void UnpackClonedMessageDataForChild(const ClonedMessageData& aClonedData,
StructuredCloneData& aData); StructuredCloneData& aData);
} // namespace ipc } // namespace ipc
typedef CallbackObjectHolder<mozilla::dom::MessageListener,
nsIMessageListener> MessageListenerHolder;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla
@@ -140,22 +128,12 @@ struct nsMessageListenerInfo
return &aOther == this; return &aOther == this;
} }
// If mWeakListener is null then mStrongListener holds either a MessageListener or an // Exactly one of mStrongListener and mWeakListener must be non-null.
// nsIMessageListener. If mWeakListener is non-null then mStrongListener contains null. nsCOMPtr<nsIMessageListener> mStrongListener;
mozilla::dom::MessageListenerHolder mStrongListener;
nsWeakPtr mWeakListener; nsWeakPtr mWeakListener;
bool mListenWhenClosed; 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 class MOZ_STACK_CLASS SameProcessCpowHolder : public mozilla::jsipc::CpowHolder
{ {
@@ -172,86 +150,25 @@ private:
JS::Rooted<JSObject*> mObj; JS::Rooted<JSObject*> mObj;
}; };
class nsFrameMessageManager : public nsIContentFrameMessageManager, class nsFrameMessageManager final : public nsIContentFrameMessageManager,
public nsIMessageBroadcaster, public nsIMessageBroadcaster,
public nsIFrameScriptLoader, public nsIFrameScriptLoader,
public nsIGlobalProcessScriptLoader public nsIGlobalProcessScriptLoader
{ {
friend class mozilla::dom::MessageManagerReporter; friend class mozilla::dom::MessageManagerReporter;
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData; typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
public:
protected:
typedef mozilla::dom::ipc::MessageManagerFlags MessageManagerFlags;
nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback, nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback,
MessageManagerFlags aFlags); nsFrameMessageManager* aParentManager,
/* mozilla::dom::ipc::MessageManagerFlags */ uint32_t aFlags);
virtual ~nsFrameMessageManager(); private:
~nsFrameMessageManager();
public: public:
explicit nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback)
: nsFrameMessageManager(aCallback, MessageManagerFlags::MM_NONE)
{}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFrameMessageManager, NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFrameMessageManager,
nsIContentFrameMessageManager) 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_NSIMESSAGELISTENERMANAGER
NS_DECL_NSIMESSAGESENDER NS_DECL_NSIMESSAGESENDER
NS_DECL_NSIMESSAGEBROADCASTER NS_DECL_NSIMESSAGEBROADCASTER
@@ -262,7 +179,7 @@ public:
NS_DECL_NSIPROCESSSCRIPTLOADER NS_DECL_NSIPROCESSSCRIPTLOADER
NS_DECL_NSIGLOBALPROCESSSCRIPTLOADER NS_DECL_NSIGLOBALPROCESSSCRIPTLOADER
static mozilla::dom::ChromeMessageSender* static nsFrameMessageManager*
NewProcessMessageManager(bool aIsRemote); NewProcessMessageManager(bool aIsRemote);
nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader, nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
@@ -271,11 +188,15 @@ public:
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal, mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneData>* aRetVal); nsTArray<StructuredCloneData>* aRetVal);
void AddChildManager(mozilla::dom::MessageListenerManager* aManager); void AddChildManager(nsFrameMessageManager* aManager);
void RemoveChildManager(mozilla::dom::MessageListenerManager* aManager); void RemoveChildManager(nsFrameMessageManager* aManager)
{
mChildManagers.RemoveObject(aManager);
}
void Disconnect(bool aRemoveFromParent = true); void Disconnect(bool aRemoveFromParent = true);
void Close(); void Close();
void InitWithCallback(mozilla::dom::ipc::MessageManagerCallback* aCallback);
void SetCallback(mozilla::dom::ipc::MessageManagerCallback* aCallback); void SetCallback(mozilla::dom::ipc::MessageManagerCallback* aCallback);
mozilla::dom::ipc::MessageManagerCallback* GetCallback() mozilla::dom::ipc::MessageManagerCallback* GetCallback()
@@ -296,6 +217,14 @@ public:
StructuredCloneData& aData, StructuredCloneData& aData,
JS::Handle<JSObject*> aCpows, JS::Handle<JSObject*> aCpows,
nsIPrincipal* aPrincipal); 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 IsGlobal() { return mGlobal; }
bool IsBroadcaster() { return mIsBroadcaster; } bool IsBroadcaster() { return mIsBroadcaster; }
@@ -303,11 +232,11 @@ public:
{ {
return sParentProcessManager; return sParentProcessManager;
} }
static mozilla::dom::ChildProcessMessageManager* GetChildProcessManager() static nsFrameMessageManager* GetChildProcessManager()
{ {
return sChildProcessManager; return sChildProcessManager;
} }
static void SetChildProcessManager(mozilla::dom::ChildProcessMessageManager* aManager) static void SetChildProcessManager(nsFrameMessageManager* aManager)
{ {
sChildProcessManager = aManager; sChildProcessManager = aManager;
} }
@@ -316,24 +245,7 @@ public:
void LoadPendingScripts(); void LoadPendingScripts();
protected: private:
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);
nsresult SendMessage(const nsAString& aMessageName, nsresult SendMessage(const nsAString& aMessageName,
JS::Handle<JS::Value> aJSON, JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects, JS::Handle<JS::Value> aObjects,
@@ -342,14 +254,6 @@ protected:
uint8_t aArgc, uint8_t aArgc,
JS::MutableHandle<JS::Value> aRetval, JS::MutableHandle<JS::Value> aRetval,
bool aIsSync); 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, nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
bool aTargetClosed, const nsAString& aMessage, bool aTargetClosed, const nsAString& aMessage,
@@ -357,28 +261,19 @@ protected:
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal, mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
nsTArray<StructuredCloneData>* aRetVal); nsTArray<StructuredCloneData>* aRetVal);
void LoadScript(const nsAString& aURL, bool aAllowDelayedLoad, NS_IMETHOD LoadScript(const nsAString& aURL,
bool aRunInGlobalScope, mozilla::ErrorResult& aError); bool aAllowDelayedLoad,
void RemoveDelayedScript(const nsAString& aURL); bool aRunInGlobalScope);
nsresult GetDelayedScripts(JSContext* aCx, NS_IMETHOD RemoveDelayedScript(const nsAString& aURL);
JS::MutableHandle<JS::Value> aList); NS_IMETHOD 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);
protected:
friend class MMListenerRemover;
// We keep the message listeners as arrays in a hastable indexed by the // We keep the message listeners as arrays in a hastable indexed by the
// message name. That gives us fast lookups in ReceiveMessage(). // message name. That gives us fast lookups in ReceiveMessage().
nsClassHashtable<nsStringHashKey, nsClassHashtable<nsStringHashKey,
nsAutoTObserverArray<nsMessageListenerInfo, 1>> mListeners; nsAutoTObserverArray<nsMessageListenerInfo, 1>> mListeners;
nsTArray<RefPtr<mozilla::dom::MessageListenerManager>> mChildManagers; nsCOMArray<nsIContentFrameMessageManager> mChildManagers;
bool mChrome; // true if we're in the chrome process bool mChrome; // true if we're in the chrome process
bool mGlobal; // true if we're the global frame message manager bool mGlobal; // true if we're the global frame message manager
bool mIsProcessManager; // true if the message manager belongs to the process realm bool mIsProcessManager; // true if the message manager belongs to the process realm
@@ -389,6 +284,7 @@ protected:
bool mDisconnected; bool mDisconnected;
mozilla::dom::ipc::MessageManagerCallback* mCallback; mozilla::dom::ipc::MessageManagerCallback* mCallback;
nsAutoPtr<mozilla::dom::ipc::MessageManagerCallback> mOwnedCallback; nsAutoPtr<mozilla::dom::ipc::MessageManagerCallback> mOwnedCallback;
RefPtr<nsFrameMessageManager> mParentManager;
nsTArray<nsString> mPendingScripts; nsTArray<nsString> mPendingScripts;
nsTArray<bool> mPendingScriptsGlobalStates; nsTArray<bool> mPendingScriptsGlobalStates;
JS::Heap<JS::Value> mInitialProcessData; JS::Heap<JS::Value> mInitialProcessData;
@@ -400,13 +296,15 @@ public:
static nsFrameMessageManager* sSameProcessParentManager; static nsFrameMessageManager* sSameProcessParentManager;
static nsTArray<nsCOMPtr<nsIRunnable> >* sPendingSameProcessAsyncMessages; static nsTArray<nsCOMPtr<nsIRunnable> >* sPendingSameProcessAsyncMessages;
private: private:
void AddMessageListener(const nsAString& aMessageName, static nsFrameMessageManager* sChildProcessManager;
mozilla::dom::MessageListenerHolder&& aListener, enum ProcessCheckerType {
bool aListenWhenClosed); PROCESS_CHECKER_PERMISSION,
void RemoveMessageListener(const nsAString& aMessageName, PROCESS_CHECKER_MANIFEST_URL,
const mozilla::dom::MessageListenerHolder& aListener); ASSERT_APP_HAS_PERMISSION
};
static mozilla::dom::ChildProcessMessageManager* sChildProcessManager; nsresult AssertProcessInternal(ProcessCheckerType aType,
const nsAString& aCapability,
bool* aValid);
}; };
/* A helper class for taking care of many details for async message sending /* A helper class for taking care of many details for async message sending
@@ -476,6 +374,10 @@ class nsMessageManagerScriptExecutor
public: public:
static void PurgeCache(); static void PurgeCache();
static void Shutdown(); static void Shutdown();
JSObject* GetGlobal()
{
return mGlobal;
}
void MarkScopesForCC(); void MarkScopesForCC();
protected: protected:
@@ -484,20 +386,17 @@ protected:
~nsMessageManagerScriptExecutor() { MOZ_COUNT_DTOR(nsMessageManagerScriptExecutor); } ~nsMessageManagerScriptExecutor() { MOZ_COUNT_DTOR(nsMessageManagerScriptExecutor); }
void DidCreateGlobal(); void DidCreateGlobal();
void LoadScriptInternal(JS::Handle<JSObject*> aGlobal, const nsAString& aURL, void LoadScriptInternal(const nsAString& aURL, bool aRunInGlobalScope);
bool aRunInGlobalScope);
void TryCacheLoadAndCompileScript(const nsAString& aURL, void TryCacheLoadAndCompileScript(const nsAString& aURL,
bool aRunInGlobalScope, bool aRunInGlobalScope,
bool aShouldCache, bool aShouldCache,
JS::MutableHandle<JSScript*> aScriptp); JS::MutableHandle<JSScript*> aScriptp);
void TryCacheLoadAndCompileScript(const nsAString& aURL, void TryCacheLoadAndCompileScript(const nsAString& aURL,
bool aRunInGlobalScope); bool aRunInGlobalScope);
bool InitChildGlobalInternal(const nsACString& aID); bool InitChildGlobalInternal(nsISupports* aScope, const nsACString& aID);
virtual bool WrapGlobalObject(JSContext* aCx,
JS::CompartmentOptions& aOptions,
JS::MutableHandle<JSObject*> aReflector) = 0;
void Trace(const TraceCallbacks& aCallbacks, void* aClosure); void Trace(const TraceCallbacks& aCallbacks, void* aClosure);
void Unlink(); void Unlink();
JS::TenuredHeap<JSObject*> mGlobal;
nsCOMPtr<nsIPrincipal> mPrincipal; nsCOMPtr<nsIPrincipal> mPrincipal;
AutoTArray<JS::Heap<JSObject*>, 2> mAnonymousGlobalScopes; AutoTArray<JS::Heap<JSObject*>, 2> mAnonymousGlobalScopes;

View File

@@ -1246,7 +1246,8 @@ nsGlobalWindowInner::CleanUp()
if (mCleanMessageManager) { if (mCleanMessageManager) {
MOZ_ASSERT(mIsChrome, "only chrome should have msg manager cleaned"); MOZ_ASSERT(mIsChrome, "only chrome should have msg manager cleaned");
if (mChromeFields.mMessageManager) { if (mChromeFields.mMessageManager) {
mChromeFields.mMessageManager->Disconnect(); static_cast<nsFrameMessageManager*>(
mChromeFields.mMessageManager.get())->Disconnect();
} }
} }
@@ -7592,7 +7593,7 @@ nsGlobalWindowInner::GetMessageManager(nsIMessageBroadcaster** aManager)
return rv.StealNSResult(); return rv.StealNSResult();
} }
ChromeMessageBroadcaster* nsIMessageBroadcaster*
nsGlobalWindowInner::GetMessageManager(ErrorResult& aError) nsGlobalWindowInner::GetMessageManager(ErrorResult& aError)
{ {
MOZ_ASSERT(IsChromeWindow()); MOZ_ASSERT(IsChromeWindow());
@@ -7600,7 +7601,9 @@ nsGlobalWindowInner::GetMessageManager(ErrorResult& aError)
nsCOMPtr<nsIMessageBroadcaster> globalMM = nsCOMPtr<nsIMessageBroadcaster> globalMM =
do_GetService("@mozilla.org/globalmessagemanager;1"); do_GetService("@mozilla.org/globalmessagemanager;1");
mChromeFields.mMessageManager = mChromeFields.mMessageManager =
new ChromeMessageBroadcaster(static_cast<nsFrameMessageManager*>(globalMM.get())); new nsFrameMessageManager(nullptr,
static_cast<nsFrameMessageManager*>(globalMM.get()),
MM_CHROME | MM_BROADCASTER);
} }
return mChromeFields.mMessageManager; return mChromeFields.mMessageManager;
} }
@@ -7615,18 +7618,21 @@ nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
return rv.StealNSResult(); return rv.StealNSResult();
} }
ChromeMessageBroadcaster* nsIMessageBroadcaster*
nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup, nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
ErrorResult& aError) ErrorResult& aError)
{ {
MOZ_ASSERT(IsChromeWindow()); MOZ_ASSERT(IsChromeWindow());
RefPtr<ChromeMessageBroadcaster> messageManager = nsCOMPtr<nsIMessageBroadcaster> messageManager =
mChromeFields.mGroupMessageManagers.LookupForAdd(aGroup).OrInsert( mChromeFields.mGroupMessageManagers.LookupForAdd(aGroup).OrInsert(
[this, &aError] () { [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; return messageManager;
} }

View File

@@ -37,11 +37,11 @@
#include "prclist.h" #include "prclist.h"
#include "mozilla/dom/DOMPrefs.h" #include "mozilla/dom/DOMPrefs.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h"
#include "mozilla/dom/StorageEvent.h" #include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h" #include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/UnionTypes.h" #include "mozilla/dom/UnionTypes.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "nsFrameMessageManager.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/GuardObjects.h" #include "mozilla/GuardObjects.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"
@@ -941,11 +941,9 @@ public:
void Restore(); void Restore();
void NotifyDefaultButtonLoaded(mozilla::dom::Element& aDefaultButton, void NotifyDefaultButtonLoaded(mozilla::dom::Element& aDefaultButton,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
mozilla::dom::ChromeMessageBroadcaster* nsIMessageBroadcaster* GetMessageManager(mozilla::ErrorResult& aError);
GetMessageManager(mozilla::ErrorResult& aError); nsIMessageBroadcaster* GetGroupMessageManager(const nsAString& aGroup,
mozilla::dom::ChromeMessageBroadcaster* mozilla::ErrorResult& aError);
GetGroupMessageManager(const nsAString& aGroup,
mozilla::ErrorResult& aError);
void BeginWindowMove(mozilla::dom::Event& aMouseDownEvent, void BeginWindowMove(mozilla::dom::Event& aMouseDownEvent,
mozilla::dom::Element* aPanel, mozilla::dom::Element* aPanel,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
@@ -1273,9 +1271,9 @@ private:
{ {
MOZ_RELEASE_ASSERT(IsChromeWindow()); MOZ_RELEASE_ASSERT(IsChromeWindow());
for (auto iter = mChromeFields.mGroupMessageManagers.Iter(); !iter.Done(); iter.Next()) { for (auto iter = mChromeFields.mGroupMessageManagers.Iter(); !iter.Done(); iter.Next()) {
mozilla::dom::ChromeMessageBroadcaster* mm = iter.UserData(); nsIMessageBroadcaster* mm = iter.UserData();
if (mm) { if (mm) {
mm->Disconnect(); static_cast<nsFrameMessageManager*>(mm)->Disconnect();
} }
} }
mChromeFields.mGroupMessageManagers.Clear(); mChromeFields.mGroupMessageManagers.Clear();
@@ -1475,9 +1473,8 @@ protected:
: mGroupMessageManagers(1) : mGroupMessageManagers(1)
{} {}
RefPtr<mozilla::dom::ChromeMessageBroadcaster> mMessageManager; nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
nsRefPtrHashtable<nsStringHashKey, nsInterfaceHashtable<nsStringHashKey, nsIMessageBroadcaster> mGroupMessageManagers;
mozilla::dom::ChromeMessageBroadcaster> mGroupMessageManagers;
} mChromeFields; } mChromeFields;
// These fields are used by the inner and outer windows to prevent // These fields are used by the inner and outer windows to prevent

View File

@@ -37,11 +37,11 @@
#include "mozilla/FlushType.h" #include "mozilla/FlushType.h"
#include "prclist.h" #include "prclist.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/ChromeMessageBroadcaster.h"
#include "mozilla/dom/StorageEvent.h" #include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h" #include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/UnionTypes.h" #include "mozilla/dom/UnionTypes.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "nsFrameMessageManager.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/GuardObjects.h" #include "mozilla/GuardObjects.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"

View File

@@ -203,7 +203,7 @@ interface nsIMessageListener : nsISupports
void receiveMessage(); void receiveMessage();
}; };
[uuid(b949bfec-bb7d-47bc-b387-ac6a9b655072)] [scriptable, builtinclass, uuid(b949bfec-bb7d-47bc-b387-ac6a9b655072)]
interface nsIMessageListenerManager : nsISupports interface nsIMessageListenerManager : nsISupports
{ {
/** /**
@@ -261,7 +261,7 @@ interface nsIMessageListenerManager : nsISupports
* messages that are only delivered to its one parent-process message * messages that are only delivered to its one parent-process message
* manager. * manager.
*/ */
[uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)] [scriptable, builtinclass, uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)]
interface nsIMessageSender : nsIMessageListenerManager interface nsIMessageSender : nsIMessageListenerManager
{ {
/** /**
@@ -309,7 +309,7 @@ interface nsIMessageSender : nsIMessageListenerManager
* manager will broadcast the message to all frame message managers * manager will broadcast the message to all frame message managers
* within its window. * within its window.
*/ */
[uuid(4d7d62ad-4725-4f39-86cf-8fb22bf9c1d8)] [scriptable, builtinclass, uuid(4d7d62ad-4725-4f39-86cf-8fb22bf9c1d8)]
interface nsIMessageBroadcaster : nsIMessageListenerManager interface nsIMessageBroadcaster : nsIMessageListenerManager
{ {
/** /**
@@ -342,7 +342,7 @@ interface nsIMessageBroadcaster : nsIMessageListenerManager
void releaseCachedProcesses(); void releaseCachedProcesses();
}; };
[uuid(0e602c9e-1977-422a-a8e4-fe0d4a4f78d0)] [scriptable, builtinclass, uuid(0e602c9e-1977-422a-a8e4-fe0d4a4f78d0)]
interface nsISyncMessageSender : nsIMessageSender interface nsISyncMessageSender : nsIMessageSender
{ {
/** /**
@@ -372,7 +372,7 @@ interface nsISyncMessageSender : nsIMessageSender
[optional] in nsIPrincipal principal); [optional] in nsIPrincipal principal);
}; };
[uuid(13f3555f-769e-44ea-b607-5239230c3162)] [scriptable, builtinclass, uuid(13f3555f-769e-44ea-b607-5239230c3162)]
interface nsIMessageManagerGlobal : nsISyncMessageSender interface nsIMessageManagerGlobal : nsISyncMessageSender
{ {
/** /**
@@ -393,7 +393,7 @@ interface nsIMessageManagerGlobal : nsISyncMessageSender
DOMString btoa(in DOMString aBase64Data); DOMString btoa(in DOMString aBase64Data);
}; };
[uuid(694e367c-aa25-4446-8499-2c527c4bd838)] [scriptable, builtinclass, uuid(694e367c-aa25-4446-8499-2c527c4bd838)]
interface nsIContentFrameMessageManager : nsIMessageManagerGlobal interface nsIContentFrameMessageManager : nsIMessageManagerGlobal
{ {
/** /**
@@ -420,7 +420,7 @@ interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
[notxpcom] void cacheFrameLoader(in nsIFrameLoader aFrameLoader); [notxpcom] void cacheFrameLoader(in nsIFrameLoader aFrameLoader);
}; };
[uuid(6d12e467-2446-46db-9965-e4e93cb87ca5)] [scriptable, builtinclass, uuid(6d12e467-2446-46db-9965-e4e93cb87ca5)]
interface nsIContentProcessMessageManager : nsIMessageManagerGlobal interface nsIContentProcessMessageManager : nsIMessageManagerGlobal
{ {
/** /**
@@ -431,7 +431,7 @@ interface nsIContentProcessMessageManager : nsIMessageManagerGlobal
readonly attribute jsval initialProcessData; readonly attribute jsval initialProcessData;
}; };
[uuid(bf61446b-ba24-4b1d-88c7-4f94724b9ce1)] [scriptable, builtinclass, uuid(bf61446b-ba24-4b1d-88c7-4f94724b9ce1)]
interface nsIFrameScriptLoader : nsISupports interface nsIFrameScriptLoader : nsISupports
{ {
/** /**
@@ -458,7 +458,7 @@ interface nsIFrameScriptLoader : nsISupports
jsval getDelayedFrameScripts(); jsval getDelayedFrameScripts();
}; };
[uuid(7e1e1a20-b24f-11e4-ab27-0800200c9a66)] [scriptable, builtinclass, uuid(7e1e1a20-b24f-11e4-ab27-0800200c9a66)]
interface nsIProcessScriptLoader : nsISupports interface nsIProcessScriptLoader : nsISupports
{ {
/** /**
@@ -483,7 +483,7 @@ interface nsIProcessScriptLoader : nsISupports
jsval getDelayedProcessScripts(); jsval getDelayedProcessScripts();
}; };
[uuid(5b390753-abb3-49b0-ae3b-b803dab58144)] [scriptable, builtinclass, uuid(5b390753-abb3-49b0-ae3b-b803dab58144)]
interface nsIGlobalProcessScriptLoader : nsIProcessScriptLoader interface nsIGlobalProcessScriptLoader : nsIProcessScriptLoader
{ {
/** /**

View File

@@ -14,9 +14,8 @@
#include "nsFrameLoader.h" #include "nsFrameLoader.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "nsIMozBrowserFrame.h" #include "nsIMozBrowserFrame.h"
#include "nsDOMClassInfoID.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/dom/ChromeMessageSender.h"
#include "mozilla/dom/MessageManagerBinding.h"
#include "mozilla/dom/SameProcessMessageQueue.h" #include "mozilla/dom/SameProcessMessageQueue.h"
#include "mozilla/dom/ScriptLoader.h" #include "mozilla/dom/ScriptLoader.h"
@@ -90,11 +89,11 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell, nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
nsIContent* aOwner, nsIContent* aOwner,
nsFrameMessageManager* aChrome) nsFrameMessageManager* aChrome)
: ContentFrameMessageManager(aChrome), : mDocShell(aShell), mInitialized(false), mLoadingScript(false),
mDocShell(aShell), mInitialized(false), mLoadingScript(false),
mPreventEventsEscaping(false), mPreventEventsEscaping(false),
mOwner(aOwner), mChromeMessageManager(aChrome) mOwner(aOwner), mChromeMessageManager(aChrome)
{ {
SetIsNotDOMBinding();
mozilla::HoldJSObjects(this); mozilla::HoldJSObjects(this);
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our // If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
@@ -120,7 +119,7 @@ NS_IMETHODIMP_(bool)
nsInProcessTabChildGlobal::MarkForCC() nsInProcessTabChildGlobal::MarkForCC()
{ {
MarkScopesForCC(); MarkScopesForCC();
return MessageManagerGlobal::MarkForCC(); return mMessageManager ? mMessageManager->MarkForCC() : false;
} }
nsresult nsresult
@@ -132,7 +131,9 @@ nsInProcessTabChildGlobal::Init()
InitTabChildGlobal(); InitTabChildGlobal();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"Couldn't initialize nsInProcessTabChildGlobal"); "Couldn't initialize nsInProcessTabChildGlobal");
mMessageManager = new nsFrameMessageManager(this); mMessageManager = new nsFrameMessageManager(this,
nullptr,
dom::ipc::MM_CHILD);
return NS_OK; return NS_OK;
} }
@@ -168,69 +169,43 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
NS_IMPL_RELEASE_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 void
nsInProcessTabChildGlobal::CacheFrameLoader(nsIFrameLoader* aFrameLoader) nsInProcessTabChildGlobal::CacheFrameLoader(nsIFrameLoader* aFrameLoader)
{ {
mFrameLoader = aFrameLoader; mFrameLoader = aFrameLoader;
} }
already_AddRefed<nsPIDOMWindowOuter>
nsInProcessTabChildGlobal::GetContent(ErrorResult& aError)
{
nsCOMPtr<nsPIDOMWindowOuter> content;
if (mDocShell) {
content = mDocShell->GetWindow();
}
return content.forget();
}
NS_IMETHODIMP NS_IMETHODIMP
nsInProcessTabChildGlobal::GetContent(mozIDOMWindowProxy** aContent) nsInProcessTabChildGlobal::GetContent(mozIDOMWindowProxy** aContent)
{ {
ErrorResult rv; *aContent = nullptr;
*aContent = GetContent(rv).take(); if (!mDocShell) {
return rv.StealNSResult(); return NS_OK;
}
nsCOMPtr<nsPIDOMWindowOuter> window = mDocShell->GetWindow();
window.forget(aContent);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInProcessTabChildGlobal::GetDocShell(nsIDocShell** aDocShell) nsInProcessTabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
{ {
ErrorResult rv; NS_IF_ADDREF(*aDocShell = mDocShell);
*aDocShell = GetDocShell(rv).take(); return NS_OK;
return rv.StealNSResult();
}
already_AddRefed<nsIEventTarget>
nsInProcessTabChildGlobal::GetTabEventTarget()
{
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
return target.forget();
} }
NS_IMETHODIMP NS_IMETHODIMP
nsInProcessTabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget) nsInProcessTabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget)
{ {
*aTarget = GetTabEventTarget().take(); nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
target.forget(aTarget);
return NS_OK; return NS_OK;
} }
@@ -337,7 +312,8 @@ nsInProcessTabChildGlobal::InitTabChildGlobal()
id.AppendLiteral("?ownedBy="); id.AppendLiteral("?ownedBy=");
id.Append(u); id.Append(u);
} }
NS_ENSURE_STATE(InitChildGlobalInternal(id)); nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, this);
NS_ENSURE_STATE(InitChildGlobalInternal(scopeSupports, id));
return NS_OK; return NS_OK;
} }
@@ -377,8 +353,7 @@ nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL, bool aRunInGlo
} }
bool tmp = mLoadingScript; bool tmp = mLoadingScript;
mLoadingScript = true; mLoadingScript = true;
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper()); LoadScriptInternal(aURL, aRunInGlobalScope);
LoadScriptInternal(global, aURL, aRunInGlobalScope);
mLoadingScript = tmp; mLoadingScript = tmp;
} }

View File

@@ -9,7 +9,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/DOMEventTargetHelper.h" #include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsFrameMessageManager.h" #include "nsFrameMessageManager.h"
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
@@ -28,7 +27,7 @@ namespace mozilla {
class EventChainPreVisitor; class EventChainPreVisitor;
} // namespace mozilla } // namespace mozilla
class nsInProcessTabChildGlobal : public mozilla::dom::ContentFrameMessageManager, class nsInProcessTabChildGlobal : public mozilla::DOMEventTargetHelper,
public nsMessageManagerScriptExecutor, public nsMessageManagerScriptExecutor,
public nsIInProcessContentFrameMessageManager, public nsIInProcessContentFrameMessageManager,
public nsIGlobalObject, public nsIGlobalObject,
@@ -47,30 +46,38 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal, NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal,
mozilla::DOMEventTargetHelper) 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_NSIMESSAGELISTENERMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager);
NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(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 NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
@@ -92,6 +99,26 @@ public:
virtual nsresult GetEventTargetParent( virtual nsresult GetEventTargetParent(
mozilla::EventChainPreVisitor& aVisitor) override; 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; } virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
void LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope); void LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope);
@@ -116,9 +143,12 @@ public:
mChromeMessageManager = aParent; 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(); already_AddRefed<nsIFrameLoader> GetFrameLoader();
@@ -128,6 +158,7 @@ protected:
nsresult Init(); nsresult Init();
nsresult InitTabChildGlobal(); nsresult InitTabChildGlobal();
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
nsCOMPtr<nsIDocShell> mDocShell; nsCOMPtr<nsIDocShell> mDocShell;
bool mInitialized; bool mInitialized;
bool mLoadingScript; bool mLoadingScript;

View File

@@ -15,7 +15,6 @@
#include "jsapi.h" #include "jsapi.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
#include "nsIScriptElement.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIXPConnect.h" #include "nsIXPConnect.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"

View File

@@ -344,7 +344,11 @@ private:
// Friend declarations for things that need to be able to call // Friend declarations for things that need to be able to call
// SetIsNotDOMBinding(). The goal is to get rid of all of these, and // SetIsNotDOMBinding(). The goal is to get rid of all of these, and
// SetIsNotDOMBinding() too. // SetIsNotDOMBinding() too.
friend class mozilla::dom::TabChildGlobal;
friend class mozilla::dom::ProcessGlobal;
friend class SandboxPrivate; friend class SandboxPrivate;
friend class nsInProcessTabChildGlobal;
friend class nsWindowRoot;
void SetIsNotDOMBinding() void SetIsNotDOMBinding()
{ {
MOZ_ASSERT(!mWrapper && !(GetWrapperFlags() & ~WRAPPER_IS_NOT_DOM_BINDING), MOZ_ASSERT(!mWrapper && !(GetWrapperFlags() & ~WRAPPER_IS_NOT_DOM_BINDING),

View File

@@ -1,6 +1,10 @@
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageBroadcaster);
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
const BASE_NUMBER_OF_PROCESSES = 3; const BASE_NUMBER_OF_PROCESSES = 3;
function checkBaseProcessCount(description) { function checkBaseProcessCount(description) {
const {childCount} = Services.ppmm; const {childCount} = ppmm;
// With preloaded activity-stream, process count is a bit undeterministic, so // With preloaded activity-stream, process count is a bit undeterministic, so
// allow for some variation // allow for some variation
const extraCount = BASE_NUMBER_OF_PROCESSES + 1; const extraCount = BASE_NUMBER_OF_PROCESSES + 1;
@@ -8,12 +12,14 @@ function checkBaseProcessCount(description) {
} }
function processScript() { 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"); dump("Test failed: wrong global object\n");
return; return;
} }
this.cpmm = Services.cpmm; this.cpmm = cpmm;
addMessageListener("ProcessTest:Reply", function listener(msg) { addMessageListener("ProcessTest:Reply", function listener(msg) {
removeMessageListener("ProcessTest:Reply", listener); removeMessageListener("ProcessTest:Reply", listener);
@@ -64,7 +70,7 @@ add_task(async function(){
if (!gMultiProcessBrowser) if (!gMultiProcessBrowser)
return; return;
Services.ppmm.releaseCachedProcesses(); ppmm.releaseCachedProcesses();
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 5]]}) await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 5]]})
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.keepProcessesAlive.web", 5]]}) await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.keepProcessesAlive.web", 5]]})
@@ -78,17 +84,17 @@ add_task(async function(){
await BrowserTestUtils.removeTab(tabs[i]); await BrowserTestUtils.removeTab(tabs[i]);
} }
Services.ppmm.releaseCachedProcesses(); ppmm.releaseCachedProcesses();
checkBaseProcessCount("Should get back to the base number of processes at this point"); checkBaseProcessCount("Should get back to the base number of processes at this point");
}) })
// Test that loading a process script loads in all existing processes // Test that loading a process script loads in all existing processes
add_task(async function() { add_task(async function() {
let checks = []; let checks = [];
for (let i = 0; i < Services.ppmm.childCount; i++) for (let i = 0; i < ppmm.childCount; i++)
checks.push(checkProcess(Services.ppmm.getChildAt(i))); checks.push(checkProcess(ppmm.getChildAt(i)));
Services.ppmm.loadProcessScript(processScriptURL, false); ppmm.loadProcessScript(processScriptURL, false);
await Promise.all(checks); await Promise.all(checks);
}); });
@@ -104,7 +110,7 @@ add_task(async function() {
gBrowser.selectedBrowser.loadURI("about:robots"); gBrowser.selectedBrowser.loadURI("about:robots");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
let init = Services.ppmm.initialProcessData; let init = ppmm.initialProcessData;
init.test123 = "hello"; init.test123 = "hello";
init.test456 = new Map(); init.test456 = new Map();
init.test456.set("hi", "bye"); init.test456.set("hi", "bye");
@@ -113,16 +119,16 @@ add_task(async function() {
// However, stuff like remote thumbnails can cause a content // However, stuff like remote thumbnails can cause a content
// process to exist nonetheless. This should be rare, though, // process to exist nonetheless. This should be rare, though,
// so the test is useful most of the time. // so the test is useful most of the time.
if (Services.ppmm.childCount == 2) { if (ppmm.childCount == 2) {
let mainMM = Services.ppmm.getChildAt(0); let mainMM = ppmm.getChildAt(0);
let check = checkProcess(Services.ppmm); let check = checkProcess(ppmm);
Services.ppmm.loadProcessScript(processScriptURL, true); ppmm.loadProcessScript(processScriptURL, true);
// The main process should respond // The main process should respond
await check; await check;
check = checkProcess(Services.ppmm); check = checkProcess(ppmm);
// Reset the default browser to start a new child process // Reset the default browser to start a new child process
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true); gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
gBrowser.selectedBrowser.loadURI("about:blank"); gBrowser.selectedBrowser.loadURI("about:blank");
@@ -133,10 +139,10 @@ add_task(async function() {
// The new process should have responded // The new process should have responded
await check; await check;
Services.ppmm.removeDelayedProcessScript(processScriptURL); ppmm.removeDelayedProcessScript(processScriptURL);
let childMM; let childMM;
childMM = Services.ppmm.getChildAt(2); childMM = ppmm.getChildAt(2);
childMM.loadProcessScript(initTestScriptURL, false); childMM.loadProcessScript(initTestScriptURL, false);
let msg = await promiseMessage(childMM, "ProcessTest:InitGood"); let msg = await promiseMessage(childMM, "ProcessTest:InitGood");

View File

@@ -11,7 +11,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1139964
<label value="Mozilla Bug 1139964"/> <label value="Mozilla Bug 1139964"/>
<!-- test code goes here --> <!-- test code goes here -->
<script type="application/javascript"><![CDATA[ <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) { function ok(cond, msg) {
opener.wrappedJSObject.ok(cond, msg); opener.wrappedJSObject.ok(cond, msg);

View File

@@ -14,9 +14,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
var didRunAsync = false; var didRunAsync = false;
var didRunLocal = false; var didRunLocal = false;
var global = Cc["@mozilla.org/globalmessagemanager;1"].getService(); var global = Cc["@mozilla.org/globalmessagemanager;1"]
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(); .getService(Components.interfaces.nsIMessageBroadcaster);
var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(); 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"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");

View File

@@ -16,7 +16,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')"; var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')"; 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) { function is(val, exp, msg) {
opener.wrappedJSObject.is(val, exp, msg); opener.wrappedJSObject.is(val, exp, msg);

View File

@@ -15,7 +15,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var FRAME_SCRIPT = "data:,sendAsyncMessage('test')"; var FRAME_SCRIPT = "data:,sendAsyncMessage('test')";
var order = ["group", "window", "global"]; 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) { function is(val, exp, msg) {
opener.wrappedJSObject.is(val, exp, msg); opener.wrappedJSObject.is(val, exp, msg);

View File

@@ -15,7 +15,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var FRAME_SCRIPT = "data:,addMessageListener('test', function (msg) {" + var FRAME_SCRIPT = "data:,addMessageListener('test', function (msg) {" +
"sendSyncMessage('test', msg.data)})"; "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) { function is(val, exp, msg) {
opener.wrappedJSObject.is(val, exp, msg); opener.wrappedJSObject.is(val, exp, msg);

View File

@@ -17,7 +17,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" + var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
"sendSyncMessage('test', 'frame2')})"; "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) { function is(val, exp, msg) {
opener.wrappedJSObject.is(val, exp, msg); opener.wrappedJSObject.is(val, exp, msg);

View File

@@ -17,7 +17,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" + var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
"sendSyncMessage('test', 'group2')})"; "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) { function is(val, exp, msg) {
opener.wrappedJSObject.is(val, exp, msg); opener.wrappedJSObject.is(val, exp, msg);

View File

@@ -16,7 +16,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')"; var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')"; 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) { function is(val, exp, msg) {
opener.wrappedJSObject.is(val, exp, msg); opener.wrappedJSObject.is(val, exp, msg);

View File

@@ -21,7 +21,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098074
// with SimpleTest.finish as a continuation function. // with SimpleTest.finish as a continuation function.
SimpleTest.monitorConsole(SimpleTest.finish, [{errorMessage: new RegExp('acopia')}]); 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.addMessageListener("flimfniffle", function onMessage(msg) {
globalMM.removeMessageListener("flimfniffle", onMessage); globalMM.removeMessageListener("flimfniffle", onMessage);
is(msg.data, "teufeltor", "correct message"); is(msg.data, "teufeltor", "correct message");

View File

@@ -18,7 +18,8 @@
ChromeUtils.import("resource://gre/modules/DOMRequestHelper.jsm"); ChromeUtils.import("resource://gre/modules/DOMRequestHelper.jsm");
let obs = Cc["@mozilla.org/observer-service;1"]. let obs = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService); getService(Ci.nsIObserverService);
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(); let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].
getService(Ci.nsIMessageBroadcaster);
function DummyHelperSubclass() { function DummyHelperSubclass() {
this.onuninit = null; this.onuninit = null;

View File

@@ -3127,22 +3127,11 @@ ConvertExceptionToPromise(JSContext* cx,
/* static */ /* static */
void void
CreateGlobalOptionsWithXPConnect::TraceGlobal(JSTracer* aTrc, JSObject* aObj) CreateGlobalOptions<nsGlobalWindowInner>::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
{ {
xpc::TraceXPCGlobal(aTrc, 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; static bool sRegisteredDOMNames = false;
nsresult nsresult
@@ -3176,7 +3165,10 @@ CreateGlobalOptions<nsGlobalWindowInner>::PostCreateGlobal(JSContext* aCx,
return Throw(aCx, rv); 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 #ifdef DEBUG

View File

@@ -50,7 +50,6 @@ enum UseCounter : int16_t;
namespace dom { namespace dom {
class CustomElementReactionsStack; class CustomElementReactionsStack;
class MessageManagerGlobal;
template<typename KeyType, typename ValueType> class Record; template<typename KeyType, typename ValueType> class Record;
nsresult nsresult
@@ -3101,9 +3100,11 @@ bool
EnumerateGlobal(JSContext* aCx, JS::HandleObject aObj, EnumerateGlobal(JSContext* aCx, JS::HandleObject aObj,
JS::AutoIdVector& aProperties, bool aEnumerableOnly); JS::AutoIdVector& aProperties, bool aEnumerableOnly);
template <class T>
struct CreateGlobalOptionsGeneric struct CreateGlobalOptions
{ {
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
ProtoAndIfaceCache::NonWindowLike;
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj) static void TraceGlobal(JSTracer* aTrc, JSObject* aObj)
{ {
mozilla::dom::TraceProtoAndIfaceCache(aTrc, 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 <> template <>
struct CreateGlobalOptions<nsGlobalWindowInner> struct CreateGlobalOptions<nsGlobalWindowInner>
: public CreateGlobalOptionsWithXPConnect
{ {
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind = static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
ProtoAndIfaceCache::WindowLike; ProtoAndIfaceCache::WindowLike;
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal); static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
}; };
@@ -3234,11 +3213,11 @@ class PinnedStringId
return true; return true;
} }
operator const jsid& () const { operator const jsid& () {
return id; return id;
} }
operator JS::Handle<jsid> () const { operator JS::Handle<jsid> () {
/* This is safe because we have pinned the string. */ /* This is safe because we have pinned the string. */
return JS::Handle<jsid>::fromMarkedLocation(&id); return JS::Handle<jsid>::fromMarkedLocation(&id);
} }

View File

@@ -152,10 +152,6 @@ DOMInterfaces = {
'implicitJSContext': ['clear', 'count', 'groupEnd', 'time', 'timeEnd'], 'implicitJSContext': ['clear', 'count', 'groupEnd', 'time', 'timeEnd'],
}, },
'ContentProcessMessageManager': {
'nativeType': 'mozilla::dom::ProcessGlobal'
},
'ConvolverNode': { 'ConvolverNode': {
'implicitJSContext': [ 'buffer' ], 'implicitJSContext': [ 'buffer' ],
}, },
@@ -574,18 +570,6 @@ DOMInterfaces = {
'headerFile': 'MediaRecorder.h', 'headerFile': 'MediaRecorder.h',
}, },
'MessageBroadcaster': {
'concrete': False
},
'MessageListenerManager': {
'concrete': False
},
'MessageSender': {
'concrete': False
},
'MimeType': { 'MimeType': {
'headerFile' : 'nsMimeTypeArray.h', 'headerFile' : 'nsMimeTypeArray.h',
'nativeType': 'nsMimeType', 'nativeType': 'nsMimeType',
@@ -1031,10 +1015,6 @@ DOMInterfaces = {
'concrete': False, 'concrete': False,
}, },
'SyncMessageSender' : {
'concrete': False,
},
'TestFunctions': { 'TestFunctions': {
'wrapperCache': False 'wrapperCache': False
}, },
@@ -1731,10 +1711,13 @@ addExternalIface('MozTreeView', nativeType='nsITreeView',
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h') addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow', addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow',
notflattened=True) notflattened=True)
addExternalIface('nsIEventTarget', nativeType='nsIEventTarget', notflattened=True)
addExternalIface('nsIFile', nativeType='nsIFile', notflattened=True) addExternalIface('nsIFile', nativeType='nsIFile', notflattened=True)
addExternalIface('nsILoadGroup', nativeType='nsILoadGroup', addExternalIface('nsILoadGroup', nativeType='nsILoadGroup',
headerFile='nsILoadGroup.h', notflattened=True) 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', addExternalIface('nsIPrintSettings', nativeType='nsIPrintSettings',
notflattened=True) notflattened=True)
addExternalIface('nsISelectionListener', nativeType='nsISelectionListener') addExternalIface('nsISelectionListener', nativeType='nsISelectionListener')

View File

@@ -281,15 +281,12 @@ class CGStringTable(CGThing):
The uint16_t indices are smaller than the pointer equivalents, and the The uint16_t indices are smaller than the pointer equivalents, and the
string table requires no runtime relocations. string table requires no runtime relocations.
""" """
def __init__(self, accessorName, strings, static=False): def __init__(self, accessorName, strings):
CGThing.__init__(self) CGThing.__init__(self)
self.accessorName = accessorName self.accessorName = accessorName
self.strings = strings self.strings = strings
self.static = static
def declare(self): def declare(self):
if self.static:
return ""
return "extern const char *%s(unsigned int aIndex);\n" % self.accessorName return "extern const char *%s(unsigned int aIndex);\n" % self.accessorName
def define(self): def define(self):
@@ -301,7 +298,7 @@ class CGStringTable(CGThing):
currentIndex += len(s) + 1 # for the null terminator currentIndex += len(s) + 1 # for the null terminator
return fill( return fill(
""" """
${static}const char *${name}(unsigned int aIndex) const char *${name}(unsigned int aIndex)
{ {
static const char table[] = ${table}; static const char table[] = ${table};
static const uint16_t indices[] = { ${indices} }; static const uint16_t indices[] = { ${indices} };
@@ -309,7 +306,6 @@ class CGStringTable(CGThing):
return &table[indices[aIndex]]; return &table[indices[aIndex]];
} }
""", """,
static="static " if self.static else "",
name=self.accessorName, name=self.accessorName,
table=table, table=table,
indices=", ".join("%d" % index for index in indices), indices=", ".join("%d" % index for index in indices),
@@ -1107,7 +1103,7 @@ class CGHeaders(CGWrapper):
interfacesImplementingSelf) interfacesImplementingSelf)
# Grab the includes for the things that involve XPCOM interfaces # 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 in descriptors if
d.interface.hasInterfaceObject() and d.interface.hasInterfaceObject() and
NeedsGeneratedHasInstance(d) and NeedsGeneratedHasInstance(d) and
@@ -13953,120 +13949,58 @@ class CGRegisterWorkletBindings(CGAbstractMethod):
lines.append(CGGeneric("return true;\n")) lines.append(CGGeneric("return true;\n"))
return CGList(lines, "\n").define() 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): class CGResolveSystemBinding(CGAbstractMethod):
def __init__(self): def __init__(self, config):
CGAbstractMethod.__init__(self, None, 'ResolveSystemBinding', 'bool', CGAbstractMethod.__init__(self, None, 'ResolveSystemBinding', 'bool',
[Argument('JSContext*', 'aCx'), [Argument('JSContext*', 'aCx'),
Argument('JS::Handle<JSObject*>', 'aObj'), Argument('JS::Handle<JSObject*>', 'aObj'),
Argument('JS::Handle<jsid>', 'aId'), Argument('JS::Handle<jsid>', 'aId'),
Argument('bool*', 'aResolvedp')]) Argument('bool*', 'aResolvedp')])
self.config = config
def definition_body(self): def definition_body(self):
return dedent(""" descriptors = self.config.getDescriptors(hasInterfaceObject=True,
MOZ_ASSERT(NS_IsMainThread()); isExposedInSystemGlobals=True,
MOZ_ASSERT(idsInited); register=True)
if (JSID_IS_VOID(aId)) { def descNameToId(name):
for (const auto& property : properties) { return "s%s_id" % name
if (!property.enabled || property.enabled(aCx, aObj)) { jsidNames = [descNameToId(desc.name) for desc in descriptors]
if (!property.define(aCx)) { jsidDecls = CGList(CGGeneric("static jsid %s;\n" % name)
return false; for name in jsidNames)
}
*aResolvedp = true;
}
}
return true;
}
for (const auto& property : properties) { jsidInits = CGList(
if (property.id == aId) { (CGIfWrapper(
if (!property.enabled || property.enabled(aCx, aObj)) { CGGeneric("return false;\n"),
if (!property.define(aCx)) { '!AtomizeAndPinJSString(aCx, %s, "%s")' %
return false; (descNameToId(desc.name), desc.interface.identifier.name))
} for desc in descriptors),
*aResolvedp = true; "\n")
break; jsidInits.append(CGGeneric("idsInited = true;\n"))
} jsidInits = CGIfWrapper(jsidInits, "!idsInited")
} jsidInits = CGList([CGGeneric("static bool idsInited = false;\n"),
} jsidInits])
return true;
""")
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): condition = "JSID_IS_VOID(aId) || aId == %s" % descNameToId(desc.name)
def __init__(self): if desc.isExposedConditionally():
CGAbstractMethod.__init__(self, None, 'MayResolveAsSystemBindingName', 'bool', condition = "(%s) && %s::ConstructorEnabled(aCx, aObj)" % (condition, bindingNS)
[Argument('jsid', 'aId')])
def definition_body(self): definitions.append(CGIfWrapper(defineCode, condition))
return dedent("""
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(idsInited);
for (const auto& property : properties) { return CGList([CGGeneric("MOZ_ASSERT(NS_IsMainThread());\n"),
if (aId == property.id) { jsidDecls,
return true; jsidInits,
} definitions,
} CGGeneric("return true;\n")],
return false; "\n").define()
""")
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;
}
}
}
""")
def getGlobalNames(config): def getGlobalNames(config):
@@ -17562,44 +17496,8 @@ class GlobalGenRoots():
@staticmethod @staticmethod
def ResolveSystemBinding(config): 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 = [] curr = CGResolveSystemBinding(config)
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())
# Wrap all of that in our namespaces. # Wrap all of that in our namespaces.
curr = CGNamespace.build(['mozilla', 'dom'], curr = CGNamespace.build(['mozilla', 'dom'],
@@ -17613,7 +17511,7 @@ class GlobalGenRoots():
isExposedInSystemGlobals=True)] isExposedInSystemGlobals=True)]
defineIncludes.append("nsThreadUtils.h") # For NS_IsMainThread defineIncludes.append("nsThreadUtils.h") # For NS_IsMainThread
defineIncludes.append("js/Id.h") # For jsid defineIncludes.append("js/Id.h") # For jsid
defineIncludes.append("mozilla/dom/WebIDLGlobalNameHash.h") defineIncludes.append("mozilla/dom/BindingUtils.h") # AtomizeAndPinJSString
curr = CGHeaders([], [], [], [], [], defineIncludes, curr = CGHeaders([], [], [], [], [], defineIncludes,
'ResolveSystemBinding', curr) 'ResolveSystemBinding', curr)

View File

@@ -233,13 +233,6 @@ ToJSValue(JSContext* aCx,
// Accept existing JS values (which may not be same-compartment with us // Accept existing JS values (which may not be same-compartment with us
MOZ_MUST_USE inline bool 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, ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
{ {
@@ -319,13 +312,33 @@ ToJSValue(JSContext* aCx,
Promise& aArgument, Promise& aArgument,
JS::MutableHandle<JS::Value> aValue); 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> template <typename T>
MOZ_MUST_USE bool MOZ_MUST_USE bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
T* aArguments, T* aArguments,
size_t aLength, 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> template <typename T>
MOZ_MUST_USE bool MOZ_MUST_USE bool
@@ -356,34 +369,6 @@ ToJSValue(JSContext* aCx,
return ToJSValue(aCx, aArgument, N, aValue); 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 dom
} // namespace mozilla } // namespace mozilla

View File

@@ -111,7 +111,7 @@ struct WebIDLNameTableEntry : public PLDHashEntryHdr
constructors::id::ID mConstructorId; constructors::id::ID mConstructorId;
WebIDLGlobalNameHash::DefineGlobalName mDefine; WebIDLGlobalNameHash::DefineGlobalName mDefine;
// May be null if enabled unconditionally // May be null if enabled unconditionally
WebIDLGlobalNameHash::ConstructorEnabled mEnabled; WebIDLGlobalNameHash::ConstructorEnabled* mEnabled;
}; };
static nsTHashtable<WebIDLNameTableEntry>* sWebIDLGlobalNames; static nsTHashtable<WebIDLNameTableEntry>* sWebIDLGlobalNames;
@@ -163,7 +163,7 @@ WebIDLGlobalNameHash::Shutdown()
void void
WebIDLGlobalNameHash::Register(uint16_t aNameOffset, uint16_t aNameLength, WebIDLGlobalNameHash::Register(uint16_t aNameOffset, uint16_t aNameLength,
DefineGlobalName aDefine, DefineGlobalName aDefine,
ConstructorEnabled aEnabled, ConstructorEnabled* aEnabled,
constructors::id::ID aConstructorId) constructors::id::ID aConstructorId)
{ {
const char* name = sNames + aNameOffset; const char* name = sNames + aNameOffset;
@@ -211,7 +211,7 @@ WebIDLGlobalNameHash::DefineIfEnabled(JSContext* aCx,
*aFound = true; *aFound = true;
ConstructorEnabled checkEnabledForScope = entry->mEnabled; ConstructorEnabled* checkEnabledForScope = entry->mEnabled;
// We do the enabled check on the current compartment of aCx, but for the // 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 // 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 // way the callee can decide whether to allow access based on the caller

View File

@@ -38,10 +38,10 @@ public:
// pointer, so it's more obvious that pointers to a ConstructorEnabled // pointer, so it's more obvious that pointers to a ConstructorEnabled
// can be null. // can be null.
typedef bool 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, static void Register(uint16_t aNameOffset, uint16_t aNameLength,
DefineGlobalName aDefine, ConstructorEnabled aEnabled, DefineGlobalName aDefine, ConstructorEnabled* aEnabled,
constructors::id::ID aConstructorId); constructors::id::ID aConstructorId);
static void Remove(const char* aName, uint32_t aLength); static void Remove(const char* aName, uint32_t aLength);

View File

@@ -72,10 +72,10 @@
let receivedMessageIndex = 0; let receivedMessageIndex = 0;
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe); let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
mm.addMessageListener("test:ipcClonedMessage", SpecialPowers.wrapCallback(function(message) { mm.addMessageListener("test:ipcClonedMessage", function(message) {
let data = message.json; let data = message.json;
if (SpecialPowers.call_Instanceof(data, Blob)) { if (data instanceof Blob) {
is(receivedMessageIndex, messages.length - 1, "Blob is last"); is(receivedMessageIndex, messages.length - 1, "Blob is last");
is (data.size, is (data.size,
messages[receivedMessageIndex].size, messages[receivedMessageIndex].size,
@@ -104,7 +104,7 @@
} }
}; };
SpecialPowers.wrap(reader1).readAsText(data); reader1.readAsText(data);
reader2.readAsText(messages[receivedMessageIndex]); reader2.readAsText(messages[receivedMessageIndex]);
return; return;
} }
@@ -112,7 +112,7 @@
is(message.json, is(message.json,
messages[receivedMessageIndex++], messages[receivedMessageIndex++],
"Got correct round-tripped response"); "Got correct round-tripped response");
})); });
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();", mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
false); false);

View File

@@ -80,14 +80,11 @@ function waitForMessage(aMessage, browser)
{ {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
/* eslint-disable no-undef */ /* 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() { function contentScript() {
addEventListener("message", function(event) { addEventListener("message", function(event) {
sendAsyncMessage("testLocal:message", sendAsyncMessage("testLocal:message",
{message: event.data}); {message: event.data});
}, {once: true, capture: true}, true); }, {once: true}, true);
} }
/* eslint-enable no-undef */ /* eslint-enable no-undef */

View File

@@ -214,16 +214,16 @@ function parentFrameScript(mm) {
function* testSteps() { function* testSteps() {
let result = yield undefined; 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"); is(result.length, 2, "Child delivered two results");
let blob = result[0]; 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.size, blobText.length, "Blob has correct size");
is(blob.type, blobType, "Blob has correct type"); is(blob.type, blobType, "Blob has correct type");
let slice = result[1]; 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.size, blobData[0].length, "Slice has correct size");
is(slice.type, blobType, "Slice has correct type"); is(slice.type, blobType, "Slice has correct type");
@@ -231,7 +231,7 @@ function parentFrameScript(mm) {
let reader = new FileReader(); let reader = new FileReader();
reader.onload = grabAndContinue; reader.onload = grabAndContinue;
SpecialPowers.wrap(reader).readAsText(blob); reader.readAsText(blob);
yield undefined; yield undefined;
is(reader.result, blobText, "Blob has correct data"); is(reader.result, blobText, "Blob has correct data");
@@ -240,14 +240,14 @@ function parentFrameScript(mm) {
reader = new FileReader(); reader = new FileReader();
reader.onload = grabAndContinue; reader.onload = grabAndContinue;
SpecialPowers.wrap(reader).readAsText(slice); reader.readAsText(slice);
yield undefined; yield undefined;
is(reader.result, blobData[0], "Slice has correct data"); is(reader.result, blobData[0], "Slice has correct data");
slice = blob.slice(0, blobData[0].length, blobType); 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.size, blobData[0].length, "Second slice has correct size");
is(slice.type, blobType, "Second slice has correct type"); is(slice.type, blobType, "Second slice has correct type");
@@ -255,7 +255,7 @@ function parentFrameScript(mm) {
reader = new FileReader(); reader = new FileReader();
reader.onload = grabAndContinue; reader.onload = grabAndContinue;
SpecialPowers.wrap(reader).readAsText(slice); reader.readAsText(slice);
yield undefined; yield undefined;
is(reader.result, blobData[0], "Second slice has correct data"); is(reader.result, blobData[0], "Second slice has correct data");
@@ -266,7 +266,7 @@ function parentFrameScript(mm) {
let testGenerator = testSteps(); let testGenerator = testSteps();
testGenerator.next(); testGenerator.next();
mm.addMessageListener(messageName, SpecialPowers.wrapCallback(function(message) { mm.addMessageListener(messageName, function(message) {
let data = message.data; let data = message.data;
switch (data.op) { switch (data.op) {
case "info": { case "info": {
@@ -289,7 +289,7 @@ function parentFrameScript(mm) {
SimpleTest.finish(); SimpleTest.finish();
} }
} }
})); });
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();", mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
false); false);

View File

@@ -5,6 +5,7 @@
#include "nsISupports.idl" #include "nsISupports.idl"
interface nsIDOMElement; interface nsIDOMElement;
interface nsIMessageSender;
interface nsIURI; interface nsIURI;
[scriptable, builtinclass, uuid(456f58be-29dd-4973-885b-95aece1c9a8a)] [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 * The process manager for this ContentParent (so a process message manager
* as opposed to a frame message manager. * as opposed to a frame message manager.
*/ */
readonly attribute nsISupports messageManager; readonly attribute nsIMessageSender messageManager;
}; };
[scriptable, uuid(83ffb063-5f65-4c45-ae07-3f553e0809bb)] [scriptable, uuid(83ffb063-5f65-4c45-ae07-3f553e0809bb)]

View File

@@ -6,6 +6,7 @@
#include "domstubs.idl" #include "domstubs.idl"
#include "nsIDroppedLinkHandler.idl" #include "nsIDroppedLinkHandler.idl"
interface nsIContentFrameMessageManager;
interface nsIWebBrowserChrome3; interface nsIWebBrowserChrome3;
native CommandsArray(nsTArray<nsCString>); native CommandsArray(nsTArray<nsCString>);
@@ -14,7 +15,7 @@ native CommandsArray(nsTArray<nsCString>);
[scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)] [scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)]
interface nsITabChild : nsISupports interface nsITabChild : nsISupports
{ {
readonly attribute nsISupports messageManager; readonly attribute nsIContentFrameMessageManager messageManager;
attribute nsIWebBrowserChrome3 webBrowserChrome; attribute nsIWebBrowserChrome3 webBrowserChrome;

View File

@@ -5,7 +5,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ContentBridgeParent.h" #include "mozilla/dom/ContentBridgeParent.h"
#include "mozilla/dom/ChromeMessageSender.h"
#include "mozilla/dom/TabParent.h" #include "mozilla/dom/TabParent.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"

View File

@@ -24,7 +24,6 @@
#include "mozilla/docshell/OfflineCacheUpdateChild.h" #include "mozilla/docshell/OfflineCacheUpdateChild.h"
#include "mozilla/dom/ClientManager.h" #include "mozilla/dom/ClientManager.h"
#include "mozilla/dom/ClientOpenWindowOpActors.h" #include "mozilla/dom/ClientOpenWindowOpActors.h"
#include "mozilla/dom/ChildProcessMessageManager.h"
#include "mozilla/dom/ContentBridgeChild.h" #include "mozilla/dom/ContentBridgeChild.h"
#include "mozilla/dom/ContentBridgeParent.h" #include "mozilla/dom/ContentBridgeParent.h"
#include "mozilla/dom/DOMPrefs.h" #include "mozilla/dom/DOMPrefs.h"

View File

@@ -526,7 +526,7 @@ ScriptableCPInfo::GetTabCount(int32_t* aTabCount)
} }
NS_IMETHODIMP NS_IMETHODIMP
ScriptableCPInfo::GetMessageManager(nsISupports** aMessenger) ScriptableCPInfo::GetMessageManager(nsIMessageSender** aMessenger)
{ {
*aMessenger = nullptr; *aMessenger = nullptr;
if (!mContentParent) { if (!mContentParent) {

View File

@@ -19,7 +19,6 @@
#include "mozilla/BrowserElementParent.h" #include "mozilla/BrowserElementParent.h"
#include "mozilla/ClearOnShutdown.h" #include "mozilla/ClearOnShutdown.h"
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
#include "mozilla/dom/MessageManagerBinding.h"
#include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h" #include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
#include "mozilla/dom/PaymentRequestChild.h" #include "mozilla/dom/PaymentRequestChild.h"
#include "mozilla/dom/TelemetryScrollProbe.h" #include "mozilla/dom/TelemetryScrollProbe.h"
@@ -105,6 +104,7 @@
#include "UnitTransforms.h" #include "UnitTransforms.h"
#include "ClientLayerManager.h" #include "ClientLayerManager.h"
#include "LayersLogging.h" #include "LayersLogging.h"
#include "nsDOMClassInfoID.h"
#include "nsColorPickerProxy.h" #include "nsColorPickerProxy.h"
#include "nsContentPermissionHelper.h" #include "nsContentPermissionHelper.h"
#include "nsNetUtil.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 // Let the BrowserElementScrolling helper (if it exists) for this
// content manipulate the frame state. // 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, mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
aMessageName, false, &data, nullptr, nullptr, nullptr); aMessageName, false, &data, nullptr, nullptr, nullptr);
} }
@@ -271,7 +272,7 @@ TabChildBase::UpdateFrameHandler(const FrameMetrics& aFrameMetrics)
void void
TabChildBase::ProcessUpdateFrame(const FrameMetrics& aFrameMetrics) TabChildBase::ProcessUpdateFrame(const FrameMetrics& aFrameMetrics)
{ {
if (!mTabChildGlobal) { if (!mGlobal || !mTabChildGlobal) {
return; return;
} }
@@ -1108,11 +1109,13 @@ TabChild::ActorDestroy(ActorDestroyReason why)
// We should have a message manager if the global is alive, but it // 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 // seems sometimes we don't. Assert in aurora/nightly, but don't
// crash in release builds. // crash in release builds.
MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->GetMessageManager()); MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->mMessageManager);
if (mTabChildGlobal->GetMessageManager()) { if (mTabChildGlobal->mMessageManager) {
// The messageManager relays messages via the TabChild which // The messageManager relays messages via the TabChild which
// no longer exists. // 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) const ScrollableLayerGuid& aGuid)
{ {
TABC_LOG("Handling double tap at %s with %p %p\n", TABC_LOG("Handling double tap at %s with %p %p\n",
Stringify(aPoint).c_str(), Stringify(aPoint).c_str(), mGlobal.get(), mTabChildGlobal.get());
mTabChildGlobal ? mTabChildGlobal->GetWrapper() : nullptr,
mTabChildGlobal.get());
if (!mTabChildGlobal || !mTabChildGlobal->GetWrapper()) { if (!mGlobal || !mTabChildGlobal) {
return; return;
} }
@@ -1404,7 +1405,7 @@ TabChild::RecvHandleTap(const GeckoContentController::TapType& aType,
switch (aType) { switch (aType) {
case GeckoContentController::TapType::eSingleTap: case GeckoContentController::TapType::eSingleTap:
if (mTabChildGlobal) { if (mGlobal && mTabChildGlobal) {
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 1); mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 1);
} }
break; break;
@@ -1412,18 +1413,18 @@ TabChild::RecvHandleTap(const GeckoContentController::TapType& aType,
HandleDoubleTap(point, aModifiers, aGuid); HandleDoubleTap(point, aModifiers, aGuid);
break; break;
case GeckoContentController::TapType::eSecondTap: case GeckoContentController::TapType::eSecondTap:
if (mTabChildGlobal) { if (mGlobal && mTabChildGlobal) {
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 2); mAPZEventState->ProcessSingleTap(point, scale, aModifiers, aGuid, 2);
} }
break; break;
case GeckoContentController::TapType::eLongTap: case GeckoContentController::TapType::eLongTap:
if (mTabChildGlobal) { if (mGlobal && mTabChildGlobal) {
mAPZEventState->ProcessLongTap(presShell, point, scale, aModifiers, aGuid, mAPZEventState->ProcessLongTap(presShell, point, scale, aModifiers, aGuid,
aInputBlockId); aInputBlockId);
} }
break; break;
case GeckoContentController::TapType::eLongTapUp: case GeckoContentController::TapType::eLongTapUp:
if (mTabChildGlobal) { if (mGlobal && mTabChildGlobal) {
mAPZEventState->ProcessLongTapUp(presShell, point, scale, aModifiers); mAPZEventState->ProcessLongTapUp(presShell, point, scale, aModifiers);
} }
break; break;
@@ -2275,18 +2276,12 @@ TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture)
mozilla::ipc::IPCResult mozilla::ipc::IPCResult
TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalScope) 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 // This can happen if we're half-destroyed. It's not a fatal
// error. // error.
return IPC_OK(); return IPC_OK();
JS::Rooted<JSObject*> global(RootingCx(), mTabChildGlobal->GetWrapper()); LoadScriptInternal(aURL, aRunInGlobalScope);
if (!global) {
// This can happen if we're half-destroyed. It's not a fatal error.
return IPC_OK();
}
LoadScriptInternal(global, aURL, aRunInGlobalScope);
return IPC_OK(); return IPC_OK();
} }
@@ -2304,19 +2299,19 @@ TabChild::RecvAsyncMessage(const nsString& aMessage,
return IPC_OK(); return IPC_OK();
} }
RefPtr<nsFrameMessageManager> mm = mTabChildGlobal->GetMessageManager();
// We should have a message manager if the global is alive, but it // 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 // seems sometimes we don't. Assert in aurora/nightly, but don't
// crash in release builds. // crash in release builds.
MOZ_DIAGNOSTIC_ASSERT(mm); MOZ_DIAGNOSTIC_ASSERT(mTabChildGlobal->mMessageManager);
if (!mm) { if (!mTabChildGlobal->mMessageManager) {
return IPC_OK(); return IPC_OK();
} }
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), mTabChildGlobal->GetWrapper()); JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), GetGlobal());
StructuredCloneData data; StructuredCloneData data;
UnpackClonedMessageDataForChild(aData, data); UnpackClonedMessageDataForChild(aData, data);
RefPtr<nsFrameMessageManager> mm =
static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr, mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal), nullptr,
aMessage, false, &data, &cpows, aPrincipal, nullptr); aMessage, false, &data, &cpows, aPrincipal, nullptr);
return IPC_OK(); return IPC_OK();
@@ -2722,29 +2717,27 @@ TabChild::DeallocPRenderFrameChild(PRenderFrameChild* aFrame)
bool bool
TabChild::InitTabChildGlobal() TabChild::InitTabChildGlobal()
{ {
if (!mTabChildGlobal) { if (!mGlobal && !mTabChildGlobal) {
nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation()); nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
NS_ENSURE_TRUE(window, false); NS_ENSURE_TRUE(window, false);
nsCOMPtr<EventTarget> chromeHandler = nsCOMPtr<EventTarget> chromeHandler =
do_QueryInterface(window->GetChromeEventHandler()); do_QueryInterface(window->GetChromeEventHandler());
NS_ENSURE_TRUE(chromeHandler, false); 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"); NS_NAMED_LITERAL_CSTRING(globalId, "outOfProcessTabChildGlobal");
if (NS_WARN_IF(!InitChildGlobalInternal(globalId))) { NS_ENSURE_TRUE(InitChildGlobalInternal(scopeSupports, globalId), false);
mTabChildGlobal = nullptr;
return false;
}
scope->Init(); scope->Init();
nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler); nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
if (NS_WARN_IF(!root)) { NS_ENSURE_TRUE(root, false);
mTabChildGlobal = nullptr;
return false;
}
root->SetParentTarget(scope); root->SetParentTarget(scope);
mTabChildGlobal = scope.forget();;
} }
if (!mTriedBrowserInit) { if (!mTriedBrowserInit) {
@@ -2965,11 +2958,14 @@ TabChild::IsVisible()
} }
NS_IMETHODIMP NS_IMETHODIMP
TabChild::GetMessageManager(nsISupports** aResult) TabChild::GetMessageManager(nsIContentFrameMessageManager** aResult)
{ {
nsCOMPtr<nsIContentFrameMessageManager> mm(mTabChildGlobal); if (mTabChildGlobal) {
mm.forget(aResult); NS_ADDREF(*aResult = mTabChildGlobal);
return *aResult ? NS_OK : NS_ERROR_FAILURE; return NS_OK;
}
*aResult = nullptr;
return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP NS_IMETHODIMP
@@ -3477,9 +3473,9 @@ TabChild::TabGroup()
} }
TabChildGlobal::TabChildGlobal(TabChild* aTabChild) TabChildGlobal::TabChildGlobal(TabChild* aTabChild)
: ContentFrameMessageManager(new nsFrameMessageManager(aTabChild)), : mTabChild(aTabChild)
mTabChild(aTabChild)
{ {
SetIsNotDOMBinding();
} }
TabChildGlobal::~TabChildGlobal() TabChildGlobal::~TabChildGlobal()
@@ -3489,6 +3485,11 @@ TabChildGlobal::~TabChildGlobal()
void void
TabChildGlobal::Init() TabChildGlobal::Init()
{ {
NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
mMessageManager = new nsFrameMessageManager(mTabChild,
nullptr,
MM_CHILD);
TelemetryScrollProbe::Create(this); TelemetryScrollProbe::Create(this);
} }
@@ -3516,26 +3517,12 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(TabChildGlobal, DOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(TabChildGlobal, DOMEventTargetHelper)
NS_IMPL_RELEASE_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 // This method isn't automatically forwarded safely because it's notxpcom, so
// the IDL binding doesn't know what value to return. // the IDL binding doesn't know what value to return.
NS_IMETHODIMP_(bool) NS_IMETHODIMP_(bool)
@@ -3548,59 +3535,36 @@ TabChildGlobal::MarkForCC()
if (elm) { if (elm) {
elm->MarkForCC(); elm->MarkForCC();
} }
return MessageManagerGlobal::MarkForCC(); return mMessageManager ? mMessageManager->MarkForCC() : false;
}
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();
} }
NS_IMETHODIMP NS_IMETHODIMP
TabChildGlobal::GetContent(mozIDOMWindowProxy** aContent) TabChildGlobal::GetContent(mozIDOMWindowProxy** aContent)
{ {
ErrorResult rv; *aContent = nullptr;
*aContent = GetContent(rv).take(); if (!mTabChild)
return rv.StealNSResult(); return NS_ERROR_NULL_POINTER;
} nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(mTabChild->WebNavigation());
window.forget(aContent);
already_AddRefed<nsIDocShell> return NS_OK;
TabChildGlobal::GetDocShell(ErrorResult& aError)
{
if (!mTabChild) {
aError.Throw(NS_ERROR_NULL_POINTER);
return nullptr;
}
nsCOMPtr<nsIDocShell> window = do_GetInterface(mTabChild->WebNavigation());
return window.forget();
} }
NS_IMETHODIMP NS_IMETHODIMP
TabChildGlobal::GetDocShell(nsIDocShell** aDocShell) TabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
{ {
ErrorResult rv; *aDocShell = nullptr;
*aDocShell = GetDocShell(rv).take(); if (!mTabChild)
return rv.StealNSResult(); return NS_ERROR_NULL_POINTER;
} nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mTabChild->WebNavigation());
docShell.swap(*aDocShell);
already_AddRefed<nsIEventTarget> return NS_OK;
TabChildGlobal::GetTabEventTarget()
{
nsCOMPtr<nsIEventTarget> target = EventTargetFor(TaskCategory::Other);
return target.forget();
} }
NS_IMETHODIMP NS_IMETHODIMP
TabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget) TabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget)
{ {
*aTarget = GetTabEventTarget().take(); nsCOMPtr<nsIEventTarget> target = EventTargetFor(TaskCategory::Other);
target.forget(aTarget);
return NS_OK; return NS_OK;
} }
@@ -3616,7 +3580,7 @@ JSObject*
TabChildGlobal::GetGlobalJSObject() TabChildGlobal::GetGlobalJSObject()
{ {
NS_ENSURE_TRUE(mTabChild, nullptr); NS_ENSURE_TRUE(mTabChild, nullptr);
return GetWrapper(); return mTabChild->GetGlobal();
} }
nsresult nsresult

View File

@@ -7,7 +7,6 @@
#ifndef mozilla_dom_TabChild_h #ifndef mozilla_dom_TabChild_h
#define mozilla_dom_TabChild_h #define mozilla_dom_TabChild_h
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/dom/PBrowserChild.h" #include "mozilla/dom/PBrowserChild.h"
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
@@ -79,7 +78,7 @@ class ClonedMessageData;
class CoalescedMouseData; class CoalescedMouseData;
class CoalescedWheelData; class CoalescedWheelData;
class TabChildGlobal : public ContentFrameMessageManager, class TabChildGlobal : public DOMEventTargetHelper,
public nsIContentFrameMessageManager, public nsIContentFrameMessageManager,
public nsIScriptObjectPrincipal, public nsIScriptObjectPrincipal,
public nsIGlobalObject, public nsIGlobalObject,
@@ -90,25 +89,58 @@ public:
void Init(); void Init();
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, DOMEventTargetHelper) 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_NSIMESSAGELISTENERMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager);
NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(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 nsresult
GetEventTargetParent(EventChainPreVisitor& aVisitor) override GetEventTargetParent(EventChainPreVisitor& aVisitor) override
@@ -120,6 +152,11 @@ public:
virtual nsIPrincipal* GetPrincipal() override; virtual nsIPrincipal* GetPrincipal() override;
virtual JSObject* GetGlobalJSObject() 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. // Dispatch a runnable related to the global.
virtual nsresult Dispatch(mozilla::TaskCategory aCategory, virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) override; already_AddRefed<nsIRunnable>&& aRunnable) override;
@@ -130,6 +167,7 @@ public:
virtual AbstractThread* virtual AbstractThread*
AbstractMainThreadFor(mozilla::TaskCategory aCategory) override; AbstractMainThreadFor(mozilla::TaskCategory aCategory) override;
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
RefPtr<TabChild> mTabChild; RefPtr<TabChild> mTabChild;
protected: protected:
@@ -164,13 +202,6 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TabChildBase) 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 nsIWebNavigation* WebNavigation() const = 0;
virtual PuppetWidget* WebWidget() = 0; virtual PuppetWidget* WebWidget() = 0;
nsIPrincipal* GetPrincipal() { return mPrincipal; } nsIPrincipal* GetPrincipal() { return mPrincipal; }
@@ -279,11 +310,6 @@ public:
FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild) FORWARD_SHMEM_ALLOCATOR_TO(PBrowserChild)
nsIContentFrameMessageManager* GetMessageManager()
{
return mTabChildGlobal;
}
/** /**
* MessageManagerCallback methods that we override. * MessageManagerCallback methods that we override.
*/ */

View File

@@ -13,7 +13,6 @@
#include "nsAccessibilityService.h" #include "nsAccessibilityService.h"
#endif #endif
#include "mozilla/BrowserElementParent.h" #include "mozilla/BrowserElementParent.h"
#include "mozilla/dom/ChromeMessageSender.h"
#include "mozilla/dom/ContentBridgeParent.h" #include "mozilla/dom/ContentBridgeParent.h"
#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/DataTransfer.h" #include "mozilla/dom/DataTransfer.h"

View File

@@ -7,7 +7,6 @@
#include "nsIContentChild.h" #include "nsIContentChild.h"
#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ChildProcessMessageManager.h"
#include "mozilla/dom/DOMTypes.h" #include "mozilla/dom/DOMTypes.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/PermissionMessageUtils.h" #include "mozilla/dom/PermissionMessageUtils.h"

View File

@@ -8,7 +8,6 @@
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/ChromeMessageSender.h"
#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentBridgeParent.h" #include "mozilla/dom/ContentBridgeParent.h"
#include "mozilla/dom/ContentProcessManager.h" #include "mozilla/dom/ContentProcessManager.h"
@@ -25,6 +24,7 @@
#include "mozilla/ipc/IPCStreamSource.h" #include "mozilla/ipc/IPCStreamSource.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "nsFrameMessageManager.h"
#include "nsIWebBrowserChrome.h" #include "nsIWebBrowserChrome.h"
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
#include "xpcpublic.h" #include "xpcpublic.h"

View File

@@ -44,7 +44,6 @@ namespace dom {
class Blob; class Blob;
class BlobConstructorParams; class BlobConstructorParams;
class BlobImpl; class BlobImpl;
class ChromeMessageSender;
class ContentParent; class ContentParent;
class ContentBridgeParent; class ContentBridgeParent;
class IPCTabContext; class IPCTabContext;
@@ -89,7 +88,7 @@ public:
ContentBridgeParent* AsContentBridgeParent(); ContentBridgeParent* AsContentBridgeParent();
mozilla::dom::ChromeMessageSender* GetMessageManager() const { return mMessageManager; } nsFrameMessageManager* GetMessageManager() const { return mMessageManager; }
virtual bool SendActivate(PBrowserParent* aTab) = 0; virtual bool SendActivate(PBrowserParent* aTab) = 0;
@@ -162,7 +161,7 @@ protected: // IPDL methods
const ClonedMessageData& aData); const ClonedMessageData& aData);
protected: // members protected: // members
RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager; RefPtr<nsFrameMessageManager> mMessageManager;
}; };
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentParent, NS_ICONTENTPARENT_IID) NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentParent, NS_ICONTENTPARENT_IID)

View File

@@ -5,7 +5,8 @@
dump("Loading remote script!\n"); dump("Loading remote script!\n");
dump(content + "\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", cpm.addMessageListener("cpm-async",
function(m) { function(m) {
cpm.sendSyncMessage("ppm-sync"); cpm.sendSyncMessage("ppm-sync");

View File

@@ -85,11 +85,11 @@
// 1. Test that loading a script works, and that accessing process level mm and // 1. Test that loading a script works, and that accessing process level mm and
// global mm works. // global mm works.
var ppm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"] var ppm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"]
.getService(); .getService(Components.interfaces.nsIMessageBroadcaster);
var gm = Components.classes["@mozilla.org/globalmessagemanager;1"] var gm = Components.classes["@mozilla.org/globalmessagemanager;1"]
.getService(); .getService(Components.interfaces.nsIMessageBroadcaster);
var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"] var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
.getService(); .getService(Components.interfaces.nsISyncMessageSender);
if (ppm.childCount != 2) { if (ppm.childCount != 2) {
alert("Should have two child processes!"); alert("Should have two child processes!");

View File

@@ -53,7 +53,7 @@ function parentFrameScript(mm) {
let finishedTestingBlob = false; let finishedTestingBlob = false;
let finishedTestingSlice = false; let finishedTestingSlice = false;
mm.addMessageListener(messageName, SpecialPowers.wrapCallback(function(message) { mm.addMessageListener(messageName, function(message) {
if ("blob" in message.data) { if ("blob" in message.data) {
is(receivedBlob, false, "Have not yet received Blob"); is(receivedBlob, false, "Have not yet received Blob");
is(receivedSlice, false, "Have not yet received Slice"); is(receivedSlice, false, "Have not yet received Slice");
@@ -64,7 +64,7 @@ function parentFrameScript(mm) {
let blob = message.data.blob; 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.size, blobText.length, "Blob has correct size");
is(blob.type, blobType, "Blob has correct type"); is(blob.type, blobType, "Blob has correct type");
@@ -73,7 +73,7 @@ function parentFrameScript(mm) {
blob.size, blob.size,
blobType); blobType);
ok(SpecialPowers.call_Instanceof(slice, Blob), "Slice returned a Blob"); ok(slice instanceof Blob, "Slice returned a Blob");
is(slice.size, is(slice.size,
blobData[blobData.length - 1].length, blobData[blobData.length - 1].length,
"Slice has correct size"); "Slice has correct size");
@@ -91,7 +91,7 @@ function parentFrameScript(mm) {
SimpleTest.finish(); SimpleTest.finish();
} }
}; };
SpecialPowers.wrap(reader).readAsText(slice); reader.readAsText(slice);
return; return;
} }
@@ -105,7 +105,7 @@ function parentFrameScript(mm) {
let slice = message.data.slice; 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.size, sliceText.length, "Slice has correct size");
is(slice.type, blobType, "Slice has correct type"); is(slice.type, blobType, "Slice has correct type");
@@ -115,7 +115,7 @@ function parentFrameScript(mm) {
let slice2 = slice.slice(1, 2, blobType); 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.size, 1, "Slice has correct size");
is(slice2.type, blobType, "Slice has correct type"); is(slice2.type, blobType, "Slice has correct type");
@@ -129,15 +129,15 @@ function parentFrameScript(mm) {
SimpleTest.finish(); SimpleTest.finish();
} }
}; };
SpecialPowers.wrap(reader2).readAsText(slice2); reader2.readAsText(slice2);
}; };
SpecialPowers.wrap(reader).readAsText(slice); reader.readAsText(slice);
return; return;
} }
ok(false, "Received a bad message: " + JSON.stringify(message.data)); ok(false, "Received a bad message: " + JSON.stringify(message.data));
})); });
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();", mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
false); false);

View File

@@ -117,13 +117,13 @@ function parentFrameScript(mm) {
function* testSteps() { function* testSteps() {
let slice = yield undefined; 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.size, sliceText.length, "Slice has correct size");
is(slice.type, blobType, "Slice has correct type"); is(slice.type, blobType, "Slice has correct type");
let reader = new FileReader(); let reader = new FileReader();
reader.onload = grabAndContinue; reader.onload = grabAndContinue;
SpecialPowers.wrap(reader).readAsText(slice); reader.readAsText(slice);
yield undefined; yield undefined;
is(reader.result, sliceText, "Slice has correct data"); is(reader.result, sliceText, "Slice has correct data");
@@ -133,7 +133,7 @@ function parentFrameScript(mm) {
let testGenerator = testSteps(); let testGenerator = testSteps();
testGenerator.next(); testGenerator.next();
mm.addMessageListener(messageName, SpecialPowers.wrapCallback(function(message) { mm.addMessageListener(messageName, function(message) {
let data = message.data; let data = message.data;
switch (data.op) { switch (data.op) {
case "info": { case "info": {
@@ -156,7 +156,7 @@ function parentFrameScript(mm) {
SimpleTest.finish(); SimpleTest.finish();
} }
} }
})); });
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();", mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
false); false);

View File

@@ -52,8 +52,7 @@
test.next(msg.data.value); test.next(msg.data.value);
} }
mm.addMessageListener("testBug1086684:childDone", mm.addMessageListener("testBug1086684:childDone", testDone);
SpecialPowers.wrapCallback(testDone));
let blob = new Blob([]); let blob = new Blob([]);
let file = new File([blob], "helloworld.txt", { type: "text/plain" }); let file = new File([blob], "helloworld.txt", { type: "text/plain" });

View File

@@ -40,8 +40,7 @@
test.next(msg.data); test.next(msg.data);
} }
mm.addMessageListener("testCPOWCookies:test1Finished", mm.addMessageListener("testCPOWCookies:test1Finished", testDone);
SpecialPowers.wrapCallback(testDone));
mm.sendAsyncMessage("testCPOWCookies:test1", {}); mm.sendAsyncMessage("testCPOWCookies:test1", {});
lastResult = yield; lastResult = yield;

View File

@@ -68,8 +68,9 @@ class GlobalPCList {
Services.obs.addObserver(this, "gmp-plugin-crash", true); Services.obs.addObserver(this, "gmp-plugin-crash", true);
Services.obs.addObserver(this, "PeerConnection:response:allow", true); Services.obs.addObserver(this, "PeerConnection:response:allow", true);
Services.obs.addObserver(this, "PeerConnection:response:deny", true); Services.obs.addObserver(this, "PeerConnection:response:deny", true);
if (Services.cpmm) { if (Cc["@mozilla.org/childprocessmessagemanager;1"]) {
Services.cpmm.addMessageListener("gmp-plugin-crash", this); let mm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
mm.addMessageListener("gmp-plugin-crash", this);
} }
} }

View File

@@ -15,6 +15,10 @@ ChromeUtils.import("resource://gre/modules/osfile.jsm");
ChromeUtils.defineModuleGetter(this, "Services", ChromeUtils.defineModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm"); "resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageListenerManager");
XPCOMUtils.defineLazyServiceGetter(this, "notificationStorage", XPCOMUtils.defineLazyServiceGetter(this, "notificationStorage",
"@mozilla.org/notificationStorage;1", "@mozilla.org/notificationStorage;1",
"nsINotificationStorage"); "nsINotificationStorage");
@@ -52,13 +56,13 @@ var NotificationDB = {
registerListeners: function() { registerListeners: function() {
for (let message of kMessages) { for (let message of kMessages) {
Services.ppmm.addMessageListener(message, this); ppmm.addMessageListener(message, this);
} }
}, },
unregisterListeners: function() { unregisterListeners: function() {
for (let message of kMessages) { for (let message of kMessages) {
Services.ppmm.removeMessageListener(message, this); ppmm.removeMessageListener(message, this);
} }
}, },

View File

@@ -15,6 +15,10 @@ const NOTIFICATIONSTORAGE_CONTRACTID = "@mozilla.org/notificationStorage;1";
ChromeUtils.defineModuleGetter(this, "Services", ChromeUtils.defineModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm"); "resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
const kMessageNotificationGetAllOk = "Notification:GetAll:Return:OK"; const kMessageNotificationGetAllOk = "Notification:GetAll:Return:OK";
const kMessageNotificationGetAllKo = "Notification:GetAll:Return:KO"; const kMessageNotificationGetAllKo = "Notification:GetAll:Return:KO";
const kMessageNotificationSaveKo = "Notification:Save:Return:KO"; const kMessageNotificationSaveKo = "Notification:Save:Return:KO";
@@ -46,13 +50,13 @@ NotificationStorage.prototype = {
registerListeners: function() { registerListeners: function() {
for (let message of kMessages) { for (let message of kMessages) {
Services.cpmm.addMessageListener(message, this); cpmm.addMessageListener(message, this);
} }
}, },
unregisterListeners: function() { unregisterListeners: function() {
for (let message of kMessages) { for (let message of kMessages) {
Services.cpmm.removeMessageListener(message, this); cpmm.removeMessageListener(message, this);
} }
}, },
@@ -100,7 +104,7 @@ NotificationStorage.prototype = {
}; };
if (serviceWorkerRegistrationScope) { if (serviceWorkerRegistrationScope) {
Services.cpmm.sendAsyncMessage("Notification:Save", { cpmm.sendAsyncMessage("Notification:Save", {
origin: origin, origin: origin,
notification: notification notification: notification
}); });
@@ -145,7 +149,7 @@ NotificationStorage.prototype = {
delete this._notifications[id]; delete this._notifications[id];
} }
Services.cpmm.sendAsyncMessage("Notification:Delete", { cpmm.sendAsyncMessage("Notification:Delete", {
origin: origin, origin: origin,
id: id id: id
}); });
@@ -190,7 +194,7 @@ NotificationStorage.prototype = {
}; };
var requestID = this._requestCount++; var requestID = this._requestCount++;
this._requests[requestID] = request; this._requests[requestID] = request;
Services.cpmm.sendAsyncMessage("Notification:GetAll", { cpmm.sendAsyncMessage("Notification:GetAll", {
origin: origin, origin: origin,
requestID: requestID requestID: requestID
}); });

Some files were not shown because too many files have changed in this diff Show More