tor-browser

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

theme_aiwindow.js (1713B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 ChromeUtils.defineESModuleGetters(this, {
      7  AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
      8 });
      9 
     10 var { AddonTestUtils } = ChromeUtils.importESModule(
     11  "resource://testing-common/AddonTestUtils.sys.mjs"
     12 );
     13 
     14 AddonTestUtils.init(this);
     15 AddonTestUtils.overrideCertDB();
     16 AddonTestUtils.createAppInfo(
     17  "xpcshell@tests.mozilla.org",
     18  "XPCShell",
     19  "1",
     20  "147"
     21 );
     22 
     23 const AI_WINDOW_THEME_ID = "firefox-aiwindow@mozilla.org";
     24 
     25 add_setup(async function () {
     26  await AddonTestUtils.promiseStartupManager();
     27 });
     28 
     29 // The AI window's theme is loaded from manifest.json by LWT without the
     30 // extension framework, which means that the manifest is not validated against
     31 // extensions/schemas/theme.json.
     32 // To make sure that the aiwindow's manifest.json is valid, we load it as an
     33 // extension here. Any errors (and even warnings) in the manifest.json file
     34 // will cause this test to fail. Warnings are turned into errors because
     35 // extensions.webextensions.warnings-as-errors defaults to true in unit tests.
     36 add_task(async function test_ai_theme_manifest_is_valid() {
     37  info("Validating AI window theme manifest through AddonManager");
     38 
     39  const themeURI = "resource://builtin-themes/aiwindow/";
     40  const addon = await AddonManager.installBuiltinAddon(themeURI);
     41 
     42  Assert.ok(addon, "Theme manifest should be valid and loadable");
     43  Assert.equal(addon.id, AI_WINDOW_THEME_ID, "Theme should have correct ID");
     44  Assert.equal(addon.type, "theme", "Should be recognized as a theme");
     45  Assert.equal(addon.name, "Firefox AI Window", "Should have correct name");
     46 
     47  await addon.uninstall();
     48 });