fune/toolkit/components/extensions/test/xpcshell/test_ext_startup_perf.js
Geoff Lankow 562dce7047 Bug 1671301 - Changes required for Thunderbird to have remote extensions. r=robwu
Thunderbird runs content scripts on browsers which are, for the time being, stuck in the parent process. This needs to keep working once we enable extensions in remote processes.

This patch also enables the tests for remote extensions when run as Thunderbird.

Differential Revision: https://phabricator.services.mozilla.com/D99175
2021-01-20 01:09:20 +00:00

73 lines
2.1 KiB
JavaScript

/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
const STARTUP_APIS = ["backgroundPage"];
const STARTUP_MODULES = [
"resource://gre/modules/Extension.jsm",
"resource://gre/modules/ExtensionCommon.jsm",
"resource://gre/modules/ExtensionParent.jsm",
// FIXME: This is only loaded at startup for new extension installs.
// Otherwise the data comes from the startup cache. We should test for
// this.
"resource://gre/modules/ExtensionPermissions.jsm",
"resource://gre/modules/ExtensionProcessScript.jsm",
"resource://gre/modules/ExtensionUtils.jsm",
"resource://gre/modules/ExtensionTelemetry.jsm",
];
if (!Services.prefs.getBoolPref("extensions.webextensions.remote")) {
STARTUP_MODULES.push(
"resource://gre/modules/ExtensionChild.jsm",
"resource://gre/modules/ExtensionPageChild.jsm"
);
}
if (AppConstants.MOZ_APP_NAME == "thunderbird") {
STARTUP_MODULES.push(
"resource://gre/modules/ExtensionChild.jsm",
"resource://gre/modules/ExtensionContent.jsm",
"resource://gre/modules/ExtensionPageChild.jsm"
);
}
AddonTestUtils.init(this);
// Tests that only the minimal set of API scripts and modules are loaded at
// startup for a simple extension.
add_task(async function test_loaded_scripts() {
await ExtensionTestUtils.startAddonManager();
let extension = ExtensionTestUtils.loadExtension({
useAddonManager: "temporary",
background() {},
manifest: {},
});
await extension.startup();
const { apiManager } = ExtensionParent;
const loadedAPIs = Array.from(apiManager.modules.values())
.filter(m => m.loaded || m.asyncLoaded)
.map(m => m.namespaceName);
deepEqual(
loadedAPIs.sort(),
STARTUP_APIS,
"No extra APIs should be loaded at startup for a simple extension"
);
let loadedModules = Cu.loadedModules.filter(url =>
url.startsWith("resource://gre/modules/Extension")
);
deepEqual(
loadedModules.sort(),
STARTUP_MODULES.sort(),
"No extra extension modules should be loaded at startup for a simple extension"
);
await extension.unload();
});