/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Refresh the tools list when a new tool or webextension has been // registered to the toolbox. this.toolbox.on("tool-registered", this.setupToolsList); this.toolbox.on("webextension-registered", this.setupToolsList); // Refresh the tools list when a new tool or webextension has been // unregistered from the toolbox. this.toolbox.on("tool-unregistered", this.setupToolsList); this.toolbox.on("webextension-unregistered", this.setupToolsList);
},
// Signal tool registering/unregistering globally (for the tools registered // globally) and per toolbox (for the tools registered to a single toolbox). // This event handler expect this to be binded to the related checkbox element. const onCheckboxClick = function (telemetry, tool) { // Set the kill switch pref boolean to true
Services.prefs.setBoolPref(tool.visibilityswitch, this.checked);
if (!tool.isWebExtension) {
gDevTools.emit( this.checked ? "tool-registered" : "tool-unregistered",
tool.id
); // Record which tools were registered and unregistered.
Glean.devtoolsTool.registered[tool.id].set(this.checked);
}
};
// We shouldn't have deprecated tools anymore, but we might have one in the future, // when migrating the storage inspector to the application panel (Bug 1681059). // Let's keep this code for now so we keep the l10n property around and avoid // unnecessary translation work if we need it again in the future. if (tool.deprecated) { const deprecationURL = this.panelDoc.createElement("a");
deprecationURL.title = deprecationURL.href = tool.deprecationURL;
deprecationURL.textContent = L10N.getStr("options.deprecationNotice"); // Cannot use a real link when we are in the Browser Toolbox.
deprecationURL.addEventListener("click", e => {
e.preventDefault();
openDocLink(tool.deprecationURL, { relatedToCurrent: true });
});
// Clean up any existent additional tools content. for (const label of additionalToolsBox.querySelectorAll("label")) {
label.remove();
}
// Populating the additional tools list.
let atleastOneAddon = false; for (const tool of gDevTools.getAdditionalTools()) {
atleastOneAddon = true;
additionalToolsBox.appendChild(createToolCheckbox(tool));
}
// Populating the additional tools that came from the installed WebExtension add-ons. for (const { uuid, name, pref } of this.toolbox.listWebExtensions()) {
atleastOneAddon = true;
// Use the preference as the unified webextensions tool id.
id: `webext-${uuid}`,
tooltip: name,
label: name, // Disable the devtools extension using the given pref name: // the toolbox options for the WebExtensions are not related to a single // tool (e.g. a devtools panel created from the extension devtools_page) // but to the entire devtools part of a webextension which is enabled // by the Addon Manager (but it may be disabled by its related // devtools about:config preference), and so the following
visibilityswitch: pref,
// Only local tabs are currently supported as targets.
isToolSupported: toolbox =>
toolbox.commands.descriptorFront.isLocalTab,
})
);
}
for (const prefDefinition of prefDefinitions) { const parent = this.panelDoc.getElementById(prefDefinition.parentId); // We want to insert the new definition after the last existing // definition, but before any other element. // For example in the "Advanced Settings" column there's indeed a <span> // text at the end, and we want that it stays at the end. // The reference element can be `null` if there's no label or if there's // no element after the last label. But that's OK and it will do what we // want. const referenceElement = parent.querySelector("label:last-of-type + *");
parent.insertBefore(
createPreferenceOption(prefDefinition),
referenceElement
);
}
},
async populatePreferences() { const prefCheckboxes = this.panelDoc.querySelectorAll( "input[type=checkbox][data-pref]"
); for (const prefCheckbox of prefCheckboxes) { if (GetPref(prefCheckbox.getAttribute("data-pref"))) {
prefCheckbox.setAttribute("checked", true);
}
prefCheckbox.addEventListener("change", function (e) { const checkbox = e.target;
SetPref(checkbox.getAttribute("data-pref"), checkbox.checked);
});
} // Themes radio inputs are handled in setupThemeList const prefRadiogroups = this.panelDoc.querySelectorAll( ".radiogroup[data-pref]:not(#devtools-theme-box)"
); for (const radioGroup of prefRadiogroups) { const selectedValue = GetPref(radioGroup.getAttribute("data-pref"));
for (const radioInput of radioGroup.querySelectorAll( "input[type=radio]"
)) { if (radioInput.getAttribute("value") == selectedValue) {
radioInput.setAttribute("checked", true);
}
radioInput.addEventListener("change", function (e) {
SetPref(radioGroup.getAttribute("data-pref"), e.target.value);
});
}
} const prefSelects = this.panelDoc.querySelectorAll("select[data-pref]"); for (const prefSelect of prefSelects) { const pref = GetPref(prefSelect.getAttribute("data-pref")); const options = [...prefSelect.options];
options.some(function (option) { const value = option.value; // non strict check to allow int values. if (value == pref) {
prefSelect.selectedIndex = options.indexOf(option); returntrue;
} returnfalse;
});
if (themeRadioInput) {
themeRadioInput.checked = true;
} else { // If the current theme does not exist anymore, switch to auto theme const autoThemeInputRadio = themeBox.querySelector("[value=auto]");
autoThemeInputRadio.checked = true;
}
},
/** * Disables JavaScript for the currently loaded tab. We force a page refresh * here because setting browsingContext.allowJavascript to true fails to block * JS execution from event listeners added using addEventListener(), AJAX * calls and timers. The page refresh prevents these things from being added * in the first place. * * @param {Event} event * The event sent by checking / unchecking the disable JS checkbox.
*/
_disableJSClicked(event) { const checked = event.target.checked;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.