tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_AppInfo.js (1333B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const { AppConstants } = ChromeUtils.importESModule(
      8  "resource://gre/modules/AppConstants.sys.mjs"
      9 );
     10 
     11 const { AppInfo, getTimeoutMultiplier } = ChromeUtils.importESModule(
     12  "chrome://remote/content/shared/AppInfo.sys.mjs"
     13 );
     14 
     15 // Minimal xpcshell tests for AppInfo; Services.appinfo.* is not available
     16 
     17 add_task(function test_custom_properties() {
     18  const properties = [
     19    // platforms
     20    "isAndroid",
     21    "isLinux",
     22    "isMac",
     23    "isWindows",
     24    // applications
     25    "isFirefox",
     26    "isThunderbird",
     27  ];
     28 
     29  for (const prop of properties) {
     30    equal(
     31      typeof AppInfo[prop],
     32      "boolean",
     33      `Custom property ${prop} has expected type`
     34    );
     35  }
     36 });
     37 
     38 add_task(function test_getTimeoutMultiplier() {
     39  const message = "Timeout multiplier has expected value";
     40  const timeoutMultiplier = getTimeoutMultiplier();
     41 
     42  if (
     43    AppConstants.DEBUG ||
     44    AppConstants.MOZ_CODE_COVERAGE ||
     45    AppConstants.ASAN
     46  ) {
     47    equal(timeoutMultiplier, 4, message);
     48  } else if (AppConstants.TSAN) {
     49    equal(timeoutMultiplier, 8, message);
     50  } else {
     51    equal(timeoutMultiplier, 1, message);
     52  }
     53 });