Skip to content

Instantly share code, notes, and snippets.

const PROXY_PREFS_TO_PROPERTIES_MAP = new Map([
["network.proxy.autoconfig_url", "automaticProxyConfigUrl"],
["signon.autologin.proxy", "autoLogin"],
["network.proxy.socks_remote_dns", "proxyDNSForSocks5"],
]);
const getProxyPref = propertyName => {
return Array.from(
PROXY_PREFS_TO_PROPERTIES_MAP.entries()).find(entry => entry[1] === propertyName)[0];
};
function showEnableExtensionMessage(settingName) {
let elements = getControllingExtensionEls(settingName);
if (elements.button
&& extensionControlledIds[settingName]
&& !document.hidden) {
elements.button.hidden = true;
elements.section.classList.add("extension-controlled-disabled");
let icon = url => `<image src="${url}" class="extension-controlled-icon"/>`;
let addonIcon = icon("chrome://mozapps/skin/extensions/extensionGeneric-16.svg");
let toolbarIcon = icon("chrome://browser/skin/menu.svg");
add_task(async function test_exceptions() {
async function background() {
await browser.test.assertRejects(
browser.browserSettings.contextMenuShowEvent.set({value: "bad"}),
/bad is not a valid value for contextMenuShowEvent/,
"contextMenuShowEvent.set rejects with an invalid value.");
browser.test.sendMessage("done");
}
842 INFO Entering test bound testBrowserActionInPanel
843 INFO Extension loaded
GECKO(5180) | --- area: widget-overflow-fixed-list ---
GECKO(5180) | --- in extension.onMessage("next-test"), expecting: {} ---
844 INFO Starting next test
GECKO(5180) | ----- in browser.test.onMessage.addListener, msg: next-test, expect: {} -----
GECKO(5180) | ---- closePopup: true -----
GECKO(5180) | ---- expect: {"event":false,"popup":"a","closePopup":true,"containingPopupShouldClose"
:true} -----
845 INFO Click browser action, expect popup "a".
setPrefs@resource://gre/modules/ExtensionPreferencesManager.jsm:91:31
setSetting@resource://gre/modules/ExtensionPreferencesManager.jsm:219:7
async*onManifestEntry@chrome://browser/content/ext-chrome-settings-overrides.js:103:7
async*asyncEmitManifestEntry@resource://gre/modules/ExtensionCommon.jsm:1080:14
async*runManifest@resource://gre/modules/Extension.jsm:1336:23
_startup@resource://gre/modules/Extension.jsm:1483:13
async*startup@resource://gre/modules/Extension.jsm:1426:27
startup@resource://gre/modules/Extension.jsm:988:12
callBootstrapMethod@resource://gre/modules/addons/XPIProvider.jsm:4419:20
updateAddonDisabledState@resource://gre/modules/addons/XPIProvider.jsm:4566:13
1. Install an extenion which overrides the home page from a file via about:addons.
2. Check about:preferences. All appears as expected: home page is overidden and user can not edit it
without disabling the extension.
3. Disable the extension.
4. Check about:preferences. All appears as expected: home page is back to the default and user can edit it.
5. Shut down Firefox normally.
6. Start Firefox.
7. Go to about:addons and enable the extension.
8. Check about:preferences. It does not appear as expected: The home page value is overidden, but it is
editable by the user and the message for disabling the extension is not present.
1. Create a manifest.json file in an empty folder with the contents of manifest.json, below.
2. Add a registry entry for the extension.
- The entry needs to be added at HKEY_CURRENT_USER\Software\Mozilla\Firefox\Extensions.
- The name of the entry should be "test_id@tests.mozilla.org" and the value is the path to the folder that holds
the manifest.json file you created in step 1.
3. Start Firefox.
4. The extension will be installed as disabled, so go to about:addons and enable it.
5. Go to about:preferences. Verify that the expected output is shown.
Expected:
The field for home page should be disabled along with a message that you must disable your
let isArticleChangeListener = (eventName, event) => {
let {gBrowser} = event.nativeTab.ownerGlobal;
let tab = tabManager.wrapTab(
gBrowser.getTabForBrowser(event.nativeTab));
fireForTab(tab, {isArticle: event.isArticle});
};
/**
* Emits a "tab-isarticle" event for the given tab element.
*
* @param {NativeTab} nativeTab
* The tab element in the window for which the reader mode is changing.
* @param {boolean} isArticle
* Whether the document in the tab can be rendered in reader mode.
* @private
*/
emitIsArticleChanged(nativeTab, isArticle) {
let readerModeChangeListener = (eventName, event) => {
let {gBrowser} = event.nativeTab.ownerGlobal;
let tabElem = gBrowser.getTabForBrowser(event.nativeTab);
let tab = tabManager.wrapTab(tabElem);
let changeInfo = {readerMode: event.isArticle};
tab.isArticle = event.isArticle;
fireForTab(tab, changeInfo);
};