зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to autoland
This commit is contained in:
Коммит
11989aa12a
|
@ -168,8 +168,7 @@ function waitForSuggestions(cb) {
|
|||
}
|
||||
|
||||
function waitForContentSearchEvent(messageType, cb) {
|
||||
let mm = content.SpecialPowers.Cc["@mozilla.org/globalmessagemanager;1"].
|
||||
getService(content.SpecialPowers.Ci.nsIMessageListenerManager);
|
||||
let mm = content.SpecialPowers.Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
mm.addMessageListener("ContentSearch", function listener(aMsg) {
|
||||
if (aMsg.data.type != messageType) {
|
||||
return;
|
||||
|
|
|
@ -24,6 +24,8 @@ const EXPECTED_APPMENU_OPEN_REFLOWS = [
|
|||
"adjustArrowPosition@chrome://global/content/bindings/popup.xml",
|
||||
"onxblpopuppositioned@chrome://global/content/bindings/popup.xml",
|
||||
],
|
||||
|
||||
maxCount: 3, // This number should only ever go down - never up.
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -42,10 +42,7 @@ var gTests = [
|
|||
|
||||
// If we have reached the max process count already, increase it to ensure
|
||||
// our new tab can have its own content process.
|
||||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
let childCount = ppmm.childCount;
|
||||
let childCount = Services.ppmm.childCount;
|
||||
let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
|
||||
// The first check is because if we are on a branch where e10s-multi is
|
||||
// disabled, we want to keep testing e10s with a single content process.
|
||||
|
@ -149,10 +146,7 @@ var gTests = [
|
|||
|
||||
// If we have reached the max process count already, increase it to ensure
|
||||
// our new tab can have its own content process.
|
||||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
let childCount = ppmm.childCount;
|
||||
let childCount = Services.ppmm.childCount;
|
||||
let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
|
||||
// The first check is because if we are on a branch where e10s-multi is
|
||||
// disabled, we want to keep testing e10s with a single content process.
|
||||
|
@ -261,10 +255,7 @@ var gTests = [
|
|||
|
||||
// If we have reached the max process count already, increase it to ensure
|
||||
// our new tab can have its own content process.
|
||||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
let childCount = ppmm.childCount;
|
||||
let childCount = Services.ppmm.childCount;
|
||||
let maxContentProcess = Services.prefs.getIntPref("dom.ipc.processCount");
|
||||
// The first check is because if we are on a branch where e10s-multi is
|
||||
// disabled, we want to keep testing e10s with a single content process.
|
||||
|
|
|
@ -4,14 +4,16 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Preferences.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/osfile.jsm");
|
||||
ChromeUtils.import("resource://testing-common/Assert.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "FileTestUtils",
|
||||
"resource://testing-common/FileTestUtils.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["EnterprisePolicyTesting"];
|
||||
var EXPORTED_SYMBOLS = ["EnterprisePolicyTesting", "PoliciesPrefTracker"];
|
||||
|
||||
this.EnterprisePolicyTesting = {
|
||||
var EnterprisePolicyTesting = {
|
||||
// |json| must be an object representing the desired policy configuration, OR a
|
||||
// path to the JSON file containing the policy configuration.
|
||||
setupPolicyEngineWithJson: async function setupPolicyEngineWithJson(json, customSchema) {
|
||||
|
@ -49,6 +51,14 @@ this.EnterprisePolicyTesting = {
|
|||
return promise;
|
||||
},
|
||||
|
||||
checkPolicyPref(prefName, expectedValue, expectedLockedness) {
|
||||
if (expectedLockedness !== undefined) {
|
||||
Assert.equal(Preferences.locked(prefName), expectedLockedness, `Pref ${prefName} is correctly locked/unlocked`);
|
||||
}
|
||||
|
||||
Assert.equal(Preferences.get(prefName), expectedValue, `Pref ${prefName} has the correct value`);
|
||||
},
|
||||
|
||||
resetRunOnceState: function resetRunOnceState() {
|
||||
const runOnceBaseKeys = [
|
||||
"browser.policies.runonce.",
|
||||
|
@ -62,3 +72,78 @@ this.EnterprisePolicyTesting = {
|
|||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* This helper will track prefs that have been changed
|
||||
* by the policy engine through the setAndLockPref and
|
||||
* setDefaultPref APIs (from Policies.jsm) and make sure
|
||||
* that they are restored to their original values when
|
||||
* the test ends or another test case restarts the engine.
|
||||
*/
|
||||
var PoliciesPrefTracker = {
|
||||
_originalFunc: null,
|
||||
_originalValues: new Map(),
|
||||
|
||||
start() {
|
||||
let PoliciesBackstage = ChromeUtils.import("resource:///modules/policies/Policies.jsm", {});
|
||||
this._originalFunc = PoliciesBackstage.setDefaultPref;
|
||||
PoliciesBackstage.setDefaultPref = this.hoistedSetDefaultPref.bind(this);
|
||||
},
|
||||
|
||||
stop() {
|
||||
this.restoreDefaultValues();
|
||||
|
||||
let PoliciesBackstage = ChromeUtils.import("resource:///modules/policies/Policies.jsm", {});
|
||||
PoliciesBackstage.setDefaultPref = this._originalFunc;
|
||||
this._originalFunc = null;
|
||||
},
|
||||
|
||||
hoistedSetDefaultPref(prefName, prefValue) {
|
||||
// If this pref is seen multiple times, the very first
|
||||
// value seen is the one that is actually the default.
|
||||
if (!this._originalValues.has(prefName)) {
|
||||
let defaults = new Preferences({defaultBranch: true});
|
||||
let stored = {};
|
||||
|
||||
if (defaults.has(prefName)) {
|
||||
stored.originalDefaultValue = defaults.get(prefName);
|
||||
}
|
||||
|
||||
if (Preferences.isSet(prefName) &&
|
||||
Preferences.get(prefName) == prefValue) {
|
||||
// If a user value exists, and we're changing the default
|
||||
// value to be th same as the user value, that will cause
|
||||
// the user value to be dropped. In that case, let's also
|
||||
// store it to ensure that we restore everything correctly.
|
||||
stored.originalUserValue = Preferences.get(prefName);
|
||||
}
|
||||
|
||||
this._originalValues.set(prefName, stored);
|
||||
}
|
||||
|
||||
// Now that we've stored the original values, call the
|
||||
// original setDefaultPref function.
|
||||
this._originalFunc(prefName, prefValue);
|
||||
},
|
||||
|
||||
restoreDefaultValues() {
|
||||
let defaults = new Preferences({defaultBranch: true});
|
||||
|
||||
for (let [prefName, stored] of this._originalValues) {
|
||||
// If a pref was used through setDefaultPref instead
|
||||
// of setAndLockPref, it wasn't locked, but calling
|
||||
// unlockPref is harmless
|
||||
Preferences.unlock(prefName);
|
||||
|
||||
if (stored.originalDefaultValue) {
|
||||
defaults.set(prefName, stored.originalDefaultValue);
|
||||
}
|
||||
|
||||
if (stored.originalUserValue) {
|
||||
Preferences.set(prefName, stored.originalUserValue);
|
||||
}
|
||||
}
|
||||
|
||||
this._originalValues.clear();
|
||||
},
|
||||
};
|
||||
|
|
|
@ -6,13 +6,14 @@ support-files =
|
|||
config_popups_cookies_addons_flash.json
|
||||
config_broken_json.json
|
||||
|
||||
[browser_policies_basic_tests.js]
|
||||
[browser_policies_broken_json.js]
|
||||
[browser_policies_enterprise_only.js]
|
||||
[browser_policies_notice_in_aboutpreferences.js]
|
||||
[browser_policies_popups_cookies_addons_flash.js]
|
||||
[browser_policies_runOnce_helper.js]
|
||||
[browser_policies_setAndLockPref_API.js]
|
||||
[browser_policies_simple_policies.js]
|
||||
[browser_policies_simple_pref_policies.js]
|
||||
[browser_policies_sorted_alphabetically.js]
|
||||
[browser_policies_validate_and_parse_API.js]
|
||||
[browser_policy_app_update.js]
|
||||
|
@ -25,9 +26,7 @@ support-files =
|
|||
[browser_policy_clear_blocked_cookies.js]
|
||||
[browser_policy_default_browser_check.js]
|
||||
[browser_policy_disable_feedback_commands.js]
|
||||
[browser_policy_disable_formhistory.js]
|
||||
[browser_policy_disable_fxaccounts.js]
|
||||
[browser_policy_disable_fxscreenshots.js]
|
||||
[browser_policy_disable_masterpassword.js]
|
||||
[browser_policy_disable_pdfjs.js]
|
||||
[browser_policy_disable_pocket.js]
|
||||
|
@ -36,7 +35,5 @@ support-files =
|
|||
[browser_policy_disable_shield.js]
|
||||
[browser_policy_display_bookmarks.js]
|
||||
[browser_policy_display_menu.js]
|
||||
[browser_policy_enable_tracking_protection.js]
|
||||
[browser_policy_proxy.js]
|
||||
[browser_policy_remember_passwords.js]
|
||||
[browser_policy_set_homepage.js]
|
||||
|
|
|
@ -16,7 +16,4 @@ add_task(async function test_runonce_helper() {
|
|||
|
||||
runOnce("test_action", callback);
|
||||
is(runCount, 1, "Callback didn't run again.");
|
||||
|
||||
// clean-up
|
||||
Services.prefs.clearUserPref("browser.policies.runonce.test_action");
|
||||
});
|
||||
|
|
|
@ -3,57 +3,38 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
let { Policies, setAndLockPref } = ChromeUtils.import("resource:///modules/policies/Policies.jsm", {});
|
||||
|
||||
function checkPref(prefName, expectedValue) {
|
||||
let prefType, prefValue;
|
||||
switch (typeof(expectedValue)) {
|
||||
case "boolean":
|
||||
prefType = Services.prefs.PREF_BOOL;
|
||||
prefValue = Services.prefs.getBoolPref(prefName);
|
||||
break;
|
||||
|
||||
case "number":
|
||||
prefType = Services.prefs.PREF_INT;
|
||||
prefValue = Services.prefs.getIntPref(prefName);
|
||||
break;
|
||||
|
||||
case "string":
|
||||
prefType = Services.prefs.PREF_STRING;
|
||||
prefValue = Services.prefs.getStringPref(prefName);
|
||||
break;
|
||||
}
|
||||
|
||||
ok(Services.prefs.prefIsLocked(prefName), `Pref ${prefName} is correctly locked`);
|
||||
is(Services.prefs.getPrefType(prefName), prefType, `Pref ${prefName} has the correct type`);
|
||||
is(prefValue, expectedValue, `Pref ${prefName} has the correct value`);
|
||||
}
|
||||
let {
|
||||
Policies,
|
||||
setAndLockPref,
|
||||
setDefaultPref,
|
||||
} = ChromeUtils.import("resource:///modules/policies/Policies.jsm", {});
|
||||
|
||||
add_task(async function test_API_directly() {
|
||||
await setupPolicyEngineWithJson("");
|
||||
setAndLockPref("policies.test.boolPref", true);
|
||||
checkPref("policies.test.boolPref", true);
|
||||
checkLockedPref("policies.test.boolPref", true);
|
||||
|
||||
// Check that a previously-locked pref can be changed
|
||||
// (it will be unlocked first).
|
||||
setAndLockPref("policies.test.boolPref", false);
|
||||
checkPref("policies.test.boolPref", false);
|
||||
checkLockedPref("policies.test.boolPref", false);
|
||||
|
||||
setAndLockPref("policies.test.intPref", 0);
|
||||
checkPref("policies.test.intPref", 0);
|
||||
checkLockedPref("policies.test.intPref", 0);
|
||||
|
||||
setAndLockPref("policies.test.stringPref", "policies test");
|
||||
checkPref("policies.test.stringPref", "policies test");
|
||||
checkLockedPref("policies.test.stringPref", "policies test");
|
||||
|
||||
// Test that user values do not override the prefs, and the get*Pref call
|
||||
// still return the value set through setAndLockPref
|
||||
Services.prefs.setBoolPref("policies.test.boolPref", true);
|
||||
checkPref("policies.test.boolPref", false);
|
||||
checkLockedPref("policies.test.boolPref", false);
|
||||
|
||||
Services.prefs.setIntPref("policies.test.intPref", 10);
|
||||
checkPref("policies.test.intPref", 0);
|
||||
checkLockedPref("policies.test.intPref", 0);
|
||||
|
||||
Services.prefs.setStringPref("policies.test.stringPref", "policies test");
|
||||
checkPref("policies.test.stringPref", "policies test");
|
||||
checkLockedPref("policies.test.stringPref", "policies test");
|
||||
|
||||
try {
|
||||
// Test that a non-integer value is correctly rejected, even though
|
||||
|
@ -120,11 +101,43 @@ add_task(async function test_API_through_policies() {
|
|||
is(Services.policies.status, Ci.nsIEnterprisePolicies.ACTIVE, "Engine is active");
|
||||
|
||||
// The expected values come from config_setAndLockPref.json
|
||||
checkPref("policies.test2.boolPref", true);
|
||||
checkPref("policies.test2.intPref", 42);
|
||||
checkPref("policies.test2.stringPref", "policies test 2");
|
||||
checkLockedPref("policies.test2.boolPref", true);
|
||||
checkLockedPref("policies.test2.intPref", 42);
|
||||
checkLockedPref("policies.test2.stringPref", "policies test 2");
|
||||
|
||||
delete Policies.bool_policy;
|
||||
delete Policies.int_policy;
|
||||
delete Policies.string_policy;
|
||||
});
|
||||
|
||||
add_task(async function test_pref_tracker() {
|
||||
// Tests the test harness functionality that tracks usage of
|
||||
// the setAndLockPref and setDefualtPref APIs.
|
||||
|
||||
let defaults = Services.prefs.getDefaultBranch("");
|
||||
|
||||
// Test prefs that had a default value and got changed to another
|
||||
defaults.setIntPref("test1.pref1", 10);
|
||||
defaults.setStringPref("test1.pref2", "test");
|
||||
|
||||
setAndLockPref("test1.pref1", 20);
|
||||
setDefaultPref("test1.pref2", "NEW VALUE");
|
||||
|
||||
PoliciesPrefTracker.restoreDefaultValues();
|
||||
|
||||
is(Services.prefs.getIntPref("test1.pref1"), 10, "Expected value for test1.pref1");
|
||||
is(Services.prefs.getStringPref("test1.pref2"), "test", "Expected value for test1.pref2");
|
||||
is(Services.prefs.prefIsLocked("test1.pref1"), false, "test1.pref1 got unlocked");
|
||||
|
||||
// Test a pref that had a default value and a user value
|
||||
defaults.setIntPref("test2.pref1", 10);
|
||||
Services.prefs.setIntPref("test2.pref1", 20);
|
||||
|
||||
setAndLockPref("test2.pref1", 20);
|
||||
|
||||
PoliciesPrefTracker.restoreDefaultValues();
|
||||
|
||||
is(Services.prefs.getIntPref("test2.pref1"), 20, "Correct user value");
|
||||
is(defaults.getIntPref("test2.pref1"), 10, "Correct default value");
|
||||
is(Services.prefs.prefIsLocked("test2.pref1"), false, "felipe pref is not locked");
|
||||
});
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* Use this file to add tests to policies that are
|
||||
* simple pref flips.
|
||||
*
|
||||
* It's best to make a test to actually test the feature
|
||||
* instead of the pref flip, but if that feature is well
|
||||
* covered by tests, including that its pref actually works,
|
||||
* it's OK to have the policy test here just to ensure
|
||||
* that the right pref values are set.
|
||||
*/
|
||||
|
||||
const POLICIES_TESTS = [
|
||||
/*
|
||||
* Example:
|
||||
* {
|
||||
* // Policies to be set at once through the engine
|
||||
* policies: { "DisableFoo": true, "ConfigureBar": 42 },
|
||||
*
|
||||
* // Locked prefs to check
|
||||
* lockedPrefs: { "feature.foo": false },
|
||||
*
|
||||
* // Unlocked prefs to check
|
||||
* unlockedPrefs: { "bar.baz": 42 }
|
||||
* },
|
||||
*/
|
||||
|
||||
// POLICY: RememberPasswords
|
||||
{
|
||||
policies: { "RememberPasswords": false },
|
||||
lockedPrefs: { "signon.rememberSignons": false },
|
||||
},
|
||||
{
|
||||
policies: { "RememberPasswords": true },
|
||||
lockedPrefs: { "signon.rememberSignons": true },
|
||||
},
|
||||
|
||||
// POLICY: DisableFormHistory
|
||||
{
|
||||
policies: { "DisableFormHistory": true },
|
||||
lockedPrefs: { "browser.formfill.enable": false },
|
||||
},
|
||||
|
||||
// POLICY: EnableTrackingProtection
|
||||
{
|
||||
policies: {
|
||||
"EnableTrackingProtection": {
|
||||
"Value": true
|
||||
}
|
||||
},
|
||||
unlockedPrefs: {
|
||||
"privacy.trackingprotection.enabled": true,
|
||||
"privacy.trackingprotection.pbmode.enabled": true,
|
||||
}
|
||||
},
|
||||
{
|
||||
policies: {
|
||||
"EnableTrackingProtection": {
|
||||
"Value": false,
|
||||
"Locked": true
|
||||
}
|
||||
},
|
||||
lockedPrefs: {
|
||||
"privacy.trackingprotection.enabled": false,
|
||||
"privacy.trackingprotection.pbmode.enabled": false,
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
add_task(async function test_policy_remember_passwords() {
|
||||
for (let test of POLICIES_TESTS) {
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": test.policies
|
||||
});
|
||||
|
||||
info("Checking policy: " + Object.keys(test.policies)[0]);
|
||||
|
||||
for (let [prefName, prefValue] of Object.entries(test.lockedPrefs || {})) {
|
||||
checkLockedPref(prefName, prefValue);
|
||||
}
|
||||
|
||||
for (let [prefName, prefValue] of Object.entries(test.unlockedPrefs || {})) {
|
||||
checkUnlockedPref(prefName, prefValue);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -3,7 +3,6 @@
|
|||
"use strict";
|
||||
|
||||
add_task(async function setup() {
|
||||
EnterprisePolicyTesting.resetRunOnceState();
|
||||
const expiry = Date.now() + 24 * 60 * 60;
|
||||
Services.cookies.add("example.com", "/", "secure", "true", true, false, false, expiry, {});
|
||||
Services.cookies.add("example.com", "/", "insecure", "true", false, false, false, expiry, {});
|
||||
|
@ -59,5 +58,4 @@ add_task(function teardown() {
|
|||
for (let host of ["example.com", "example.org", "example.net"]) {
|
||||
Services.cookies.removeCookiesWithOriginAttributes("{}", host);
|
||||
}
|
||||
EnterprisePolicyTesting.resetRunOnceState();
|
||||
});
|
||||
|
|
|
@ -24,8 +24,4 @@ add_task(async function test_default_browser_check() {
|
|||
ShellService.shouldCheckDefaultBrowser = true;
|
||||
|
||||
is(ShellService.shouldCheckDefaultBrowser, false, "Policy is enforced");
|
||||
|
||||
// Unlock the pref because if it stays locked, and this test runs twice in a row,
|
||||
// the first sanity check will fail.
|
||||
Services.prefs.unlockPref("browser.shell.checkDefaultBrowser");
|
||||
});
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_policy_disable_formhistory() {
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"DisableFormHistory": true
|
||||
}
|
||||
});
|
||||
|
||||
is(Services.prefs.getBoolPref("browser.formfill.enable"), false, "FormHistory has been disabled");
|
||||
is(Services.prefs.prefIsLocked("browser.formfill.enable"), true, "FormHistory pref has been locked");
|
||||
});
|
|
@ -13,11 +13,4 @@ add_task(async function test_policy_disable_fxaccounts() {
|
|||
});
|
||||
|
||||
is(gSync.SYNC_ENABLED, false, "Sync is disabled after setting the policy.");
|
||||
|
||||
// Manually clean-up the change made by the policy engine.
|
||||
// This is needed in case this test runs twice in a row
|
||||
// (such as in test-verify), in order for the first check
|
||||
// to pass again.
|
||||
Services.prefs.unlockPref("identity.fxaccounts.enabled");
|
||||
Services.prefs.getDefaultBranch("").setBoolPref("identity.fxaccounts.enabled", true);
|
||||
});
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const PREF_DISABLE_FX_SCREENSHOTS = "extensions.screenshots.disabled";
|
||||
|
||||
async function checkScreenshots(shouldBeEnabled) {
|
||||
return BrowserTestUtils.waitForCondition(() => {
|
||||
return !!PageActions.actionForID("screenshots") == shouldBeEnabled;
|
||||
}, "Expecting screenshots to be " + shouldBeEnabled);
|
||||
}
|
||||
|
||||
add_task(async function test_disable_firefox_screenshots() {
|
||||
await BrowserTestUtils.withNewTab("data:text/html,Test", async function() {
|
||||
// Firefox Screenshots are disabled in tests, so make sure we enable
|
||||
// it first to ensure that the test is valid.
|
||||
Services.prefs.setBoolPref(PREF_DISABLE_FX_SCREENSHOTS, false);
|
||||
await checkScreenshots(true);
|
||||
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"DisableFirefoxScreenshots": true
|
||||
}
|
||||
});
|
||||
|
||||
is(Services.policies.status, Services.policies.ACTIVE, "Policy engine is active");
|
||||
await checkScreenshots(false);
|
||||
|
||||
// Clear the change we made and make sure it remains disabled.
|
||||
await setupPolicyEngineWithJson("");
|
||||
|
||||
Services.prefs.unlockPref(PREF_DISABLE_FX_SCREENSHOTS);
|
||||
Services.prefs.clearUserPref(PREF_DISABLE_FX_SCREENSHOTS);
|
||||
|
||||
await checkScreenshots(false);
|
||||
});
|
||||
});
|
|
@ -24,13 +24,5 @@ add_task(async function test_disable_firefox_screenshots() {
|
|||
});
|
||||
|
||||
await checkPocket(false);
|
||||
|
||||
// Clear the change made by the engine to restore Pocket.
|
||||
// This is needed in case this test runs twice in a row
|
||||
// (such as in test-verify), in order for the first sanity check
|
||||
// to pass again.
|
||||
await setupPolicyEngineWithJson("");
|
||||
Services.prefs.unlockPref(PREF_POCKET);
|
||||
Services.prefs.getDefaultBranch("").setBoolPref(PREF_POCKET, true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_policy_enable_tracking_protection1() {
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"EnableTrackingProtection": {
|
||||
"Value": true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
is(Services.prefs.getBoolPref("privacy.trackingprotection.enabled"), true, "Tracking protection has been enabled by default.");
|
||||
is(Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled"), true, "Tracking protection has been enabled by default in private browsing mode.");
|
||||
is(Services.prefs.prefIsLocked("privacy.trackingprotection.enabled"), false, "Tracking protection pref is not locked.");
|
||||
});
|
||||
|
||||
add_task(async function test_policy_enable_tracking_protection_locked() {
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"EnableTrackingProtection": {
|
||||
"Value": false,
|
||||
"Locked": true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
is(Services.prefs.getBoolPref("privacy.trackingprotection.enabled"), false, "Tracking protection has been disabled by default.");
|
||||
is(Services.prefs.getBoolPref("privacy.trackingprotection.pbmode.enabled"), false, "Tracking protection has been disabled by default in private browsing mode.");
|
||||
is(Services.prefs.prefIsLocked("privacy.trackingprotection.enabled"), true, "Tracking protection pref is locked.");
|
||||
|
||||
Services.prefs.unlockPref("privacy.trackingprotection.enabled");
|
||||
Services.prefs.unlockPref("privacy.trackingprotection.pbmode.enabled");
|
||||
});
|
|
@ -2,32 +2,6 @@
|
|||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
function checkPref(prefName, expectedValue, expectedLockedness) {
|
||||
let prefType, prefValue;
|
||||
switch (typeof(expectedValue)) {
|
||||
case "boolean":
|
||||
prefType = Services.prefs.PREF_BOOL;
|
||||
prefValue = Services.prefs.getBoolPref(prefName);
|
||||
break;
|
||||
|
||||
case "number":
|
||||
prefType = Services.prefs.PREF_INT;
|
||||
prefValue = Services.prefs.getIntPref(prefName);
|
||||
break;
|
||||
|
||||
case "string":
|
||||
prefType = Services.prefs.PREF_STRING;
|
||||
prefValue = Services.prefs.getStringPref(prefName);
|
||||
break;
|
||||
}
|
||||
|
||||
if (expectedLockedness !== undefined) {
|
||||
is(Services.prefs.prefIsLocked(prefName), expectedLockedness, `Pref ${prefName} is correctly locked`);
|
||||
}
|
||||
is(Services.prefs.getPrefType(prefName), prefType, `Pref ${prefName} has the correct type`);
|
||||
is(prefValue, expectedValue, `Pref ${prefName} has the correct value`);
|
||||
}
|
||||
|
||||
add_task(async function test_proxy_modes_and_autoconfig() {
|
||||
// Directly test the proxy Mode and AutoconfigURL parameters through
|
||||
// the API instead of the policy engine, because the test harness
|
||||
|
@ -59,8 +33,8 @@ add_task(async function test_proxy_boolean_settings() {
|
|||
}
|
||||
});
|
||||
|
||||
checkPref("network.proxy.socks_remote_dns", false);
|
||||
checkPref("signon.autologin.proxy", false);
|
||||
checkUnlockedPref("network.proxy.socks_remote_dns", false);
|
||||
checkUnlockedPref("signon.autologin.proxy", false);
|
||||
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
|
@ -71,8 +45,8 @@ add_task(async function test_proxy_boolean_settings() {
|
|||
}
|
||||
});
|
||||
|
||||
checkPref("network.proxy.socks_remote_dns", true);
|
||||
checkPref("signon.autologin.proxy", true);
|
||||
checkUnlockedPref("network.proxy.socks_remote_dns", true);
|
||||
checkUnlockedPref("signon.autologin.proxy", true);
|
||||
});
|
||||
|
||||
add_task(async function test_proxy_socks_and_passthrough() {
|
||||
|
@ -85,14 +59,14 @@ add_task(async function test_proxy_socks_and_passthrough() {
|
|||
}
|
||||
});
|
||||
|
||||
checkPref("network.proxy.socks_version", 4);
|
||||
checkPref("network.proxy.no_proxies_on", "a, b, c");
|
||||
checkUnlockedPref("network.proxy.socks_version", 4);
|
||||
checkUnlockedPref("network.proxy.no_proxies_on", "a, b, c");
|
||||
});
|
||||
|
||||
add_task(async function test_proxy_addresses() {
|
||||
function checkProxyPref(proxytype, address, port) {
|
||||
checkPref(`network.proxy.${proxytype}`, address);
|
||||
checkPref(`network.proxy.${proxytype}_port`, port);
|
||||
checkUnlockedPref(`network.proxy.${proxytype}`, address);
|
||||
checkUnlockedPref(`network.proxy.${proxytype}_port`, port);
|
||||
}
|
||||
|
||||
await setupPolicyEngineWithJson({
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_policy_remember_passwords() {
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"RememberPasswords": false
|
||||
}
|
||||
});
|
||||
|
||||
is(Services.prefs.getBoolPref("signon.rememberSignons"), false, "Logins & Passwords have been disabled");
|
||||
is(Services.prefs.prefIsLocked("signon.rememberSignons"), true, "Logins & Passwords pref has been locked");
|
||||
|
||||
|
||||
await setupPolicyEngineWithJson({
|
||||
"policies": {
|
||||
"RememberPasswords": true
|
||||
}
|
||||
});
|
||||
|
||||
is(Services.prefs.getBoolPref("signon.rememberSignons"), true, "Logins & Passwords have been enabled");
|
||||
is(Services.prefs.prefIsLocked("signon.rememberSignons"), true, "Logins & Passwords pref has been locked");
|
||||
});
|
|
@ -2,36 +2,12 @@
|
|||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
// Prefs that will be touched by the test and need to be reset when the test
|
||||
// cleans up.
|
||||
const TOUCHED_PREFS = {
|
||||
"browser.startup.homepage": "String",
|
||||
"browser.startup.page": "Int",
|
||||
"pref.browser.homepage.disable_button.current_page": "Bool",
|
||||
"pref.browser.homepage.disable_button.bookmark_page": "Bool",
|
||||
"pref.browser.homepage.disable_button.restore_default": "Bool",
|
||||
"browser.policies.runOncePerModification.setHomepage": "String",
|
||||
};
|
||||
let ORIGINAL_PREF_VALUE = {};
|
||||
|
||||
add_task(function read_original_pref_values() {
|
||||
for (let pref in TOUCHED_PREFS) {
|
||||
let prefType = TOUCHED_PREFS[pref];
|
||||
ORIGINAL_PREF_VALUE[pref] =
|
||||
Services.prefs[`get${prefType}Pref`](pref, undefined);
|
||||
}
|
||||
});
|
||||
registerCleanupFunction(function restore_pref_values() {
|
||||
let defaults = Services.prefs.getDefaultBranch("");
|
||||
for (let pref in TOUCHED_PREFS) {
|
||||
Services.prefs.unlockPref(pref);
|
||||
Services.prefs.clearUserPref(pref);
|
||||
let originalValue = ORIGINAL_PREF_VALUE[pref];
|
||||
let prefType = TOUCHED_PREFS[pref];
|
||||
if (originalValue !== undefined) {
|
||||
defaults[`set${prefType}Pref`](pref, originalValue);
|
||||
}
|
||||
}
|
||||
// These two prefs are set as user prefs in case the "Locked"
|
||||
// option from this policy was not used. In this case, it won't
|
||||
// be tracked nor restored by the PoliciesPrefTracker.
|
||||
Services.prefs.clearUserPref("browser.startup.homepage");
|
||||
Services.prefs.clearUserPref("browser.startup.page");
|
||||
});
|
||||
|
||||
add_task(async function homepage_test_simple() {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
[DEFAULT]
|
||||
prefs =
|
||||
browser.policies.enabled=true
|
||||
browser.policies.alternatePath='<test-root>/browser/components/enterprisepolicies/tests/browser/disable_fxscreenshots/config_disable_fxscreenshots.json'
|
||||
extensions.screenshots.disabled=false
|
||||
support-files =
|
||||
config_disable_fxscreenshots.json
|
||||
|
||||
[browser_policy_disable_fxscreenshots.js]
|
|
@ -0,0 +1,29 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const PREF_DISABLE_FX_SCREENSHOTS = "extensions.screenshots.disabled";
|
||||
|
||||
async function checkScreenshots(shouldBeEnabled) {
|
||||
return BrowserTestUtils.waitForCondition(() => {
|
||||
return !!PageActions.actionForID("screenshots") == shouldBeEnabled;
|
||||
}, "Expecting screenshots to be " + shouldBeEnabled);
|
||||
}
|
||||
|
||||
add_task(async function test_disable_firefox_screenshots() {
|
||||
// Dynamically toggling the PREF_DISABLE_FX_SCREENSHOTS is very finicky, because
|
||||
// that pref is being watched, and it makes the Firefox Screenshots system add-on
|
||||
// to start or stop, causing intermittency.
|
||||
//
|
||||
// Firefox Screenshots is disabled by default on tests (in prefs_general.js).
|
||||
// What we do here to test this policy is to enable it on this specific
|
||||
// test folder (through browser.ini) and then we let the policy engine
|
||||
// be responsible for disabling Firefox Screenshots in this case.
|
||||
|
||||
is(Services.prefs.getBoolPref(PREF_DISABLE_FX_SCREENSHOTS), true, "Screenshots pref is disabled");
|
||||
|
||||
await BrowserTestUtils.withNewTab("data:text/html,Test", async function() {
|
||||
await checkScreenshots(false);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"policies": {
|
||||
"DisableFirefoxScreenshots": true
|
||||
}
|
||||
}
|
|
@ -4,9 +4,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {EnterprisePolicyTesting} = ChromeUtils.import("resource://testing-common/EnterprisePolicyTesting.jsm", {});
|
||||
const {
|
||||
EnterprisePolicyTesting,
|
||||
PoliciesPrefTracker,
|
||||
} = ChromeUtils.import("resource://testing-common/EnterprisePolicyTesting.jsm", {});
|
||||
|
||||
PoliciesPrefTracker.start();
|
||||
|
||||
async function setupPolicyEngineWithJson(json, customSchema) {
|
||||
PoliciesPrefTracker.restoreDefaultValues();
|
||||
if (typeof(json) != "object") {
|
||||
let filePath = getTestFilePath(json ? json : "non-existing-file.json");
|
||||
return EnterprisePolicyTesting.setupPolicyEngineWithJson(filePath, customSchema);
|
||||
|
@ -14,6 +20,14 @@ async function setupPolicyEngineWithJson(json, customSchema) {
|
|||
return EnterprisePolicyTesting.setupPolicyEngineWithJson(json, customSchema);
|
||||
}
|
||||
|
||||
function checkLockedPref(prefName, prefValue) {
|
||||
EnterprisePolicyTesting.checkPolicyPref(prefName, prefValue, true);
|
||||
}
|
||||
|
||||
function checkUnlockedPref(prefName, prefValue) {
|
||||
EnterprisePolicyTesting.checkPolicyPref(prefName, prefValue, false);
|
||||
}
|
||||
|
||||
add_task(async function policies_headjs_startWithCleanSlate() {
|
||||
if (Services.policies.status != Ci.nsIEnterprisePolicies.INACTIVE) {
|
||||
await setupPolicyEngineWithJson("");
|
||||
|
@ -26,4 +40,7 @@ registerCleanupFunction(async function policies_headjs_finishWithCleanSlate() {
|
|||
await setupPolicyEngineWithJson("");
|
||||
}
|
||||
is(Services.policies.status, Ci.nsIEnterprisePolicies.INACTIVE, "Engine is inactive at the end of the test");
|
||||
|
||||
EnterprisePolicyTesting.resetRunOnceState();
|
||||
PoliciesPrefTracker.stop();
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ BROWSER_CHROME_MANIFESTS += [
|
|||
'browser/disable_app_update/browser.ini',
|
||||
'browser/disable_default_bookmarks/browser.ini',
|
||||
'browser/disable_developer_tools/browser.ini',
|
||||
'browser/disable_fxscreenshots/browser.ini',
|
||||
]
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
|
|
|
@ -19,12 +19,6 @@ add_task(async function testExecuteScript() {
|
|||
Services.ppmm.getChildAt(0),
|
||||
];
|
||||
for (let mm of messageManagerMap.keys()) {
|
||||
// Sanity check: mm is a message manager.
|
||||
try {
|
||||
mm.QueryInterface(Ci.nsIMessageSender);
|
||||
} catch (e) {
|
||||
mm.QueryInterface(Ci.nsIMessageBroadcaster);
|
||||
}
|
||||
if (!globalMMs.includes(mm)) {
|
||||
++count;
|
||||
}
|
||||
|
|
|
@ -3048,14 +3048,13 @@ this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|
|||
// Listen for UITour messages.
|
||||
// Do it here instead of the UITour module itself so that the UITour module is lazy loaded
|
||||
// when the first message is received.
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
|
||||
globalMM.addMessageListener("UITour:onPageEvent", function(aMessage) {
|
||||
Services.mm.addMessageListener("UITour:onPageEvent", function(aMessage) {
|
||||
UITour.onPageEvent(aMessage, aMessage.data);
|
||||
});
|
||||
|
||||
// Listen for HybridContentTelemetry messages.
|
||||
// Do it here instead of HybridContentTelemetry.init() so that
|
||||
// the module can be lazily loaded on the first message.
|
||||
globalMM.addMessageListener("HybridContentTelemetry:onTelemetryMessage", aMessage => {
|
||||
Services.mm.addMessageListener("HybridContentTelemetry:onTelemetryMessage", aMessage => {
|
||||
HybridContentTelemetry.onTelemetryMessage(aMessage, aMessage.data);
|
||||
});
|
||||
|
|
|
@ -15,16 +15,13 @@ const FRAME_SCRIPTS = [
|
|||
ROOT + "content-forms.js"
|
||||
];
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
for (let script of FRAME_SCRIPTS) {
|
||||
globalMM.loadFrameScript(script, true);
|
||||
Services.mm.loadFrameScript(script, true);
|
||||
}
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
for (let script of FRAME_SCRIPTS) {
|
||||
globalMM.removeDelayedFrameScript(script, true);
|
||||
Services.mm.removeDelayedFrameScript(script, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -408,9 +408,7 @@ var PocketOverlay = {
|
|||
}
|
||||
},
|
||||
shutdown(reason) {
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.broadcastAsyncMessage("PocketShuttingDown");
|
||||
Services.ppmm.broadcastAsyncMessage("PocketShuttingDown");
|
||||
Services.obs.removeObserver(this, "browser-delayed-startup-finished");
|
||||
// Although the ppmm loads the scripts into the chrome process as well,
|
||||
// we need to manually unregister here anyway to ensure these aren't part
|
||||
|
|
|
@ -178,8 +178,7 @@ var AboutHome = {
|
|||
if (target && target.messageManager) {
|
||||
target.messageManager.sendAsyncMessage("AboutHome:Update", data);
|
||||
} else {
|
||||
let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
|
||||
mm.broadcastAsyncMessage("AboutHome:Update", data);
|
||||
Services.mm.broadcastAsyncMessage("AboutHome:Update", data);
|
||||
}
|
||||
}).catch(function onError(x) {
|
||||
Cu.reportError("Error in AboutHome.sendAboutHomeData: " + x);
|
||||
|
|
|
@ -24,6 +24,13 @@ const PREF_SAMPLE_RATE = "browser.chrome.errorReporter.sampleRate";
|
|||
const PREF_SUBMIT_URL = "browser.chrome.errorReporter.submitUrl";
|
||||
const SDK_NAME = "firefox-error-reporter";
|
||||
const SDK_VERSION = "1.0.0";
|
||||
const TELEMETRY_ERROR_COLLECTED = "browser.errors.collected_count";
|
||||
const TELEMETRY_ERROR_COLLECTED_FILENAME = "browser.errors.collected_count_by_filename";
|
||||
const TELEMETRY_ERROR_COLLECTED_STACK = "browser.errors.collected_with_stack_count";
|
||||
const TELEMETRY_ERROR_REPORTED = "browser.errors.reported_success_count";
|
||||
const TELEMETRY_ERROR_REPORTED_FAIL = "browser.errors.reported_failure_count";
|
||||
const TELEMETRY_ERROR_SAMPLE_RATE = "browser.errors.sample_rate";
|
||||
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIScriptError#Categories
|
||||
const REPORTED_CATEGORIES = new Set([
|
||||
|
@ -45,6 +52,13 @@ const PLATFORM_NAMES = {
|
|||
android: "Android",
|
||||
};
|
||||
|
||||
// Filename URI regexes that we are okay with reporting to Telemetry. URIs not
|
||||
// matching these patterns may contain local file paths.
|
||||
const TELEMETRY_REPORTED_PATTERNS = new Set([
|
||||
/^resource:\/\/(?:\/|gre)/,
|
||||
/^chrome:\/\/(?:global|browser|devtools)/,
|
||||
]);
|
||||
|
||||
/**
|
||||
* Collects nsIScriptError messages logged to the browser console and reports
|
||||
* them to a remotely-hosted error collection service.
|
||||
|
@ -110,6 +124,13 @@ class BrowserErrorReporter {
|
|||
false,
|
||||
this.handleEnabledPrefChanged.bind(this),
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"sampleRatePref",
|
||||
PREF_SAMPLE_RATE,
|
||||
"0.0",
|
||||
this.handleSampleRatePrefChanged.bind(this),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,6 +173,19 @@ class BrowserErrorReporter {
|
|||
}
|
||||
}
|
||||
|
||||
handleSampleRatePrefChanged(prefName, previousValue, newValue) {
|
||||
Services.telemetry.scalarSet(TELEMETRY_ERROR_SAMPLE_RATE, newValue);
|
||||
}
|
||||
|
||||
shouldReportFilename(filename) {
|
||||
for (const pattern of TELEMETRY_REPORTED_PATTERNS) {
|
||||
if (filename.match(pattern)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async observe(message) {
|
||||
try {
|
||||
message.QueryInterface(Ci.nsIScriptError);
|
||||
|
@ -165,8 +199,21 @@ class BrowserErrorReporter {
|
|||
return;
|
||||
}
|
||||
|
||||
// Record that we collected an error prior to applying the sample rate
|
||||
Services.telemetry.scalarAdd(TELEMETRY_ERROR_COLLECTED, 1);
|
||||
if (message.stack) {
|
||||
Services.telemetry.scalarAdd(TELEMETRY_ERROR_COLLECTED_STACK, 1);
|
||||
}
|
||||
if (message.sourceName) {
|
||||
let filename = "FILTERED";
|
||||
if (this.shouldReportFilename(message.sourceName)) {
|
||||
filename = message.sourceName;
|
||||
}
|
||||
Services.telemetry.keyedScalarAdd(TELEMETRY_ERROR_COLLECTED_FILENAME, filename.slice(0, 69), 1);
|
||||
}
|
||||
|
||||
// Sample the amount of errors we send out
|
||||
const sampleRate = Number.parseFloat(Services.prefs.getCharPref(PREF_SAMPLE_RATE));
|
||||
const sampleRate = Number.parseFloat(this.sampleRatePref);
|
||||
if (!Number.isFinite(sampleRate) || (Math.random() >= sampleRate)) {
|
||||
return;
|
||||
}
|
||||
|
@ -209,8 +256,10 @@ class BrowserErrorReporter {
|
|||
referrer: "https://fake.mozilla.org",
|
||||
body: JSON.stringify(requestBody)
|
||||
});
|
||||
Services.telemetry.scalarAdd(TELEMETRY_ERROR_REPORTED, 1);
|
||||
this.logger.debug("Sent error successfully.");
|
||||
} catch (error) {
|
||||
Services.telemetry.scalarAdd(TELEMETRY_ERROR_REPORTED_FAIL, 1);
|
||||
this.logger.warn(`Failed to send error: ${error}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -995,11 +995,9 @@ var PluginCrashReporter = {
|
|||
// Only the parent process gets the gmp-plugin-crash observer
|
||||
// notification, so we need to inform any content processes that
|
||||
// the GMP has crashed.
|
||||
if (Cc["@mozilla.org/parentprocessmessagemanager;1"]) {
|
||||
if (Services.ppmm) {
|
||||
let pluginName = propertyBag.getPropertyAsAString("pluginName");
|
||||
let mm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
mm.broadcastAsyncMessage("gmp-plugin-crash",
|
||||
Services.ppmm.broadcastAsyncMessage("gmp-plugin-crash",
|
||||
{ pluginName, pluginID });
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -489,9 +489,7 @@ var ContentSearch = {
|
|||
},
|
||||
|
||||
_broadcast(type, data) {
|
||||
Cc["@mozilla.org/globalmessagemanager;1"].
|
||||
getService(Ci.nsIMessageListenerManager).
|
||||
broadcastAsyncMessage(...this._msgArgs(type, data));
|
||||
Services.mm.broadcastAsyncMessage(...this._msgArgs(type, data));
|
||||
},
|
||||
|
||||
_msgArgs(type, data) {
|
||||
|
|
|
@ -66,6 +66,12 @@ function fetchPassedError(fetchSpy, message) {
|
|||
return fetchCallForMessage(fetchSpy, message) !== null;
|
||||
}
|
||||
|
||||
add_task(async function testSetup() {
|
||||
const canRecordExtended = Services.telemetry.canRecordExtended;
|
||||
Services.telemetry.canRecordExtended = true;
|
||||
registerCleanupFunction(() => Services.telemetry.canRecordExtended = canRecordExtended);
|
||||
});
|
||||
|
||||
add_task(async function testInitPrefDisabled() {
|
||||
let listening = false;
|
||||
const reporter = new BrowserErrorReporter({
|
||||
|
@ -449,3 +455,138 @@ add_task(async function testExtensionTag() {
|
|||
body = JSON.parse(call.args[1].body);
|
||||
is(body.tags.isExtensionError, undefined, "Normal errors do not have an isExtensionError tag.");
|
||||
});
|
||||
|
||||
add_task(async function testScalars() {
|
||||
const fetchStub = sinon.stub();
|
||||
const reporter = new BrowserErrorReporter({fetch: fetchStub});
|
||||
await SpecialPowers.pushPrefEnv({set: [
|
||||
[PREF_ENABLED, true],
|
||||
[PREF_SAMPLE_RATE, "1.0"],
|
||||
]});
|
||||
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
const messages = [
|
||||
createScriptError({message: "No name"}),
|
||||
createScriptError({message: "Also no name", sourceName: "resource://gre/modules/Foo.jsm"}),
|
||||
createScriptError({message: "More no name", sourceName: "resource://gre/modules/Bar.jsm"}),
|
||||
createScriptError({message: "Yeah sures", sourceName: "unsafe://gre/modules/Bar.jsm"}),
|
||||
createScriptError({
|
||||
message: "long",
|
||||
sourceName: "resource://gre/modules/long/long/long/long/long/long/long/long/long/long/",
|
||||
}),
|
||||
{message: "Not a scripterror instance."},
|
||||
|
||||
// No easy way to create an nsIScriptError with a stack, so let's pretend.
|
||||
Object.create(
|
||||
createScriptError({message: "Whatever"}),
|
||||
{stack: {value: new Error().stack}},
|
||||
),
|
||||
];
|
||||
|
||||
// Use observe to avoid errors from other code messing up our counts.
|
||||
for (const message of messages) {
|
||||
await reporter.observe(message);
|
||||
}
|
||||
|
||||
await SpecialPowers.pushPrefEnv({set: [[PREF_SAMPLE_RATE, "0.0"]]});
|
||||
await reporter.observe(createScriptError({message: "Additionally no name"}));
|
||||
|
||||
await SpecialPowers.pushPrefEnv({set: [[PREF_SAMPLE_RATE, "1.0"]]});
|
||||
fetchStub.rejects(new Error("Could not report"));
|
||||
await reporter.observe(createScriptError({message: "Maybe name?"}));
|
||||
|
||||
const optin = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN;
|
||||
const scalars = Services.telemetry.snapshotScalars(optin, false).parent;
|
||||
is(
|
||||
scalars[TELEMETRY_ERROR_COLLECTED],
|
||||
8,
|
||||
`${TELEMETRY_ERROR_COLLECTED} is incremented when an error is collected.`,
|
||||
);
|
||||
is(
|
||||
scalars[TELEMETRY_ERROR_SAMPLE_RATE],
|
||||
"1.0",
|
||||
`${TELEMETRY_ERROR_SAMPLE_RATE} contains the last sample rate used.`,
|
||||
);
|
||||
is(
|
||||
scalars[TELEMETRY_ERROR_REPORTED],
|
||||
6,
|
||||
`${TELEMETRY_ERROR_REPORTED} is incremented when an error is reported.`,
|
||||
);
|
||||
is(
|
||||
scalars[TELEMETRY_ERROR_REPORTED_FAIL],
|
||||
1,
|
||||
`${TELEMETRY_ERROR_REPORTED_FAIL} is incremented when an error fails to be reported.`,
|
||||
);
|
||||
is(
|
||||
scalars[TELEMETRY_ERROR_COLLECTED_STACK],
|
||||
1,
|
||||
`${TELEMETRY_ERROR_REPORTED_FAIL} is incremented when an error with a stack trace is collected.`,
|
||||
);
|
||||
|
||||
const keyedScalars = Services.telemetry.snapshotKeyedScalars(optin, false).parent;
|
||||
Assert.deepEqual(
|
||||
keyedScalars[TELEMETRY_ERROR_COLLECTED_FILENAME],
|
||||
{
|
||||
"FILTERED": 1,
|
||||
"resource://gre/modules/Foo.jsm": 1,
|
||||
"resource://gre/modules/Bar.jsm": 1,
|
||||
// Cut off at 70-character limit
|
||||
"resource://gre/modules/long/long/long/long/long/long/long/long/long/l": 1,
|
||||
},
|
||||
`${TELEMETRY_ERROR_COLLECTED_FILENAME} is incremented when an error is collected.`,
|
||||
);
|
||||
|
||||
resetConsole();
|
||||
});
|
||||
|
||||
add_task(async function testCollectedFilenameScalar() {
|
||||
const fetchStub = sinon.stub();
|
||||
const reporter = new BrowserErrorReporter(fetchStub);
|
||||
await SpecialPowers.pushPrefEnv({set: [
|
||||
[PREF_ENABLED, true],
|
||||
[PREF_SAMPLE_RATE, "1.0"],
|
||||
]});
|
||||
|
||||
const testCases = [
|
||||
["chrome://unknown/module.jsm", false],
|
||||
["resource://unknown/module.jsm", false],
|
||||
["unknown://unknown/module.jsm", false],
|
||||
|
||||
["resource://gre/modules/Foo.jsm", true],
|
||||
["resource:///modules/Foo.jsm", true],
|
||||
["chrome://global/Foo.jsm", true],
|
||||
["chrome://browser/Foo.jsm", true],
|
||||
["chrome://devtools/Foo.jsm", true],
|
||||
];
|
||||
|
||||
for (const [filename, shouldMatch] of testCases) {
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
// Use observe to avoid errors from other code messing up our counts.
|
||||
await reporter.observe(createScriptError({
|
||||
message: "Fine",
|
||||
sourceName: filename,
|
||||
}));
|
||||
|
||||
const keyedScalars = (
|
||||
Services.telemetry.snapshotKeyedScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false).parent
|
||||
);
|
||||
|
||||
let matched = null;
|
||||
if (shouldMatch) {
|
||||
matched = keyedScalars[TELEMETRY_ERROR_COLLECTED_FILENAME][filename] === 1;
|
||||
} else {
|
||||
matched = keyedScalars[TELEMETRY_ERROR_COLLECTED_FILENAME].FILTERED === 1;
|
||||
}
|
||||
|
||||
ok(
|
||||
matched,
|
||||
shouldMatch
|
||||
? `${TELEMETRY_ERROR_COLLECTED_FILENAME} logs a key for ${filename}.`
|
||||
: `${TELEMETRY_ERROR_COLLECTED_FILENAME} logs a FILTERED key for ${filename}.`,
|
||||
);
|
||||
}
|
||||
|
||||
resetConsole();
|
||||
});
|
||||
|
|
|
@ -137,10 +137,8 @@ function Inspector(toolbox) {
|
|||
this.onSidebarSelect = this.onSidebarSelect.bind(this);
|
||||
this.onSidebarShown = this.onSidebarShown.bind(this);
|
||||
this.onSidebarToggle = this.onSidebarToggle.bind(this);
|
||||
this.onSplitRuleViewPrefChanged = this.onSplitRuleViewPrefChanged.bind(this);
|
||||
|
||||
this._target.on("will-navigate", this._onBeforeNavigate);
|
||||
this.prefsObserver.on(SPLIT_RULE_VIEW_PREF, this.onSplitRuleViewPrefChanged);
|
||||
}
|
||||
|
||||
Inspector.prototype = {
|
||||
|
@ -581,13 +579,9 @@ Inspector.prototype = {
|
|||
this.sidebarSplitBox.setState({ width: splitSidebarWidth });
|
||||
},
|
||||
|
||||
onSidebarToggle: function() {
|
||||
Services.prefs.setBoolPref(SPLIT_RULE_VIEW_PREF, !this.isSplitRuleViewEnabled);
|
||||
},
|
||||
|
||||
async onSplitRuleViewPrefChanged() {
|
||||
// Update the stored value of the split rule view preference since it changed.
|
||||
this.isSplitRuleViewEnabled = Services.prefs.getBoolPref(SPLIT_RULE_VIEW_PREF);
|
||||
async onSidebarToggle() {
|
||||
this.isSplitRuleViewEnabled = !this.isSplitRuleViewEnabled;
|
||||
Services.prefs.setBoolPref(SPLIT_RULE_VIEW_PREF, this.isSplitRuleViewEnabled);
|
||||
|
||||
await this.setupToolbar();
|
||||
await this.addRuleView();
|
||||
|
@ -1278,7 +1272,6 @@ Inspector.prototype = {
|
|||
|
||||
this.cancelUpdate();
|
||||
|
||||
this.prefsObserver.off(SPLIT_RULE_VIEW_PREF, this.onSplitRuleViewPrefChanged);
|
||||
this.target.off("will-navigate", this._onBeforeNavigate);
|
||||
this.target.off("thread-paused", this.updateDebuggerPausedWarning);
|
||||
this.target.off("thread-resumed", this.updateDebuggerPausedWarning);
|
||||
|
@ -1326,6 +1319,7 @@ Inspector.prototype = {
|
|||
this._toolbox = null;
|
||||
this.breadcrumbs = null;
|
||||
this.highlighters = null;
|
||||
this.isSplitRuleViewEnabled = null;
|
||||
this.panelDoc = null;
|
||||
this.panelWin.inspector = null;
|
||||
this.panelWin = null;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {Cc, Ci, Cu, CC} = require("chrome");
|
||||
const {Ci, Cu, CC} = require("chrome");
|
||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const Services = require("Services");
|
||||
|
||||
|
@ -17,9 +17,6 @@ loader.lazyGetter(this, "debugJsModules", function() {
|
|||
return !!(AppConstants.DEBUG_JS_MODULES);
|
||||
});
|
||||
|
||||
const childProcessMessageManager =
|
||||
Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Ci.nsISyncMessageSender);
|
||||
const BinaryInput = CC("@mozilla.org/binaryinputstream;1",
|
||||
"nsIBinaryInputStream", "setInputStream");
|
||||
const BufferStream = CC("@mozilla.org/io/arraybuffer-input-stream;1",
|
||||
|
@ -309,7 +306,7 @@ function onContentMessage(e) {
|
|||
let value = e.detail.value;
|
||||
switch (e.detail.type) {
|
||||
case "save":
|
||||
childProcessMessageManager.sendAsyncMessage(
|
||||
Services.cpmm.sendAsyncMessage(
|
||||
"devtools:jsonview:save", value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@ add_task(async function() {
|
|||
// Set a higher panel height in order to get full CodeMirror content
|
||||
await pushPref("devtools.toolbox.footer.height", 400);
|
||||
|
||||
// Async stacks aren't on by default in all builds
|
||||
await pushPref("javascript.options.asyncstack", true);
|
||||
|
||||
let { tab, monitor, toolbox } = await initNetMonitor(POST_DATA_URL);
|
||||
info("Starting test... ");
|
||||
|
||||
|
@ -28,7 +31,7 @@ add_task(async function() {
|
|||
await waitForContentRequests;
|
||||
|
||||
info("Clicking stack-trace tab and waiting for stack-trace panel to open");
|
||||
let wait = waitForDOM(document, "#stack-trace-panel .frame-link", 4);
|
||||
let wait = waitForDOM(document, "#stack-trace-panel .frame-link", 5);
|
||||
// Click on the first request
|
||||
EventUtils.sendMouseEvent({ type: "mousedown" },
|
||||
document.querySelector(".request-list-item"));
|
||||
|
|
|
@ -20,12 +20,10 @@ function waitForDeviceClosed() {
|
|||
|
||||
return new Promise((resolve, reject) => {
|
||||
const message = "webrtc:UpdateGlobalIndicators";
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.addMessageListener(message, function listener(aMessage) {
|
||||
Services.ppmm.addMessageListener(message, function listener(aMessage) {
|
||||
info("Received " + message + " message");
|
||||
if (!aMessage.data.showGlobalIndicator) {
|
||||
ppmm.removeMessageListener(message, listener);
|
||||
Services.ppmm.removeMessageListener(message, listener);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var { Cc, Ci } = require("chrome");
|
||||
var { Cc } = require("chrome");
|
||||
|
||||
loader.lazyGetter(this, "ppmm", () => {
|
||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(
|
||||
Ci.nsIMessageBroadcaster);
|
||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
});
|
||||
|
||||
function ProcessActorList() {
|
||||
|
|
|
@ -6,15 +6,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { Cc, Ci, Cu } = require("chrome");
|
||||
const { Cu } = require("chrome");
|
||||
const Services = require("Services");
|
||||
const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common");
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
|
||||
loader.lazyGetter(this, "ppmm", () => {
|
||||
return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(
|
||||
Ci.nsIMessageBroadcaster);
|
||||
});
|
||||
loader.lazyRequireGetter(this, "WindowActor",
|
||||
"devtools/server/actors/window", true);
|
||||
|
||||
|
@ -547,7 +543,7 @@ RootActor.prototype = {
|
|||
}
|
||||
|
||||
let { id } = request;
|
||||
let mm = ppmm.getChildAt(id);
|
||||
let mm = Services.ppmm.getChildAt(id);
|
||||
if (!mm) {
|
||||
return { error: "noProcess",
|
||||
message: "There is no process with id '" + id + "'." };
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {Cc, Ci, Cu, CC} = require("chrome");
|
||||
const {Ci, Cu, CC} = require("chrome");
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const {LongStringActor} = require("devtools/server/actors/string");
|
||||
const {DebuggerServer} = require("devtools/server/main");
|
||||
|
@ -1939,20 +1939,14 @@ StorageActors.createActor({
|
|||
|
||||
var indexedDBHelpers = {
|
||||
backToChild(...args) {
|
||||
let mm = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
Services.mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
method: "backToChild",
|
||||
args: args
|
||||
});
|
||||
},
|
||||
|
||||
onItemUpdated(action, host, path) {
|
||||
let mm = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
Services.mm.broadcastAsyncMessage("debug:storage-indexedDB-request-child", {
|
||||
method: "onItemUpdated",
|
||||
args: [ action, host, path ]
|
||||
});
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
||||
"resource://gre/modules/E10SUtils.jsm");
|
||||
|
||||
|
@ -37,7 +34,7 @@ const MSG_MGR_CONSOLE_INFO_MAX = 1024;
|
|||
function ContentProcessForward() {
|
||||
Services.obs.addObserver(this, "console-api-log-event");
|
||||
Services.obs.addObserver(this, "xpcom-shutdown");
|
||||
cpmm.addMessageListener("DevTools:StopForwardingContentProcessMessage", this);
|
||||
Services.cpmm.addMessageListener("DevTools:StopForwardingContentProcessMessage", this);
|
||||
}
|
||||
ContentProcessForward.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
|
@ -107,7 +104,7 @@ ContentProcessForward.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
cpmm.sendAsyncMessage("Console:Log", msgData);
|
||||
Services.cpmm.sendAsyncMessage("Console:Log", msgData);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -120,7 +117,8 @@ ContentProcessForward.prototype = {
|
|||
uninit() {
|
||||
Services.obs.removeObserver(this, "console-api-log-event");
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
cpmm.removeMessageListener("DevTools:StopForwardingContentProcessMessage", this);
|
||||
Services.cpmm.removeMessageListener("DevTools:StopForwardingContentProcessMessage",
|
||||
this);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ function setupServer(mm) {
|
|||
|
||||
function init(msg) {
|
||||
let mm = msg.target;
|
||||
mm.QueryInterface(Ci.nsISyncMessageSender);
|
||||
let prefix = msg.data.prefix;
|
||||
|
||||
// Using the JS debugger causes problems when we're trying to
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
const {Cc, Ci} = require("chrome");
|
||||
const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
const {Cc} = require("chrome");
|
||||
const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
|
||||
exports.setupChild = function(a, b, c) {
|
||||
|
|
|
@ -49,10 +49,8 @@ function runTests() {
|
|||
let client = new DebuggerClient(transport);
|
||||
|
||||
// Wait for a response from setupInChild
|
||||
const ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
let onChild = msg => {
|
||||
ppmm.removeMessageListener("test:setupChild", onChild);
|
||||
Services.ppmm.removeMessageListener("test:setupChild", onChild);
|
||||
let args = msg.json;
|
||||
|
||||
is(args[0], 1, "Got first numeric argument");
|
||||
|
@ -65,7 +63,7 @@ function runTests() {
|
|||
setupChild: "callParent"
|
||||
});
|
||||
};
|
||||
ppmm.addMessageListener("test:setupChild", onChild);
|
||||
Services.ppmm.addMessageListener("test:setupChild", onChild);
|
||||
|
||||
// Wait also for a reponse from setupInParent called from setup-in-child.js
|
||||
let onParent = (_, topic, args) => {
|
||||
|
|
|
@ -649,11 +649,10 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
|
|||
*aSink = GetTabChild().take();
|
||||
return *aSink ? NS_OK : NS_ERROR_FAILURE;
|
||||
} else if (aIID.Equals(NS_GET_IID(nsIContentFrameMessageManager))) {
|
||||
nsCOMPtr<nsITabChild> tabChild =
|
||||
do_GetInterface(static_cast<nsIDocShell*>(this));
|
||||
RefPtr<TabChild> tabChild = TabChild::GetFrom(this);
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm;
|
||||
if (tabChild) {
|
||||
tabChild->GetMessageManager(getter_AddRefs(mm));
|
||||
mm = tabChild->GetMessageManager();
|
||||
} else {
|
||||
if (nsPIDOMWindowOuter* win = GetWindow()) {
|
||||
mm = do_QueryInterface(win->GetParentTarget());
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ChildProcessMessageManager_h
|
||||
#define mozilla_dom_ChildProcessMessageManager_h
|
||||
|
||||
#include "mozilla/dom/SyncMessageSender.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ChildProcessMessageManager final : public SyncMessageSender
|
||||
{
|
||||
public:
|
||||
explicit ChildProcessMessageManager(ipc::MessageManagerCallback* aCallback)
|
||||
: SyncMessageSender(aCallback,
|
||||
MessageManagerFlags::MM_PROCESSMANAGER |
|
||||
MessageManagerFlags::MM_OWNSCALLBACK)
|
||||
{
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
return ChildProcessMessageManagerBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~ChildProcessMessageManager()
|
||||
{
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ChildProcessMessageManager_h
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
||||
#include "AccessCheck.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
ChromeMessageBroadcaster::ChromeMessageBroadcaster(nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageListenerManager(nullptr, aParentManager,
|
||||
aFlags |
|
||||
MessageManagerFlags::MM_BROADCASTER |
|
||||
MessageManagerFlags::MM_CHROME)
|
||||
{
|
||||
if (mIsProcessManager) {
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
if (aParentManager) {
|
||||
aParentManager->AddChildManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
ChromeMessageBroadcaster::~ChromeMessageBroadcaster()
|
||||
{
|
||||
if (mIsProcessManager) {
|
||||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
ChromeMessageBroadcaster::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
|
||||
|
||||
return ChromeMessageBroadcasterBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,95 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ChromeMessageBroadcaster_h
|
||||
#define mozilla_dom_ChromeMessageBroadcaster_h
|
||||
|
||||
#include "mozilla/dom/MessageListenerManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ChromeMessageBroadcaster final : public MessageListenerManager
|
||||
{
|
||||
public:
|
||||
explicit ChromeMessageBroadcaster(MessageManagerFlags aFlags)
|
||||
: ChromeMessageBroadcaster(nullptr, aFlags)
|
||||
{
|
||||
MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
|
||||
MessageManagerFlags::MM_PROCESSMANAGER |
|
||||
MessageManagerFlags::MM_OWNSCALLBACK)));
|
||||
}
|
||||
explicit ChromeMessageBroadcaster(nsFrameMessageManager* aParentManager)
|
||||
: ChromeMessageBroadcaster(aParentManager, MessageManagerFlags::MM_NONE)
|
||||
{}
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
using nsFrameMessageManager::BroadcastAsyncMessage;
|
||||
void BroadcastAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, nullptr,
|
||||
JS::UndefinedHandleValue, aError);
|
||||
}
|
||||
uint32_t ChildCount()
|
||||
{
|
||||
return mChildManagers.Length();
|
||||
}
|
||||
using nsFrameMessageManager::GetChildAt;
|
||||
MessageListenerManager* GetChildAt(uint32_t aIndex)
|
||||
{
|
||||
return mChildManagers.SafeElementAt(aIndex);
|
||||
}
|
||||
// XPCOM ReleaseCachedProcesses is OK
|
||||
|
||||
// ProcessScriptLoader
|
||||
using nsFrameMessageManager::LoadProcessScript;
|
||||
void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, false, aError);
|
||||
}
|
||||
// XPCOM RemoveDelayedProcessScript is OK
|
||||
using nsFrameMessageManager::GetDelayedProcessScripts;
|
||||
void GetDelayedProcessScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
|
||||
// GlobalProcessScriptLoader
|
||||
// XPCOM GetInitialProcessData is OK
|
||||
|
||||
// FrameScriptLoader
|
||||
using nsFrameMessageManager::LoadFrameScript;
|
||||
void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope, mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
|
||||
}
|
||||
using nsFrameMessageManager::GetDelayedFrameScripts;
|
||||
void GetDelayedFrameScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
|
||||
private:
|
||||
ChromeMessageBroadcaster(nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags);
|
||||
virtual ~ChromeMessageBroadcaster();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ChromeMessageBroadcaster_h
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
ChromeMessageSender::ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageSender(aCallback, aParentManager, aFlags | MessageManagerFlags::MM_CHROME)
|
||||
{
|
||||
MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
|
||||
MessageManagerFlags::MM_PROCESSMANAGER |
|
||||
MessageManagerFlags::MM_OWNSCALLBACK)));
|
||||
|
||||
// This is a bit hackish. We attach to the parent, but only if we have a callback. We
|
||||
// don't have a callback for the frame message manager, and for parent process message
|
||||
// managers (except the parent in-process message manager). In those cases we wait until
|
||||
// the child process is running (see MessageSender::InitWithCallback).
|
||||
if (aParentManager && mCallback) {
|
||||
aParentManager->AddChildManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
JSObject*
|
||||
ChromeMessageSender::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
MOZ_ASSERT(nsContentUtils::IsSystemCaller(aCx));
|
||||
|
||||
return ChromeMessageSenderBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ChromeMessageSender_h
|
||||
#define mozilla_dom_ChromeMessageSender_h
|
||||
|
||||
#include "mozilla/dom/MessageSender.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ChromeMessageSender final : public MessageSender
|
||||
{
|
||||
public:
|
||||
ChromeMessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags=MessageManagerFlags::MM_NONE);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// ProcessScriptLoader
|
||||
using nsFrameMessageManager::LoadProcessScript;
|
||||
void LoadProcessScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, false, aError);
|
||||
}
|
||||
// XPCOM RemoveDelayedProcessScript is OK
|
||||
using nsFrameMessageManager::GetDelayedProcessScripts;
|
||||
void GetDelayedProcessScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
|
||||
// FrameScriptLoader
|
||||
using nsFrameMessageManager::LoadFrameScript;
|
||||
void LoadFrameScript(const nsAString& aUrl, bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope, mozilla::ErrorResult& aError)
|
||||
{
|
||||
LoadScript(aUrl, aAllowDelayedLoad, aRunInGlobalScope, aError);
|
||||
}
|
||||
using nsFrameMessageManager::GetDelayedFrameScripts;
|
||||
void GetDelayedFrameScripts(JSContext* aCx,
|
||||
nsTArray<nsTArray<JS::Value>>& aScripts,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
GetDelayedScripts(aCx, aScripts, aError);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ChromeMessageSender_h
|
|
@ -0,0 +1,95 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_ContentFrameMessageManager_h
|
||||
#define mozilla_dom_ContentFrameMessageManager_h
|
||||
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/MessageManagerGlobal.h"
|
||||
#include "mozilla/dom/ResolveSystemBinding.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* Base class for implementing the WebIDL ContentFrameMessageManager class.
|
||||
*/
|
||||
class ContentFrameMessageManager : public DOMEventTargetHelper,
|
||||
public MessageManagerGlobal
|
||||
{
|
||||
public:
|
||||
using DOMEventTargetHelper::AddRef;
|
||||
using DOMEventTargetHelper::Release;
|
||||
|
||||
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc)
|
||||
{
|
||||
bool found;
|
||||
if (!SystemGlobalResolve(aCx, aObj, aId, &found)) {
|
||||
return false;
|
||||
}
|
||||
if (found) {
|
||||
FillPropertyDescriptor(aDesc, aObj, JS::UndefinedValue(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool MayResolve(jsid aId)
|
||||
{
|
||||
return MayResolveAsSystemBindingName(aId);
|
||||
}
|
||||
void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, mozilla::ErrorResult& aRv)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
GetSystemBindingNames(aCx, thisObj, aNames, aEnumerableOnly, aRv);
|
||||
}
|
||||
|
||||
nsresult AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false, 2);
|
||||
}
|
||||
using DOMEventTargetHelper::AddEventListener;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter> GetContent(ErrorResult& aError) = 0;
|
||||
virtual already_AddRefed<nsIDocShell> GetDocShell(ErrorResult& aError) = 0;
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() = 0;
|
||||
|
||||
nsFrameMessageManager* GetMessageManager()
|
||||
{
|
||||
return mMessageManager;
|
||||
}
|
||||
void DisconnectMessageManager()
|
||||
{
|
||||
mMessageManager->Disconnect();
|
||||
mMessageManager = nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit ContentFrameMessageManager(nsFrameMessageManager* aMessageManager)
|
||||
: MessageManagerGlobal(aMessageManager)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ContentFrameMessageManager_h
|
|
@ -15,6 +15,7 @@
|
|||
#include "mozilla/RuleNodeCacheConditions.h"
|
||||
#include "mozilla/ServoCSSParser.h"
|
||||
#include "nsCSSParser.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
#include "nsStyleTransformMatrix.h"
|
||||
#include "nsGlobalWindowInner.h"
|
||||
|
||||
|
|
|
@ -21,10 +21,6 @@ var EXPORTED_SYMBOLS = ["DOMRequestIpcHelper"];
|
|||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageListenerManager");
|
||||
|
||||
function DOMRequestIpcHelper() {
|
||||
// _listeners keeps a list of messages for which we added a listener and the
|
||||
// kind of listener that we added (strong or weak). It's an object of this
|
||||
|
@ -89,8 +85,8 @@ DOMRequestIpcHelper.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
aMsg.weakRef ? cpmm.addWeakMessageListener(name, this)
|
||||
: cpmm.addMessageListener(name, this);
|
||||
aMsg.weakRef ? Services.cpmm.addWeakMessageListener(name, this)
|
||||
: Services.cpmm.addMessageListener(name, this);
|
||||
this._listeners[name] = {
|
||||
weakRef: !!aMsg.weakRef,
|
||||
count: 1
|
||||
|
@ -120,8 +116,8 @@ DOMRequestIpcHelper.prototype = {
|
|||
// be waiting on a message.
|
||||
if (!--this._listeners[aName].count) {
|
||||
this._listeners[aName].weakRef ?
|
||||
cpmm.removeWeakMessageListener(aName, this)
|
||||
: cpmm.removeMessageListener(aName, this);
|
||||
Services.cpmm.removeWeakMessageListener(aName, this)
|
||||
: Services.cpmm.removeMessageListener(aName, this);
|
||||
delete this._listeners[aName];
|
||||
}
|
||||
});
|
||||
|
@ -181,8 +177,9 @@ DOMRequestIpcHelper.prototype = {
|
|||
|
||||
if (this._listeners) {
|
||||
Object.keys(this._listeners).forEach((aName) => {
|
||||
this._listeners[aName].weakRef ? cpmm.removeWeakMessageListener(aName, this)
|
||||
: cpmm.removeMessageListener(aName, this);
|
||||
this._listeners[aName].weakRef ?
|
||||
Services.cpmm.removeWeakMessageListener(aName, this)
|
||||
: Services.cpmm.removeMessageListener(aName, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,7 @@
|
|||
|
||||
#include "nsINode.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/MessageListenerManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
MessageListenerManager::MessageListenerManager(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
ipc::MessageManagerFlags aFlags)
|
||||
: nsFrameMessageManager(aCallback, aFlags),
|
||||
mParentManager(aParentManager)
|
||||
{
|
||||
}
|
||||
|
||||
MessageListenerManager::~MessageListenerManager()
|
||||
{
|
||||
}
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MessageListenerManager)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsFrameMessageManager)
|
||||
NS_IMPL_ADDREF_INHERITED(MessageListenerManager, nsFrameMessageManager)
|
||||
NS_IMPL_RELEASE_INHERITED(MessageListenerManager, nsFrameMessageManager)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(MessageListenerManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
void
|
||||
MessageListenerManager::ClearParentManager(bool aRemove)
|
||||
{
|
||||
if (aRemove && mParentManager) {
|
||||
mParentManager->RemoveChildManager(this);
|
||||
}
|
||||
mParentManager = nullptr;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MessageListenerManager_h
|
||||
#define mozilla_dom_MessageListenerManager_h
|
||||
|
||||
#include "nsCycleCollectionNoteChild.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MessageListenerManager : public nsFrameMessageManager,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageListenerManager,
|
||||
nsFrameMessageManager)
|
||||
|
||||
nsISupports* GetParentObject()
|
||||
{
|
||||
return ToSupports(mParentManager.get());
|
||||
}
|
||||
|
||||
virtual nsFrameMessageManager* GetParentManager() override
|
||||
{
|
||||
return mParentManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* If aRemove is true then RemoveChildManager(this) will be called on the parent manager
|
||||
* first.
|
||||
*/
|
||||
virtual void ClearParentManager(bool aRemove) override;
|
||||
|
||||
protected:
|
||||
MessageListenerManager(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags);
|
||||
virtual ~MessageListenerManager();
|
||||
|
||||
RefPtr<nsFrameMessageManager> mParentManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MessageListenerManager_h
|
|
@ -0,0 +1,181 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MessageManagerGlobal_h
|
||||
#define mozilla_dom_MessageManagerGlobal_h
|
||||
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
/**
|
||||
* Base class for implementing the WebIDL MessageManagerGlobal class.
|
||||
*/
|
||||
class MessageManagerGlobal
|
||||
{
|
||||
public:
|
||||
// MessageListenerManager
|
||||
void AddMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
bool aListenWhenClosed,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->AddMessageListener(aMessageName, aListener,
|
||||
aListenWhenClosed, aError);
|
||||
}
|
||||
void RemoveMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->RemoveMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
void AddWeakMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->AddWeakMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
void RemoveWeakMessageListener(const nsAString& aMessageName,
|
||||
MessageListener& aListener,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->RemoveWeakMessageListener(aMessageName, aListener, aError);
|
||||
}
|
||||
|
||||
// MessageSender
|
||||
void SendAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JS::Handle<JS::Value> aTransfers,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendAsyncMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aTransfers, aError);
|
||||
}
|
||||
already_AddRefed<nsIMessageSender> GetProcessMessageManager(mozilla::ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return nullptr;
|
||||
}
|
||||
return mMessageManager->GetProcessMessageManager(aError);
|
||||
}
|
||||
|
||||
void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->GetRemoteType(aRemoteType, aError);
|
||||
}
|
||||
|
||||
// SyncMessageSender
|
||||
void SendSyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendSyncMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aResult, aError);
|
||||
}
|
||||
void SendRpcMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->SendRpcMessage(aCx, aMessageName, aObj, aObjects,
|
||||
aPrincipal, aResult, aError);
|
||||
}
|
||||
|
||||
// MessageManagerGlobal
|
||||
void Dump(const nsAString& aStr, ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Dump(aStr);
|
||||
}
|
||||
void PrivateNoteIntentionalCrash(ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->PrivateNoteIntentionalCrash();
|
||||
}
|
||||
void Atob(const nsAString& aAsciiString, nsAString& aBase64Data,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Atob(aAsciiString, aBase64Data);
|
||||
}
|
||||
void Btoa(const nsAString& aBase64Data, nsAString& aAsciiString,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
aError = mMessageManager->Btoa(aBase64Data, aAsciiString);
|
||||
}
|
||||
|
||||
bool MarkForCC()
|
||||
{
|
||||
return mMessageManager && mMessageManager->MarkForCC();
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit MessageManagerGlobal(nsFrameMessageManager* aMessageManager)
|
||||
: mMessageManager(aMessageManager)
|
||||
{}
|
||||
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MessageManagerGlobal_h
|
|
@ -0,0 +1,33 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/MessageSender.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
void
|
||||
MessageSender::InitWithCallback(ipc::MessageManagerCallback* aCallback)
|
||||
{
|
||||
if (mCallback) {
|
||||
// Initialization should only happen once.
|
||||
return;
|
||||
}
|
||||
|
||||
SetCallback(aCallback);
|
||||
|
||||
// First load parent scripts by adding this to parent manager.
|
||||
if (mParentManager) {
|
||||
mParentManager->AddChildManager(this);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mPendingScripts.Length(); ++i) {
|
||||
LoadFrameScript(mPendingScripts[i], false, mPendingScriptsGlobalStates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,31 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_MessageSender_h
|
||||
#define mozilla_dom_MessageSender_h
|
||||
|
||||
#include "mozilla/dom/MessageListenerManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class MessageSender : public MessageListenerManager
|
||||
{
|
||||
public:
|
||||
void InitWithCallback(ipc::MessageManagerCallback* aCallback);
|
||||
|
||||
protected:
|
||||
MessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageListenerManager(aCallback, aParentManager, aFlags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_MessageSender_h
|
|
@ -7,17 +7,16 @@
|
|||
#include "ProcessGlobal.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/HoldDropJSObjects.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/ResolveSystemBinding.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
ProcessGlobal::ProcessGlobal(nsFrameMessageManager* aMessageManager)
|
||||
: mInitialized(false),
|
||||
mMessageManager(aMessageManager)
|
||||
: MessageManagerGlobal(aMessageManager),
|
||||
mInitialized(false)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
||||
|
@ -27,6 +26,36 @@ ProcessGlobal::~ProcessGlobal()
|
|||
mozilla::DropJSObjects(this);
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessGlobal::DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc)
|
||||
{
|
||||
bool found;
|
||||
if (!SystemGlobalResolve(aCx, aObj, aId, &found)) {
|
||||
return false;
|
||||
}
|
||||
if (found) {
|
||||
FillPropertyDescriptor(aDesc, aObj, JS::UndefinedValue(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
ProcessGlobal::MayResolve(jsid aId)
|
||||
{
|
||||
return MayResolveAsSystemBindingName(aId);
|
||||
}
|
||||
|
||||
void
|
||||
ProcessGlobal::GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, ErrorResult& aRv)
|
||||
{
|
||||
JS::Rooted<JSObject*> thisObj(aCx, GetWrapper());
|
||||
GetSystemBindingNames(aCx, thisObj, aNames, aEnumerableOnly, aRv);
|
||||
}
|
||||
|
||||
ProcessGlobal*
|
||||
ProcessGlobal::Get()
|
||||
{
|
||||
|
@ -43,7 +72,7 @@ NS_IMETHODIMP_(bool)
|
|||
ProcessGlobal::MarkForCC()
|
||||
{
|
||||
MarkScopesForCC();
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(ProcessGlobal)
|
||||
|
@ -75,7 +104,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ProcessGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentProcessMessageManager)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ProcessGlobal)
|
||||
|
@ -89,15 +117,30 @@ ProcessGlobal::Init()
|
|||
}
|
||||
mInitialized = true;
|
||||
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIContentProcessMessageManager*, this);
|
||||
return InitChildGlobalInternal(scopeSupports, NS_LITERAL_CSTRING("processChildGlobal"));
|
||||
return InitChildGlobalInternal(NS_LITERAL_CSTRING("processChildGlobal"));
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentProcessMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mPrincipal),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
ProcessGlobal::LoadScript(const nsAString& aURL)
|
||||
{
|
||||
Init();
|
||||
LoadScriptInternal(aURL, false);
|
||||
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());
|
||||
LoadScriptInternal(global, aURL, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_ProcessGlobal_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/MessageManagerGlobal.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -25,18 +26,26 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
class ProcessGlobal :
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIContentProcessMessageManager,
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIGlobalObject,
|
||||
public nsIScriptObjectPrincipal,
|
||||
public nsSupportsWeakReference,
|
||||
public mozilla::dom::ipc::MessageManagerCallback,
|
||||
public ipc::MessageManagerCallback,
|
||||
public MessageManagerGlobal,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
explicit ProcessGlobal(nsFrameMessageManager* aMessageManager);
|
||||
|
||||
using mozilla::dom::ipc::MessageManagerCallback::GetProcessMessageManager;
|
||||
bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId,
|
||||
JS::MutableHandle<JS::PropertyDescriptor> aDesc);
|
||||
static bool MayResolve(jsid aId);
|
||||
void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
|
||||
bool aEnumerableOnly, ErrorResult& aRv);
|
||||
|
||||
using ipc::MessageManagerCallback::GetProcessMessageManager;
|
||||
|
||||
bool Init();
|
||||
|
||||
|
@ -45,6 +54,41 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ProcessGlobal, nsIContentProcessMessageManager)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override;
|
||||
|
||||
using MessageManagerGlobal::AddMessageListener;
|
||||
using MessageManagerGlobal::RemoveMessageListener;
|
||||
using MessageManagerGlobal::AddWeakMessageListener;
|
||||
using MessageManagerGlobal::RemoveWeakMessageListener;
|
||||
using MessageManagerGlobal::SendAsyncMessage;
|
||||
using MessageManagerGlobal::GetProcessMessageManager;
|
||||
using MessageManagerGlobal::GetRemoteType;
|
||||
using MessageManagerGlobal::SendSyncMessage;
|
||||
using MessageManagerGlobal::SendRpcMessage;
|
||||
using MessageManagerGlobal::Dump;
|
||||
using MessageManagerGlobal::PrivateNoteIntentionalCrash;
|
||||
using MessageManagerGlobal::Atob;
|
||||
using MessageManagerGlobal::Btoa;
|
||||
|
||||
// ContentProcessMessageManager
|
||||
void GetInitialProcessData(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aInitialProcessData,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
if (!mMessageManager) {
|
||||
aError.Throw(NS_ERROR_NULL_POINTER);
|
||||
return;
|
||||
}
|
||||
mMessageManager->GetInitialProcessData(aCx, aInitialProcessData, aError);
|
||||
}
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager)
|
||||
|
@ -55,15 +99,10 @@ public:
|
|||
|
||||
virtual JSObject* GetGlobalJSObject() override
|
||||
{
|
||||
return mGlobal;
|
||||
return GetWrapper();
|
||||
}
|
||||
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("ProcessGlobal doesn't use DOM bindings!");
|
||||
}
|
||||
|
||||
void SetInitialProcessData(JS::HandleValue aInitialData);
|
||||
|
||||
protected:
|
||||
|
@ -71,7 +110,6 @@ protected:
|
|||
|
||||
private:
|
||||
bool mInitialized;
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_SyncMessageSender_h
|
||||
#define mozilla_dom_SyncMessageSender_h
|
||||
|
||||
#include "mozilla/dom/MessageSender.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class SyncMessageSender : public MessageSender
|
||||
{
|
||||
protected:
|
||||
SyncMessageSender(ipc::MessageManagerCallback* aCallback,
|
||||
MessageManagerFlags aFlags)
|
||||
: MessageSender(aCallback, nullptr, aFlags)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_SyncMessageSender_h
|
|
@ -18,6 +18,7 @@
|
|||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPresContext.h"
|
||||
|
||||
using mozilla::dom::KeyboardEvent;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "mozilla/dom/TimeoutManager.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIEventTarget.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
class nsIEventTarget;
|
||||
class nsITimeoutHandler;
|
||||
class nsITimer;
|
||||
class nsGlobalWindowInner;
|
||||
|
||||
namespace mozilla {
|
||||
|
|
|
@ -155,9 +155,13 @@ EXPORTS.mozilla.dom += [
|
|||
'BorrowedAttrInfo.h',
|
||||
'CharacterData.h',
|
||||
'ChildIterator.h',
|
||||
'ChildProcessMessageManager.h',
|
||||
'ChromeMessageBroadcaster.h',
|
||||
'ChromeMessageSender.h',
|
||||
'ChromeNodeList.h',
|
||||
'ChromeUtils.h',
|
||||
'Comment.h',
|
||||
'ContentFrameMessageManager.h',
|
||||
'CustomElementRegistry.h',
|
||||
'DirectionalityUtils.h',
|
||||
'DispatcherTrait.h',
|
||||
|
@ -194,6 +198,9 @@ EXPORTS.mozilla.dom += [
|
|||
'IntlUtils.h',
|
||||
'Link.h',
|
||||
'Location.h',
|
||||
'MessageListenerManager.h',
|
||||
'MessageManagerGlobal.h',
|
||||
'MessageSender.h',
|
||||
'NameSpaceConstants.h',
|
||||
'Navigator.h',
|
||||
'NodeInfo.h',
|
||||
|
@ -211,6 +218,7 @@ EXPORTS.mozilla.dom += [
|
|||
'StructuredCloneTags.h',
|
||||
'StyleSheetList.h',
|
||||
'SubtleCrypto.h',
|
||||
'SyncMessageSender.h',
|
||||
'TabGroup.h',
|
||||
'Text.h',
|
||||
'Timeout.h',
|
||||
|
@ -234,6 +242,8 @@ UNIFIED_SOURCES += [
|
|||
'BorrowedAttrInfo.cpp',
|
||||
'CharacterData.cpp',
|
||||
'ChildIterator.cpp',
|
||||
'ChromeMessageBroadcaster.cpp',
|
||||
'ChromeMessageSender.cpp',
|
||||
'ChromeNodeList.cpp',
|
||||
'ChromeUtils.cpp',
|
||||
'Comment.cpp',
|
||||
|
@ -269,6 +279,8 @@ UNIFIED_SOURCES += [
|
|||
'IntlUtils.cpp',
|
||||
'Link.cpp',
|
||||
'Location.cpp',
|
||||
'MessageListenerManager.cpp',
|
||||
'MessageSender.cpp',
|
||||
'Navigator.cpp',
|
||||
'NodeInfo.cpp',
|
||||
'NodeIterator.cpp',
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "nsISHistory.h"
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsISHContainer.h"
|
||||
#include "nsITabChild.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIXULWindow.h"
|
||||
|
@ -33,6 +32,7 @@
|
|||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ProcessGlobal.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/TimeoutManager.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsObserverService.h"
|
||||
|
@ -294,11 +294,9 @@ MarkWindowList(nsISimpleEnumerator* aWindowList, bool aCleanupJS)
|
|||
|
||||
MarkDocShell(rootDocShell, aCleanupJS);
|
||||
|
||||
nsCOMPtr<nsITabChild> tabChild =
|
||||
rootDocShell ? rootDocShell->GetTabChild() : nullptr;
|
||||
RefPtr<TabChild> tabChild = TabChild::GetFrom(rootDocShell);
|
||||
if (tabChild) {
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm;
|
||||
tabChild->GetMessageManager(getter_AddRefs(mm));
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm = tabChild->GetMessageManager();
|
||||
if (mm) {
|
||||
// MarkForCC ends up calling UnmarkGray on message listeners, which
|
||||
// TraceBlackJS can't do yet.
|
||||
|
@ -516,7 +514,7 @@ mozilla::dom::TraceBlackJS(JSTracer* aTrc, bool aIsShutdownGC)
|
|||
if (ds) {
|
||||
nsCOMPtr<nsITabChild> tabChild = ds->GetTabChild();
|
||||
if (tabChild) {
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mm;
|
||||
nsCOMPtr<nsISupports> mm;
|
||||
tabChild->GetMessageManager(getter_AddRefs(mm));
|
||||
nsCOMPtr<EventTarget> et = do_QueryInterface(mm);
|
||||
if (et) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "nsElementTable.h"
|
||||
|
||||
using mozilla::DebugOnly;
|
||||
using mozilla::Move;
|
||||
using mozilla::RawRangeBoundary;
|
||||
|
||||
// couple of utility static functs
|
||||
|
|
|
@ -71,7 +71,6 @@
|
|||
// includes needed for the prototype chain interfaces
|
||||
|
||||
#include "nsIEventListenerService.h"
|
||||
#include "nsIMessageManager.h"
|
||||
|
||||
#include "mozilla/dom/TouchEvent.h"
|
||||
|
||||
|
@ -129,9 +128,6 @@ using namespace mozilla::dom;
|
|||
#define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, false, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, false)
|
||||
|
||||
#define NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(_class, _helper, _flags) \
|
||||
NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, true, true)
|
||||
|
||||
|
@ -166,20 +162,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
|
||||
// Misc Core related classes
|
||||
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentFrameMessageManager,
|
||||
nsMessageManagerSH<nsEventTargetSH>,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
XPC_SCRIPTABLE_WANT_ENUMERATE |
|
||||
XPC_SCRIPTABLE_IS_GLOBAL_OBJECT)
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ContentProcessMessageManager,
|
||||
nsMessageManagerSH<nsDOMGenericSH>,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS |
|
||||
XPC_SCRIPTABLE_WANT_ENUMERATE |
|
||||
XPC_SCRIPTABLE_IS_GLOBAL_OBJECT)
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageBroadcaster, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA(ChromeMessageSender, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
};
|
||||
|
||||
nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
|
||||
|
@ -413,36 +395,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentFrameMessageManager, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIContentFrameMessageManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentProcessMessageManager, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsISyncMessageSender)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIContentProcessMessageManager)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeMessageBroadcaster, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIProcessScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIGlobalProcessScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageBroadcaster)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ChromeMessageSender, nsISupports)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIFrameScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIProcessScriptLoader)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageListenerManager)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIMessageSender)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
static_assert(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
|
||||
"The number of items in sClassInfoData doesn't match the "
|
||||
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
|
||||
|
@ -1894,41 +1846,3 @@ nsDOMConstructorSH::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
return wrapped->HasInstance(wrapper, cx, obj, val, bp, _retval);
|
||||
}
|
||||
|
||||
// nsContentFrameMessageManagerSH
|
||||
|
||||
template<typename Super>
|
||||
NS_IMETHODIMP
|
||||
nsMessageManagerSH<Super>::Resolve(nsIXPConnectWrappedNative* wrapper,
|
||||
JSContext* cx, JSObject* obj_,
|
||||
jsid id_, bool* resolvedp,
|
||||
bool* _retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, obj_);
|
||||
JS::Rooted<jsid> id(cx, id_);
|
||||
|
||||
*_retval = SystemGlobalResolve(cx, obj, id, resolvedp);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
if (*resolvedp) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return Super::Resolve(wrapper, cx, obj, id, resolvedp, _retval);
|
||||
}
|
||||
|
||||
template<typename Super>
|
||||
NS_IMETHODIMP
|
||||
nsMessageManagerSH<Super>::Enumerate(nsIXPConnectWrappedNative* wrapper,
|
||||
JSContext* cx, JSObject* obj_,
|
||||
bool* _retval)
|
||||
{
|
||||
JS::Rooted<JSObject*> obj(cx, obj_);
|
||||
|
||||
*_retval = SystemGlobalEnumerate(cx, obj);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
// Don't call up to our superclass, since neither nsDOMGenericSH nor
|
||||
// nsEventTargetSH have WANT_ENUMERATE.
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -212,29 +212,4 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template<typename Super>
|
||||
class nsMessageManagerSH : public Super
|
||||
{
|
||||
protected:
|
||||
explicit nsMessageManagerSH(nsDOMClassInfoData* aData)
|
||||
: Super(aData)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsMessageManagerSH()
|
||||
{
|
||||
}
|
||||
public:
|
||||
NS_IMETHOD Resolve(nsIXPConnectWrappedNative* wrapper, JSContext* cx,
|
||||
JSObject* obj_, jsid id_, bool* resolvedp,
|
||||
bool* _retval) override;
|
||||
NS_IMETHOD Enumerate(nsIXPConnectWrappedNative* wrapper, JSContext* cx,
|
||||
JSObject* obj_, bool* _retval) override;
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
|
||||
{
|
||||
return new nsMessageManagerSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* nsDOMClassInfo_h___ */
|
||||
|
|
|
@ -19,11 +19,6 @@ enum nsDOMClassInfoID
|
|||
eDOMClassInfo_DOMPrototype_id,
|
||||
eDOMClassInfo_DOMConstructor_id,
|
||||
|
||||
eDOMClassInfo_ContentFrameMessageManager_id,
|
||||
eDOMClassInfo_ContentProcessMessageManager_id,
|
||||
eDOMClassInfo_ChromeMessageBroadcaster_id,
|
||||
eDOMClassInfo_ChromeMessageSender_id,
|
||||
|
||||
// This one better be the last one in this list
|
||||
eDOMClassInfoIDCount
|
||||
};
|
||||
|
|
|
@ -1500,7 +1500,6 @@ nsIDocument::nsIDocument()
|
|||
mAsyncOnloadBlockCount(0),
|
||||
mCompatMode(eCompatibility_FullStandards),
|
||||
mReadyState(ReadyState::READYSTATE_UNINITIALIZED),
|
||||
mStyleBackendType(StyleBackendType::None),
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
mVisibilityState(dom::VisibilityState::Hidden),
|
||||
#else
|
||||
|
@ -2156,13 +2155,9 @@ nsDocument::Init()
|
|||
|
||||
NS_ASSERTION(OwnerDoc() == this, "Our nodeinfo is busted!");
|
||||
|
||||
UpdateStyleBackendType();
|
||||
|
||||
// Set this when document is initialized and value stays the same for the
|
||||
// lifetime of the document.
|
||||
mIsShadowDOMEnabled =
|
||||
mStyleBackendType == StyleBackendType::Servo &&
|
||||
nsContentUtils::IsShadowDOMEnabled();
|
||||
mIsShadowDOMEnabled = nsContentUtils::IsShadowDOMEnabled();
|
||||
|
||||
// If after creation the owner js global is not set for a document
|
||||
// we use the default compartment for this document, instead of creating
|
||||
|
@ -8903,7 +8898,6 @@ nsDocument::CloneDocHelper(nsDocument* clone, bool aPreallocateChildren) const
|
|||
clone->mContentLanguage = mContentLanguage;
|
||||
clone->SetContentTypeInternal(GetContentTypeInternal());
|
||||
clone->mSecurityInfo = mSecurityInfo;
|
||||
clone->mStyleBackendType = mStyleBackendType;
|
||||
|
||||
// State from nsDocument
|
||||
clone->mType = mType;
|
||||
|
@ -12607,21 +12601,6 @@ nsIDocument::ReportHasScrollLinkedEffect()
|
|||
"ScrollLinkedEffectFound2");
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::UpdateStyleBackendType()
|
||||
{
|
||||
MOZ_ASSERT(mStyleBackendType == StyleBackendType::None,
|
||||
"no need to call UpdateStyleBackendType now");
|
||||
|
||||
// Assume Gecko by default.
|
||||
mStyleBackendType = StyleBackendType::Gecko;
|
||||
|
||||
if (nsLayoutUtils::StyloEnabled() &&
|
||||
nsLayoutUtils::ShouldUseStylo(NodePrincipal())) {
|
||||
mStyleBackendType = StyleBackendType::Servo;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsIDocument::SetUserHasInteracted(bool aUserHasInteracted)
|
||||
{
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/FrameLoaderBinding.h"
|
||||
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
|
||||
|
@ -1642,14 +1643,12 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
|||
RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
|
||||
// Swap pointers in child message managers.
|
||||
if (mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
nsInProcessTabChildGlobal* tabChild = mChildMessageManager;
|
||||
tabChild->SetOwner(otherContent);
|
||||
tabChild->SetChromeMessageManager(otherMessageManager);
|
||||
}
|
||||
if (aOther->mChildMessageManager) {
|
||||
nsInProcessTabChildGlobal* otherTabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(aOther->mChildMessageManager.get());
|
||||
nsInProcessTabChildGlobal* otherTabChild = aOther->mChildMessageManager;
|
||||
otherTabChild->SetOwner(ourContent);
|
||||
otherTabChild->SetChromeMessageManager(ourMessageManager);
|
||||
}
|
||||
|
@ -1884,7 +1883,7 @@ nsFrameLoader::DestroyDocShell()
|
|||
|
||||
// Fire the "unload" event if we're in-process.
|
||||
if (mChildMessageManager) {
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->FireUnloadEvent();
|
||||
mChildMessageManager->FireUnloadEvent();
|
||||
}
|
||||
|
||||
// Destroy the docshell.
|
||||
|
@ -1896,7 +1895,7 @@ nsFrameLoader::DestroyDocShell()
|
|||
|
||||
if (mChildMessageManager) {
|
||||
// Stop handling events in the in-process frame script.
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->DisconnectEventListeners();
|
||||
mChildMessageManager->DisconnectEventListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1931,7 +1930,7 @@ nsFrameLoader::DestroyComplete()
|
|||
}
|
||||
|
||||
if (mChildMessageManager) {
|
||||
static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get())->Disconnect();
|
||||
mChildMessageManager->Disconnect();
|
||||
}
|
||||
|
||||
mMessageManager = nullptr;
|
||||
|
@ -2987,12 +2986,11 @@ public:
|
|||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
nsInProcessTabChildGlobal* tabChild =
|
||||
static_cast<nsInProcessTabChildGlobal*>(mFrameLoader->mChildMessageManager.get());
|
||||
nsInProcessTabChildGlobal* tabChild = mFrameLoader->mChildMessageManager;
|
||||
// Since bug 1126089, messages can arrive even when the docShell is destroyed.
|
||||
// Here we make sure that those messages are not delivered.
|
||||
if (tabChild && tabChild->GetInnerManager() && mFrameLoader->GetExistingDocShell()) {
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), tabChild->GetGlobal());
|
||||
JS::Rooted<JSObject*> kungFuDeathGrip(dom::RootingCx(), tabChild->GetWrapper());
|
||||
ReceiveMessage(static_cast<EventTarget*>(tabChild), mFrameLoader,
|
||||
tabChild->GetInnerManager());
|
||||
}
|
||||
|
@ -3106,9 +3104,8 @@ nsFrameLoader::EnsureMessageManager()
|
|||
parentManager = do_GetService("@mozilla.org/globalmessagemanager;1");
|
||||
}
|
||||
|
||||
mMessageManager = new nsFrameMessageManager(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()),
|
||||
MM_CHROME);
|
||||
mMessageManager = new ChromeMessageSender(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(parentManager.get()));
|
||||
if (!IsRemoteFrame()) {
|
||||
nsresult rv = MaybeCreateDocShell();
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -3141,7 +3138,7 @@ nsFrameLoader::ReallyLoadFrameScripts()
|
|||
EventTarget*
|
||||
nsFrameLoader::GetTabChildGlobalAsEventTarget()
|
||||
{
|
||||
return static_cast<nsInProcessTabChildGlobal*>(mChildMessageManager.get());
|
||||
return mChildMessageManager.get();
|
||||
}
|
||||
|
||||
already_AddRefed<Element>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
class nsIURI;
|
||||
class nsSubDocumentFrame;
|
||||
class nsView;
|
||||
class nsIInProcessContentFrameMessageManager;
|
||||
class nsInProcessTabChildGlobal;
|
||||
class AutoResetInShow;
|
||||
class AutoResetInFrameSwap;
|
||||
class nsITabParent;
|
||||
|
@ -44,6 +44,7 @@ namespace mozilla {
|
|||
class OriginAttributes;
|
||||
|
||||
namespace dom {
|
||||
class ChromeMessageSender;
|
||||
class ContentParent;
|
||||
class PBrowserParent;
|
||||
class Promise;
|
||||
|
@ -268,7 +269,7 @@ public:
|
|||
*/
|
||||
RenderFrameParent* GetCurrentRenderFrame() const;
|
||||
|
||||
nsFrameMessageManager* GetFrameMessageManager() { return mMessageManager; }
|
||||
mozilla::dom::ChromeMessageSender* GetFrameMessageManager() { return mMessageManager; }
|
||||
|
||||
mozilla::dom::Element* GetOwnerContent() { return mOwnerContent; }
|
||||
bool ShouldClipSubdocument() { return mClipSubdocument; }
|
||||
|
@ -319,8 +320,8 @@ public:
|
|||
virtual nsIMessageSender* GetProcessMessageManager() const override;
|
||||
|
||||
// public because a callback needs these.
|
||||
RefPtr<nsFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIInProcessContentFrameMessageManager> mChildMessageManager;
|
||||
RefPtr<mozilla::dom::ChromeMessageSender> mMessageManager;
|
||||
RefPtr<nsInProcessTabChildGlobal> mChildMessageManager;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -28,6 +28,8 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "js/RootingAPI.h"
|
||||
#include "nsTObserverArray.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
#include "mozilla/dom/CallbackObject.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
||||
#include "mozilla/jsipc/CpowHolder.h"
|
||||
|
@ -39,8 +41,13 @@ namespace dom {
|
|||
|
||||
class nsIContentParent;
|
||||
class nsIContentChild;
|
||||
class ChildProcessMessageManager;
|
||||
class ChromeMessageSender;
|
||||
class ClonedMessageData;
|
||||
class MessageListener;
|
||||
class MessageListenerManager;
|
||||
class MessageManagerReporter;
|
||||
template<typename T> class Optional;
|
||||
|
||||
namespace ipc {
|
||||
|
||||
|
@ -48,14 +55,15 @@ namespace ipc {
|
|||
// of 1 ms actually captures from 500us and above.
|
||||
static const uint32_t kMinTelemetrySyncMessageManagerLatencyMs = 1;
|
||||
|
||||
enum MessageManagerFlags {
|
||||
MM_CHILD = 0,
|
||||
enum class MessageManagerFlags {
|
||||
MM_NONE = 0,
|
||||
MM_CHROME = 1,
|
||||
MM_GLOBAL = 2,
|
||||
MM_PROCESSMANAGER = 4,
|
||||
MM_BROADCASTER = 8,
|
||||
MM_OWNSCALLBACK = 16
|
||||
};
|
||||
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(MessageManagerFlags);
|
||||
|
||||
class MessageManagerCallback
|
||||
{
|
||||
|
@ -118,6 +126,10 @@ void UnpackClonedMessageDataForChild(const ClonedMessageData& aClonedData,
|
|||
StructuredCloneData& aData);
|
||||
|
||||
} // namespace ipc
|
||||
|
||||
typedef CallbackObjectHolder<mozilla::dom::MessageListener,
|
||||
nsIMessageListener> MessageListenerHolder;
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -128,12 +140,22 @@ struct nsMessageListenerInfo
|
|||
return &aOther == this;
|
||||
}
|
||||
|
||||
// Exactly one of mStrongListener and mWeakListener must be non-null.
|
||||
nsCOMPtr<nsIMessageListener> mStrongListener;
|
||||
// If mWeakListener is null then mStrongListener holds either a MessageListener or an
|
||||
// nsIMessageListener. If mWeakListener is non-null then mStrongListener contains null.
|
||||
mozilla::dom::MessageListenerHolder mStrongListener;
|
||||
nsWeakPtr mWeakListener;
|
||||
bool mListenWhenClosed;
|
||||
};
|
||||
|
||||
inline void
|
||||
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
|
||||
nsMessageListenerInfo& aField,
|
||||
const char* aName,
|
||||
uint32_t aFlags = 0)
|
||||
{
|
||||
ImplCycleCollectionTraverse(aCallback, aField.mStrongListener, aName, aFlags);
|
||||
ImplCycleCollectionTraverse(aCallback, aField.mWeakListener, aName, aFlags);
|
||||
}
|
||||
|
||||
class MOZ_STACK_CLASS SameProcessCpowHolder : public mozilla::jsipc::CpowHolder
|
||||
{
|
||||
|
@ -150,25 +172,86 @@ private:
|
|||
JS::Rooted<JSObject*> mObj;
|
||||
};
|
||||
|
||||
class nsFrameMessageManager final : public nsIContentFrameMessageManager,
|
||||
class nsFrameMessageManager : public nsIContentFrameMessageManager,
|
||||
public nsIMessageBroadcaster,
|
||||
public nsIFrameScriptLoader,
|
||||
public nsIGlobalProcessScriptLoader
|
||||
{
|
||||
friend class mozilla::dom::MessageManagerReporter;
|
||||
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
|
||||
public:
|
||||
|
||||
protected:
|
||||
typedef mozilla::dom::ipc::MessageManagerFlags MessageManagerFlags;
|
||||
|
||||
nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback,
|
||||
nsFrameMessageManager* aParentManager,
|
||||
/* mozilla::dom::ipc::MessageManagerFlags */ uint32_t aFlags);
|
||||
MessageManagerFlags aFlags);
|
||||
|
||||
private:
|
||||
~nsFrameMessageManager();
|
||||
virtual ~nsFrameMessageManager();
|
||||
|
||||
public:
|
||||
explicit nsFrameMessageManager(mozilla::dom::ipc::MessageManagerCallback* aCallback)
|
||||
: nsFrameMessageManager(aCallback, MessageManagerFlags::MM_NONE)
|
||||
{}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFrameMessageManager,
|
||||
nsIContentFrameMessageManager)
|
||||
|
||||
// MessageListenerManager
|
||||
void AddMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
bool aListenWhenClosed,
|
||||
mozilla::ErrorResult& aError);
|
||||
void RemoveMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
mozilla::ErrorResult& aError);
|
||||
void AddWeakMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
mozilla::ErrorResult& aError);
|
||||
void RemoveWeakMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListener& aListener,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
// MessageSender
|
||||
void SendAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JS::Handle<JS::Value> aTransfers,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
DispatchAsyncMessage(aCx, aMessageName, aObj, aObjects, aPrincipal, aTransfers,
|
||||
aError);
|
||||
}
|
||||
already_AddRefed<nsIMessageSender>
|
||||
GetProcessMessageManager(mozilla::ErrorResult& aError);
|
||||
void GetRemoteType(nsAString& aRemoteType, mozilla::ErrorResult& aError) const;
|
||||
|
||||
// SyncMessageSender
|
||||
void SendSyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
SendMessage(aCx, aMessageName, aObj, aObjects, aPrincipal, true, aResult, aError);
|
||||
}
|
||||
void SendRpcMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
nsTArray<JS::Value>& aResult,
|
||||
mozilla::ErrorResult& aError)
|
||||
{
|
||||
SendMessage(aCx, aMessageName, aObj, aObjects, aPrincipal, false, aResult, aError);
|
||||
}
|
||||
|
||||
// GlobalProcessScriptLoader
|
||||
void GetInitialProcessData(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aInitialProcessData,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
NS_DECL_NSIMESSAGELISTENERMANAGER
|
||||
NS_DECL_NSIMESSAGESENDER
|
||||
NS_DECL_NSIMESSAGEBROADCASTER
|
||||
|
@ -179,7 +262,7 @@ public:
|
|||
NS_DECL_NSIPROCESSSCRIPTLOADER
|
||||
NS_DECL_NSIGLOBALPROCESSSCRIPTLOADER
|
||||
|
||||
static nsFrameMessageManager*
|
||||
static mozilla::dom::ChromeMessageSender*
|
||||
NewProcessMessageManager(bool aIsRemote);
|
||||
|
||||
nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
|
||||
|
@ -188,15 +271,11 @@ public:
|
|||
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
|
||||
nsTArray<StructuredCloneData>* aRetVal);
|
||||
|
||||
void AddChildManager(nsFrameMessageManager* aManager);
|
||||
void RemoveChildManager(nsFrameMessageManager* aManager)
|
||||
{
|
||||
mChildManagers.RemoveObject(aManager);
|
||||
}
|
||||
void AddChildManager(mozilla::dom::MessageListenerManager* aManager);
|
||||
void RemoveChildManager(mozilla::dom::MessageListenerManager* aManager);
|
||||
void Disconnect(bool aRemoveFromParent = true);
|
||||
void Close();
|
||||
|
||||
void InitWithCallback(mozilla::dom::ipc::MessageManagerCallback* aCallback);
|
||||
void SetCallback(mozilla::dom::ipc::MessageManagerCallback* aCallback);
|
||||
|
||||
mozilla::dom::ipc::MessageManagerCallback* GetCallback()
|
||||
|
@ -217,14 +296,6 @@ public:
|
|||
StructuredCloneData& aData,
|
||||
JS::Handle<JSObject*> aCpows,
|
||||
nsIPrincipal* aPrincipal);
|
||||
void RemoveFromParent();
|
||||
nsFrameMessageManager* GetParentManager() { return mParentManager; }
|
||||
void SetParentManager(nsFrameMessageManager* aParent)
|
||||
{
|
||||
NS_ASSERTION(!mParentManager, "We have parent manager already!");
|
||||
NS_ASSERTION(mChrome, "Should not set parent manager!");
|
||||
mParentManager = aParent;
|
||||
}
|
||||
bool IsGlobal() { return mGlobal; }
|
||||
bool IsBroadcaster() { return mIsBroadcaster; }
|
||||
|
||||
|
@ -232,11 +303,11 @@ public:
|
|||
{
|
||||
return sParentProcessManager;
|
||||
}
|
||||
static nsFrameMessageManager* GetChildProcessManager()
|
||||
static mozilla::dom::ChildProcessMessageManager* GetChildProcessManager()
|
||||
{
|
||||
return sChildProcessManager;
|
||||
}
|
||||
static void SetChildProcessManager(nsFrameMessageManager* aManager)
|
||||
static void SetChildProcessManager(mozilla::dom::ChildProcessMessageManager* aManager)
|
||||
{
|
||||
sChildProcessManager = aManager;
|
||||
}
|
||||
|
@ -245,7 +316,24 @@ public:
|
|||
|
||||
void LoadPendingScripts();
|
||||
|
||||
private:
|
||||
protected:
|
||||
friend class MMListenerRemover;
|
||||
|
||||
virtual nsFrameMessageManager* GetParentManager()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
virtual void ClearParentManager(bool aRemove)
|
||||
{
|
||||
}
|
||||
|
||||
void DispatchAsyncMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj,
|
||||
JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JS::Handle<JS::Value> aTransfers,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
nsresult SendMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aJSON,
|
||||
JS::Handle<JS::Value> aObjects,
|
||||
|
@ -254,6 +342,14 @@ private:
|
|||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval,
|
||||
bool aIsSync);
|
||||
void SendMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObj, JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal, bool aIsSync, nsTArray<JS::Value>& aResult,
|
||||
mozilla::ErrorResult& aError);
|
||||
void SendMessage(JSContext* aCx, const nsAString& aMessageName,
|
||||
StructuredCloneData& aData, JS::Handle<JSObject*> aObjects,
|
||||
nsIPrincipal* aPrincipal, bool aIsSync,
|
||||
nsTArray<JS::Value>& aResult, mozilla::ErrorResult& aError);
|
||||
|
||||
nsresult ReceiveMessage(nsISupports* aTarget, nsIFrameLoader* aTargetFrameLoader,
|
||||
bool aTargetClosed, const nsAString& aMessage,
|
||||
|
@ -261,19 +357,28 @@ private:
|
|||
mozilla::jsipc::CpowHolder* aCpows, nsIPrincipal* aPrincipal,
|
||||
nsTArray<StructuredCloneData>* aRetVal);
|
||||
|
||||
NS_IMETHOD LoadScript(const nsAString& aURL,
|
||||
bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope);
|
||||
NS_IMETHOD RemoveDelayedScript(const nsAString& aURL);
|
||||
NS_IMETHOD GetDelayedScripts(JSContext* aCx, JS::MutableHandle<JS::Value> aList);
|
||||
void LoadScript(const nsAString& aURL, bool aAllowDelayedLoad,
|
||||
bool aRunInGlobalScope, mozilla::ErrorResult& aError);
|
||||
void RemoveDelayedScript(const nsAString& aURL);
|
||||
nsresult GetDelayedScripts(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aList);
|
||||
void GetDelayedScripts(JSContext* aCx, nsTArray<nsTArray<JS::Value>>& aList,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
enum ProcessCheckerType {
|
||||
PROCESS_CHECKER_PERMISSION,
|
||||
PROCESS_CHECKER_MANIFEST_URL,
|
||||
ASSERT_APP_HAS_PERMISSION
|
||||
};
|
||||
bool AssertProcessInternal(ProcessCheckerType aType,
|
||||
const nsAString& aCapability,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
||||
protected:
|
||||
friend class MMListenerRemover;
|
||||
// We keep the message listeners as arrays in a hastable indexed by the
|
||||
// message name. That gives us fast lookups in ReceiveMessage().
|
||||
nsClassHashtable<nsStringHashKey,
|
||||
nsAutoTObserverArray<nsMessageListenerInfo, 1>> mListeners;
|
||||
nsCOMArray<nsIContentFrameMessageManager> mChildManagers;
|
||||
nsTArray<RefPtr<mozilla::dom::MessageListenerManager>> mChildManagers;
|
||||
bool mChrome; // true if we're in the chrome process
|
||||
bool mGlobal; // true if we're the global frame message manager
|
||||
bool mIsProcessManager; // true if the message manager belongs to the process realm
|
||||
|
@ -284,7 +389,6 @@ protected:
|
|||
bool mDisconnected;
|
||||
mozilla::dom::ipc::MessageManagerCallback* mCallback;
|
||||
nsAutoPtr<mozilla::dom::ipc::MessageManagerCallback> mOwnedCallback;
|
||||
RefPtr<nsFrameMessageManager> mParentManager;
|
||||
nsTArray<nsString> mPendingScripts;
|
||||
nsTArray<bool> mPendingScriptsGlobalStates;
|
||||
JS::Heap<JS::Value> mInitialProcessData;
|
||||
|
@ -296,15 +400,13 @@ public:
|
|||
static nsFrameMessageManager* sSameProcessParentManager;
|
||||
static nsTArray<nsCOMPtr<nsIRunnable> >* sPendingSameProcessAsyncMessages;
|
||||
private:
|
||||
static nsFrameMessageManager* sChildProcessManager;
|
||||
enum ProcessCheckerType {
|
||||
PROCESS_CHECKER_PERMISSION,
|
||||
PROCESS_CHECKER_MANIFEST_URL,
|
||||
ASSERT_APP_HAS_PERMISSION
|
||||
};
|
||||
nsresult AssertProcessInternal(ProcessCheckerType aType,
|
||||
const nsAString& aCapability,
|
||||
bool* aValid);
|
||||
void AddMessageListener(const nsAString& aMessageName,
|
||||
mozilla::dom::MessageListenerHolder&& aListener,
|
||||
bool aListenWhenClosed);
|
||||
void RemoveMessageListener(const nsAString& aMessageName,
|
||||
const mozilla::dom::MessageListenerHolder& aListener);
|
||||
|
||||
static mozilla::dom::ChildProcessMessageManager* sChildProcessManager;
|
||||
};
|
||||
|
||||
/* A helper class for taking care of many details for async message sending
|
||||
|
@ -374,10 +476,6 @@ class nsMessageManagerScriptExecutor
|
|||
public:
|
||||
static void PurgeCache();
|
||||
static void Shutdown();
|
||||
JSObject* GetGlobal()
|
||||
{
|
||||
return mGlobal;
|
||||
}
|
||||
|
||||
void MarkScopesForCC();
|
||||
protected:
|
||||
|
@ -386,17 +484,20 @@ protected:
|
|||
~nsMessageManagerScriptExecutor() { MOZ_COUNT_DTOR(nsMessageManagerScriptExecutor); }
|
||||
|
||||
void DidCreateGlobal();
|
||||
void LoadScriptInternal(const nsAString& aURL, bool aRunInGlobalScope);
|
||||
void LoadScriptInternal(JS::Handle<JSObject*> aGlobal, const nsAString& aURL,
|
||||
bool aRunInGlobalScope);
|
||||
void TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
bool aRunInGlobalScope,
|
||||
bool aShouldCache,
|
||||
JS::MutableHandle<JSScript*> aScriptp);
|
||||
void TryCacheLoadAndCompileScript(const nsAString& aURL,
|
||||
bool aRunInGlobalScope);
|
||||
bool InitChildGlobalInternal(nsISupports* aScope, const nsACString& aID);
|
||||
bool InitChildGlobalInternal(const nsACString& aID);
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) = 0;
|
||||
void Trace(const TraceCallbacks& aCallbacks, void* aClosure);
|
||||
void Unlink();
|
||||
JS::TenuredHeap<JSObject*> mGlobal;
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
AutoTArray<JS::Heap<JSObject*>, 2> mAnonymousGlobalScopes;
|
||||
|
||||
|
|
|
@ -1244,8 +1244,7 @@ nsGlobalWindowInner::CleanUp()
|
|||
if (mCleanMessageManager) {
|
||||
MOZ_ASSERT(mIsChrome, "only chrome should have msg manager cleaned");
|
||||
if (mChromeFields.mMessageManager) {
|
||||
static_cast<nsFrameMessageManager*>(
|
||||
mChromeFields.mMessageManager.get())->Disconnect();
|
||||
mChromeFields.mMessageManager->Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7629,7 +7628,7 @@ nsGlobalWindowInner::GetMessageManager(nsIMessageBroadcaster** aManager)
|
|||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
nsIMessageBroadcaster*
|
||||
ChromeMessageBroadcaster*
|
||||
nsGlobalWindowInner::GetMessageManager(ErrorResult& aError)
|
||||
{
|
||||
MOZ_ASSERT(IsChromeWindow());
|
||||
|
@ -7637,9 +7636,7 @@ nsGlobalWindowInner::GetMessageManager(ErrorResult& aError)
|
|||
nsCOMPtr<nsIMessageBroadcaster> globalMM =
|
||||
do_GetService("@mozilla.org/globalmessagemanager;1");
|
||||
mChromeFields.mMessageManager =
|
||||
new nsFrameMessageManager(nullptr,
|
||||
static_cast<nsFrameMessageManager*>(globalMM.get()),
|
||||
MM_CHROME | MM_BROADCASTER);
|
||||
new ChromeMessageBroadcaster(static_cast<nsFrameMessageManager*>(globalMM.get()));
|
||||
}
|
||||
return mChromeFields.mMessageManager;
|
||||
}
|
||||
|
@ -7654,21 +7651,18 @@ nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
|
|||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
nsIMessageBroadcaster*
|
||||
ChromeMessageBroadcaster*
|
||||
nsGlobalWindowInner::GetGroupMessageManager(const nsAString& aGroup,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
MOZ_ASSERT(IsChromeWindow());
|
||||
|
||||
nsCOMPtr<nsIMessageBroadcaster> messageManager =
|
||||
RefPtr<ChromeMessageBroadcaster> messageManager =
|
||||
mChromeFields.mGroupMessageManagers.LookupForAdd(aGroup).OrInsert(
|
||||
[this, &aError] () {
|
||||
nsFrameMessageManager* parent =
|
||||
static_cast<nsFrameMessageManager*>(GetMessageManager(aError));
|
||||
nsFrameMessageManager* parent = GetMessageManager(aError);
|
||||
|
||||
return new nsFrameMessageManager(nullptr,
|
||||
parent,
|
||||
MM_CHROME | MM_BROADCASTER);
|
||||
return new ChromeMessageBroadcaster(parent);
|
||||
});
|
||||
return messageManager;
|
||||
}
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "prclist.h"
|
||||
#include "mozilla/dom/DOMPrefs.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
|
@ -947,8 +947,10 @@ public:
|
|||
void Restore();
|
||||
void NotifyDefaultButtonLoaded(mozilla::dom::Element& aDefaultButton,
|
||||
mozilla::ErrorResult& aError);
|
||||
nsIMessageBroadcaster* GetMessageManager(mozilla::ErrorResult& aError);
|
||||
nsIMessageBroadcaster* GetGroupMessageManager(const nsAString& aGroup,
|
||||
mozilla::dom::ChromeMessageBroadcaster*
|
||||
GetMessageManager(mozilla::ErrorResult& aError);
|
||||
mozilla::dom::ChromeMessageBroadcaster*
|
||||
GetGroupMessageManager(const nsAString& aGroup,
|
||||
mozilla::ErrorResult& aError);
|
||||
void BeginWindowMove(mozilla::dom::Event& aMouseDownEvent,
|
||||
mozilla::dom::Element* aPanel,
|
||||
|
@ -1277,9 +1279,9 @@ private:
|
|||
{
|
||||
MOZ_RELEASE_ASSERT(IsChromeWindow());
|
||||
for (auto iter = mChromeFields.mGroupMessageManagers.Iter(); !iter.Done(); iter.Next()) {
|
||||
nsIMessageBroadcaster* mm = iter.UserData();
|
||||
mozilla::dom::ChromeMessageBroadcaster* mm = iter.UserData();
|
||||
if (mm) {
|
||||
static_cast<nsFrameMessageManager*>(mm)->Disconnect();
|
||||
mm->Disconnect();
|
||||
}
|
||||
}
|
||||
mChromeFields.mGroupMessageManagers.Clear();
|
||||
|
@ -1485,8 +1487,9 @@ protected:
|
|||
: mGroupMessageManagers(1)
|
||||
{}
|
||||
|
||||
nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
|
||||
nsInterfaceHashtable<nsStringHashKey, nsIMessageBroadcaster> mGroupMessageManagers;
|
||||
RefPtr<mozilla::dom::ChromeMessageBroadcaster> mMessageManager;
|
||||
nsRefPtrHashtable<nsStringHashKey,
|
||||
mozilla::dom::ChromeMessageBroadcaster> mGroupMessageManagers;
|
||||
} mChromeFields;
|
||||
|
||||
// These fields are used by the inner and outer windows to prevent
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "mozilla/FlushType.h"
|
||||
#include "prclist.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/ChromeMessageBroadcaster.h"
|
||||
#include "mozilla/dom/StorageEvent.h"
|
||||
#include "mozilla/dom/StorageEventBinding.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
|
|
|
@ -1737,24 +1737,13 @@ public:
|
|||
return mCSSLoader;
|
||||
}
|
||||
|
||||
mozilla::StyleBackendType GetStyleBackendType() const {
|
||||
MOZ_ASSERT(mStyleBackendType != mozilla::StyleBackendType::None,
|
||||
"Not initialized yet");
|
||||
return mStyleBackendType;
|
||||
mozilla::StyleBackendType GetStyleBackendType() const
|
||||
{
|
||||
return mozilla::StyleBackendType::Servo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Documents generally decide their style backend type themselves, and
|
||||
* this is only used for XBL documents to set their style backend type to
|
||||
* their bounding document's.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Decide this document's own style backend type.
|
||||
*/
|
||||
void UpdateStyleBackendType();
|
||||
|
||||
bool IsStyledByServo() const {
|
||||
bool IsStyledByServo() const
|
||||
{
|
||||
return GetStyleBackendType() == mozilla::StyleBackendType::Servo;
|
||||
}
|
||||
|
||||
|
@ -4225,10 +4214,6 @@ protected:
|
|||
// Our readyState
|
||||
ReadyState mReadyState;
|
||||
|
||||
// Whether this document has (or will have, once we have a pres shell) a
|
||||
// Gecko- or Servo-backed style system.
|
||||
mozilla::StyleBackendType mStyleBackendType;
|
||||
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
// Our visibility state
|
||||
mozilla::dom::VisibilityState mVisibilityState;
|
||||
|
|
|
@ -203,7 +203,7 @@ interface nsIMessageListener : nsISupports
|
|||
void receiveMessage();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(b949bfec-bb7d-47bc-b387-ac6a9b655072)]
|
||||
[uuid(b949bfec-bb7d-47bc-b387-ac6a9b655072)]
|
||||
interface nsIMessageListenerManager : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -261,7 +261,7 @@ interface nsIMessageListenerManager : nsISupports
|
|||
* messages that are only delivered to its one parent-process message
|
||||
* manager.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)]
|
||||
[uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)]
|
||||
interface nsIMessageSender : nsIMessageListenerManager
|
||||
{
|
||||
/**
|
||||
|
@ -309,7 +309,7 @@ interface nsIMessageSender : nsIMessageListenerManager
|
|||
* manager will broadcast the message to all frame message managers
|
||||
* within its window.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(4d7d62ad-4725-4f39-86cf-8fb22bf9c1d8)]
|
||||
[uuid(4d7d62ad-4725-4f39-86cf-8fb22bf9c1d8)]
|
||||
interface nsIMessageBroadcaster : nsIMessageListenerManager
|
||||
{
|
||||
/**
|
||||
|
@ -342,7 +342,7 @@ interface nsIMessageBroadcaster : nsIMessageListenerManager
|
|||
void releaseCachedProcesses();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(0e602c9e-1977-422a-a8e4-fe0d4a4f78d0)]
|
||||
[uuid(0e602c9e-1977-422a-a8e4-fe0d4a4f78d0)]
|
||||
interface nsISyncMessageSender : nsIMessageSender
|
||||
{
|
||||
/**
|
||||
|
@ -372,7 +372,7 @@ interface nsISyncMessageSender : nsIMessageSender
|
|||
[optional] in nsIPrincipal principal);
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(13f3555f-769e-44ea-b607-5239230c3162)]
|
||||
[uuid(13f3555f-769e-44ea-b607-5239230c3162)]
|
||||
interface nsIMessageManagerGlobal : nsISyncMessageSender
|
||||
{
|
||||
/**
|
||||
|
@ -393,7 +393,7 @@ interface nsIMessageManagerGlobal : nsISyncMessageSender
|
|||
DOMString btoa(in DOMString aBase64Data);
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(694e367c-aa25-4446-8499-2c527c4bd838)]
|
||||
[uuid(694e367c-aa25-4446-8499-2c527c4bd838)]
|
||||
interface nsIContentFrameMessageManager : nsIMessageManagerGlobal
|
||||
{
|
||||
/**
|
||||
|
@ -420,7 +420,7 @@ interface nsIInProcessContentFrameMessageManager : nsIContentFrameMessageManager
|
|||
[notxpcom] void cacheFrameLoader(in nsIFrameLoader aFrameLoader);
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(6d12e467-2446-46db-9965-e4e93cb87ca5)]
|
||||
[uuid(6d12e467-2446-46db-9965-e4e93cb87ca5)]
|
||||
interface nsIContentProcessMessageManager : nsIMessageManagerGlobal
|
||||
{
|
||||
/**
|
||||
|
@ -431,7 +431,7 @@ interface nsIContentProcessMessageManager : nsIMessageManagerGlobal
|
|||
readonly attribute jsval initialProcessData;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(bf61446b-ba24-4b1d-88c7-4f94724b9ce1)]
|
||||
[uuid(bf61446b-ba24-4b1d-88c7-4f94724b9ce1)]
|
||||
interface nsIFrameScriptLoader : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -458,7 +458,7 @@ interface nsIFrameScriptLoader : nsISupports
|
|||
jsval getDelayedFrameScripts();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(7e1e1a20-b24f-11e4-ab27-0800200c9a66)]
|
||||
[uuid(7e1e1a20-b24f-11e4-ab27-0800200c9a66)]
|
||||
interface nsIProcessScriptLoader : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -483,7 +483,7 @@ interface nsIProcessScriptLoader : nsISupports
|
|||
jsval getDelayedProcessScripts();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(5b390753-abb3-49b0-ae3b-b803dab58144)]
|
||||
[uuid(5b390753-abb3-49b0-ae3b-b803dab58144)]
|
||||
interface nsIGlobalProcessScriptLoader : nsIProcessScriptLoader
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
#include "nsFrameLoader.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsIMozBrowserFrame.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/dom/ChromeMessageSender.h"
|
||||
#include "mozilla/dom/MessageManagerBinding.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
|
||||
|
@ -89,11 +90,11 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
|
|||
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
|
||||
nsIContent* aOwner,
|
||||
nsFrameMessageManager* aChrome)
|
||||
: mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
||||
: ContentFrameMessageManager(aChrome),
|
||||
mDocShell(aShell), mInitialized(false), mLoadingScript(false),
|
||||
mPreventEventsEscaping(false),
|
||||
mOwner(aOwner), mChromeMessageManager(aChrome)
|
||||
{
|
||||
SetIsNotDOMBinding();
|
||||
mozilla::HoldJSObjects(this);
|
||||
|
||||
// If owner corresponds to an <iframe mozbrowser>, we'll have to tweak our
|
||||
|
@ -119,7 +120,7 @@ NS_IMETHODIMP_(bool)
|
|||
nsInProcessTabChildGlobal::MarkForCC()
|
||||
{
|
||||
MarkScopesForCC();
|
||||
return mMessageManager ? mMessageManager->MarkForCC() : false;
|
||||
return MessageManagerGlobal::MarkForCC();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -131,9 +132,7 @@ nsInProcessTabChildGlobal::Init()
|
|||
InitTabChildGlobal();
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
"Couldn't initialize nsInProcessTabChildGlobal");
|
||||
mMessageManager = new nsFrameMessageManager(this,
|
||||
nullptr,
|
||||
dom::ipc::MM_CHILD);
|
||||
mMessageManager = new nsFrameMessageManager(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -169,43 +168,69 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsInProcessTabChildGlobal)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentFrameMessageManager)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(nsInProcessTabChildGlobal, DOMEventTargetHelper)
|
||||
|
||||
bool
|
||||
nsInProcessTabChildGlobal::WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector)
|
||||
{
|
||||
bool ok = ContentFrameMessageManagerBinding::Wrap(aCx, this, this, aOptions,
|
||||
nsJSPrincipals::get(mPrincipal),
|
||||
true, aReflector);
|
||||
if (ok) {
|
||||
// Since we can't rewrap we have to preserve the global's wrapper here.
|
||||
PreserveWrapper(ToSupports(this));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
nsInProcessTabChildGlobal::CacheFrameLoader(nsIFrameLoader* aFrameLoader)
|
||||
{
|
||||
mFrameLoader = aFrameLoader;
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIDOMWindowOuter>
|
||||
nsInProcessTabChildGlobal::GetContent(ErrorResult& aError)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowOuter> content;
|
||||
if (mDocShell) {
|
||||
content = mDocShell->GetWindow();
|
||||
}
|
||||
return content.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetContent(mozIDOMWindowProxy** aContent)
|
||||
{
|
||||
*aContent = nullptr;
|
||||
if (!mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = mDocShell->GetWindow();
|
||||
window.forget(aContent);
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
*aContent = GetContent(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetDocShell(nsIDocShell** aDocShell)
|
||||
{
|
||||
NS_IF_ADDREF(*aDocShell = mDocShell);
|
||||
return NS_OK;
|
||||
ErrorResult rv;
|
||||
*aDocShell = GetDocShell(rv).take();
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsInProcessTabChildGlobal::GetTabEventTarget()
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
|
||||
return target.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInProcessTabChildGlobal::GetTabEventTarget(nsIEventTarget** aTarget)
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> target = GetMainThreadEventTarget();
|
||||
target.forget(aTarget);
|
||||
*aTarget = GetTabEventTarget().take();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -312,8 +337,7 @@ nsInProcessTabChildGlobal::InitTabChildGlobal()
|
|||
id.AppendLiteral("?ownedBy=");
|
||||
id.Append(u);
|
||||
}
|
||||
nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, this);
|
||||
NS_ENSURE_STATE(InitChildGlobalInternal(scopeSupports, id));
|
||||
NS_ENSURE_STATE(InitChildGlobalInternal(id));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -353,7 +377,8 @@ nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL, bool aRunInGlo
|
|||
}
|
||||
bool tmp = mLoadingScript;
|
||||
mLoadingScript = true;
|
||||
LoadScriptInternal(aURL, aRunInGlobalScope);
|
||||
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());
|
||||
LoadScriptInternal(global, aURL, aRunInGlobalScope);
|
||||
mLoadingScript = tmp;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameMessageManager.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -27,7 +28,7 @@ namespace mozilla {
|
|||
class EventChainPreVisitor;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsInProcessTabChildGlobal : public mozilla::DOMEventTargetHelper,
|
||||
class nsInProcessTabChildGlobal : public mozilla::dom::ContentFrameMessageManager,
|
||||
public nsMessageManagerScriptExecutor,
|
||||
public nsIInProcessContentFrameMessageManager,
|
||||
public nsIGlobalObject,
|
||||
|
@ -46,38 +47,30 @@ public:
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal,
|
||||
mozilla::DOMEventTargetHelper)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override
|
||||
{
|
||||
MOZ_CRASH("We should never get here!");
|
||||
}
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
JS::CompartmentOptions& aOptions,
|
||||
JS::MutableHandle<JSObject*> aReflector) override;
|
||||
|
||||
virtual already_AddRefed<nsPIDOMWindowOuter>
|
||||
GetContent(mozilla::ErrorResult& aError) override;
|
||||
virtual already_AddRefed<nsIDocShell>
|
||||
GetDocShell(mozilla::ErrorResult& aError) override
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell(mDocShell);
|
||||
return docShell.forget();
|
||||
}
|
||||
virtual already_AddRefed<nsIEventTarget> GetTabEventTarget() override;
|
||||
|
||||
NS_FORWARD_SAFE_NSIMESSAGELISTENERMANAGER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
|
||||
NS_FORWARD_SAFE_NSISYNCMESSAGESENDER(mMessageManager);
|
||||
NS_FORWARD_SAFE_NSIMESSAGEMANAGERGLOBAL(mMessageManager)
|
||||
NS_IMETHOD SendSyncMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendSyncMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD SendRpcMessage(const nsAString& aMessageName,
|
||||
JS::Handle<JS::Value> aObject,
|
||||
JS::Handle<JS::Value> aRemote,
|
||||
nsIPrincipal* aPrincipal,
|
||||
JSContext* aCx,
|
||||
uint8_t aArgc,
|
||||
JS::MutableHandle<JS::Value> aRetval) override
|
||||
{
|
||||
return mMessageManager
|
||||
? mMessageManager->SendRpcMessage(aMessageName, aObject, aRemote,
|
||||
aPrincipal, aCx, aArgc, aRetval)
|
||||
: NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHOD GetContent(mozIDOMWindowProxy** aContent) override;
|
||||
NS_IMETHOD GetDocShell(nsIDocShell** aDocShell) override;
|
||||
NS_IMETHOD GetTabEventTarget(nsIEventTarget** aTarget) override;
|
||||
NS_DECL_NSICONTENTFRAMEMESSAGEMANAGER
|
||||
|
||||
NS_DECL_NSIINPROCESSCONTENTFRAMEMESSAGEMANAGER
|
||||
|
||||
|
@ -99,26 +92,6 @@ public:
|
|||
|
||||
virtual nsresult GetEventTargetParent(
|
||||
mozilla::EventChainPreVisitor& aVisitor) override;
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture)
|
||||
{
|
||||
// By default add listeners only for trusted events!
|
||||
return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture, false,
|
||||
2);
|
||||
}
|
||||
NS_IMETHOD AddEventListener(const nsAString& aType,
|
||||
nsIDOMEventListener* aListener,
|
||||
bool aUseCapture, bool aWantsUntrusted,
|
||||
uint8_t optional_argc) override
|
||||
{
|
||||
return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener,
|
||||
aUseCapture,
|
||||
aWantsUntrusted,
|
||||
optional_argc);
|
||||
}
|
||||
using mozilla::DOMEventTargetHelper::AddEventListener;
|
||||
|
||||
virtual nsIPrincipal* GetPrincipal() override { return mPrincipal; }
|
||||
void LoadFrameScript(const nsAString& aURL, bool aRunInGlobalScope);
|
||||
|
@ -143,12 +116,9 @@ public:
|
|||
mChromeMessageManager = aParent;
|
||||
}
|
||||
|
||||
virtual JSObject* GetGlobalJSObject() override {
|
||||
return mGlobal;
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
|
||||
virtual JSObject* GetGlobalJSObject() override
|
||||
{
|
||||
MOZ_CRASH("nsInProcessTabChildGlobal doesn't use DOM bindings!");
|
||||
return GetWrapper();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIFrameLoader> GetFrameLoader();
|
||||
|
@ -158,7 +128,6 @@ protected:
|
|||
|
||||
nsresult Init();
|
||||
nsresult InitTabChildGlobal();
|
||||
nsCOMPtr<nsIContentFrameMessageManager> mMessageManager;
|
||||
nsCOMPtr<nsIDocShell> mDocShell;
|
||||
bool mInitialized;
|
||||
bool mLoadingScript;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptElement.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
|
|
@ -344,11 +344,7 @@ private:
|
|||
// Friend declarations for things that need to be able to call
|
||||
// SetIsNotDOMBinding(). The goal is to get rid of all of these, and
|
||||
// SetIsNotDOMBinding() too.
|
||||
friend class mozilla::dom::TabChildGlobal;
|
||||
friend class mozilla::dom::ProcessGlobal;
|
||||
friend class SandboxPrivate;
|
||||
friend class nsInProcessTabChildGlobal;
|
||||
friend class nsWindowRoot;
|
||||
void SetIsNotDOMBinding()
|
||||
{
|
||||
MOZ_ASSERT(!mWrapper && !(GetWrapperFlags() & ~WRAPPER_IS_NOT_DOM_BINDING),
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
var ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
ppmm.QueryInterface(Ci.nsIProcessScriptLoader);
|
||||
|
||||
const BASE_NUMBER_OF_PROCESSES = 3;
|
||||
function checkBaseProcessCount(description) {
|
||||
const {childCount} = ppmm;
|
||||
const {childCount} = Services.ppmm;
|
||||
// With preloaded activity-stream, process count is a bit undeterministic, so
|
||||
// allow for some variation
|
||||
const extraCount = BASE_NUMBER_OF_PROCESSES + 1;
|
||||
|
@ -12,14 +8,12 @@ function checkBaseProcessCount(description) {
|
|||
}
|
||||
|
||||
function processScript() {
|
||||
let cpmm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsISyncMessageSender);
|
||||
if (cpmm !== this) {
|
||||
if (Services.cpmm !== this) {
|
||||
dump("Test failed: wrong global object\n");
|
||||
return;
|
||||
}
|
||||
|
||||
this.cpmm = cpmm;
|
||||
this.cpmm = Services.cpmm;
|
||||
|
||||
addMessageListener("ProcessTest:Reply", function listener(msg) {
|
||||
removeMessageListener("ProcessTest:Reply", listener);
|
||||
|
@ -70,7 +64,7 @@ add_task(async function(){
|
|||
if (!gMultiProcessBrowser)
|
||||
return;
|
||||
|
||||
ppmm.releaseCachedProcesses();
|
||||
Services.ppmm.releaseCachedProcesses();
|
||||
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.processCount", 5]]})
|
||||
await SpecialPowers.pushPrefEnv({"set": [["dom.ipc.keepProcessesAlive.web", 5]]})
|
||||
|
@ -88,17 +82,17 @@ add_task(async function(){
|
|||
await sessionStorePromise;
|
||||
}
|
||||
|
||||
ppmm.releaseCachedProcesses();
|
||||
Services.ppmm.releaseCachedProcesses();
|
||||
checkBaseProcessCount("Should get back to the base number of processes at this point");
|
||||
})
|
||||
|
||||
// Test that loading a process script loads in all existing processes
|
||||
add_task(async function() {
|
||||
let checks = [];
|
||||
for (let i = 0; i < ppmm.childCount; i++)
|
||||
checks.push(checkProcess(ppmm.getChildAt(i)));
|
||||
for (let i = 0; i < Services.ppmm.childCount; i++)
|
||||
checks.push(checkProcess(Services.ppmm.getChildAt(i)));
|
||||
|
||||
ppmm.loadProcessScript(processScriptURL, false);
|
||||
Services.ppmm.loadProcessScript(processScriptURL, false);
|
||||
await Promise.all(checks);
|
||||
});
|
||||
|
||||
|
@ -114,7 +108,7 @@ add_task(async function() {
|
|||
gBrowser.selectedBrowser.loadURI("about:robots");
|
||||
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
|
||||
|
||||
let init = ppmm.initialProcessData;
|
||||
let init = Services.ppmm.initialProcessData;
|
||||
init.test123 = "hello";
|
||||
init.test456 = new Map();
|
||||
init.test456.set("hi", "bye");
|
||||
|
@ -123,16 +117,16 @@ add_task(async function() {
|
|||
// However, stuff like remote thumbnails can cause a content
|
||||
// process to exist nonetheless. This should be rare, though,
|
||||
// so the test is useful most of the time.
|
||||
if (ppmm.childCount == 2) {
|
||||
let mainMM = ppmm.getChildAt(0);
|
||||
if (Services.ppmm.childCount == 2) {
|
||||
let mainMM = Services.ppmm.getChildAt(0);
|
||||
|
||||
let check = checkProcess(ppmm);
|
||||
ppmm.loadProcessScript(processScriptURL, true);
|
||||
let check = checkProcess(Services.ppmm);
|
||||
Services.ppmm.loadProcessScript(processScriptURL, true);
|
||||
|
||||
// The main process should respond
|
||||
await check;
|
||||
|
||||
check = checkProcess(ppmm);
|
||||
check = checkProcess(Services.ppmm);
|
||||
// Reset the default browser to start a new child process
|
||||
gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
|
||||
gBrowser.selectedBrowser.loadURI("about:blank");
|
||||
|
@ -143,10 +137,10 @@ add_task(async function() {
|
|||
// The new process should have responded
|
||||
await check;
|
||||
|
||||
ppmm.removeDelayedProcessScript(processScriptURL);
|
||||
Services.ppmm.removeDelayedProcessScript(processScriptURL);
|
||||
|
||||
let childMM;
|
||||
childMM = ppmm.getChildAt(2);
|
||||
childMM = Services.ppmm.getChildAt(2);
|
||||
|
||||
childMM.loadProcessScript(initTestScriptURL, false);
|
||||
let msg = await promiseMessage(childMM, "ProcessTest:InitGood");
|
||||
|
|
|
@ -11,8 +11,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1139964
|
|||
<label value="Mozilla Bug 1139964"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageBroadcaster);
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
|
||||
function ok(cond, msg) {
|
||||
opener.wrappedJSObject.ok(cond, msg);
|
||||
|
|
|
@ -14,12 +14,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682
|
|||
var didRunAsync = false;
|
||||
var didRunLocal = false;
|
||||
|
||||
var global = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsIMessageBroadcaster);
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsIMessageBroadcaster);
|
||||
var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Components.interfaces.nsISyncMessageSender);
|
||||
var global = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
var ppm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
|
||||
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -15,8 +15,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT = "data:,sendAsyncMessage('test')";
|
||||
var order = ["group", "window", "global"];
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -15,8 +15,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT = "data:,addMessageListener('test', function (msg) {" +
|
||||
"sendSyncMessage('test', msg.data)})";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -17,8 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'frame2')})";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -17,8 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'group2')})";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -16,8 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
|||
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
|
||||
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')";
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
|
|
|
@ -21,8 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098074
|
|||
// with SimpleTest.finish as a continuation function.
|
||||
SimpleTest.monitorConsole(SimpleTest.finish, [{errorMessage: new RegExp('acopia')}]);
|
||||
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"].getService();
|
||||
globalMM.addMessageListener("flimfniffle", function onMessage(msg) {
|
||||
globalMM.removeMessageListener("flimfniffle", onMessage);
|
||||
is(msg.data, "teufeltor", "correct message");
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
ChromeUtils.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
let obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].
|
||||
getService(Ci.nsIMessageBroadcaster);
|
||||
let ppmm = Cc["@mozilla.org/parentprocessmessagemanager;1"].getService();
|
||||
|
||||
function DummyHelperSubclass() {
|
||||
this.onuninit = null;
|
||||
|
|
|
@ -3127,11 +3127,22 @@ ConvertExceptionToPromise(JSContext* cx,
|
|||
|
||||
/* static */
|
||||
void
|
||||
CreateGlobalOptions<nsGlobalWindowInner>::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
CreateGlobalOptionsWithXPConnect::TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
{
|
||||
xpc::TraceXPCGlobal(aTrc, aObj);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
CreateGlobalOptionsWithXPConnect::PostCreateGlobal(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGlobal)
|
||||
{
|
||||
// Invoking the XPCWrappedNativeScope constructor automatically hooks it
|
||||
// up to the compartment of aGlobal.
|
||||
(void) new XPCWrappedNativeScope(aCx, aGlobal);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sRegisteredDOMNames = false;
|
||||
|
||||
nsresult
|
||||
|
@ -3165,10 +3176,7 @@ CreateGlobalOptions<nsGlobalWindowInner>::PostCreateGlobal(JSContext* aCx,
|
|||
return Throw(aCx, rv);
|
||||
}
|
||||
|
||||
// Invoking the XPCWrappedNativeScope constructor automatically hooks it
|
||||
// up to the compartment of aGlobal.
|
||||
(void) new XPCWrappedNativeScope(aCx, aGlobal);
|
||||
return true;
|
||||
return CreateGlobalOptionsWithXPConnect::PostCreateGlobal(aCx, aGlobal);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -50,6 +50,7 @@ enum UseCounter : int16_t;
|
|||
|
||||
namespace dom {
|
||||
class CustomElementReactionsStack;
|
||||
class MessageManagerGlobal;
|
||||
template<typename KeyType, typename ValueType> class Record;
|
||||
|
||||
nsresult
|
||||
|
@ -3100,11 +3101,9 @@ bool
|
|||
EnumerateGlobal(JSContext* aCx, JS::HandleObject aObj,
|
||||
JS::AutoIdVector& aProperties, bool aEnumerableOnly);
|
||||
|
||||
template <class T>
|
||||
struct CreateGlobalOptions
|
||||
|
||||
struct CreateGlobalOptionsGeneric
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::NonWindowLike;
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj)
|
||||
{
|
||||
mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj);
|
||||
|
@ -3117,12 +3116,34 @@ struct CreateGlobalOptions
|
|||
}
|
||||
};
|
||||
|
||||
struct CreateGlobalOptionsWithXPConnect
|
||||
{
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
|
||||
static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
using IsGlobalWithXPConnect =
|
||||
IntegralConstant<bool,
|
||||
IsBaseOf<nsGlobalWindowInner, T>::value ||
|
||||
IsBaseOf<MessageManagerGlobal, T>::value>;
|
||||
|
||||
template <class T>
|
||||
struct CreateGlobalOptions
|
||||
: Conditional<IsGlobalWithXPConnect<T>::value,
|
||||
CreateGlobalOptionsWithXPConnect,
|
||||
CreateGlobalOptionsGeneric>::Type
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::NonWindowLike;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct CreateGlobalOptions<nsGlobalWindowInner>
|
||||
: public CreateGlobalOptionsWithXPConnect
|
||||
{
|
||||
static constexpr ProtoAndIfaceCache::Kind ProtoAndIfaceCacheKind =
|
||||
ProtoAndIfaceCache::WindowLike;
|
||||
static void TraceGlobal(JSTracer* aTrc, JSObject* aObj);
|
||||
static bool PostCreateGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
};
|
||||
|
||||
|
@ -3203,7 +3224,7 @@ class PinnedStringId
|
|||
jsid id;
|
||||
|
||||
public:
|
||||
PinnedStringId() : id(JSID_VOID) {}
|
||||
constexpr PinnedStringId() : id(JSID_VOID) {}
|
||||
|
||||
bool init(JSContext *cx, const char *string) {
|
||||
JSString* str = JS_AtomizeAndPinString(cx, string);
|
||||
|
@ -3213,11 +3234,11 @@ class PinnedStringId
|
|||
return true;
|
||||
}
|
||||
|
||||
operator const jsid& () {
|
||||
operator const jsid& () const {
|
||||
return id;
|
||||
}
|
||||
|
||||
operator JS::Handle<jsid> () {
|
||||
operator JS::Handle<jsid> () const {
|
||||
/* This is safe because we have pinned the string. */
|
||||
return JS::Handle<jsid>::fromMarkedLocation(&id);
|
||||
}
|
||||
|
|
|
@ -151,6 +151,10 @@ DOMInterfaces = {
|
|||
'implicitJSContext': ['clear', 'count', 'groupEnd', 'time', 'timeEnd'],
|
||||
},
|
||||
|
||||
'ContentProcessMessageManager': {
|
||||
'nativeType': 'mozilla::dom::ProcessGlobal'
|
||||
},
|
||||
|
||||
'ConvolverNode': {
|
||||
'implicitJSContext': [ 'buffer' ],
|
||||
},
|
||||
|
@ -568,6 +572,18 @@ DOMInterfaces = {
|
|||
'headerFile': 'MediaRecorder.h',
|
||||
},
|
||||
|
||||
'MessageBroadcaster': {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'MessageListenerManager': {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'MessageSender': {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'MimeType': {
|
||||
'headerFile' : 'nsMimeTypeArray.h',
|
||||
'nativeType': 'nsMimeType',
|
||||
|
@ -1013,6 +1029,10 @@ DOMInterfaces = {
|
|||
'concrete': False,
|
||||
},
|
||||
|
||||
'SyncMessageSender' : {
|
||||
'concrete': False,
|
||||
},
|
||||
|
||||
'TestFunctions': {
|
||||
'wrapperCache': False
|
||||
},
|
||||
|
@ -1709,13 +1729,10 @@ addExternalIface('MozTreeView', nativeType='nsITreeView',
|
|||
addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h')
|
||||
addExternalIface('nsIBrowserDOMWindow', nativeType='nsIBrowserDOMWindow',
|
||||
notflattened=True)
|
||||
addExternalIface('nsIEventTarget', nativeType='nsIEventTarget', notflattened=True)
|
||||
addExternalIface('nsIFile', nativeType='nsIFile', notflattened=True)
|
||||
addExternalIface('nsILoadGroup', nativeType='nsILoadGroup',
|
||||
headerFile='nsILoadGroup.h', notflattened=True)
|
||||
addExternalIface('nsIMessageBroadcaster', nativeType='nsIMessageBroadcaster',
|
||||
headerFile='nsIMessageManager.h', notflattened=True)
|
||||
addExternalIface('nsIMessageSender', nativeType='nsIMessageSender',
|
||||
headerFile='nsIMessageManager.h', notflattened=True)
|
||||
addExternalIface('nsIPrintSettings', nativeType='nsIPrintSettings',
|
||||
notflattened=True)
|
||||
addExternalIface('nsISelectionListener', nativeType='nsISelectionListener')
|
||||
|
|
|
@ -281,12 +281,15 @@ class CGStringTable(CGThing):
|
|||
The uint16_t indices are smaller than the pointer equivalents, and the
|
||||
string table requires no runtime relocations.
|
||||
"""
|
||||
def __init__(self, accessorName, strings):
|
||||
def __init__(self, accessorName, strings, static=False):
|
||||
CGThing.__init__(self)
|
||||
self.accessorName = accessorName
|
||||
self.strings = strings
|
||||
self.static = static
|
||||
|
||||
def declare(self):
|
||||
if self.static:
|
||||
return ""
|
||||
return "extern const char *%s(unsigned int aIndex);\n" % self.accessorName
|
||||
|
||||
def define(self):
|
||||
|
@ -298,7 +301,7 @@ class CGStringTable(CGThing):
|
|||
currentIndex += len(s) + 1 # for the null terminator
|
||||
return fill(
|
||||
"""
|
||||
const char *${name}(unsigned int aIndex)
|
||||
${static}const char *${name}(unsigned int aIndex)
|
||||
{
|
||||
static const char table[] = ${table};
|
||||
static const uint16_t indices[] = { ${indices} };
|
||||
|
@ -306,6 +309,7 @@ class CGStringTable(CGThing):
|
|||
return &table[indices[aIndex]];
|
||||
}
|
||||
""",
|
||||
static="static " if self.static else "",
|
||||
name=self.accessorName,
|
||||
table=table,
|
||||
indices=", ".join("%d" % index for index in indices),
|
||||
|
@ -1103,7 +1107,7 @@ class CGHeaders(CGWrapper):
|
|||
interfacesImplementingSelf)
|
||||
|
||||
# Grab the includes for the things that involve XPCOM interfaces
|
||||
hasInstanceIncludes = set("nsIDOM" + d.interface.identifier.name + ".h" for d
|
||||
hasInstanceIncludes = set(self.getDeclarationFilename(d.interface) for d
|
||||
in descriptors if
|
||||
d.interface.hasInterfaceObject() and
|
||||
NeedsGeneratedHasInstance(d) and
|
||||
|
@ -13924,58 +13928,120 @@ class CGRegisterWorkletBindings(CGAbstractMethod):
|
|||
lines.append(CGGeneric("return true;\n"))
|
||||
return CGList(lines, "\n").define()
|
||||
|
||||
|
||||
class CGSystemBindingInitIds(CGAbstractMethod):
|
||||
def __init__(self):
|
||||
CGAbstractMethod.__init__(self, None, 'SystemBindingInitIds', 'bool',
|
||||
[Argument('JSContext*', 'aCx')])
|
||||
|
||||
def definition_body(self):
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!idsInited) {
|
||||
// We can't use range-based for because we need the index to call IdString.
|
||||
for (uint32_t i = 0; i < ArrayLength(properties); ++i) {
|
||||
if (!properties[i].id.init(aCx, IdString(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
idsInited = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
""")
|
||||
|
||||
|
||||
class CGResolveSystemBinding(CGAbstractMethod):
|
||||
def __init__(self, config):
|
||||
def __init__(self):
|
||||
CGAbstractMethod.__init__(self, None, 'ResolveSystemBinding', 'bool',
|
||||
[Argument('JSContext*', 'aCx'),
|
||||
Argument('JS::Handle<JSObject*>', 'aObj'),
|
||||
Argument('JS::Handle<jsid>', 'aId'),
|
||||
Argument('bool*', 'aResolvedp')])
|
||||
self.config = config
|
||||
|
||||
def definition_body(self):
|
||||
descriptors = self.config.getDescriptors(hasInterfaceObject=True,
|
||||
isExposedInSystemGlobals=True,
|
||||
register=True)
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(idsInited);
|
||||
|
||||
def descNameToId(name):
|
||||
return "s%s_id" % name
|
||||
jsidNames = [descNameToId(desc.name) for desc in descriptors]
|
||||
jsidDecls = CGList(CGGeneric("static jsid %s;\n" % name)
|
||||
for name in jsidNames)
|
||||
if (JSID_IS_VOID(aId)) {
|
||||
for (const auto& property : properties) {
|
||||
if (!property.enabled || property.enabled(aCx, aObj)) {
|
||||
if (!property.define(aCx)) {
|
||||
return false;
|
||||
}
|
||||
*aResolvedp = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
jsidInits = CGList(
|
||||
(CGIfWrapper(
|
||||
CGGeneric("return false;\n"),
|
||||
'!AtomizeAndPinJSString(aCx, %s, "%s")' %
|
||||
(descNameToId(desc.name), desc.interface.identifier.name))
|
||||
for desc in descriptors),
|
||||
"\n")
|
||||
jsidInits.append(CGGeneric("idsInited = true;\n"))
|
||||
jsidInits = CGIfWrapper(jsidInits, "!idsInited")
|
||||
jsidInits = CGList([CGGeneric("static bool idsInited = false;\n"),
|
||||
jsidInits])
|
||||
for (const auto& property : properties) {
|
||||
if (property.id == aId) {
|
||||
if (!property.enabled || property.enabled(aCx, aObj)) {
|
||||
if (!property.define(aCx)) {
|
||||
return false;
|
||||
}
|
||||
*aResolvedp = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
""")
|
||||
|
||||
definitions = CGList([], "\n")
|
||||
for desc in descriptors:
|
||||
bindingNS = toBindingNamespace(desc.name)
|
||||
defineCode = "!%s::GetConstructorObject(aCx)" % bindingNS
|
||||
defineCode = CGIfWrapper(CGGeneric("return false;\n"), defineCode)
|
||||
defineCode = CGList([defineCode,
|
||||
CGGeneric("*aResolvedp = true;\n")])
|
||||
|
||||
condition = "JSID_IS_VOID(aId) || aId == %s" % descNameToId(desc.name)
|
||||
if desc.isExposedConditionally():
|
||||
condition = "(%s) && %s::ConstructorEnabled(aCx, aObj)" % (condition, bindingNS)
|
||||
class CGMayResolveAsSystemBindingName(CGAbstractMethod):
|
||||
def __init__(self):
|
||||
CGAbstractMethod.__init__(self, None, 'MayResolveAsSystemBindingName', 'bool',
|
||||
[Argument('jsid', 'aId')])
|
||||
|
||||
definitions.append(CGIfWrapper(defineCode, condition))
|
||||
def definition_body(self):
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(idsInited);
|
||||
|
||||
return CGList([CGGeneric("MOZ_ASSERT(NS_IsMainThread());\n"),
|
||||
jsidDecls,
|
||||
jsidInits,
|
||||
definitions,
|
||||
CGGeneric("return true;\n")],
|
||||
"\n").define()
|
||||
for (const auto& property : properties) {
|
||||
if (aId == property.id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
""")
|
||||
|
||||
|
||||
class CGGetSystemBindingNames(CGAbstractMethod):
|
||||
def __init__(self):
|
||||
CGAbstractMethod.__init__(self, None, 'GetSystemBindingNames', 'void',
|
||||
[Argument('JSContext*', 'aCx'),
|
||||
Argument('JS::Handle<JSObject*>', 'aObj'),
|
||||
Argument('JS::AutoIdVector&', 'aNames'),
|
||||
Argument('bool', 'aEnumerableOnly'),
|
||||
Argument('mozilla::ErrorResult&', 'aRv')])
|
||||
|
||||
def definition_body(self):
|
||||
return dedent("""
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (aEnumerableOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SystemBindingInitIds(aCx)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& property : properties) {
|
||||
if (!property.enabled || property.enabled(aCx, aObj)) {
|
||||
if (!aNames.append(property.id)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
|
||||
def getGlobalNames(config):
|
||||
|
@ -17474,8 +17540,44 @@ class GlobalGenRoots():
|
|||
|
||||
@staticmethod
|
||||
def ResolveSystemBinding(config):
|
||||
curr = CGList([], "\n")
|
||||
|
||||
curr = CGResolveSystemBinding(config)
|
||||
descriptors = config.getDescriptors(hasInterfaceObject=True,
|
||||
isExposedInSystemGlobals=True,
|
||||
register=True)
|
||||
properties = [desc.name for desc in descriptors]
|
||||
|
||||
curr.append(CGStringTable("IdString", properties, static=True))
|
||||
|
||||
initValues = []
|
||||
for desc in descriptors:
|
||||
bindingNS = toBindingNamespace(desc.name)
|
||||
if desc.isExposedConditionally():
|
||||
enabled = "%s::ConstructorEnabled" % bindingNS
|
||||
else:
|
||||
enabled = "nullptr"
|
||||
define = "%s::GetConstructorObject" % bindingNS
|
||||
initValues.append("{ %s, %s },\n" % (enabled, define))
|
||||
curr.append(CGGeneric(fill("""
|
||||
struct SystemProperty
|
||||
{
|
||||
WebIDLGlobalNameHash::ConstructorEnabled enabled;
|
||||
ProtoGetter define;
|
||||
PinnedStringId id;
|
||||
};
|
||||
|
||||
static SystemProperty properties[] = {
|
||||
$*{init}
|
||||
};
|
||||
|
||||
static bool idsInited = false;
|
||||
""",
|
||||
init="".join(initValues))))
|
||||
|
||||
curr.append(CGSystemBindingInitIds())
|
||||
curr.append(CGResolveSystemBinding())
|
||||
curr.append(CGMayResolveAsSystemBindingName())
|
||||
curr.append(CGGetSystemBindingNames())
|
||||
|
||||
# Wrap all of that in our namespaces.
|
||||
curr = CGNamespace.build(['mozilla', 'dom'],
|
||||
|
@ -17489,7 +17591,7 @@ class GlobalGenRoots():
|
|||
isExposedInSystemGlobals=True)]
|
||||
defineIncludes.append("nsThreadUtils.h") # For NS_IsMainThread
|
||||
defineIncludes.append("js/Id.h") # For jsid
|
||||
defineIncludes.append("mozilla/dom/BindingUtils.h") # AtomizeAndPinJSString
|
||||
defineIncludes.append("mozilla/dom/WebIDLGlobalNameHash.h")
|
||||
|
||||
curr = CGHeaders([], [], [], [], [], defineIncludes,
|
||||
'ResolveSystemBinding', curr)
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче