From 503cf68b4bcba1f5224219c885e1e6196561a1de Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 1 Mar 2018 12:32:33 -0500 Subject: [PATCH] Bug 1441927 part 2. Move the is* constants to the top of test_interfaces.js so we can use them in our property lists. r=bkelly MozReview-Commit-ID: FXqx6tn4W32 --- .../mochitest/general/test_interfaces.js | 25 +++++++++++-------- dom/workers/test/test_worker_interfaces.js | 6 +++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index eae7b280d642..290947dab584 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -20,6 +20,21 @@ // ]; // // See createInterfaceMap() below for a complete list of properties. +// +// The values of the properties need to be either literal true/false +// (e.g. indicating whether something is enabled on a particular +// 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 isRelease = !version.includes("a"); +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 isInsecureContext = !window.isSecureContext; // IMPORTANT: Do not change this list without review from // a JavaScript Engine peer! @@ -1267,16 +1282,6 @@ var interfaceNamesInGlobalScope = // IMPORTANT: Do not change the list above without review from a DOM peer! function createInterfaceMap(isXBLScope) { - 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 isDesktop = !/Mobile|Tablet/.test(navigator.userAgent); - var isMac = /Mac OS/.test(navigator.oscpu); - var isWindows = /Windows/.test(navigator.oscpu); - var isAndroid = navigator.userAgent.includes("Android"); - var isLinux = /Linux/.test(navigator.oscpu) && !isAndroid; - var isInsecureContext = !window.isSecureContext; - var interfaceMap = {}; function addInterfaces(interfaces) diff --git a/dom/workers/test/test_worker_interfaces.js b/dom/workers/test/test_worker_interfaces.js index f11c49d5e0b3..8d2d498ca522 100644 --- a/dom/workers/test/test_worker_interfaces.js +++ b/dom/workers/test/test_worker_interfaces.js @@ -18,6 +18,12 @@ // ]; // // See createInterfaceMap() below for a complete list of properties. +// +// The values of the properties need to be literal true/false +// (e.g. indicating whether something is enabled on a particular +// channel/OS). If we ever end up in a situation where a propert +// value needs to depend on channel or OS, we will need to make sure +// we have that information before setting up the property lists. // IMPORTANT: Do not change this list without review from // a JavaScript Engine peer!