tor-browser

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

test_ChromeMigrationUtils.js (2421B)


      1 "use strict";
      2 
      3 const { ChromeMigrationUtils } = ChromeUtils.importESModule(
      4  "resource:///modules/ChromeMigrationUtils.sys.mjs"
      5 );
      6 
      7 // Setup chrome user data path for all platforms.
      8 ChromeMigrationUtils.getDataPath = () => {
      9  return Promise.resolve(
     10    do_get_file("Library/Application Support/Google/Chrome/").path
     11  );
     12 };
     13 
     14 add_task(async function test_getExtensionList_function() {
     15  let extensionList = await ChromeMigrationUtils.getExtensionList("Default");
     16  Assert.equal(
     17    extensionList.length,
     18    2,
     19    "There should be 2 extensions installed."
     20  );
     21  Assert.deepEqual(
     22    extensionList.find(extension => extension.id == "fake-extension-1"),
     23    {
     24      id: "fake-extension-1",
     25      name: "Fake Extension 1",
     26      description: "It is the description of fake extension 1.",
     27    },
     28    "First extension should match expectations."
     29  );
     30  Assert.deepEqual(
     31    extensionList.find(extension => extension.id == "fake-extension-2"),
     32    {
     33      id: "fake-extension-2",
     34      name: "Fake Extension 2",
     35      // There is no description in the `manifest.json` file of this extension.
     36      description: null,
     37    },
     38    "Second extension should match expectations."
     39  );
     40 });
     41 
     42 add_task(async function test_getExtensionInformation_function() {
     43  let extension = await ChromeMigrationUtils.getExtensionInformation(
     44    "fake-extension-1",
     45    "Default"
     46  );
     47  Assert.deepEqual(
     48    extension,
     49    {
     50      id: "fake-extension-1",
     51      name: "Fake Extension 1",
     52      description: "It is the description of fake extension 1.",
     53    },
     54    "Should get the extension information correctly."
     55  );
     56 });
     57 
     58 add_task(async function test_getLocaleString_function() {
     59  let name = await ChromeMigrationUtils._getLocaleString(
     60    "__MSG_name__",
     61    "en_US",
     62    "fake-extension-1",
     63    "Default"
     64  );
     65  Assert.deepEqual(
     66    name,
     67    "Fake Extension 1",
     68    "The value of __MSG_name__ locale key is Fake Extension 1."
     69  );
     70 });
     71 
     72 add_task(async function test_isExtensionInstalled_function() {
     73  let isInstalled = await ChromeMigrationUtils.isExtensionInstalled(
     74    "fake-extension-1",
     75    "Default"
     76  );
     77  Assert.ok(isInstalled, "The fake-extension-1 extension should be installed.");
     78 });
     79 
     80 add_task(async function test_getLastUsedProfileId_function() {
     81  let profileId = await ChromeMigrationUtils.getLastUsedProfileId();
     82  Assert.equal(
     83    profileId,
     84    "Default",
     85    "The last used profile ID should be Default."
     86  );
     87 });