Merge the last PGO-green inbound changeset to m-c.

This commit is contained in:
Ryan VanderMeulen 2012-08-27 15:01:44 -04:00
commit d7d4930e6d
116 changed files with 1366 additions and 779 deletions

View File

@ -49,7 +49,7 @@ XPCOMUtils.defineLazyGetter(this, 'DebuggerServer', function() {
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager);
.getService(Ci.nsIMessageListenerManager);
});
function getContentWindow() {

View File

@ -14,7 +14,8 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
return Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsIMessageSender);
});
function log(aMsg) {

View File

@ -14,7 +14,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
const messageManager = Cc["@mozilla.org/globalmessagemanager;1"]
.getService(Ci.nsIChromeFrameMessageManager);
.getService(Ci.nsIMessageBroadcaster);
// -----------------------------------------------------------------------
@ -70,19 +70,19 @@ MozKeyboard.prototype = {
},
setSelectedOption: function mozKeyboardSetSelectedOption(index) {
messageManager.sendAsyncMessage("Forms:Select:Choice", {
messageManager.broadcastAsyncMessage("Forms:Select:Choice", {
"index": index
});
},
setValue: function mozKeyboardSetValue(value) {
messageManager.sendAsyncMessage("Forms:Input:Value", {
messageManager.broadcastAsyncMessage("Forms:Input:Value", {
"value": value
});
},
setSelectedOptions: function mozKeyboardSetSelectedOptions(indexes) {
messageManager.sendAsyncMessage("Forms:Select:Choice", {
messageManager.broadcastAsyncMessage("Forms:Select:Choice", {
"indexes": indexes || []
});
},

View File

@ -293,6 +293,12 @@ let SocialFlyout = {
}
let SocialShareButton = {
// promptImages and promptMessages being null means we are yet to get the
// message back from the provider with the images and icons (or that we got
// the response but determined it was invalid.)
promptImages: null,
promptMessages: null,
// Called once, after window load, when the Social.provider object is initialized
init: function SSB_init() {
this.updateButtonHiddenState();
@ -311,6 +317,61 @@ let SocialShareButton = {
} else {
profileRow.hidden = true;
}
// XXX - this shouldn't be done as part of updateProfileInfo, but instead
// whenever we notice the provider has changed - but the concept of
// "provider changed" will only exist once bug 774520 lands.
this.promptImages = null;
this.promptMessages = null;
// get the recommend-prompt info.
let port = Social.provider._getWorkerPort();
if (port) {
port.onmessage = function(evt) {
if (evt.data.topic == "social.user-recommend-prompt-response") {
port.close();
this.acceptRecommendInfo(evt.data.data);
this.updateButtonHiddenState();
this.updateShareState();
}
}.bind(this);
port.postMessage({topic: "social.user-recommend-prompt"});
}
},
acceptRecommendInfo: function SSB_acceptRecommendInfo(data) {
// Accept *and validate* the user-recommend-prompt-response message.
let promptImages = {};
let promptMessages = {};
function reportError(reason) {
Cu.reportError("Invalid recommend data from provider: " + reason + ": sharing is disabled for this provider");
return false;
}
if (!data ||
!data.images || typeof data.images != "object" ||
!data.messages || typeof data.messages != "object") {
return reportError("data is missing valid 'images' or 'messages' elements");
}
for (let sub of ["share", "unshare"]) {
let url = data.images[sub];
if (!url || typeof url != "string" || url.length == 0) {
return reportError('images["' + sub + '"] is missing or not a non-empty string');
}
// resolve potentially relative URLs then check the scheme is acceptable.
url = Services.io.newURI(Social.provider.origin, null, null).resolve(url);
let uri = Services.io.newURI(url, null, null);
if (!uri.schemeIs("http") && !uri.schemeIs("https") && !uri.schemeIs("data")) {
return reportError('images["' + sub + '"] does not have a valid scheme');
}
promptImages[sub] = url;
}
for (let sub of ["shareTooltip", "unshareTooltip", "sharedLabel", "unsharedLabel"]) {
if (typeof data.messages[sub] != "string" || data.messages[sub].length == 0) {
return reportError('messages["' + sub + '"] is not a valid string');
}
promptMessages[sub] = data.messages[sub];
}
this.promptImages = promptImages;
this.promptMessages = promptMessages;
return true;
},
get shareButton() {
@ -327,7 +388,7 @@ let SocialShareButton = {
updateButtonHiddenState: function SSB_updateButtonHiddenState() {
let shareButton = this.shareButton;
if (shareButton)
shareButton.hidden = !Social.uiVisible;
shareButton.hidden = !Social.uiVisible || this.promptImages == null;
},
onClick: function SSB_onClick(aEvent) {
@ -370,23 +431,33 @@ let SocialShareButton = {
// Provide a11y-friendly notification of share.
let status = document.getElementById("share-button-status");
if (status) {
// XXX - this should also be capable of reflecting that the page was
// unshared (ie, it needs to manage three-states: (1) nothing done, (2)
// shared, (3) shared then unshared)
// Note that we *do* have an appropriate string from the provider for
// this (promptMessages['unsharedLabel'] but currently lack a way of
// tracking this state)
let statusString = currentPageShared ?
gNavigatorBundle.getString("social.pageShared.label") : "";
this.promptMessages['sharedLabel'] : "";
status.setAttribute("value", statusString);
}
// Update the share button, if present
let shareButton = this.shareButton;
if (!shareButton)
if (!shareButton || shareButton.hidden)
return;
let imageURL;
if (currentPageShared) {
shareButton.setAttribute("shared", "true");
shareButton.setAttribute("tooltiptext", gNavigatorBundle.getString("social.shareButton.sharedtooltip"));
shareButton.setAttribute("tooltiptext", this.promptMessages['unshareTooltip']);
imageURL = this.promptImages["unshare"]
} else {
shareButton.removeAttribute("shared");
shareButton.setAttribute("tooltiptext", gNavigatorBundle.getString("social.shareButton.tooltip"));
shareButton.setAttribute("tooltiptext", this.promptMessages['shareTooltip']);
imageURL = this.promptImages["share"]
}
shareButton.style.backgroundImage = 'url("' + encodeURI(imageURL) + '")';
}
};

View File

@ -360,7 +360,7 @@ const gSessionHistoryObserver = {
fwdCommand.setAttribute("disabled", "true");
// Hide session restore button on about:home
window.messageManager.sendAsyncMessage("Browser:HideSessionRestoreButton");
window.messageManager.broadcastAsyncMessage("Browser:HideSessionRestoreButton");
if (gURLBar) {
// Clear undo history of the URL bar

View File

@ -268,6 +268,7 @@ _BROWSER_FILES = \
browser_social_isVisible.js \
browser_social_chatwindow.js \
social_panel.html \
social_share_image.png \
social_sidebar.html \
social_chat.html \
social_flyout.html \

View File

@ -48,11 +48,12 @@ function testInitial(finishcb) {
let okButton = document.getElementById("editSharePopupOkButton");
let undoButton = document.getElementById("editSharePopupUndoButton");
let shareStatusLabel = document.getElementById("share-button-status");
// ensure the worker initialization and handshakes are all done and we
// have a profile.
waitForCondition(function() Social.provider.profile, function() {
is(shareButton.hidden, false, "share button should be visible");
// have a profile and the worker has responsed to the recommend-prompt msg.
waitForCondition(function() Social.provider.profile && SocialShareButton.promptImages != null, function() {
is(shareButton.hasAttribute("shared"), false, "Share button should not have 'shared' attribute before share button is clicked");
// check dom values
let profile = Social.provider.profile;
let portrait = document.getElementById("socialUserPortrait").getAttribute("src");
@ -61,14 +62,24 @@ function testInitial(finishcb) {
is(displayName.label, profile.displayName, "display name is set");
ok(!document.getElementById("editSharePopupHeader").hidden, "user profile is visible");
// Check the strings from our worker actually ended up on the button.
is(shareButton.getAttribute("tooltiptext"), "Share this page", "check tooltip text is correct");
is(shareStatusLabel.getAttribute("value"), "", "check status label text is blank");
// Check the relative URL was resolved correctly (note this image has offsets of zero...)
is(shareButton.style.backgroundImage, 'url("https://example.com/browser/browser/base/content/test/social_share_image.png")', "check image url is correct");
// Test clicking the share button
shareButton.addEventListener("click", function listener() {
shareButton.removeEventListener("click", listener);
is(shareButton.hasAttribute("shared"), true, "Share button should have 'shared' attribute after share button is clicked");
is(shareButton.getAttribute("tooltiptext"), "Unshare this page", "check tooltip text is correct");
is(shareStatusLabel.getAttribute("value"), "This page has been shared", "check status label text is correct");
// Check the URL and offsets were applied correctly
is(shareButton.style.backgroundImage, 'url("https://example.com/browser/browser/base/content/test/social_share_image.png")', "check image url is correct");
executeSoon(testSecondClick.bind(window, testPopupOKButton));
});
EventUtils.synthesizeMouseAtCenter(shareButton, {});
}, "provider didn't provide a profile");
}, "provider didn't provide user-recommend-prompt response");
}
function testSecondClick(nextTest) {

View File

@ -134,6 +134,15 @@ function runSocialTestWithProvider(manifest, callback) {
Services.prefs.setBoolPref("social.enabled", true);
registerCleanupFunction(function () {
// if one test happens to fail, it is likely finishSocialTest will not
// be called, causing most future social tests to also fail as they
// attempt to add a provider which already exists - so work
// around that by also attempting to remove the test provider.
try {
SocialService.removeProvider(provider.origin, finish);
} catch (ex) {
;
}
Social.provider = oldProvider;
Services.prefs.clearUserPref("social.enabled");
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 934 B

View File

@ -91,6 +91,25 @@ onconnect = function(e) {
case "test-isVisible-response":
testPort.postMessage({topic: "got-isVisible-response", result: event.data.result});
break;
case "social.user-recommend-prompt":
port.postMessage({
topic: "social.user-recommend-prompt-response",
data: {
images: {
// this one is relative to test we handle relative ones.
share: "browser/browser/base/content/test/social_share_image.png",
// absolute to check we handle them too.
unshare: "https://example.com/browser/browser/base/content/test/social_share_image.png"
},
messages: {
shareTooltip: "Share this page",
unshareTooltip: "Unshare this page",
sharedLabel: "This page has been shared",
unsharedLabel: "This page is no longer shared",
}
}
});
break;
}
}
}

View File

@ -372,10 +372,6 @@ fullscreen.entered=%S is now fullscreen.
# LOCALIZATION NOTE (fullscreen.rememberDecision): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).
fullscreen.rememberDecision=Remember decision for %S
social.shareButton.tooltip=Share this
social.shareButton.sharedtooltip=You shared this
social.pageShared.label=Page shared
# LOCALIZATION NOTE (social.toggle.label): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
social.toggle.label=%1$S for %2$S
social.toggle.accesskey=f

View File

@ -1373,15 +1373,8 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
/* social recommending panel */
#share-button {
list-style-image: url(chrome://browser/skin/share-button.png);
}
#share-button:not([shared]):not([disabled]):hover {
list-style-image: url(chrome://browser/skin/share-button-active.png);
}
#share-button[shared] {
list-style-image: url(chrome://browser/skin/share-button-shared.png);
width: 16px;
height: 16px;
}
#socialUserPortrait {

View File

@ -39,9 +39,6 @@ browser.jar:
skin/classic/browser/Secure.png
skin/classic/browser/Security-broken.png
skin/classic/browser/setDesktopBackground.css
skin/classic/browser/share-button.png
skin/classic/browser/share-button-active.png
skin/classic/browser/share-button-shared.png
skin/classic/browser/Toolbar.png
skin/classic/browser/Toolbar-small.png
skin/classic/browser/urlbar-arrow.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1245,15 +1245,8 @@ window[tabsontop="false"] richlistitem[type~="action"][actiontype="switchtab"][s
/* social recommending panel */
#share-button {
list-style-image: url(chrome://browser/skin/share-button.png);
}
#share-button:not([shared]):not([disabled]):hover {
list-style-image: url(chrome://browser/skin/share-button-active.png);
}
#share-button[shared] {
list-style-image: url(chrome://browser/skin/share-button-shared.png);
width: 16px;
height: 16px;
}
#socialUserPortrait {

View File

@ -64,9 +64,6 @@ browser.jar:
skin/classic/browser/newtab/controls.png (newtab/controls.png)
skin/classic/browser/newtab/noise.png (newtab/noise.png)
skin/classic/browser/setDesktopBackground.css
skin/classic/browser/share-button.png
skin/classic/browser/share-button-active.png
skin/classic/browser/share-button-shared.png
skin/classic/browser/monitor.png
skin/classic/browser/monitor_16-10.png
skin/classic/browser/places/allBookmarks.png (places/allBookmarks.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1636,15 +1636,8 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
/* social recommending panel */
#share-button {
list-style-image: url(chrome://browser/skin/share-button.png);
}
#share-button:not([shared]):not([disabled]):hover {
list-style-image: url(chrome://browser/skin/share-button-active.png);
}
#share-button[shared] {
list-style-image: url(chrome://browser/skin/share-button-shared.png);
width: 16px;
height: 16px;
}
#socialUserPortrait {

View File

@ -50,9 +50,6 @@ browser.jar:
skin/classic/browser/searchbar.css (searchbar.css)
skin/classic/browser/searchbar-dropdown-arrow.png
skin/classic/browser/setDesktopBackground.css
skin/classic/browser/share-button.png
skin/classic/browser/share-button-active.png
skin/classic/browser/share-button-shared.png
skin/classic/browser/menu-back.png (menu-back.png)
skin/classic/browser/menu-forward.png (menu-forward.png)
skin/classic/browser/monitor.png
@ -254,9 +251,6 @@ browser.jar:
skin/classic/aero/browser/searchbar.css (searchbar.css)
skin/classic/aero/browser/searchbar-dropdown-arrow.png (searchbar-dropdown-arrow-aero.png)
skin/classic/aero/browser/setDesktopBackground.css
skin/classic/aero/browser/share-button.png
skin/classic/aero/browser/share-button-active.png
skin/classic/aero/browser/share-button-shared.png
skin/classic/aero/browser/menu-back.png (menu-back-aero.png)
skin/classic/aero/browser/menu-forward.png (menu-forward-aero.png)
skin/classic/aero/browser/monitor.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -70,6 +70,8 @@ def build_one_stage(env, stage_dir, is_stage_one):
build_one_stage_aux(stage_dir, is_stage_one)
with_env(env, f)
isDarwin = platform.system() == "Darwin"
def build_one_stage_aux(stage_dir, is_stage_one):
os.mkdir(stage_dir)
@ -80,12 +82,11 @@ def build_one_stage_aux(stage_dir, is_stage_one):
"--disable-assertions",
"--prefix=%s" % inst_dir,
"--with-gcc-toolchain=/tools/gcc-4.5-0moz3"]
if is_stage_one:
if is_stage_one and not isDarwin:
configure_opts.append("--with-optimize-option=-O0")
build_package(llvm_source_dir, build_dir, configure_opts)
isDarwin = platform.system() == "Darwin"
if isDarwin:
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.7'

View File

@ -81,7 +81,7 @@ XPIDLSRCS = \
nsIFrameLoader.idl \
nsIXMLHttpRequest.idl \
nsIContentSecurityPolicy.idl \
nsIFrameMessageManager.idl \
nsIMessageManager.idl \
nsIWebSocket.idl \
nsIEventSource.idl \
$(NULL)

View File

@ -8,7 +8,7 @@
interface nsIDocShell;
interface nsIURI;
interface nsIFrame;
interface nsIChromeFrameMessageManager;
interface nsIMessageSender;
interface nsIVariant;
interface nsIDOMElement;
@ -108,7 +108,7 @@ interface nsIContentViewManager : nsISupports
readonly attribute nsIContentView rootContentView;
};
[scriptable, uuid(fc338eea-47dc-475e-add7-a3933fcfa07c)]
[scriptable, uuid(f234c232-bb17-4450-b324-bf1ef5ccfd34)]
interface nsIFrameLoader : nsISupports
{
/**
@ -177,7 +177,7 @@ interface nsIFrameLoader : nsISupports
void activateFrameEvent(in AString aType, in boolean capture);
// Note, when frameloaders are swapped, also messageManagers are swapped.
readonly attribute nsIChromeFrameMessageManager messageManager;
readonly attribute nsIMessageSender messageManager;
/**
* @see nsIDOMWindowUtils sendKeyEvent.

View File

@ -1,120 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsISupports.idl"
interface nsIDOMWindow;
interface nsIDocShell;
interface nsIContent;
[scriptable, function, uuid(938fcb95-3d63-46be-aa72-94d08fd3b418)]
interface nsIFrameMessageListener : nsISupports
{
/**
* This is for JS only.
* receiveMessage is called with one parameter, which has the following
* properties:
* {
* target: %the target of the message. Either an element owning
* the message manager, or message manager itself if no
* element owns it%
* name: %message name%,
* sync: %true or false%.
* json: %structured clone of the sent message data%,
* json: %same as .data, deprecated%,
* objects: %array of handles or null, always null if sync is false%
* }
* @note objects property isn't implemented yet.
*
* if the message is synchronous, possible return value is sent back
* as JSON (will be changed to use structured clones).
*
* When the listener is called, 'this' value is the target of the message.
*/
void receiveMessage();
};
[scriptable, builtinclass, uuid(9be42627-a5db-456f-8de2-9097da45a8c3)]
interface nsIFrameMessageManager : nsISupports
{
void addMessageListener(in AString aMessage, in nsIFrameMessageListener aListener);
void removeMessageListener(in AString aMessage, in nsIFrameMessageListener aListener);
[implicit_jscontext,optional_argc]
void sendAsyncMessage([optional] in AString messageName, [optional] in jsval obj);
[notxpcom] boolean markForCC();
};
[scriptable, builtinclass, uuid(28a36ac7-2868-4fa0-ae24-be957d7dce10)]
interface nsISyncMessageSender : nsIFrameMessageManager
{
/**
* Returns an array of JSON objects.
*/
[implicit_jscontext,optional_argc]
jsval sendSyncMessage([optional] in AString messageName, [optional] in jsval obj);
};
[scriptable, builtinclass, uuid(a83f4393-e3cf-44da-8867-1f9174c2c595)]
interface nsIContentFrameMessageManager : nsISyncMessageSender
{
/**
* The current top level window in the frame or null.
*/
readonly attribute nsIDOMWindow content;
/**
* The top level docshell or null.
*/
readonly attribute nsIDocShell docShell;
/**
* Print a string to stdout.
*/
void dump(in DOMString aStr);
/**
* If leak detection is enabled, print a note to the leak log that this
* process will intentionally crash.
*/
void privateNoteIntentionalCrash();
/**
* Ascii base64 data to binary data and vice versa
*/
DOMString atob(in DOMString aAsciiString);
DOMString btoa(in DOMString aBase64Data);
};
[uuid(f0936c56-e92c-4927-a85b-e289c3d4a01c)]
interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
{
[notxpcom] nsIContent getOwnerContent();
};
[scriptable, builtinclass, uuid(09f79e8c-101b-432b-a494-02f9b5e111c0)]
interface nsITreeItemFrameMessageManager : nsIFrameMessageManager
{
readonly attribute unsigned long childCount;
nsITreeItemFrameMessageManager getChildAt(in unsigned long aIndex);
};
[scriptable, builtinclass, uuid(a51597f0-d669-4260-83e6-1d426a8ac802)]
interface nsIChromeFrameMessageManager : nsITreeItemFrameMessageManager
{
/**
* Load a script in the (remote) frame. aURL must be the absolute URL.
* data: URLs are also supported. For example data:,dump("foo\n");
* If aAllowDelayedLoad is true, script will be loaded when the
* remote frame becomes available. Otherwise the script will be loaded
* only if the frame is already available.
*/
void loadFrameScript(in AString aURL, in boolean aAllowDelayedLoad);
/**
* Removes aURL from the list of scripts which support delayed load.
*/
void removeDelayedFrameScript(in AString aURL);
};

View File

@ -0,0 +1,330 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "nsISupports.idl"
interface nsIDOMWindow;
interface nsIDocShell;
interface nsIContent;
/**
* Message managers provide a way for chrome-privileged JS code to
* communicate with each other, even across process boundaries.
*
* Message managers are separated into "parent side" and "child side".
* These don't always correspond to process boundaries, but can. For
* each child-side message manager, there is always exactly one
* corresponding parent-side message manager that it sends messages
* to. However, for each parent-side message manager, there may be
* either one or many child-side managers it can message.
*
* Message managers that always have exactly one "other side" are of
* type nsIMessageSender. Parent-side message managers that have many
* "other sides" are of type nsIMessageBroadcaster.
*
* Child-side message managers can send synchronous messages to their
* parent side, but not the other way around.
*
* There are two realms of message manager hierarchies. One realm
* approximately corresponds to DOM elements, the other corresponds to
* process boundaries.
*
* Message managers corresponding to DOM elements
* ==============================================
*
* In this realm of message managers, there are
* - "frame message managers" which correspond to frame elements
* - "window message managers" which correspond to top-level chrome
* windows
* - the "global message manager", on the parent side. See below.
*
* The DOM-realm message managers can communicate in the ways shown by
* the following diagram. The parent side and child side can
* correspond to process boundaries, but don't always.
*
* Parent side Child side
* ------------- ------------
* global MMg
* |
* +-->window MMw1
* | |
* | +-->frame MMp1_1<------------>frame MMc1_1
* | |
* | +-->frame MMp1_2<------------>frame MMc1_2
* | ...
* |
* +-->window MMw2
* ...
*
* For example: a message sent from MMc1_1, from the child side, is
* sent only to MMp1_1 on the parent side. However, note that all
* message managers in the hierarchy above MMp1_1, in this diagram
* MMw1 and MMg, will also notify their message listeners when the
* message arrives.
* For example: a message broadcast through the global MMg on the
* parent side would be broadcast to MMw1, which would transitively
* broadcast it to MMp1_1, MM1p_2". The message would next be
* broadcast to MMw2, and so on down the hierarchy.
*
* ***** PERFORMANCE AND SECURITY WARNING *****
* Messages broadcast through the global MM and window MMs can result
* in messages being dispatched across many OS processes, and to many
* processes with different permissions. Great care should be taken
* when broadcasting.
*
* Interfaces
* ----------
*
* The global MMg and window MMw's are message broadcasters implementing
* nsIMessageBroadcaster while the frame MMp's are simple message senders
* (nsIMessageSender). Their counterparts in the content processes are
* message senders implementing nsIContentFrameMessageManager.
*
* nsIMessageListenerManager
* / \
* nsIMessageSender nsIMessageBroadcaster
* |
* nsISyncMessageSender (content process/in-process only)
* |
* nsIContentFrameMessageManager (content process/in-process only)
* |
* nsIInProcessContentFrameMessageManager (in-process only)
*
*
* Message managers in the chrome process can also be QI'ed to nsIFrameScriptLoader.
*
*
* Message managers corresponding to process boundaries
* ====================================================
*
* The second realm of message managers is the "process message
* managers". With one exception, these always correspond to process
* boundaries. The picture looks like
*
* Parent process Child processes
* ---------------- -----------------
* global PPMM
* |
* +<----> child PPMM
* |
* +-->parent PMM1<------------------>child process CMM1
* |
* +-->parent PMM2<------------------>child process PMM2
* ...
*
* For example: the parent-process PMM1 sends messages directly to
* only the child-process CMM1.
*
* For example: CMM1 sends messages directly to PMM1. The global PPMM
* will also notify their message listeners when the message arrives.
*
* For example: messages sent through the global PPMM will be
* dispatched to the listeners of the same-process, "child PPMM".
* They will also be broadcast to PPM1, PPM2, etc.
*
* ***** PERFORMANCE AND SECURITY WARNING *****
* Messages broadcast through the global PPMM can result in messages
* being dispatched across many OS processes, and to many processes
* with different permissions. Great care should be taken when
* broadcasting.
*
* Requests sent to parent-process message listeners should usually
* have replies scoped to the requesting CPMM. The following pattern
* is common
*
* const ParentProcessListener = {
* receiveMessage: function(aMessage) {
* let childMM = aMessage.target.QueryInterface(Ci.nsIMessageSender);
* switch (aMessage.name) {
* case "Foo:Request":
* // service request
* childMM.sendAsyncMessage("Foo:Response", { data });
* }
* }
* };
*/
[scriptable, function, uuid(2b44eb57-a9c6-4773-9a1e-fe0818739a4c)]
interface nsIMessageListener : nsISupports
{
/**
* This is for JS only.
* receiveMessage is called with one parameter, which has the following
* properties:
* {
* target: %the target of the message. Either an element owning
* the message manager, or message manager itself if no
* element owns it%
* name: %message name%,
* sync: %true or false%.
* data: %structured clone of the sent message data%,
* json: %same as .data, deprecated%,
* objects: %array of handles or null, always null if sync is false%
* }
* @note objects property isn't implemented yet.
*
* Each listener is invoked with its own copy of the message
* parameter.
*
* When the listener is called, 'this' value is the target of the message.
*
* If the message is synchronous, the possible return value is
* returned as JSON (will be changed to use structured clones).
* When there are multiple listeners to sync messages, each
* listener's return value is sent back as an array. |undefined|
* return values show up as undefined values in the array.
*/
void receiveMessage();
};
[scriptable, builtinclass, uuid(9c37a142-3de3-4902-a1a4-133f37d5980a)]
interface nsIMessageListenerManager : nsISupports
{
/**
* Register |listener| to receive |messageName|. All listener
* callbacks for a particular message are invoked when that message
* is received.
*
* The message manager holds a strong ref to |listener|.
*
* If the same listener registers twice for the same message, the
* second registration is ignored.
*/
void addMessageListener(in AString messageName,
in nsIMessageListener listener);
/**
* No longer invoke |listener| when |messageName| is received, after
* the first time removeMessageListener() is called.
*/
void removeMessageListener(in AString messageName,
in nsIMessageListener listener);
[notxpcom] boolean markForCC();
};
/**
* Message "senders" have a single "other side" to which messages are
* sent. For example, a child-process message manager will send
* messages that are only delivered to its one parent-process message
* manager.
*/
[scriptable, builtinclass, uuid(7f23767d-0f39-40c1-a22d-d3ab8a481f9d)]
interface nsIMessageSender : nsIMessageListenerManager
{
/**
* Send |messageName| and |obj| to the "other side" of this message
* manager. This invokes listeners who registered for
* |messageName|.
*
* See nsIMessageListener::receiveMessage() for the format of the
* data delivered to listeners.
*/
[implicit_jscontext, optional_argc]
void sendAsyncMessage([optional] in AString messageName,
[optional] in jsval obj);
};
/**
* Message "broadcasters" don't have a single "other side" that they
* send messages to, but rather a set of subordinate message managers.
* For example, broadcasting a message through a window message
* manager will broadcast the message to all frame message managers
* within its window.
*/
[scriptable, builtinclass, uuid(d36346b9-5d3b-497d-9c28-ffbc3e4f6d0d)]
interface nsIMessageBroadcaster : nsIMessageListenerManager
{
/**
* Like |sendAsyncMessage()|, but also broadcasts this message to
* all "child" message managers of this message manager. See long
* comment above for details.
*
* WARNING: broadcasting messages can be very expensive and leak
* sensitive data. Use with extreme caution.
*/
[implicit_jscontext, optional_argc]
void broadcastAsyncMessage([optional] in AString messageName,
[optional] in jsval obj);
/**
* Number of subordinate message managers.
*/
readonly attribute unsigned long childCount;
/**
* Return a single subordinate message manager.
*/
nsIMessageListenerManager getChildAt(in unsigned long aIndex);
};
[scriptable, builtinclass, uuid(83be5862-2996-4685-ae7d-ae25bd795d50)]
interface nsISyncMessageSender : nsIMessageSender
{
/**
* Like |sendAsyncMessage()|, except blocks the sender until all
* listeners of the message have been invoked. Returns an array
* containing return values from each listener invoked.
*/
[implicit_jscontext, optional_argc]
jsval sendSyncMessage([optional] in AString messageName,
[optional] in jsval obj);
};
[scriptable, builtinclass, uuid(894ff2d4-39a3-4df8-9d76-8ee329975488)]
interface nsIContentFrameMessageManager : nsISyncMessageSender
{
/**
* The current top level window in the frame or null.
*/
readonly attribute nsIDOMWindow content;
/**
* The top level docshell or null.
*/
readonly attribute nsIDocShell docShell;
/**
* Print a string to stdout.
*/
void dump(in DOMString aStr);
/**
* If leak detection is enabled, print a note to the leak log that this
* process will intentionally crash.
*/
void privateNoteIntentionalCrash();
/**
* Ascii base64 data to binary data and vice versa
*/
DOMString atob(in DOMString aAsciiString);
DOMString btoa(in DOMString aBase64Data);
};
[uuid(a2325927-9c0c-437d-9215-749c79235031)]
interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
{
[notxpcom] nsIContent getOwnerContent();
};
[scriptable, builtinclass, uuid(a54acd34-4141-46f5-b71b-e2ca32879b08)]
interface nsIFrameScriptLoader : nsISupports
{
/**
* Load a script in the (remote) frame. aURL must be the absolute URL.
* data: URLs are also supported. For example data:,dump("foo\n");
* If aAllowDelayedLoad is true, script will be loaded when the
* remote frame becomes available. Otherwise the script will be loaded
* only if the frame is already available.
*/
void loadFrameScript(in AString aURL, in boolean aAllowDelayedLoad);
/**
* Removes aURL from the list of scripts which support delayed load.
*/
void removeDelayedFrameScript(in AString aURL);
};

View File

@ -21,7 +21,7 @@ MessageWakeupService.prototype =
get messageManager() {
if (!this._messageManager)
this._messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"].
getService(Ci.nsIFrameMessageManager);
getService(Ci.nsIMessageListenerManager);
return this._messageManager;
},
@ -39,7 +39,7 @@ MessageWakeupService.prototype =
let data = this.messagesData[aMessage.name];
// TODO: When bug 593407 is ready, stop doing the wrappedJSObject hack
// and use this line instead:
// QueryInterface(Ci.nsIFrameMessageListener);
// QueryInterface(Ci.nsIMessageListener);
let service = Cc[data.cid][data.method](Ci[data.iid]).
wrappedJSObject;

View File

@ -92,7 +92,7 @@ MarkUserDataHandler(void* aNode, nsIAtom* aKey, void* aValue, void* aData)
static void
MarkMessageManagers()
{
nsCOMPtr<nsIChromeFrameMessageManager> globalMM =
nsCOMPtr<nsIMessageBroadcaster> globalMM =
do_GetService("@mozilla.org/globalmessagemanager;1");
if (!globalMM) {
return;
@ -102,20 +102,22 @@ MarkMessageManagers()
uint32_t childCount = 0;
globalMM->GetChildCount(&childCount);
for (uint32_t i = 0; i < childCount; ++i) {
nsCOMPtr<nsITreeItemFrameMessageManager> windowMM;
globalMM->GetChildAt(i, getter_AddRefs(windowMM));
if (!windowMM) {
nsCOMPtr<nsIMessageListenerManager> childMM;
globalMM->GetChildAt(i, getter_AddRefs(childMM));
if (!childMM) {
continue;
}
nsCOMPtr<nsIMessageBroadcaster> windowMM = do_QueryInterface(childMM);
windowMM->MarkForCC();
uint32_t tabChildCount = 0;
windowMM->GetChildCount(&tabChildCount);
for (uint32_t j = 0; j < tabChildCount; ++j) {
nsCOMPtr<nsITreeItemFrameMessageManager> tabMM;
windowMM->GetChildAt(j, getter_AddRefs(tabMM));
if (!tabMM) {
nsCOMPtr<nsIMessageListenerManager> childMM;
windowMM->GetChildAt(j, getter_AddRefs(childMM));
if (!childMM) {
continue;
}
nsCOMPtr<nsIMessageSender> tabMM = do_QueryInterface(childMM);
tabMM->MarkForCC();
//XXX hack warning, but works, since we know that
// callback data is frameloader.

View File

@ -2244,7 +2244,7 @@ bool SendAsyncMessageToChild(void* aCallbackData,
}
NS_IMETHODIMP
nsFrameLoader::GetMessageManager(nsIChromeFrameMessageManager** aManager)
nsFrameLoader::GetMessageManager(nsIMessageSender** aManager)
{
EnsureMessageManager();
if (mMessageManager) {
@ -2336,13 +2336,13 @@ nsFrameLoader::EnsureMessageManager()
nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
do_QueryInterface(GetOwnerDoc()->GetWindow());
nsCOMPtr<nsIChromeFrameMessageManager> parentManager;
nsCOMPtr<nsIMessageBroadcaster> parentManager;
if (chromeWindow) {
chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
}
if (ShouldUseRemoteProcess()) {
mMessageManager = new nsFrameMessageManager(true,
mMessageManager = new nsFrameMessageManager(true, /* aChrome */
nullptr,
SendAsyncMessageToChild,
LoadScript,
@ -2350,7 +2350,7 @@ nsFrameLoader::EnsureMessageManager()
static_cast<nsFrameMessageManager*>(parentManager.get()),
cx);
} else {
mMessageManager = new nsFrameMessageManager(true,
mMessageManager = new nsFrameMessageManager(true, /* aChrome */
nullptr,
SendAsyncMessageToChild,
LoadScript,

View File

@ -24,6 +24,7 @@
#include "nsIProtocolHandler.h"
#include "nsIScriptSecurityManager.h"
#include "nsIJSRuntimeService.h"
#include "nsIDOMClassInfo.h"
#include "nsIDOMFile.h"
#include "xpcpublic.h"
#include "mozilla/Preferences.h"
@ -64,7 +65,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFrameMessageManager)
tmp->mListeners.Clear();
for (int32_t i = tmp->mChildManagers.Count(); i > 0; --i) {
for (PRInt32 i = tmp->mChildManagers.Count(); i > 0; --i) {
static_cast<nsFrameMessageManager*>(tmp->mChildManagers[i - 1])->
Disconnect(false);
}
@ -74,30 +75,48 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameMessageManager)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIFrameMessageManager,
(mChrome ?
static_cast<nsIFrameMessageManager*>(
static_cast<nsIChromeFrameMessageManager*>(this)) :
static_cast<nsIFrameMessageManager*>(
static_cast<nsIContentFrameMessageManager*>(this))))
/* nsFrameMessageManager implements nsIMessageSender and nsIMessageBroadcaster,
* both of which descend from nsIMessageListenerManager. QI'ing to
* nsIMessageListenerManager is therefore ambiguous and needs explicit casts
* depending on which child interface applies. */
NS_INTERFACE_MAP_ENTRY_AGGREGATED(nsIMessageListenerManager,
(mIsBroadcaster ?
static_cast<nsIMessageListenerManager*>(
static_cast<nsIMessageBroadcaster*>(this)) :
static_cast<nsIMessageListenerManager*>(
static_cast<nsIMessageSender*>(this))))
/* Message managers in child process implement nsIMessageSender and
nsISyncMessageSender. Message managers in the chrome process are
either broadcasters (if they have subordinate/child message
managers) or they're simple message senders. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISyncMessageSender, !mChrome)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIMessageSender, !mChrome || !mIsBroadcaster)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIMessageBroadcaster, mChrome && mIsBroadcaster)
/* nsIContentFrameMessageManager is accessible only in TabChildGlobal. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIContentFrameMessageManager,
!mChrome && !mIsProcessManager)
/* Message managers in child process support nsISyncMessageSender. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsISyncMessageSender, !mChrome)
/* Message managers in chrome process support nsITreeItemFrameMessageManager. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsITreeItemFrameMessageManager, mChrome)
/* Process message manager doesn't support nsIChromeFrameMessageManager. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIChromeFrameMessageManager,
/* Frame message managers (non-process message managers) support nsIFrameScriptLoader. */
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIFrameScriptLoader,
mChrome && !mIsProcessManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(ChromeMessageBroadcaster,
mChrome && mIsBroadcaster)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(ChromeMessageSender,
mChrome && !mIsBroadcaster)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameMessageManager)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameMessageManager)
// nsIMessageListenerManager
NS_IMETHODIMP
nsFrameMessageManager::AddMessageListener(const nsAString& aMessage,
nsIFrameMessageListener* aListener)
nsIMessageListener* aListener)
{
nsCOMPtr<nsIAtom> message = do_GetAtom(aMessage);
uint32_t len = mListeners.Length();
@ -116,7 +135,7 @@ nsFrameMessageManager::AddMessageListener(const nsAString& aMessage,
NS_IMETHODIMP
nsFrameMessageManager::RemoveMessageListener(const nsAString& aMessage,
nsIFrameMessageListener* aListener)
nsIMessageListener* aListener)
{
nsCOMPtr<nsIAtom> message = do_GetAtom(aMessage);
uint32_t len = mListeners.Length();
@ -130,6 +149,8 @@ nsFrameMessageManager::RemoveMessageListener(const nsAString& aMessage,
return NS_OK;
}
// nsIFrameScriptLoader
NS_IMETHODIMP
nsFrameMessageManager::LoadFrameScript(const nsAString& aURL,
bool aAllowDelayedLoad)
@ -152,7 +173,7 @@ nsFrameMessageManager::LoadFrameScript(const nsAString& aURL,
NS_ENSURE_TRUE(mLoadScriptCallback(mCallbackData, aURL), NS_ERROR_FAILURE);
}
for (int32_t i = 0; i < mChildManagers.Count(); ++i) {
for (PRInt32 i = 0; i < mChildManagers.Count(); ++i) {
nsRefPtr<nsFrameMessageManager> mm =
static_cast<nsFrameMessageManager*>(mChildManagers[i]);
if (mm) {
@ -208,6 +229,9 @@ GetParamsForMessage(JSContext* aCx,
return WriteStructuredClone(aCx, val, aBuffer, aClosure);
}
// nsISyncMessageSender
NS_IMETHODIMP
nsFrameMessageManager::SendSyncMessage(const nsAString& aMessageName,
const jsval& aObject,
@ -257,26 +281,30 @@ nsFrameMessageManager::SendSyncMessage(const nsAString& aMessageName,
}
nsresult
nsFrameMessageManager::SendAsyncMessageInternal(const nsAString& aMessage,
const StructuredCloneData& aData)
nsFrameMessageManager::DispatchAsyncMessageInternal(const nsAString& aMessage,
const StructuredCloneData& aData,
ShouldBroadcast aBroadcast)
{
if (mAsyncCallback) {
NS_ENSURE_TRUE(mCallbackData, NS_ERROR_NOT_INITIALIZED);
mAsyncCallback(mCallbackData, aMessage, aData);
}
int32_t len = mChildManagers.Count();
for (int32_t i = 0; i < len; ++i) {
static_cast<nsFrameMessageManager*>(mChildManagers[i])->
SendAsyncMessageInternal(aMessage, aData);
if (aBroadcast == BROADCAST) {
PRInt32 len = mChildManagers.Count();
for (PRInt32 i = 0; i < len; ++i) {
static_cast<nsFrameMessageManager*>(mChildManagers[i])->
DispatchAsyncMessageInternal(aMessage, aData, aBroadcast);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::SendAsyncMessage(const nsAString& aMessageName,
const jsval& aObject,
JSContext* aCx,
uint8_t aArgc)
nsresult
nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
const jsval& aObject,
JSContext* aCx,
uint8_t aArgc,
ShouldBroadcast aBroadcast)
{
StructuredCloneData data;
JSAutoStructuredCloneBuffer buffer;
@ -289,9 +317,54 @@ nsFrameMessageManager::SendAsyncMessage(const nsAString& aMessageName,
data.mData = buffer.data();
data.mDataLength = buffer.nbytes();
return SendAsyncMessageInternal(aMessageName, data);
return DispatchAsyncMessageInternal(aMessageName, data, aBroadcast);
}
// nsIMessageSender
NS_IMETHODIMP
nsFrameMessageManager::SendAsyncMessage(const nsAString& aMessageName,
const jsval& aObject,
JSContext* aCx,
uint8_t aArgc)
{
return DispatchAsyncMessage(aMessageName, aObject, aCx, aArgc, DONT_BROADCAST);
}
// nsIMessageBroadcaster
NS_IMETHODIMP
nsFrameMessageManager::BroadcastAsyncMessage(const nsAString& aMessageName,
const jsval& aObject,
JSContext* aCx,
uint8_t aArgc)
{
return DispatchAsyncMessage(aMessageName, aObject, aCx, aArgc, BROADCAST);
}
NS_IMETHODIMP
nsFrameMessageManager::GetChildCount(uint32_t* aChildCount)
{
*aChildCount = static_cast<uint32_t>(mChildManagers.Count());
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::GetChildAt(uint32_t aIndex,
nsIMessageListenerManager** aMM)
{
*aMM = nullptr;
nsCOMPtr<nsIMessageListenerManager> mm =
do_QueryInterface(mChildManagers.SafeObjectAt(static_cast<uint32_t>(aIndex)));
mm.swap(*aMM);
return NS_OK;
}
// nsIContentFrameMessageManager
NS_IMETHODIMP
nsFrameMessageManager::Dump(const nsAString& aStr)
{
@ -328,24 +401,6 @@ nsFrameMessageManager::GetDocShell(nsIDocShell** aDocShell)
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::GetChildCount(uint32_t* aChildCount)
{
*aChildCount = static_cast<uint32_t>(mChildManagers.Count());
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::GetChildAt(uint32_t aIndex,
nsITreeItemFrameMessageManager** aMM)
{
*aMM = nullptr;
nsCOMPtr<nsITreeItemFrameMessageManager> mm =
do_QueryInterface(mChildManagers.SafeObjectAt(static_cast<uint32_t>(aIndex)));
mm.swap(*aMM);
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::Btoa(const nsAString& aBinaryData,
nsAString& aAsciiBase64String)
@ -360,6 +415,7 @@ nsFrameMessageManager::Atob(const nsAString& aAsciiString,
return NS_OK;
}
class MMListenerRemover
{
public:
@ -383,6 +439,9 @@ public:
nsRefPtr<nsFrameMessageManager> mMM;
};
// nsIMessageListener
nsresult
nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
const nsAString& aMessage,
@ -591,17 +650,19 @@ nsFrameMessageManager::Disconnect(bool aRemoveFromParent)
}
nsresult
NS_NewGlobalMessageManager(nsIChromeFrameMessageManager** aResult)
NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult)
{
NS_ENSURE_TRUE(IsChromeProcess(), NS_ERROR_NOT_AVAILABLE);
nsFrameMessageManager* mm = new nsFrameMessageManager(true,
nsFrameMessageManager* mm = new nsFrameMessageManager(true /* aChrome */,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
true);
true /* aGlobal */,
false /* aProcessManager */,
true /* aBroadcaster */);
NS_ENSURE_TRUE(mm, NS_ERROR_OUT_OF_MEMORY);
return CallQueryInterface(mm, aResult);
}
@ -827,17 +888,13 @@ nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL)
mGlobal->GetJSObject(&global);
if (global) {
JSAutoCompartment ac(mCx, global);
uint32_t oldopts = JS_GetOptions(mCx);
JS_SetOptions(mCx, oldopts | JSOPTION_NO_SCRIPT_RVAL);
JSScript* script =
JS_CompileUCScriptForPrincipals(mCx, nullptr,
nsJSPrincipals::get(mPrincipal),
static_cast<const jschar*>(dataString.get()),
dataString.Length(),
url.get(), 1);
JS_SetOptions(mCx, oldopts);
JS::CompileOptions options(mCx);
options.setNoScriptRval(true)
.setFileAndLine(url.get(), 1)
.setPrincipals(nsJSPrincipals::get(mPrincipal));
JS::RootedObject empty(mCx, NULL);
JSScript* script = JS::Compile(mCx, empty, options,
dataString.get(), dataString.Length());
if (script) {
nsCAutoString scheme;
@ -1138,20 +1195,21 @@ bool SendAsyncMessageToSameProcessParent(void* aCallbackData,
// This creates the global parent process message manager.
nsresult
NS_NewParentProcessMessageManager(nsIFrameMessageManager** aResult)
NS_NewParentProcessMessageManager(nsIMessageBroadcaster** aResult)
{
NS_ASSERTION(!nsFrameMessageManager::sParentProcessManager,
"Re-creating sParentProcessManager");
NS_ENSURE_TRUE(IsChromeProcess(), NS_ERROR_NOT_AVAILABLE);
nsRefPtr<nsFrameMessageManager> mm = new nsFrameMessageManager(true,
nsRefPtr<nsFrameMessageManager> mm = new nsFrameMessageManager(true /* aChrome */,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
false,
true);
false, /* aGlobal */
true /* aProcessManager */,
true /* aBroadcaster */);
NS_ENSURE_TRUE(mm, NS_ERROR_OUT_OF_MEMORY);
nsFrameMessageManager::sParentProcessManager = mm;
nsFrameMessageManager::NewProcessMessageManager(nullptr); // Create same process message manager.
@ -1162,11 +1220,11 @@ nsFrameMessageManager*
nsFrameMessageManager::NewProcessMessageManager(mozilla::dom::ContentParent* aProcess)
{
if (!nsFrameMessageManager::sParentProcessManager) {
nsCOMPtr<nsIFrameMessageManager> dummy;
nsCOMPtr<nsIMessageBroadcaster> dummy;
NS_NewParentProcessMessageManager(getter_AddRefs(dummy));
}
nsFrameMessageManager* mm = new nsFrameMessageManager(true,
nsFrameMessageManager* mm = new nsFrameMessageManager(true /* aChrome */,
nullptr,
aProcess ? SendAsyncMessageToChildProcess
: SendAsyncMessageToSameProcessChild,
@ -1175,8 +1233,8 @@ nsFrameMessageManager::NewProcessMessageManager(mozilla::dom::ContentParent* aPr
: static_cast<void*>(&nsFrameMessageManager::sChildProcessManager),
nsFrameMessageManager::sParentProcessManager,
nullptr,
false,
true);
false, /* aGlobal */
true /* aProcessManager */);
if (!aProcess) {
sSameProcessParentManager = mm;
}
@ -1189,7 +1247,7 @@ NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)
NS_ASSERTION(!nsFrameMessageManager::sChildProcessManager,
"Re-creating sChildProcessManager");
bool isChrome = IsChromeProcess();
nsFrameMessageManager* mm = new nsFrameMessageManager(false,
nsFrameMessageManager* mm = new nsFrameMessageManager(false /* aChrome */,
isChrome ? SendSyncMessageToSameProcessParent
: SendSyncMessageToParentProcess,
isChrome ? SendAsyncMessageToSameProcessParent
@ -1198,8 +1256,8 @@ NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)
&nsFrameMessageManager::sChildProcessManager,
nullptr,
nullptr,
false,
true);
false /* aGlobal */,
true /* aProcessManager */);
NS_ENSURE_TRUE(mm, NS_ERROR_OUT_OF_MEMORY);
nsFrameMessageManager::sChildProcessManager = mm;
return CallQueryInterface(mm, aResult);

View File

@ -5,7 +5,7 @@
#ifndef nsFrameMessageManager_h__
#define nsFrameMessageManager_h__
#include "nsIFrameMessageManager.h"
#include "nsIMessageManager.h"
#include "nsIObserver.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
@ -35,7 +35,7 @@ struct JSObject;
struct nsMessageListenerInfo
{
nsCOMPtr<nsIFrameMessageListener> mListener;
nsCOMPtr<nsIMessageListener> mListener;
nsCOMPtr<nsIAtom> mMessage;
};
@ -49,7 +49,8 @@ typedef bool (*nsAsyncMessageCallback)(void* aCallbackData,
const mozilla::dom::StructuredCloneData& aData);
class nsFrameMessageManager MOZ_FINAL : public nsIContentFrameMessageManager,
public nsIChromeFrameMessageManager
public nsIMessageBroadcaster,
public nsIFrameScriptLoader
{
typedef mozilla::dom::StructuredCloneData StructuredCloneData;
public:
@ -61,10 +62,17 @@ public:
nsFrameMessageManager* aParentManager,
JSContext* aContext,
bool aGlobal = false,
bool aProcessManager = false)
: mChrome(aChrome), mGlobal(aGlobal), mIsProcessManager(aProcessManager),
mHandlingMessage(false), mDisconnected(false), mParentManager(aParentManager),
mSyncCallback(aSyncCallback), mAsyncCallback(aAsyncCallback),
bool aProcessManager = false,
bool aBroadcaster = false)
: mChrome(aChrome),
mGlobal(aGlobal),
mIsProcessManager(aProcessManager),
mIsBroadcaster(aBroadcaster),
mHandlingMessage(false),
mDisconnected(false),
mParentManager(aParentManager),
mSyncCallback(aSyncCallback),
mAsyncCallback(aAsyncCallback),
mLoadScriptCallback(aLoadScriptCallback),
mCallbackData(aCallbackData),
mContext(aContext)
@ -105,11 +113,12 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFrameMessageManager,
nsIContentFrameMessageManager)
NS_DECL_NSIFRAMEMESSAGEMANAGER
NS_DECL_NSIMESSAGELISTENERMANAGER
NS_DECL_NSIMESSAGESENDER
NS_DECL_NSIMESSAGEBROADCASTER
NS_DECL_NSISYNCMESSAGESENDER
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
NS_DECL_NSICHROMEFRAMEMESSAGEMANAGER
NS_DECL_NSITREEITEMFRAMEMESSAGEMANAGER
NS_DECL_NSIFRAMESCRIPTLOADER
static nsFrameMessageManager*
NewProcessMessageManager(mozilla::dom::ContentParent* aProcess);
@ -130,8 +139,15 @@ public:
void Disconnect(bool aRemoveFromParent = true);
void SetCallbackData(void* aData, bool aLoadScripts = true);
void* GetCallbackData() { return mCallbackData; }
nsresult SendAsyncMessageInternal(const nsAString& aMessage,
const StructuredCloneData& aData);
enum ShouldBroadcast { BROADCAST, DONT_BROADCAST };
nsresult DispatchAsyncMessage(const nsAString& aMessageName,
const jsval& aObject,
JSContext* aCx,
PRUint8 aArgc,
ShouldBroadcast aBroadcast);
nsresult DispatchAsyncMessageInternal(const nsAString& aMessage,
const StructuredCloneData& aData,
ShouldBroadcast aBroadcast);
JSContext* GetJSContext() { return mContext; }
void SetJSContext(JSContext* aCx) { mContext = aCx; }
void RemoveFromParent();
@ -157,9 +173,10 @@ protected:
friend class MMListenerRemover;
nsTArray<nsMessageListenerInfo> mListeners;
nsCOMArray<nsIContentFrameMessageManager> mChildManagers;
bool mChrome;
bool mGlobal;
bool mIsProcessManager;
bool mChrome; // true if we're in the chrome process
bool mGlobal; // true if
bool mIsProcessManager; // true if the message manager belongs to the process realm
bool mIsBroadcaster; // true if the message manager is a broadcaster
bool mHandlingMessage;
bool mDisconnected;
nsFrameMessageManager* mParentManager;

View File

@ -126,7 +126,7 @@ nsInProcessTabChildGlobal::Init()
InitTabChildGlobal();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
"Couldn't initialize nsInProcessTabChildGlobal");
mMessageManager = new nsFrameMessageManager(false,
mMessageManager = new nsFrameMessageManager(false, /* aChrome */
SendSyncMessageToParent,
SendAsyncMessageToParent,
nullptr,
@ -160,7 +160,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsInProcessTabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIMessageListenerManager)
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIInProcessContentFrameMessageManager)

View File

@ -33,7 +33,8 @@ public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsInProcessTabChildGlobal,
nsDOMEventTargetHelper)
NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
const jsval& aObject,
JSContext* aCx,

View File

@ -13,9 +13,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
<script type="application/javascript"><![CDATA[
var didRunAsync = false;
var didRunLocal = false;
var global = Components.classes["@mozilla.org/globalmessagemanager;1"].getService(Components.interfaces.nsIChromeFrameMessageManager);
var ppm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"].getService(Components.interfaces.nsIFrameMessageManager);
var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"].getService(Components.interfaces.nsISyncMessageSender);
var global = Components.classes["@mozilla.org/globalmessagemanager;1"]
.getService(Components.interfaces.nsIMessageBroadcaster);
var ppm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Components.interfaces.nsIMessageBroadcaster);
var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
.getService(Components.interfaces.nsISyncMessageSender);
var asyncPPML = false;
function ppmASL(m) {
@ -36,7 +39,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
asyncCPML = true;
}
cpm.addMessageListener("childprocessmessage", cpmASL);
ppm.sendAsyncMessage("childprocessmessage", "");
ppm.broadcastAsyncMessage("childprocessmessage", "");
function checkPMMMessages() {
opener.wrappedJSObject.ok(asyncPPML, "should have handled async message");

View File

@ -30,8 +30,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=616841
function recvContentReady(m) {
for (var i = 0; i < toCompare.length; ++i) {
var pair = toCompare[i];
messageManager.sendAsyncMessage("cmp",
{ i: i, a: pair[0], b: pair[1] });
messageManager.broadcastAsyncMessage("cmp",
{ i: i, a: pair[0], b: pair[1] });
}
}

View File

@ -3429,7 +3429,7 @@ nsHTMLMediaElement::CopyInnerTo(nsGenericElement* aDest)
nsresult nsHTMLMediaElement::GetBuffered(nsIDOMTimeRanges** aBuffered)
{
nsRefPtr<nsTimeRanges> ranges = new nsTimeRanges();
if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_CURRENT_DATA && mDecoder) {
if (mReadyState > nsIDOMHTMLMediaElement::HAVE_NOTHING && mDecoder) {
// If GetBuffered fails we ignore the error result and just return the
// time ranges we found up till the error.
mDecoder->GetBuffered(ranges);

View File

@ -190,7 +190,6 @@
#include "nsDOMNavigationTiming.h"
#include "nsITimedChannel.h"
#include "mozilla/StartupTimeline.h"
#include "nsIFrameMessageManager.h"
#include "mozilla/Telemetry.h"
#include "nsISecurityUITelemetry.h"

View File

@ -12,10 +12,9 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageBroadcaster");
const EXPORTED_SYMBOLS = [];
@ -194,7 +193,7 @@ let Activities = {
// We have no matching activity registered, let's fire an error.
if (aResults.options.length === 0) {
ppmm.sendAsyncMessage("Activity:FireError", {
ppmm.broadcastAsyncMessage("Activity:FireError", {
"id": aMsg.id,
"error": "NO_PROVIDER"
});
@ -206,7 +205,7 @@ let Activities = {
// The user has cancelled the choice, fire an error.
if (aChoice === -1) {
ppmm.sendAsyncMessage("Activity:FireError", {
ppmm.broadcastAsyncMessage("Activity:FireError", {
"id": aMsg.id,
"error": "USER_ABORT"
});
@ -231,7 +230,7 @@ let Activities = {
Services.io.newURI(result.manifest, null, null));
if (!result.description.returnValue) {
ppmm.sendAsyncMessage("Activity:FireSuccess", {
ppmm.broadcastAsyncMessage("Activity:FireSuccess", {
"id": aMsg.id,
"result": null
});
@ -266,7 +265,7 @@ let Activities = {
},
receiveMessage: function activities_receiveMessage(aMessage) {
let mm = aMessage.target.QueryInterface(Ci.nsIFrameMessageManager);
let mm = aMessage.target;
let msg = aMessage.json;
switch(aMessage.name) {
case "Activity:Start":
@ -274,10 +273,10 @@ let Activities = {
break;
case "Activity:PostResult":
ppmm.sendAsyncMessage("Activity:FireSuccess", msg);
ppmm.broadcastAsyncMessage("Activity:FireSuccess", msg);
break;
case "Activity:PostError":
ppmm.sendAsyncMessage("Activity:FireError", msg);
ppmm.broadcastAsyncMessage("Activity:FireError", msg);
break;
case "Activities:Register":

View File

@ -12,11 +12,9 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager)
.QueryInterface(Ci.nsISyncMessageSender);
});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsISyncMessageSender");
function debug(aMsg) {
//dump("-- ActivityProxy " + Date.now() + " : " + aMsg + "\n");

View File

@ -10,11 +10,9 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager)
.QueryInterface(Ci.nsISyncMessageSender);
});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsISyncMessageSender");
function debug(aMsg) {
//dump("-- ActivityRequestHandler.js " + Date.now() + " : " + aMsg + "\n");

View File

@ -20,9 +20,9 @@ Cu.import("resource://gre/modules/AlarmDB.jsm");
let EXPORTED_SYMBOLS = ["AlarmService"];
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageListenerManager");
XPCOMUtils.defineLazyGetter(this, "messenger", function() {
return Cc["@mozilla.org/system-message-internal;1"].getService(Ci.nsISystemMessagesInternal);
@ -75,7 +75,7 @@ let AlarmService = {
receiveMessage: function receiveMessage(aMessage) {
debug("receiveMessage(): " + aMessage.name);
let mm = aMessage.target.QueryInterface(Ci.nsIFrameMessageManager);
let mm = aMessage.target.QueryInterface(Ci.nsIMessageSender);
let json = aMessage.json;
switch (aMessage.name) {
case "AlarmsManager:GetAll":

View File

@ -26,8 +26,7 @@ function AppsService()
Cu.import("resource://gre/modules/Webapps.jsm");
} else {
this.cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager)
.QueryInterface(Ci.nsISyncMessageSender);
.getService(Ci.nsISyncMessageSender);
}
}

View File

@ -12,9 +12,9 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
function convertAppsArray(aApps, aWindow) {
let apps = Cu.createArrayIn(aWindow);

View File

@ -23,14 +23,13 @@ XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
return NetUtil;
});
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageBroadcaster");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIFrameMessageManager");
"nsIMessageSender");
XPCOMUtils.defineLazyGetter(this, "msgmgr", function() {
return Cc["@mozilla.org/system-message-internal;1"]
@ -243,7 +242,7 @@ let DOMApplicationRegistry = {
if (msg.hasPrivileges)
this.getAll(msg);
else
ppmm.sendAsyncMessage("Webapps:GetAll:Return:KO", msg);
ppmm.broadcastAsyncMessage("Webapps:GetAll:Return:KO", msg);
break;
case "Webapps:InstallPackage":
this.installPackage(msg);
@ -307,7 +306,7 @@ let DOMApplicationRegistry = {
} catch(e) {
}
}
ppmm.sendAsyncMessage("Webapps:Install:Return:KO", aData);
ppmm.broadcastAsyncMessage("Webapps:Install:Return:KO", aData);
},
confirmInstall: function(aData, aFromSync, aProfileDir, aOfflineCacheObserver) {
@ -365,7 +364,7 @@ let DOMApplicationRegistry = {
if (!aFromSync)
this._saveApps((function() {
ppmm.sendAsyncMessage("Webapps:Install:Return:OK", aData);
ppmm.broadcastAsyncMessage("Webapps:Install:Return:OK", aData);
Services.obs.notifyObservers(this, "webapps-sync-install", appNote);
}).bind(this));
@ -492,7 +491,7 @@ let DOMApplicationRegistry = {
try {
dir.remove(true);
} catch (e) { }
ppmm.sendAsyncMessage("Webapps:Install:Return:KO",
ppmm.broadcastAsyncMessage("Webapps:Install:Return:KO",
{ oid: aData.oid,
requestID: aData.requestID,
error: aError });
@ -584,13 +583,13 @@ let DOMApplicationRegistry = {
delete this.webapps[id];
this._saveApps((function() {
ppmm.sendAsyncMessage("Webapps:Uninstall:Return:OK", aData);
ppmm.broadcastAsyncMessage("Webapps:Uninstall:Return:OK", aData);
Services.obs.notifyObservers(this, "webapps-sync-uninstall", appNote);
}).bind(this));
}
if (!found) {
ppmm.sendAsyncMessage("Webapps:Uninstall:Return:KO", aData);
ppmm.broadcastAsyncMessage("Webapps:Uninstall:Return:KO", aData);
}
},
@ -608,7 +607,7 @@ let DOMApplicationRegistry = {
this._readManifests(tmp, (function(aResult) {
for (let i = 0; i < aResult.length; i++)
aData.apps[i].manifest = aResult[i].manifest;
ppmm.sendAsyncMessage("Webapps:GetSelf:Return:OK", aData);
ppmm.broadcastAsyncMessage("Webapps:GetSelf:Return:OK", aData);
}).bind(this));
},
@ -627,7 +626,7 @@ let DOMApplicationRegistry = {
this._readManifests(tmp, (function(aResult) {
for (let i = 0; i < aResult.length; i++)
aData.apps[i].manifest = aResult[i].manifest;
ppmm.sendAsyncMessage("Webapps:GetInstalled:Return:OK", aData);
ppmm.broadcastAsyncMessage("Webapps:GetInstalled:Return:OK", aData);
}).bind(this));
},
@ -645,7 +644,7 @@ let DOMApplicationRegistry = {
this._readManifests(tmp, (function(aResult) {
for (let i = 0; i < aResult.length; i++)
aData.apps[i].manifest = aResult[i].manifest;
ppmm.sendAsyncMessage("Webapps:GetNotInstalled:Return:OK", aData);
ppmm.broadcastAsyncMessage("Webapps:GetNotInstalled:Return:OK", aData);
}).bind(this));
},
@ -665,7 +664,7 @@ let DOMApplicationRegistry = {
this._readManifests(tmp, (function(aResult) {
for (let i = 0; i < aResult.length; i++)
aData.apps[i].manifest = aResult[i].manifest;
ppmm.sendAsyncMessage("Webapps:GetAll:Return:OK", aData);
ppmm.broadcastAsyncMessage("Webapps:GetAll:Return:OK", aData);
}).bind(this));
},
@ -783,7 +782,7 @@ let DOMApplicationRegistry = {
dir.remove(true);
} catch (e) {
}
ppmm.sendAsyncMessage("Webapps:Uninstall:Return:OK", { origin: origin });
ppmm.broadcastAsyncMessage("Webapps:Uninstall:Return:OK", { origin: origin });
} else {
if (this.webapps[record.id]) {
this.webapps[record.id] = record.value;
@ -791,7 +790,7 @@ let DOMApplicationRegistry = {
} else {
let data = { app: record.value };
this.confirmInstall(data, true);
ppmm.sendAsyncMessage("Webapps:Install:Return:OK", data);
ppmm.broadcastAsyncMessage("Webapps:Install:Return:OK", data);
}
}
}
@ -893,7 +892,7 @@ AppcacheObserver.prototype = {
let setStatus = function appObs_setStatus(aStatus) {
mustSave = (app.status != aStatus);
app.status = aStatus;
ppmm.sendAsyncMessage("Webapps:OfflineCache", { manifest: app.manifestURL, status: aStatus });
ppmm.broadcastAsyncMessage("Webapps:OfflineCache", { manifest: app.manifestURL, status: aStatus });
}
switch (aState) {

View File

@ -15,9 +15,9 @@ let EXPORTED_SYMBOLS = ["DOMRequestIpcHelper"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageListenerManager");
function DOMRequestIpcHelper() {
}

View File

@ -461,7 +461,7 @@
#include "nsIDOMMozTouchEvent.h"
#include "nsIEventListenerService.h"
#include "nsIFrameMessageManager.h"
#include "nsIMessageManager.h"
#include "mozilla/dom/Element.h"
#include "nsHTMLSelectElement.h"
#include "nsHTMLLegendElement.h"
@ -640,6 +640,8 @@ DOMCI_DATA_NO_CLASS(Crypto)
DOMCI_DATA_NO_CLASS(CRMFObject)
DOMCI_DATA_NO_CLASS(SmartCardEvent)
DOMCI_DATA_NO_CLASS(ContentFrameMessageManager)
DOMCI_DATA_NO_CLASS(ChromeMessageBroadcaster)
DOMCI_DATA_NO_CLASS(ChromeMessageSender)
DOMCI_DATA_NO_CLASS(DOMPrototype)
DOMCI_DATA_NO_CLASS(DOMConstructor)
@ -1595,8 +1597,13 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(AnimationEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS | nsIXPCScriptable::IS_GLOBAL_OBJECT)
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager, nsEventTargetSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS |
nsIXPCScriptable::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_CLASSINFO_DATA(FormData, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -4305,13 +4312,26 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsIContentFrameMessageManager)
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsISupports)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIFrameMessageManager)
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(ChromeMessageBroadcaster, nsISupports)
DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
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(nsIMessageListenerManager)
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(FormData, nsIDOMFormData)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFormData)
DOM_CLASSINFO_MAP_END
@ -7197,7 +7217,8 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
// method on an interface that would let us just call into the
// window code directly...
if (!ObjectIsNativeWrapper(cx, obj)) {
if (!ObjectIsNativeWrapper(cx, obj) ||
xpc::WrapperFactory::XrayWrapperNotShadowing(obj, id)) {
nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(win->GetDocShell()));
int32_t count = 0;
@ -9221,7 +9242,8 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSAutoRequest ar(cx);
if (!ObjectIsNativeWrapper(cx, obj)) {
if (!ObjectIsNativeWrapper(cx, obj) ||
xpc::WrapperFactory::XrayWrapperNotShadowing(obj, id)) {
nsCOMPtr<nsISupports> result;
nsWrapperCache *cache;
nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result),
@ -9313,23 +9335,20 @@ nsHTMLDocumentSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
JSContext *cx, JSObject *obj, jsid id,
jsval *vp, bool *_retval)
{
// For native wrappers, do not get random names on document
if (!ObjectIsNativeWrapper(cx, obj)) {
nsCOMPtr<nsISupports> result;
nsCOMPtr<nsISupports> result;
JSAutoRequest ar(cx);
JSAutoRequest ar(cx);
nsWrapperCache *cache;
nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result), &cache);
NS_ENSURE_SUCCESS(rv, rv);
nsWrapperCache *cache;
nsresult rv = ResolveImpl(cx, wrapper, id, getter_AddRefs(result), &cache);
NS_ENSURE_SUCCESS(rv, rv);
if (result) {
rv = WrapNative(cx, obj, result, cache, true, vp);
if (NS_SUCCEEDED(rv)) {
rv = NS_SUCCESS_I_DID_SOMETHING;
}
return rv;
if (result) {
rv = WrapNative(cx, obj, result, cache, true, vp);
if (NS_SUCCEEDED(rv)) {
rv = NS_SUCCESS_I_DID_SOMETHING;
}
return rv;
}
return NS_OK;
@ -9371,7 +9390,8 @@ nsHTMLFormElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
{
// For native wrappers, do not resolve random names on form
if ((!(JSRESOLVE_ASSIGNING & flags)) && JSID_IS_STRING(id) &&
!ObjectIsNativeWrapper(cx, obj)) {
(!ObjectIsNativeWrapper(cx, obj) ||
xpc::WrapperFactory::XrayWrapperNotShadowing(obj, id))) {
nsCOMPtr<nsIForm> form(do_QueryWrappedNative(wrapper, obj));
nsCOMPtr<nsISupports> result;
nsWrapperCache *cache;
@ -9402,18 +9422,16 @@ nsHTMLFormElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
if (JSID_IS_STRING(id)) {
// For native wrappers, do not get random names on form
if (!ObjectIsNativeWrapper(cx, obj)) {
nsCOMPtr<nsISupports> result;
nsWrapperCache *cache;
nsCOMPtr<nsISupports> result;
nsWrapperCache *cache;
FindNamedItem(form, id, getter_AddRefs(result), &cache);
FindNamedItem(form, id, getter_AddRefs(result), &cache);
if (result) {
// Wrap result, result can be either an element or a list of
// elements
nsresult rv = WrapNative(cx, obj, result, cache, true, vp);
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
}
if (result) {
// Wrap result, result can be either an element or a list of
// elements
nsresult rv = WrapNative(cx, obj, result, cache, true, vp);
return NS_FAILED(rv) ? rv : NS_SUCCESS_I_DID_SOMETHING;
}
} else {
int32_t n = GetArrayIndexFromId(cx, id);

View File

@ -132,6 +132,11 @@ public:
* dealing with document.domain, it's possible to end up in a scriptable
* helper with a wrapper, even though we should be treating the lookup as a
* transparent one.
*
* Note: So ObjectIsNativeWrapper(cx, obj) check usually means "through xray
* wrapper this part is not visible" while combined with
* || xpc::WrapperFactory::XrayWrapperNotShadowing(obj) it means "through
* xray wrapper it is visible only if it does not hide any native property."
*/
static bool ObjectIsNativeWrapper(JSContext* cx, JSObject* obj);

View File

@ -475,6 +475,8 @@ DOMCI_CLASS(TransitionEvent)
DOMCI_CLASS(AnimationEvent)
DOMCI_CLASS(ContentFrameMessageManager)
DOMCI_CLASS(ChromeMessageBroadcaster)
DOMCI_CLASS(ChromeMessageSender)
DOMCI_CLASS(FormData)

View File

@ -10957,7 +10957,7 @@ nsGlobalChromeWindow::NotifyDefaultButtonLoaded(nsIDOMElement* aDefaultButton)
}
NS_IMETHODIMP
nsGlobalChromeWindow::GetMessageManager(nsIChromeFrameMessageManager** aManager)
nsGlobalChromeWindow::GetMessageManager(nsIMessageBroadcaster** aManager)
{
FORWARD_TO_INNER_CHROME(GetMessageManager, (aManager), NS_ERROR_FAILURE);
if (!mMessageManager) {
@ -10965,16 +10965,19 @@ nsGlobalChromeWindow::GetMessageManager(nsIChromeFrameMessageManager** aManager)
NS_ENSURE_STATE(scx);
JSContext* cx = scx->GetNativeContext();
NS_ENSURE_STATE(cx);
nsCOMPtr<nsIChromeFrameMessageManager> globalMM =
nsCOMPtr<nsIMessageBroadcaster> globalMM =
do_GetService("@mozilla.org/globalmessagemanager;1");
mMessageManager =
new nsFrameMessageManager(true,
new nsFrameMessageManager(true, /* aChrome */
nullptr,
nullptr,
nullptr,
nullptr,
static_cast<nsFrameMessageManager*>(globalMM.get()),
cx);
cx,
false, /* aGlobal */
false, /* aProcessManager */
true /* aBroadcaster */);
NS_ENSURE_TRUE(mMessageManager, NS_ERROR_OUT_OF_MEMORY);
}
CallQueryInterface(mMessageManager, aManager);

View File

@ -1135,7 +1135,7 @@ public:
nsGlobalWindow)
nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
nsCOMPtr<nsIChromeFrameMessageManager> mMessageManager;
nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
};
/*

View File

@ -1293,15 +1293,13 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
++mExecuteDepth;
ok = ::JS_EvaluateUCScriptForPrincipalsVersion(mContext,
aScopeObject,
nsJSPrincipals::get(principal),
static_cast<const jschar*>(PromiseFlatString(aScript).get()),
aScript.Length(),
aURL,
aLineNo,
&val,
JSVersion(aVersion));
JS::CompileOptions options(mContext);
options.setFileAndLine(aURL, aLineNo)
.setVersion(JSVersion(aVersion))
.setPrincipals(nsJSPrincipals::get(principal));
JS::RootedObject rootedScope(mContext, aScopeObject);
ok = JS::Evaluate(mContext, rootedScope, options, PromiseFlatString(aScript).get(),
aScript.Length(), &val);
--mExecuteDepth;
@ -1490,11 +1488,15 @@ nsJSContext::EvaluateString(const nsAString& aScript,
XPCAutoRequest ar(mContext);
JSAutoCompartment ac(mContext, aScopeObject);
ok = JS_EvaluateUCScriptForPrincipalsVersionOrigin(
mContext, aScopeObject,
nsJSPrincipals::get(principal), nsJSPrincipals::get(aOriginPrincipal),
static_cast<const jschar*>(PromiseFlatString(aScript).get()),
aScript.Length(), aURL, aLineNo, vp, JSVersion(aVersion));
JS::RootedObject rootedScope(mContext, aScopeObject);
JS::CompileOptions options(mContext);
options.setFileAndLine(aURL, aLineNo)
.setPrincipals(nsJSPrincipals::get(principal))
.setOriginPrincipals(nsJSPrincipals::get(aOriginPrincipal))
.setVersion(JSVersion(aVersion));
ok = JS::Evaluate(mContext, rootedScope, options,
PromiseFlatString(aScript).get(),
aScript.Length(), vp);
if (!ok) {
// Tell XPConnect about any pending exceptions. This is needed
@ -1751,17 +1753,16 @@ nsJSContext::CompileEventHandler(nsIAtom *aName,
#endif
// Event handlers are always shared, and must be bound before use.
// Therefore we never bother compiling with principals.
// (that probably means we should avoid JS_CompileUCFunctionForPrincipals!)
// Therefore we don't bother compiling with principals.
XPCAutoRequest ar(mContext);
JSFunction* fun =
::JS_CompileUCFunctionForPrincipalsVersion(mContext,
nullptr, nullptr,
nsAtomCString(aName).get(), aArgCount, aArgNames,
(jschar*)PromiseFlatString(aBody).get(),
aBody.Length(),
aURL, aLineNo, JSVersion(aVersion));
JS::CompileOptions options(mContext);
options.setVersion(JSVersion(aVersion))
.setFileAndLine(aURL, aLineNo);
JS::RootedObject empty(mContext, NULL);
JSFunction* fun = JS::CompileFunction(mContext, empty, options, nsAtomCString(aName).get(),
aArgCount, aArgNames,
PromiseFlatString(aBody).get(), aBody.Length());
if (!fun) {
ReportPendingException();
@ -1814,20 +1815,18 @@ nsJSContext::CompileFunction(JSObject* aTarget,
}
}
JSObject *target = aTarget;
JS::RootedObject target(mContext, aShared ? NULL : aTarget);
XPCAutoRequest ar(mContext);
JSFunction* fun =
::JS_CompileUCFunctionForPrincipalsVersion(mContext,
aShared ? nullptr : target,
nsJSPrincipals::get(principal),
PromiseFlatCString(aName).get(),
aArgCount, aArgArray,
static_cast<const jschar*>(PromiseFlatString(aBody).get()),
aBody.Length(),
aURL, aLineNo,
JSVersion(aVersion));
JS::CompileOptions options(mContext);
options.setPrincipals(nsJSPrincipals::get(principal))
.setVersion(JSVersion(aVersion))
.setFileAndLine(aURL, aLineNo);
JSFunction* fun = JS::CompileFunction(mContext, target,
options, PromiseFlatCString(aName).get(),
aArgCount, aArgArray,
PromiseFlatString(aBody).get(), aBody.Length());
if (!fun)
return NS_ERROR_FAILURE;

View File

@ -19,9 +19,9 @@ XPCOMUtils.defineLazyGetter(Services, "DOMRequest", function() {
return Cc["@mozilla.org/dom/dom-request-service;1"].getService(Ci.nsIDOMRequestService);
});
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
XPCOMUtils.defineLazyGetter(this, "mRIL", function () {
return Cc["@mozilla.org/telephony/system-worker-manager;1"].getService(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIRadioInterfaceLayer);

View File

@ -17,9 +17,9 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ContactDB.jsm");
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageListenerManager");
let myGlobal = this;
@ -54,7 +54,7 @@ let DOMContactManager = {
receiveMessage: function(aMessage) {
if (DEBUG) debug("Fallback DOMContactManager::receiveMessage " + aMessage.name);
let mm = aMessage.target.QueryInterface(Ci.nsIFrameMessageManager);
let mm = aMessage.target;
let msg = aMessage.data;
/*

View File

@ -100,7 +100,7 @@
let spObserver =
comp.classes["@mozilla.org/special-powers-observer;1"]
.getService(comp.interfaces.nsIFrameMessageListener);
.getService(comp.interfaces.nsIMessageListener);
mm.addMessageListener("SPPrefService", spObserver);
mm.addMessageListener("SPProcessCrashService", spObserver);

View File

@ -116,7 +116,7 @@ RPWatchContext.prototype = {
};
let DOMIdentity = {
// nsIFrameMessageListener
// nsIMessageListener
receiveMessage: function DOMIdentity_receiveMessage(aMessage) {
let msg = aMessage.json;
@ -200,7 +200,7 @@ let DOMIdentity = {
: "removeMessageListener"];
for (let message of this.messages) {
func(message, this);
func.call(aWindow.messageManager, message, this);
}
},

View File

@ -420,7 +420,7 @@ function nsDOMIdentityInternal() {
}
nsDOMIdentityInternal.prototype = {
// nsIFrameMessageListener
// nsIMessageListener
receiveMessage: function nsDOMIdentityInternal_receiveMessage(aMessage) {
let msg = aMessage.json;
// Is this message intended for this window?
@ -515,7 +515,7 @@ nsDOMIdentityInternal.prototype = {
classID: Components.ID("{8bcac6a3-56a4-43a4-a44c-cdf42763002f}"),
QueryInterface: XPCOMUtils.generateQI(
[Ci.nsIDOMGlobalPropertyInitializer, Ci.nsIFrameMessageListener]
[Ci.nsIDOMGlobalPropertyInitializer, Ci.nsIMessageListener]
),
classInfo: XPCOMUtils.generateCI({

View File

@ -114,7 +114,7 @@
let spObserver =
comp.classes["@mozilla.org/special-powers-observer;1"]
.getService(comp.interfaces.nsIFrameMessageListener);
.getService(comp.interfaces.nsIMessageListener);
mm.addMessageListener("SPPrefService", spObserver);
mm.addMessageListener("SPProcessCrashService", spObserver);

View File

@ -8,9 +8,9 @@
interface nsIBrowserDOMWindow;
interface nsIDOMElement;
interface nsIDOMEvent;
interface nsIChromeFrameMessageManager;
interface nsIMessageBroadcaster;
[scriptable, uuid(7cfbc355-cbf9-4408-8e4c-a3c603ff1428)]
[scriptable, uuid(6ff5df67-22da-4379-bf57-da775dad19f8)]
interface nsIDOMChromeWindow : nsISupports
{
const unsigned short STATE_MAXIMIZED = 1;
@ -43,7 +43,7 @@ interface nsIDOMChromeWindow : nsISupports
*/
void notifyDefaultButtonLoaded(in nsIDOMElement defaultButton);
readonly attribute nsIChromeFrameMessageManager messageManager;
readonly attribute nsIMessageBroadcaster messageManager;
/**
* On some operating systems, we must allow the window manager to

View File

@ -1372,7 +1372,7 @@ void
TabChildGlobal::Init()
{
NS_ASSERTION(!mMessageManager, "Re-initializing?!?");
mMessageManager = new nsFrameMessageManager(false,
mMessageManager = new nsFrameMessageManager(false, /* aChrome */
SendSyncMessageToParent,
SendAsyncMessageToParent,
nullptr,
@ -1394,7 +1394,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(TabChildGlobal,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(TabChildGlobal)
NS_INTERFACE_MAP_ENTRY(nsIFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIMessageListenerManager)
NS_INTERFACE_MAP_ENTRY(nsIMessageSender)
NS_INTERFACE_MAP_ENTRY(nsISyncMessageSender)
NS_INTERFACE_MAP_ENTRY(nsIContentFrameMessageManager)
NS_INTERFACE_MAP_ENTRY(nsIScriptContextPrincipal)

View File

@ -72,7 +72,8 @@ public:
void Init();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TabChildGlobal, nsDOMEventTargetHelper)
NS_FORWARD_SAFE_NSIFRAMEMESSAGEMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
const jsval& aObject,
JSContext* aCx,

View File

@ -97,17 +97,16 @@
// 1. Test that loading a script works, and that accessing process level mm and
// global mm works.
var ppm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Components.interfaces.nsIFrameMessageManager);
.getService(Components.interfaces.nsIMessageBroadcaster);
var gm = Components.classes["@mozilla.org/globalmessagemanager;1"]
.getService(Components.interfaces.nsIChromeFrameMessageManager);
.getService(Components.interfaces.nsIMessageBroadcaster);
var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
.getService(Components.interfaces.nsISyncMessageSender);
.getService(Components.interfaces.nsISyncMessageSender);
var tppm = ppm.QueryInterface(Components.interfaces.nsITreeItemFrameMessageManager);
if (tppm.childCount != 2) {
if (ppm.childCount != 2) {
alert("Should have two child processes!");
}
var childprocessmm = tppm.getChildAt(1); // 0 is the in-process child process mm
var childprocessmm = ppm.getChildAt(1); // 0 is the in-process child process mm
childprocessmm.addMessageListener("ppm-sync",
function(m) {
@ -161,7 +160,7 @@
receiveMessage: function(m) {
var s = (m.json.message == "linkclick-received") &amp;&amp;
(this.foobarObjectVar) ? "PASS" : "FAIL";
messageManager.sendAsyncMessage("chrome-message", { ok : s } );
messageManager.broadcastAsyncMessage("chrome-message", { ok : s } );
}
}
);
@ -197,7 +196,7 @@
function messageSpeed() {
speedTestCount = 0;
messageManager.addMessageListener("speed-test", speedHandler);
messageManager.sendAsyncMessage("speed-test-start");
messageManager.broadcastAsyncMessage("speed-test-start");
}
function speedHandler() {
@ -217,7 +216,7 @@
if (++addRemoveTestCount == 1) {
alert("Expected echo message");
messageManager.removeMessageListener("async-echo", echoListener);
messageManager.sendAsyncMessage("async-echo");
messageManager.broadcastAsyncMessage("async-echo");
return;
}
alert("Unexpected echo message");
@ -226,7 +225,7 @@
function listenerAddRemove() {
addRemoveTestCount = 0;
messageManager.addMessageListener("async-echo", echoListener);
messageManager.sendAsyncMessage("async-echo");
messageManager.broadcastAsyncMessage("async-echo");
}
var MozAfterPaintCount = 0;
@ -286,8 +285,10 @@
</toolbar>
<toolbar><label value="Load a script (URL) to content process:"/>
<textbox flex="1" id="script"/><button
label="send" oncommand="document.getElementById('page').QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.
messageManager.loadFrameScript(this.previousSibling.value, false);"/>
label="send" oncommand="document.getElementById('page')
.QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
.frameLoader.messageManager
.loadFrameScript(this.previousSibling.value, false);"/>
</toolbar>
<toolbar>
<label value="Eval script in chrome context"/>

View File

@ -49,9 +49,10 @@
}
Services.obs.addObserver(crashObserver, 'ipc:content-shutdown', false);
document.getElementById('thebrowser').
QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.
messageManager.loadFrameScript('chrome://mochitests/content/chrome/dom/ipc/tests/process_error_contentscript.js', true);
document.getElementById('thebrowser')
.QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
.frameLoader.messageManager
.loadFrameScript('chrome://mochitests/content/chrome/dom/ipc/tests/process_error_contentscript.js', true);
]]></script>
</window>

View File

@ -12,9 +12,9 @@ const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageBroadcaster");
// Limit the number of pending messages for a given page.
let kMaxPendingMessages;
@ -42,9 +42,9 @@ function SystemMessageInternal() {
SystemMessageInternal.prototype = {
sendMessage: function sendMessage(aType, aMessage, aPageURI, aManifestURI) {
debug("Broadcasting " + aType + " " + JSON.stringify(aMessage));
ppmm.sendAsyncMessage("SystemMessageManager:Message" , { type: aType,
msg: aMessage,
manifest: aManifestURI.spec });
ppmm.broadcastAsyncMessage("SystemMessageManager:Message" , { type: aType,
msg: aMessage,
manifest: aManifestURI.spec });
// Queue the message for pages that registered an handler for this type.
this._pages.forEach(function sendMess_openPage(aPage) {

View File

@ -13,11 +13,9 @@ Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/ObjectWrapper.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsIFrameMessageManager)
.QueryInterface(Ci.nsISyncMessageSender);
});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsISyncMessageSender");
// Limit the number of pending messages for a given type.
let kMaxPendingMessages;

View File

@ -34,9 +34,9 @@ let EXPORTED_SYMBOLS = ["PermissionPromptHelper"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageListenerManager");
var permissionManager = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager);
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
@ -77,7 +77,7 @@ let PermissionPromptHelper = {
receiveMessage: function(aMessage) {
debug("PermissionPromptHelper::receiveMessage " + aMessage.name);
let mm = aMessage.target.QueryInterface(Ci.nsIFrameMessageManager);
let mm = aMessage.target;
let msg = aMessage.data;
let result;

View File

@ -17,9 +17,9 @@ let EXPORTED_SYMBOLS = ["SettingsChangeNotifier"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "ppmm", function() {
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIMessageBroadcaster");
let SettingsChangeNotifier = {
@ -41,7 +41,7 @@ let SettingsChangeNotifier = {
let msg = aMessage.json;
switch (aMessage.name) {
case "Settings:Changed":
ppmm.sendAsyncMessage("Settings:Change:Return:OK", { key: msg.key, value: msg.value });
ppmm.broadcastAsyncMessage("Settings:Change:Return:OK", { key: msg.key, value: msg.value });
Services.obs.notifyObservers(this, "mozsettings-changed", JSON.stringify({
key: msg.key,
value: msg.value

View File

@ -17,9 +17,9 @@ Cu.import("resource://gre/modules/SettingsDB.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "cpmm", function() {
return Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
});
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIMessageSender");
const nsIClassInfo = Ci.nsIClassInfo;
const SETTINGSLOCK_CONTRACTID = "@mozilla.org/settingsLock;1";

View File

@ -66,7 +66,7 @@ const kUssdReceivedTopic = "mobile-connection-ussd-received";
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsIFrameMessageManager");
"nsISyncMessageSender");
XPCOMUtils.defineLazyServiceGetter(this, "gUUIDGenerator",
"@mozilla.org/uuid-generator;1",
@ -161,8 +161,7 @@ function RILContentHelper() {
Services.obs.addObserver(this, "xpcom-shutdown", false);
// Request initial context.
let rilContext = cpmm.QueryInterface(Ci.nsISyncMessageSender)
.sendSyncMessage("RIL:GetRilContext")[0];
let rilContext = cpmm.sendSyncMessage("RIL:GetRilContext")[0];
if (!rilContext) {
debug("Received null rilContext from chrome process.");
@ -508,7 +507,7 @@ RILContentHelper.prototype = {
}
},
// nsIFrameMessageListener
// nsIMessageListener
fireRequestSuccess: function fireRequestSuccess(requestId, result) {
let request = this.takeRequest(requestId);

View File

@ -79,7 +79,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "gSmsDatabaseService",
XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
"@mozilla.org/parentprocessmessagemanager;1",
"nsIFrameMessageManager");
"nsIMessageBroadcaster");
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
"@mozilla.org/settingsService;1",
@ -376,7 +376,7 @@ RadioInterfaceLayer.prototype = {
break;
case "cardstatechange":
this.rilContext.cardState = message.cardState;
ppmm.sendAsyncMessage("RIL:CardStateChanged", message);
ppmm.broadcastAsyncMessage("RIL:CardStateChanged", message);
break;
case "sms-received":
this.handleSmsReceived(message);
@ -428,7 +428,7 @@ RadioInterfaceLayer.prototype = {
}
break;
case "iccmbdn":
ppmm.sendAsyncMessage("RIL:VoicemailNumberChanged", message);
ppmm.broadcastAsyncMessage("RIL:VoicemailNumberChanged", message);
break;
case "ussdreceived":
debug("ussdreceived " + JSON.stringify(message));
@ -454,8 +454,7 @@ RadioInterfaceLayer.prototype = {
return;
}
let mm = msg.target.QueryInterface(Ci.nsIFrameMessageManager);
this._messageManagerByRequest[requestId] = mm;
this._messageManagerByRequest[requestId] = msg.target;
},
_sendRequestResults: function _sendRequestResults(requestType, options) {
@ -466,7 +465,7 @@ RadioInterfaceLayer.prototype = {
return;
}
target.sendAsyncMessage(requestType, options);
target.syncAsyncMessage(requestType, options);
},
updateNetworkInfo: function updateNetworkInfo(message) {
@ -499,10 +498,10 @@ RadioInterfaceLayer.prototype = {
}
if (voiceMessage || operatorMessage) {
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", voice);
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voice);
}
if (dataMessage || operatorMessage) {
ppmm.sendAsyncMessage("RIL:DataInfoChanged", data);
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", data);
}
if (selectionMessage) {
@ -544,7 +543,7 @@ RadioInterfaceLayer.prototype = {
}
if (!newInfo.batch) {
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
}
},
@ -574,7 +573,7 @@ RadioInterfaceLayer.prototype = {
}
if (!newInfo.batch) {
ppmm.sendAsyncMessage("RIL:DataInfoChanged", dataInfo);
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", dataInfo);
}
if (!this.dataCallSettings["enabled"]) {
@ -600,7 +599,7 @@ RadioInterfaceLayer.prototype = {
voiceInfo.relSignalStrength != message.gsmRelative) {
voiceInfo.signalStrength = message.gsmDBM;
voiceInfo.relSignalStrength = message.gsmRelative;
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voiceInfo);
}
let dataInfo = this.rilContext.data;
@ -608,7 +607,7 @@ RadioInterfaceLayer.prototype = {
dataInfo.relSignalStrength != message.gsmRelative) {
dataInfo.signalStrength = message.gsmDBM;
dataInfo.relSignalStrength = message.gsmRelative;
ppmm.sendAsyncMessage("RIL:DataInfoChanged", dataInfo);
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", dataInfo);
}
},
@ -626,12 +625,12 @@ RadioInterfaceLayer.prototype = {
if (this.networkChanged(message, voice.network)) {
voice.network = message;
ppmm.sendAsyncMessage("RIL:VoiceInfoChanged", voice);
ppmm.broadcastAsyncMessage("RIL:VoiceInfoChanged", voice);
}
if (this.networkChanged(message, data.network)) {
data.network = message;
ppmm.sendAsyncMessage("RIL:DataInfoChanged", data);
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", data);
}
},
@ -748,7 +747,7 @@ RadioInterfaceLayer.prototype = {
this._activeCall = null;
}
this.updateCallAudioState();
ppmm.sendAsyncMessage("RIL:CallStateChanged", call);
ppmm.broadcastAsyncMessage("RIL:CallStateChanged", call);
},
/**
@ -761,7 +760,7 @@ RadioInterfaceLayer.prototype = {
}
this.updateCallAudioState();
call.state = nsIRadioInterfaceLayer.CALL_STATE_DISCONNECTED;
ppmm.sendAsyncMessage("RIL:CallStateChanged", call);
ppmm.broadcastAsyncMessage("RIL:CallStateChanged", call);
},
/**
@ -789,7 +788,7 @@ RadioInterfaceLayer.prototype = {
*/
updateNetworkSelectionMode: function updateNetworkSelectionMode(message) {
debug("updateNetworkSelectionMode: " + JSON.stringify(message));
ppmm.sendAsyncMessage("RIL:NetworkSelectionModeChanged", message);
ppmm.broadcastAsyncMessage("RIL:NetworkSelectionModeChanged", message);
},
/**
@ -812,7 +811,7 @@ RadioInterfaceLayer.prototype = {
* Handle call error.
*/
handleCallError: function handleCallError(message) {
ppmm.sendAsyncMessage("RIL:CallError", message);
ppmm.broadcastAsyncMessage("RIL:CallError", message);
},
/**
@ -873,7 +872,7 @@ RadioInterfaceLayer.prototype = {
if (mwi) {
mwi.returnNumber = message.sender || null;
mwi.returnMessage = message.fullBody || null;
ppmm.sendAsyncMessage("RIL:VoicemailNotification", mwi);
ppmm.broadcastAsyncMessage("RIL:VoicemailNotification", mwi);
return;
}
@ -975,7 +974,7 @@ RadioInterfaceLayer.prototype = {
if (datacall.ifname) {
data.connected = (datacall.state == RIL.GECKO_NETWORK_STATE_CONNECTED);
ppmm.sendAsyncMessage("RIL:DataInfoChanged", data);
ppmm.broadcastAsyncMessage("RIL:DataInfoChanged", data);
}
this._deliverDataCallCallback("dataCallStateChanged",
@ -996,7 +995,7 @@ RadioInterfaceLayer.prototype = {
handleUSSDReceived: function handleUSSDReceived(ussd) {
debug("handleUSSDReceived " + JSON.stringify(ussd));
ppmm.sendAsyncMessage("RIL:UssdReceived", ussd);
ppmm.broadcastAsyncMessage("RIL:UssdReceived", ussd);
},
handleSendUSSD: function handleSendUSSD(message) {

View File

@ -296,7 +296,6 @@ var interfaceNamesInGlobalScope =
"SVGPathSegLinetoHorizontalAbs",
"SVGAnimatedRect",
"SVGTextContentElement",
"SyncMessageSender",
"WebGLRenderbuffer",
"TreeColumn",
"WebGLExtensionStandardDerivatives",
@ -402,7 +401,6 @@ var interfaceNamesInGlobalScope =
"SVGStyleElement",
"XULContainerElement",
"DOMTokenList",
"FrameMessageManager",
"HTMLHRElement",
"HTMLFontElement",
"SVGFEFloodElement",
@ -490,7 +488,6 @@ var interfaceNamesInGlobalScope =
"MutationObserver",
"RequestService",
"Counter",
"ContentFrameMessageManager",
"SVGAnimatedAngle",
"SVGPathSegList",
"SVGFEFuncAElement",

View File

@ -1326,7 +1326,8 @@ let netFromDOM;
function WifiWorker() {
var self = this;
this._mm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
this._mm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageListenerManager);
const messages = ["WifiManager:setEnabled", "WifiManager:getNetworks",
"WifiManager:associate", "WifiManager:forget",
"WifiManager:wps", "WifiManager:getState",
@ -1889,7 +1890,7 @@ WifiWorker.prototype = {
receiveMessage: function MessageManager_receiveMessage(aMessage) {
let msg = aMessage.json || {};
msg.manager = aMessage.target.QueryInterface(Ci.nsIFrameMessageManager);
msg.manager = aMessage.target;
switch (aMessage.name) {
case "WifiManager:setEnabled":

View File

@ -576,7 +576,7 @@ ScriptExecutorRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
}
}
JSObject* global = JS_GetGlobalObject(aCx);
JS::RootedObject global(aCx, JS_GetGlobalObject(aCx));
NS_ASSERTION(global, "Must have a global by now!");
JSPrincipals* principal = GetWorkerPrincipal();
@ -615,10 +615,11 @@ ScriptExecutorRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
NS_ConvertUTF16toUTF8 filename(loadInfo.mURL);
if (!JS_EvaluateUCScriptForPrincipals(aCx, global, principal,
loadInfo.mScriptText.get(),
loadInfo.mScriptText.Length(),
filename.get(), 1, nullptr)) {
JS::CompileOptions options(aCx);
options.setPrincipals(principal)
.setFileAndLine(filename.get(), 1);
if (!JS::Evaluate(aCx, global, options, loadInfo.mScriptText.get(),
loadInfo.mScriptText.Length(), nullptr)) {
return true;
}

View File

@ -3760,7 +3760,7 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
bool retval = true;
AutoPtrComparator<TimeoutInfo> comparator = GetAutoPtrComparator(mTimeouts);
JSObject* global = JS_GetGlobalObject(aCx);
JS::RootedObject global(aCx, JS_GetGlobalObject(aCx));
JSPrincipals* principal = GetWorkerPrincipal();
// We want to make sure to run *something*, even if the timer fired a little
@ -3794,15 +3794,14 @@ WorkerPrivate::RunExpiredTimeouts(JSContext* aCx)
if (info->mTimeoutVal.isString()) {
JSString* expression = info->mTimeoutVal.toString();
JS::CompileOptions options(aCx);
options.setPrincipals(principal)
.setFileAndLine(info->mFilename.get(), info->mLineNumber);
size_t stringLength;
const jschar* string = JS_GetStringCharsAndLength(aCx, expression,
&stringLength);
if ((!string ||
!JS_EvaluateUCScriptForPrincipals(aCx, global, principal, string,
stringLength,
info->mFilename.get(),
info->mLineNumber, nullptr)) &&
if ((!string || !JS::Evaluate(aCx, global, options, string, stringLength, nullptr)) &&
!JS_ReportPendingException(aCx)) {
retval = false;
break;

View File

@ -27,7 +27,7 @@ function run_test() {
pm.addFromPrincipal(getPrincipalForURI("http://mozilla.net"), "cookie3", pm.ALLOW_ACTION, pm.EXPIRE_TIME, Date.now() + 1000*60*60*24);
var mM = Cc["@mozilla.org/parentprocessmessagemanager;1"].
getService(Ci.nsIFrameMessageManager);
getService(Ci.nsIMessageBroadcaster);
var messageListener = {
receiveMessage: function(aMessage) {
@ -37,7 +37,7 @@ function run_test() {
pm.addFromPrincipal(getPrincipalForURI("http://firefox.org"), "cookie1", pm.ALLOW_ACTION, pm.EXPIRE_NEVER, 0);
pm.addFromPrincipal(getPrincipalForURI("http://firefox.com"), "cookie2", pm.DENY_ACTION, pm.EXPIRE_SESSION, 0);
pm.addFromPrincipal(getPrincipalForURI("http://firefox.net"), "cookie3", pm.ALLOW_ACTION, pm.EXPIRE_TIME, Date.now() + 1000*60*60*24);
mM.sendAsyncMessage("TESTING:Stage2A");
mM.broadcastAsyncMessage("TESTING:Stage2A");
break;
case "TESTING:Stage3":

View File

@ -195,9 +195,11 @@ nsresult EvaluateAdminConfigScript(const char *js_buffer, size_t length,
JS_BeginRequest(autoconfig_cx);
nsCOMPtr<nsIPrincipal> principal;
nsContentUtils::GetSecurityManager()->GetSystemPrincipal(getter_AddRefs(principal));
ok = JS_EvaluateScriptForPrincipals(autoconfig_cx, autoconfig_glob,
nsJSPrincipals::get(principal),
js_buffer, length, filename, 0, nullptr);
JS::CompileOptions options(autoconfig_cx);
options.setPrincipals(nsJSPrincipals::get(principal))
.setFileAndLine(filename, 1);
JS::RootedObject glob(autoconfig_cx, autoconfig_glob);
ok = JS::Evaluate(autoconfig_cx, glob, options, js_buffer, length, nullptr);
JS_EndRequest(autoconfig_cx);
JS_MaybeGC(autoconfig_cx);

View File

@ -1,111 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sw=4 et tw=0 ft=C: */
/* 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/. */
/* Note : contiguity of 'simple opcodes' is important for SimpleMatch() */
/* match rest of input against rest of r.e. */
REOP_DEF(REOP_EMPTY, "empty")
/* beginning of input (or line if multiline) */
REOP_DEF(REOP_BOL, "bol")
/* end of input (or line if multiline) */
REOP_DEF(REOP_EOL, "eol")
/* match "" at word boundary */
REOP_DEF(REOP_WBDRY, "wbdry")
/* match "" at word non-boundary */
REOP_DEF(REOP_WNONBDRY, "wnonbdry")
/* stands for any character */
REOP_DEF(REOP_DOT, "dot")
/* match a digit char: [0-9] */
REOP_DEF(REOP_DIGIT, "digit")
/* match a non-digit char: [^0-9] */
REOP_DEF(REOP_NONDIGIT, "nondigit")
/* match an alphanumeric char: [0-9a-z_A-Z] */
REOP_DEF(REOP_ALNUM, "alnum")
/* match a non-alphanumeric char: [^0-9a-z_A-Z] */
REOP_DEF(REOP_NONALNUM, "nonalnum")
/* match a whitespace char */
REOP_DEF(REOP_SPACE, "space")
/* match a non-whitespace char */
REOP_DEF(REOP_NONSPACE, "nonspace")
/* back-reference (e.g., \1) to a parenthetical */
REOP_DEF(REOP_BACKREF, "backref")
/* match a flat string */
REOP_DEF(REOP_FLAT, "flat")
/* match a single char */
REOP_DEF(REOP_FLAT1, "flat1")
/* case-independent REOP_FLAT */
REOP_DEF(REOP_FLATi, "flati")
/* case-independent REOP_FLAT1 */
REOP_DEF(REOP_FLAT1i, "flat1i")
/* single Unicode char */
REOP_DEF(REOP_UCFLAT1, "ucflat1")
/* case-independent REOP_UCFLAT1 */
REOP_DEF(REOP_UCFLAT1i, "ucflat1i")
/* flat Unicode string; len immediate counts chars */
REOP_DEF(REOP_UCFLAT, "ucflat")
/* case-independent REOP_UCFLAT */
REOP_DEF(REOP_UCFLATi, "ucflati")
/* character class with index */
REOP_DEF(REOP_CLASS, "class")
/* negated character class with index */
REOP_DEF(REOP_NCLASS, "nclass")
/* NCLASS is considered to be the last "simple" op-code */
/* alternative subexpressions in kid and next */
REOP_DEF(REOP_ALT, "alt")
/* quantified atom: atom{1,2} */
REOP_DEF(REOP_QUANT, "quant")
/* zero or more occurrences of kid */
REOP_DEF(REOP_STAR, "star")
/* one or more occurrences of kid */
REOP_DEF(REOP_PLUS, "plus")
/* optional subexpression in kid */
REOP_DEF(REOP_OPT, "opt")
/* left paren bytecode: kid is u.num'th sub-regexp */
REOP_DEF(REOP_LPAREN, "lparen")
/* right paren bytecode */
REOP_DEF(REOP_RPAREN, "rparen")
/* for deoptimized closure loops */
REOP_DEF(REOP_JUMP, "jump")
/* optimize .* to use a single opcode */
REOP_DEF(REOP_DOTSTAR, "dotstar")
/* non-capturing version of REOP_LPAREN */
REOP_DEF(REOP_LPARENNON, "lparennon")
/* zero width positive lookahead assertion */
REOP_DEF(REOP_ASSERT, "assert")
/* zero width negative lookahead assertion */
REOP_DEF(REOP_ASSERT_NOT, "assert_not")
/* sentinel at end of assertion child */
REOP_DEF(REOP_ASSERTTEST, "asserttest")
/* sentinel at end of !assertion child */
REOP_DEF(REOP_ASSERTNOTTEST, "assertnottest")
/* non-greedy version of * */
REOP_DEF(REOP_MINIMALSTAR, "minimalstar")
/* non-greedy version of + */
REOP_DEF(REOP_MINIMALPLUS, "minimalplus")
/* non-greedy version of ? */
REOP_DEF(REOP_MINIMALOPT, "minimalopt")
/* non-greedy version of {} */
REOP_DEF(REOP_MINIMALQUANT, "minimalquant")
/* sentinel at end of quantifier child */
REOP_DEF(REOP_ENDCHILD, "endchild")
/* directs execution of greedy quantifier */
REOP_DEF(REOP_REPEAT, "repeat")
/* directs execution of non-greedy quantifier */
REOP_DEF(REOP_MINIMALREPEAT, "minimalrepeat")
/* prerequisite for ALT, either of two chars */
REOP_DEF(REOP_ALTPREREQ, "altprereq")
/* prerequisite for ALT, a char or a class */
REOP_DEF(REOP_ALTPREREQ2, "altprereq2")
/* end of final alternate */
REOP_DEF(REOP_ENDALT, "endalt")
/* concatenation of terms (parse time only) */
REOP_DEF(REOP_CONCAT, "concat")
/* end of expression */
REOP_DEF(REOP_END, "end")

View File

@ -3915,13 +3915,12 @@ xpc_EvalInSandbox(JSContext *cx, JSObject *sandbox, const nsAString& source,
jsval v;
JSString *str = nullptr;
JSBool ok =
JS_EvaluateUCScriptForPrincipals(sandcx->GetJSContext(), sandbox,
nsJSPrincipals::get(prin),
reinterpret_cast<const jschar *>
(PromiseFlatString(source).get()),
source.Length(), filename, lineNo,
&v);
JS::CompileOptions options(sandcx->GetJSContext());
options.setPrincipals(nsJSPrincipals::get(prin))
.setFileAndLine(filename, lineNo);
JS::RootedObject rootedSandbox(sandcx->GetJSContext(), sandbox);
bool ok = JS::Evaluate(sandcx->GetJSContext(), rootedSandbox, options,
PromiseFlatString(source).get(), source.Length(), &v);
if (ok && returnStringOnly && !(JSVAL_IS_VOID(v))) {
ok = !!(str = JS_ValueToString(sandcx->GetJSContext(), v));
}

View File

@ -65,7 +65,8 @@ const char* XPCJSRuntime::mStrings[] = {
"__scriptOnly__", // IDX_SCRIPTONLY
"baseURIObject", // IDX_BASEURIOBJECT
"nodePrincipal", // IDX_NODEPRINCIPAL
"documentURIObject" // IDX_DOCUMENTURIOBJECT
"documentURIObject", // IDX_DOCUMENTURIOBJECT
"mozMatchesSelector" // IDX_MOZMATCHESSELECTOR
};
/***************************************************************************/

View File

@ -730,6 +730,7 @@ public:
IDX_BASEURIOBJECT ,
IDX_NODEPRINCIPAL ,
IDX_DOCUMENTURIOBJECT ,
IDX_MOZMATCHESSELECTOR ,
IDX_TOTAL_COUNT // just a count of the above
};

View File

@ -32,6 +32,7 @@ MOCHITEST_CHROME_FILES = \
test_bug679861.xul \
test_bug706301.xul \
test_bug726949.xul \
test_bug738244.xul \
test_bug743843.xul \
test_bug760076.xul \
test_bug760109.xul \
@ -51,6 +52,7 @@ MOCHITEST_CHROME_FILES = \
test_expandosharing.xul \
file_expandosharing.jsm \
test_getweakmapkeys.xul \
test_mozMatchesSelector.xul \
test_nodelists.xul \
test_precisegc.xul \
test_sandboxImport.xul \

View File

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=533596
-->
<window title="Mozilla Bug 533596"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/file_bug738244.html"
onload="xrayTest(this)">
</iframe>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
function xrayTest(ifr) {
var win = ifr.contentWindow;
var doc = ifr.contentDocument;
doc.getElementById = 42;
is(doc.getElementById, 42,
"Native property cannot be shadowed on the xray");
is(doc.form1.name, "form1",
"Form elements cannot be found by name on the document through xray");
is(doc.form1.input1.name, "input1",
"Input element cannot be found by name on a form element through xray");
is(typeof doc.form1.appendChild, "function",
"Input element shadows native property with its name through xray");
is(win.frame1.name, "frame1",
"IFrames cannot be found by name on the window through xray");
SimpleTest.finish();
}
]]></script>
</window>

View File

@ -0,0 +1,50 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=533596
-->
<window title="Mozilla Bug 533596"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/file_mozMatchesSelector.html"
onload="runTest(this)">
</iframe>
</body>
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
function runTest(ifr)
{
var doc = ifr.contentDocument;
var docElem = doc.documentElement;
var res = doc.createElement('div').mozMatchesSelector('div');
is(res, true, "mozMatchesSelector call through xray, regular case");
res = docElem.mozMatchesSelector.call(
doc.createElement('div'), 'div');
is(res, true, "mozMatchesSelector call through xray, with .call");
var sb = new Components.utils.Sandbox(ifr.contentWindow);
sb.doc = doc;
var str = "doc.documentElement.mozMatchesSelector.call(doc.createElement( 'div' ),'div')";
res = Components.utils.evalInSandbox(str, sb);
is(res, true, "mozMatchesSelector call through xray (same origin), with .call");
docElem.mozMatchesSelector = function(){return false};
res = docElem.mozMatchesSelector.call(doc.createElement( 'div' ),'div');
is(res, false, "shadowing mozMatchesSelector with an expando on the xray wrapper");
SimpleTest.finish();
}
]]></script>
</window>

View File

@ -72,6 +72,8 @@ MOCHITEST_FILES = bug500931_helper.html \
file_empty.html \
file_documentdomain.html \
test_lookupMethod.html \
file_bug738244.html \
file_mozMatchesSelector.html \
$(NULL)
MOCHITEST_CHROME_FILES = \

View File

@ -0,0 +1,10 @@
<html>
<body>
<form name="form1">
<input name="input1" />
<input name="appendChild" />
</form>
<iframe name="frame1">
</iframe>
</body>
</html>

View File

@ -0,0 +1 @@
<html><body></body></html>

View File

@ -625,6 +625,14 @@ WrapperFactory::WrapForSameCompartmentXray(JSContext *cx, JSObject *obj)
return wrapperObj;
}
bool
WrapperFactory::XrayWrapperNotShadowing(JSObject *wrapper, jsid id)
{
ResolvingId *rid = ResolvingId::getResolvingIdFromWrapper(wrapper);
return rid->isXrayShadowing(id);
}
/*
* Calls to JS_TransplantObject* should go through these helpers here so that
* waivers get fixed up properly.

View File

@ -93,6 +93,9 @@ class WrapperFactory {
// Wrap a same-compartment object for Xray inspection.
static JSObject *WrapForSameCompartmentXray(JSContext *cx, JSObject *obj);
// Returns true if the wrapper is in not shadowing mode for the id.
static bool XrayWrapperNotShadowing(JSObject *wrapper, jsid id);
};
extern js::DirectWrapper XrayWaiver;

View File

@ -18,6 +18,7 @@
#include "xpcprivate.h"
#include "jsapi.h"
#include "nsJSUtils.h"
#include "mozilla/dom/BindingUtils.h"
@ -279,6 +280,68 @@ createHolder(JSContext *cx, JSObject *wrappedNative, JSObject *parent)
using namespace XrayUtils;
ResolvingId::ResolvingId(JSObject *wrapper, jsid id)
: mId(id),
mHolder(getHolderObject(wrapper)),
mPrev(getResolvingId(mHolder)),
mXrayShadowing(false)
{
js::SetReservedSlot(mHolder, JSSLOT_RESOLVING, js::PrivateValue(this));
}
ResolvingId::~ResolvingId()
{
MOZ_ASSERT(getResolvingId(mHolder) == this, "unbalanced ResolvingIds");
js::SetReservedSlot(mHolder, JSSLOT_RESOLVING, js::PrivateValue(mPrev));
}
bool
ResolvingId::isXrayShadowing(jsid id)
{
if (!mXrayShadowing)
return false;
return mId == id;
}
bool
ResolvingId::isResolving(jsid id)
{
for (ResolvingId *cur = this; cur; cur = cur->mPrev) {
if (cur->mId == id)
return true;
}
return false;
}
ResolvingId *
ResolvingId::getResolvingId(JSObject *holder)
{
MOZ_ASSERT(strcmp(JS_GetClass(holder)->name, "NativePropertyHolder") == 0);
return (ResolvingId *)js::GetReservedSlot(holder, JSSLOT_RESOLVING).toPrivate();
}
JSObject *
ResolvingId::getHolderObject(JSObject *wrapper)
{
return &js::GetProxyExtra(wrapper, 0).toObject();
}
ResolvingId *
ResolvingId::getResolvingIdFromWrapper(JSObject *wrapper)
{
return getResolvingId(getHolderObject(wrapper));
}
class ResolvingIdDummy
{
public:
ResolvingIdDummy(JSObject *wrapper, jsid id)
{
}
};
class XPCWrappedNativeXrayTraits
{
public:
@ -298,30 +361,18 @@ public:
}
static JSObject* getInnerObject(JSObject *wrapper);
class ResolvingId
{
public:
ResolvingId(JSObject *holder, jsid id);
~ResolvingId();
private:
friend class XPCWrappedNativeXrayTraits;
jsid mId;
JSObject *mHolder;
ResolvingId *mPrev;
};
static bool isResolving(JSContext *cx, JSObject *holder, jsid id);
static bool resolveDOMCollectionProperty(JSContext *cx, JSObject *wrapper, JSObject *holder,
jsid id, bool set, PropertyDescriptor *desc);
typedef ResolvingId ResolvingIdImpl;
private:
static JSObject* getHolderObject(JSObject *wrapper)
{
return &js::GetProxyExtra(wrapper, 0).toObject();
}
static ResolvingId* getResolvingId(JSObject *holder)
{
return (ResolvingId *)js::GetReservedSlot(holder, JSSLOT_RESOLVING).toPrivate();
}
};
class ProxyXrayTraits
@ -346,18 +397,13 @@ public:
return &js::GetProxyPrivate(wrapper).toObject();
}
class ResolvingId
{
public:
ResolvingId(JSObject *holder, jsid id)
{
}
};
static bool isResolving(JSContext *cx, JSObject *holder, jsid id)
{
return false;
return false;
}
typedef ResolvingIdDummy ResolvingIdImpl;
private:
static JSObject* getHolderObject(JSContext *cx, JSObject *wrapper,
bool createHolder)
@ -395,18 +441,13 @@ public:
return &js::GetProxyPrivate(wrapper).toObject();
}
class ResolvingId
{
public:
ResolvingId(JSObject *holder, jsid id)
{
}
};
static bool isResolving(JSContext *cx, JSObject *holder, jsid id)
{
return false;
return false;
}
typedef ResolvingIdDummy ResolvingIdImpl;
private:
static JSObject* getHolderObject(JSContext *cx, JSObject *wrapper,
bool createHolder)
@ -472,30 +513,11 @@ XPCWrappedNativeXrayTraits::getInnerObject(JSObject *wrapper)
return GetWrappedNativeObjectFromHolder(getHolderObject(wrapper));
}
XPCWrappedNativeXrayTraits::ResolvingId::ResolvingId(JSObject *wrapper, jsid id)
: mId(id),
mHolder(getHolderObject(wrapper)),
mPrev(getResolvingId(mHolder))
{
js::SetReservedSlot(mHolder, JSSLOT_RESOLVING, PrivateValue(this));
}
XPCWrappedNativeXrayTraits::ResolvingId::~ResolvingId()
{
NS_ASSERTION(getResolvingId(mHolder) == this, "unbalanced ResolvingIds");
js::SetReservedSlot(mHolder, JSSLOT_RESOLVING, PrivateValue(mPrev));
}
bool
XPCWrappedNativeXrayTraits::isResolving(JSContext *cx, JSObject *holder,
jsid id)
{
for (ResolvingId *cur = getResolvingId(holder); cur; cur = cur->mPrev) {
if (cur->mId == id)
return true;
}
return false;
return ResolvingId::getResolvingId(holder)->isResolving(id);
}
// Some DOM objects have shared properties that don't have an explicit
@ -548,25 +570,174 @@ holder_set(JSContext *cx, JSHandleObject wrapper_, JSHandleId id, JSBool strict,
return true;
}
class AutoSetWrapperNotShadowing
{
public:
AutoSetWrapperNotShadowing(JSObject *wrapper MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
MOZ_ASSERT(wrapper);
mResolvingId = ResolvingId::getResolvingIdFromWrapper(wrapper);
MOZ_ASSERT(mResolvingId);
mResolvingId->mXrayShadowing = true;
}
~AutoSetWrapperNotShadowing()
{
mResolvingId->mXrayShadowing = false;
}
private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
ResolvingId *mResolvingId;
};
// This is called after the resolveNativeProperty could not find any property
// with the given id. At this point we can check for DOM specific collections
// like document["formName"] because we already know that it is not shadowing
// any native property.
bool
XPCWrappedNativeXrayTraits::resolveDOMCollectionProperty(JSContext *cx, JSObject *wrapper,
JSObject *holder, jsid id, bool set,
PropertyDescriptor *desc)
{
// If we are not currently resolving this id and resolveNative is called
// we don't do anything. (see defineProperty in case of shadowing is forbidden).
ResolvingId *rid = ResolvingId::getResolvingId(holder);
if (!rid || rid->mId != id)
return true;
XPCWrappedNative *wn = GetWrappedNativeFromHolder(holder);
if (!NATIVE_HAS_FLAG(wn, WantNewResolve))
return true;
// Setting the current ResolvingId in non-shadowing mode. So for this id
// Xray won't ignore DOM specific collection properties temporarily.
AutoSetWrapperNotShadowing asw(wrapper);
bool retval = true;
JSObject *pobj = NULL;
unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0) | JSRESOLVE_QUALIFIED;
nsresult rv = wn->GetScriptableInfo()->GetCallback()->NewResolve(wn, cx, wrapper, id,
flags, &pobj, &retval);
if (NS_FAILED(rv)) {
if (retval)
XPCThrower::Throw(rv, cx);
return false;
}
if (pobj && !JS_GetPropertyDescriptorById(cx, holder, id,
JSRESOLVE_QUALIFIED, desc))
{
return false;
}
return true;
}
template <typename T>
static bool
Is(JSObject *wrapper)
{
JSObject *holder = GetHolder(wrapper);
XPCWrappedNative *wn = GetWrappedNativeFromHolder(holder);
nsCOMPtr<T> native = do_QueryWrappedNative(wn);
return !!native;
}
// Helper function to work around some limitations of the current XPC
// calling mechanism. See: bug 763897.
// The idea is that we unwrap the 'this' object, and find the wrapped
// native that belongs to it. Then we simply make the call directly
// on it after a Query Interface.
static JSBool
mozMatchesSelectorStub(JSContext *cx, unsigned argc, jsval *vp)
{
if (argc < 1)
JS_ReportError(cx, "Not enough arguments");
JSObject *wrapper = JS_THIS_OBJECT(cx, vp);
JSString *selector = JS_ValueToString(cx, JS_ARGV(cx, vp)[0]);
nsDependentJSString selectorStr;
NS_ENSURE_TRUE(selectorStr.init(cx, selector), false);
nsCOMPtr<nsIDOMElement> element;
if (IsWrapper(wrapper) && WrapperFactory::IsXrayWrapper(wrapper)) {
// If it's xray wrapped we can get the wn directly.
JSObject *holder = GetHolder(wrapper);
XPCWrappedNative *wn = GetWrappedNativeFromHolder(holder);
element = do_QueryWrappedNative(wn);
} else {
// Else we can use the XPC utility function for unwrapping it.
nsCOMPtr<nsIXPConnectWrappedNative> iwn;
nsIXPConnect *xpc = nsXPConnect::GetXPConnect();
nsresult rv = xpc->GetWrappedNativeOfJSObject(cx, wrapper,
getter_AddRefs(iwn));
if (NS_FAILED(rv) || !iwn) {
JS_ReportError(cx, "Unexpected object");
return false;
}
element = do_QueryWrappedNative(iwn);
}
if (!element) {
JS_ReportError(cx, "Unexpected object");
return false;
}
bool ret;
nsresult rv = element->MozMatchesSelector(selectorStr, &ret);
if (NS_FAILED(rv)) {
XPCThrower::Throw(rv, cx);
return false;
}
JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret));
return true;
}
bool
XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapper,
JSObject *holder, jsid id, bool set,
JSPropertyDescriptor *desc)
{
MOZ_ASSERT(js::GetObjectJSClass(holder) == &HolderClass);
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
if (!set &&
id == rt->GetStringID(XPCJSRuntime::IDX_MOZMATCHESSELECTOR) &&
Is<nsIDOMElement>(wrapper))
{
// XPC calling mechanism cannot handle call/bind properly in some cases
// especially through xray wrappers. This is a temoorary work around for
// this problem for mozMatchesSelector. See: bug 763897.
desc->obj = wrapper;
desc->attrs = JSPROP_ENUMERATE;
JSFunction *fun = JS_NewFunction(cx, mozMatchesSelectorStub,
1, 0, JS_GetPrototype(wrapper),
"mozMatchesSelector");
NS_ENSURE_TRUE(fun, false);
desc->value = OBJECT_TO_JSVAL(JS_GetFunctionObject(fun));
desc->getter = NULL;
desc->setter = NULL;
desc->shortid = 0;
return true;
}
desc->obj = NULL;
MOZ_ASSERT(js::GetObjectJSClass(holder) == &HolderClass);
JSObject *wnObject = GetWrappedNativeObjectFromHolder(holder);
XPCWrappedNative *wn = GetWrappedNative(wnObject);
// This will do verification and the method lookup for us.
XPCCallContext ccx(JS_CALLER, cx, wnObject, nullptr, id);
// There are no native numeric properties, so we can shortcut here. We will not
// find the property.
// There are no native numeric properties, so we can shortcut here. We will
// not find the property. However we want to support non shadowing dom
// specific collection properties like window.frames, so we still have to
// check for those.
if (!JSID_IS_STRING(id)) {
/* Not found */
return true;
return resolveDOMCollectionProperty(cx, wrapper, holder, id, set, desc);
}
XPCNativeInterface *iface;
@ -576,7 +747,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapp
!(iface = ccx.GetInterface()) ||
!(member = ccx.GetMember())) {
/* Not found */
return true;
return resolveDOMCollectionProperty(cx, wrapper, holder, id, set, desc);
}
desc->obj = holder;
@ -647,16 +818,6 @@ wrappedJSObject_getter(JSContext *cx, JSHandleObject wrapper, JSHandleId id, JSM
return WrapperFactory::WaiveXrayAndWrap(cx, vp.address());
}
template <typename T>
static bool
Is(JSObject *wrapper)
{
JSObject *holder = GetHolder(wrapper);
XPCWrappedNative *wn = GetWrappedNativeFromHolder(holder);
nsCOMPtr<T> native = do_QueryWrappedNative(wn);
return !!native;
}
static JSBool
WrapURI(JSContext *cx, nsIURI *uri, jsval *vp)
{
@ -845,13 +1006,9 @@ XPCWrappedNativeXrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWra
return false;
}
if (!pobj) {
return true;
}
#ifdef DEBUG
NS_ASSERTION(JS_HasPropertyById(cx, holder, id, &hasProp) &&
hasProp, "id got defined somewhere else?");
NS_ASSERTION(!pobj || (JS_HasPropertyById(cx, holder, id, &hasProp) &&
hasProp), "id got defined somewhere else?");
#endif
}
@ -1235,7 +1392,7 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, JSObject *wrappe
if (!this->enter(cx, wrapper, id, action, &status))
return status;
typename Traits::ResolvingId resolving(wrapper, id);
typename Traits::ResolvingIdImpl resolving(wrapper, id);
// Redirect access straight to the wrapper if we should be transparent.
if (XrayUtils::IsTransparent(cx, wrapper)) {
@ -1334,7 +1491,7 @@ XrayWrapper<Base, Traits>::getOwnPropertyDescriptor(JSContext *cx, JSObject *wra
if (!this->enter(cx, wrapper, id, action, &status))
return status;
typename Traits::ResolvingId resolving(wrapper, id);
typename Traits::ResolvingIdImpl resolving(wrapper, id);
// NB: Nothing we do here acts on the wrapped native itself, so we don't
// enter our policy.

View File

@ -7,6 +7,7 @@
#include "jsapi.h"
#include "jswrapper.h"
#include "mozilla/GuardObjects.h"
// Xray wrappers re-resolve the original native properties on the native
// object and always directly access to those properties.
@ -100,4 +101,30 @@ public:
};
extern SandboxProxyHandler sandboxProxyHandler;
class AutoSetWrapperNotShadowing;
class XPCWrappedNativeXrayTraits;
class ResolvingId {
public:
ResolvingId(JSObject *wrapper, jsid id);
~ResolvingId();
bool isXrayShadowing(jsid id);
bool isResolving(jsid id);
static ResolvingId* getResolvingId(JSObject *holder);
static JSObject* getHolderObject(JSObject *wrapper);
static ResolvingId *getResolvingIdFromWrapper(JSObject *wrapper);
private:
friend class AutoSetWrapperNotShadowing;
friend class XPCWrappedNativeXrayTraits;
jsid mId;
JSObject *mHolder;
ResolvingId *mPrev;
bool mXrayShadowing;
};
}

View File

@ -58,7 +58,7 @@
#include "nsTransitionManager.h"
#include "nsAnimationManager.h"
#include "mozilla/dom/Element.h"
#include "nsIFrameMessageManager.h"
#include "nsIMessageManager.h"
#include "FrameLayerBuilder.h"
#include "nsDOMMediaQueryList.h"
#include "nsSMILAnimationController.h"

View File

@ -54,7 +54,7 @@
#include "mozilla/Attributes.h"
#include "nsIEventListenerService.h"
#include "nsIFrameMessageManager.h"
#include "nsIMessageManager.h"
// Transformiix stuff
#include "nsXPathEvaluator.h"
@ -422,8 +422,8 @@ nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult);
nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
nsresult NS_NewEventListenerService(nsIEventListenerService** aResult);
nsresult NS_NewGlobalMessageManager(nsIChromeFrameMessageManager** aResult);
nsresult NS_NewParentProcessMessageManager(nsIFrameMessageManager** aResult);
nsresult NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult);
nsresult NS_NewParentProcessMessageManager(nsIMessageBroadcaster** aResult);
nsresult NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult);
nsresult NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult);
@ -519,9 +519,9 @@ MAKE_CTOR(CreateXMLContentBuilder, nsIXMLContentBuilder, NS_NewXML
#endif
MAKE_CTOR(CreateContentDLF, nsIDocumentLoaderFactory, NS_NewContentDocumentLoaderFactory)
MAKE_CTOR(CreateEventListenerService, nsIEventListenerService, NS_NewEventListenerService)
MAKE_CTOR(CreateGlobalMessageManager, nsIChromeFrameMessageManager,NS_NewGlobalMessageManager)
MAKE_CTOR(CreateParentMessageManager, nsIFrameMessageManager,NS_NewParentProcessMessageManager)
MAKE_CTOR(CreateChildMessageManager, nsISyncMessageSender,NS_NewChildProcessMessageManager)
MAKE_CTOR(CreateGlobalMessageManager, nsIMessageBroadcaster, NS_NewGlobalMessageManager)
MAKE_CTOR(CreateParentMessageManager, nsIMessageBroadcaster, NS_NewParentProcessMessageManager)
MAKE_CTOR(CreateChildMessageManager, nsISyncMessageSender, NS_NewChildProcessMessageManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDocumentContentPolicy)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoDataProtocolContentPolicy)
MAKE_CTOR(CreatePluginDocument, nsIDocument, NS_NewPluginDocument)

View File

@ -36,29 +36,29 @@ function loadURL(url) {
}
function scrollContentBy(dx, dy) {
messageManager.sendAsyncMessage("scrollBy",
{ dx: dx, dy: dy });
messageManager.broadcastAsyncMessage("scrollBy",
{ dx: dx, dy: dy });
}
function scrollContentTo(x, y) {
messageManager.sendAsyncMessage("scrollTo",
{ x: x, y: y });
messageManager.broadcastAsyncMessage("scrollTo",
{ x: x, y: y });
}
function setContentViewport(w, h) {
messageManager.sendAsyncMessage("setViewport",
{ w: w, h: h });
messageManager.broadcastAsyncMessage("setViewport",
{ w: w, h: h });
}
function setContentDisplayPort(x, y, w, h) {
messageManager.sendAsyncMessage("setDisplayPort",
{ x: x, y: y, w: w, h: h });
messageManager.broadcastAsyncMessage("setDisplayPort",
{ x: x, y: y, w: w, h: h });
}
function setContentResolution(xres, yres) {
messageManager.sendAsyncMessage("setResolution",
{ xres: xres, yres: yres });
messageManager.broadcastAsyncMessage("setResolution",
{ xres: xres, yres: yres });
}
// Functions affecting <browser>.
@ -107,8 +107,8 @@ function startAnimatedScrollBy(dx, dy) {
rootView().scrollBy(ddx, ddy);
if (!sentScrollBy && 100 <= (now - start)) {
messageManager.sendAsyncMessage("scrollBy",
{ dx: dx, dy: dy });
messageManager.broadcastAsyncMessage("scrollBy",
{ dx: dx, dy: dy });
sentScrollBy = true;
}

View File

@ -733,7 +733,7 @@ nsSVGUtils::ScheduleReflowSVG(nsIFrame *aFrame)
"Do not call under nsISVGChildFrame::ReflowSVG!");
// We don't call nsSVGEffects::InvalidateRenderingObservers here because
// we should only be called under InvalidateAndScheduleBoundsUpdate (which
// we should only be called under InvalidateAndScheduleReflowSVG (which
// calls InvalidateBounds) or nsSVGDisplayContainerFrame::InsertFrames
// (at which point the frame has no observers).

View File

@ -262,7 +262,7 @@ function OnRefTestLoad(win)
#endif
gBrowserMessageManager = gBrowser.QueryInterface(CI.nsIFrameLoaderOwner)
.frameLoader.messageManager;
.frameLoader.messageManager;
// The content script waits for the initial onload, then notifies
// us.
RegisterMessageListenersAndLoadContentScript();

View File

@ -4,7 +4,8 @@
var CapturePickerUI = {
init: function() {
this.messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager);
this.messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Ci.nsIMessageListenerManager);
this.messageManager.addMessageListener("CapturePicker:Show", this);
},

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