Bug 1313741 - Use AppConstants in DOM and XPConnect tests instead of manual detection. r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D30973

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ryan VanderMeulen 2019-05-14 21:01:05 +00:00
parent 3e08d898d0
commit 8f5477d25e
8 changed files with 41 additions and 38 deletions

View File

@ -2176,10 +2176,9 @@ var setupIceServerConfig = useIceServer => {
async function runNetworkTest(testFunction, fixtureOptions = {}) {
let version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].
getService(SpecialPowers.Ci.nsIXULAppInfo).version;
let isNightly = version.endsWith("a1");
let isAndroid = !!navigator.userAgent.includes("Android");
let {AppConstants} = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
let isNightly = AppConstants.NIGHTLY_BUILD;
let isAndroid = AppConstants.platform == "android";
await scriptsReady;
await runTestWhenReady(async options =>

View File

@ -42,20 +42,21 @@
});
} else if (event.data.type == 'getHelperData') {
const version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
const isNightly = version.endsWith("a1");
const isEarlyBetaOrEarlier = SpecialPowers.EARLY_BETA_OR_EARLIER;
const isRelease = !version.includes("a");
const {AppConstants} = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
const isNightly = AppConstants.NIGHTLY_BUILD;
const isEarlyBetaOrEarlier = AppConstants.EARLY_BETA_OR_EARLIER;
const isRelease = AppConstants.RELEASE_OR_BETA;
const isDesktop = !/Mobile|Tablet/.test(navigator.userAgent);
const isMac = /Mac OS/.test(navigator.oscpu);
const isWindows = /Windows/.test(navigator.oscpu);
const isAndroid = navigator.userAgent.includes("Android");
const isLinux = /Linux/.test(navigator.oscpu) && !isAndroid;
const isMac = AppConstants.platform == "macosx";
const isWindows = AppConstants.platform == "win";
const isAndroid = AppConstants.platform == "android";
const isLinux = AppConstants.platform == "linux";
const isInsecureContext = !window.isSecureContext;
// Currently, MOZ_APP_NAME is always "fennec" for all mobile builds, so we can't use AppConstants for this
const isFennec = isAndroid && SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(SpecialPowers.Ci.nsIAndroidBridge).isFennec;
const result = {
version, isNightly, isEarlyBetaOrEarlier, isRelease, isDesktop, isMac,
isNightly, isEarlyBetaOrEarlier, isRelease, isDesktop, isMac,
isWindows, isAndroid, isLinux, isInsecureContext, isFennec
};

View File

@ -242,7 +242,7 @@ var interfaceNamesInGlobalScope =
];
// IMPORTANT: Do not change the list above without review from a DOM peer!
function createInterfaceMap({ version, isNightly, isRelease, isDesktop, isAndroid, isInsecureContext, isFennec }) {
function createInterfaceMap({ isNightly, isRelease, isDesktop, isAndroid, isInsecureContext, isFennec }) {
var interfaceMap = {};
function addInterfaces(interfaces)

View File

@ -25,16 +25,18 @@
// channel/OS) or one of the is* constants below (in cases when
// exposure is affected by channel or OS in a nontrivial way).
const version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
const isNightly = version.endsWith("a1");
const isEarlyBetaOrEarlier = SpecialPowers.EARLY_BETA_OR_EARLIER;
const isRelease = !version.includes("a");
const {AppConstants} = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
const isNightly = AppConstants.NIGHTLY_BUILD;
const isEarlyBetaOrEarlier = AppConstants.EARLY_BETA_OR_EARLIER;
const isRelease = AppConstants.RELEASE_OR_BETA;
const isDesktop = !/Mobile|Tablet/.test(navigator.userAgent);
const isMac = /Mac OS/.test(navigator.oscpu);
const isWindows = /Windows/.test(navigator.oscpu);
const isAndroid = navigator.userAgent.includes("Android");
const isLinux = /Linux/.test(navigator.oscpu) && !isAndroid;
const isMac = AppConstants.platform == "macosx";
const isWindows = AppConstants.platform == "win";
const isAndroid = AppConstants.platform == "android";
const isLinux = AppConstants.platform == "linux";
const isInsecureContext = !window.isSecureContext;
// Currently, MOZ_APP_NAME is always "fennec" for all mobile builds, so we can't use AppConstants for this
const isFennec = isAndroid && SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(SpecialPowers.Ci.nsIAndroidBridge).isFennec;
// IMPORTANT: Do not change this list without review from

View File

@ -46,8 +46,8 @@ worker.onerror = function(event) {
SimpleTest.finish();
}
var version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
var isNightly = version.endsWith("a1");
var isRelease = !version.includes("a");
var {AppConstants} = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
var isNightly = AppConstants.NIGHTLY_BUILD;
var isRelease = AppConstants.RELEASE_OR_BETA;
worker.postMessage({ isNightly, isRelease });

View File

@ -262,7 +262,7 @@ var interfaceNamesInGlobalScope =
];
// IMPORTANT: Do not change the list above without review from a DOM peer!
function createInterfaceMap({ version, isNightly, isRelease, isDesktop, isAndroid, isInsecureContext, isFennec }) {
function createInterfaceMap({ isNightly, isRelease, isDesktop, isAndroid, isInsecureContext, isFennec }) {
var interfaceMap = {};
function addInterfaces(interfaces)

View File

@ -36,20 +36,21 @@ function workerTestExec(script) {
ok(event.data.status, event.data.msg);
} else if (event.data.type == 'getHelperData') {
const version = SpecialPowers.Cc["@mozilla.org/xre/app-info;1"].getService(SpecialPowers.Ci.nsIXULAppInfo).version;
const isNightly = version.endsWith("a1");
const isEarlyBetaOrEarlier = SpecialPowers.EARLY_BETA_OR_EARLIER;
const isRelease = !version.includes("a");
const {AppConstants} = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
const isNightly = AppConstants.NIGHTLY_BUILD;
const isEarlyBetaOrEarlier = AppConstants.EARLY_BETA_OR_EARLIER;
const isRelease = AppConstants.RELEASE_OR_BETA;
const isDesktop = !/Mobile|Tablet/.test(navigator.userAgent);
const isMac = /Mac OS/.test(navigator.oscpu);
const isWindows = /Windows/.test(navigator.oscpu);
const isAndroid = navigator.userAgent.includes("Android");
const isLinux = /Linux/.test(navigator.oscpu) && !isAndroid;
const isMac = AppConstants.platform == "macosx";
const isWindows = AppConstants.platform == "win";
const isAndroid = AppConstants.platform == "android";
const isLinux = AppConstants.platform == "linux";
const isInsecureContext = !window.isSecureContext;
// Currently, MOZ_APP_NAME is always "fennec" for all mobile builds, so we can't use AppConstants for this
const isFennec = isAndroid && SpecialPowers.Cc["@mozilla.org/android/bridge;1"].getService(SpecialPowers.Ci.nsIAndroidBridge).isFennec;
const result = {
version, isNightly, isEarlyBetaOrEarlier, isRelease, isDesktop, isMac,
isNightly, isEarlyBetaOrEarlier, isRelease, isDesktop, isMac,
isWindows, isAndroid, isLinux, isInsecureContext, isFennec
};

View File

@ -170,9 +170,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
// Xray-safe.
//
// DO NOT CHANGE WTIHOUT REVIEW FROM AN XPCONNECT PEER.
var version = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo).version;
var isNightlyBuild = version.endsWith("a1");
var isReleaseOrBeta = !version.includes("a");
var {AppConstants} = SpecialPowers.Cu.import("resource://gre/modules/AppConstants.jsm", {});
var isNightlyBuild = AppConstants.NIGHTLY_BUILD;
var isReleaseOrBeta = AppConstants.RELEASE_OR_BETA;
var gPrototypeProperties = {};
var gConstructorProperties = {};
function constructorProps(arr) {