Bug 1497191: Apply Meta CSP to about:config.r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D41526

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Christoph Kerschbaumer 2019-09-03 11:03:30 +00:00
Родитель d5803b5f62
Коммит 08753eb725
5 изменённых файлов: 97 добавлений и 26 удалений

Просмотреть файл

@ -5,6 +5,7 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src chrome:">
<meta charset="utf-8">
<link rel="stylesheet" media="screen, projection" type="text/css"
href="chrome://global/skin/in-content/common.css">
@ -36,7 +37,7 @@
</div>
<div class="button-container">
<button autofocus onclick="onWarningButtonClick();"
<button autofocus id="warningButton"
data-l10n-id="about-config-warning-button"></button>
</div>
</div>

Просмотреть файл

@ -398,6 +398,11 @@ if (!Preferences.get("browser.aboutConfig.showWarning")) {
},
{ once: true }
);
} else {
document.addEventListener("DOMContentLoaded", function() {
let warningButton = document.getElementById("warningButton");
warningButton.addEventListener("click", onWarningButtonClick);
});
}
function onWarningButtonClick() {

Просмотреть файл

@ -2340,7 +2340,7 @@ pref("security.dialog_enable_delay", 1000);
pref("security.notification_enable_delay", 500);
#if defined(DEBUG) && !defined(ANDROID)
pref("csp.about_uris_without_csp", "blank,printpreview,srcdoc,config,downloads,preferences,sync-log");
pref("csp.about_uris_without_csp", "blank,printpreview,srcdoc,downloads,preferences,sync-log");
// the following prefs are for testing purposes only.
pref("csp.overrule_about_uris_without_csp_whitelist", false);
pref("csp.skip_about_page_has_csp_assert", false);

Просмотреть файл

@ -363,6 +363,74 @@ function fetchPref(prefName, prefIndex) {
}
async function onConfigLoad() {
let configContext = document.getElementById("configContext");
configContext.addEventListener("popupshowing", function(event) {
if (event.target == this) {
updateContextMenu();
}
});
let commandListeners = {
toggleSelected: ModifySelected,
modifySelected: ModifySelected,
copyPref,
copyName,
copyValue,
resetSelected: ResetSelected,
};
configContext.addEventListener("command", e => {
if (e.target.id in commandListeners) {
commandListeners[e.target.id]();
}
});
let configString = document.getElementById("configString");
configString.addEventListener("command", function() {
NewPref(nsIPrefBranch.PREF_STRING);
});
let configInt = document.getElementById("configInt");
configInt.addEventListener("command", function() {
NewPref(nsIPrefBranch.PREF_INT);
});
let configBool = document.getElementById("configBool");
configBool.addEventListener("command", function() {
NewPref(nsIPrefBranch.PREF_BOOL);
});
let keyVKReturn = document.getElementById("keyVKReturn");
keyVKReturn.addEventListener("command", ModifySelected);
let textBox = document.getElementById("textbox");
textBox.addEventListener("command", FilterPrefs);
let configFocuSearch = document.getElementById("configFocuSearch");
configFocuSearch.addEventListener("command", function() {
textBox.focus();
});
let configFocuSearch2 = document.getElementById("configFocuSearch2");
configFocuSearch2.addEventListener("command", function() {
textBox.focus();
});
let warningButton = document.getElementById("warningButton");
warningButton.addEventListener("command", ShowPrefs);
let configTree = document.getElementById("configTree");
configTree.addEventListener("select", function() {
window.updateCommands("select");
});
let configTreeBody = document.getElementById("configTreeBody");
configTreeBody.addEventListener("dblclick", function(event) {
if (event.button == 0) {
ModifySelected();
}
});
// Load strings
let [
lockDefault,
@ -756,3 +824,6 @@ function recordTelemetryOnce(categoryLabel) {
gCategoriesRecordedOnce.add(categoryLabel);
}
}
window.onload = onConfigLoad;
window.onunload = onConfigUnload;

Просмотреть файл

@ -9,6 +9,7 @@
<?xml-stylesheet href="chrome://global/skin/config.css" type="text/css"?>
<window id="config"
csp="default-src chrome:"
data-l10n-id="config-window"
aria-describedby="warningTitle warningText"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@ -16,9 +17,7 @@
windowtype="Preferences:ConfigManager"
role="application"
width="750"
height="500"
onunload="onConfigUnload();"
onload="onConfigLoad();">
height="500">
<linkset>
<html:link rel="localization" href="toolkit/about/aboutConfig.ftl"/>
@ -26,29 +25,27 @@
<script src="chrome://global/content/config.js"/>
<menupopup id="configContext" onpopupshowing="if (event.target == this) updateContextMenu();">
<menuitem id="toggleSelected" data-l10n-id="config-toggle" default="true"
oncommand="ModifySelected();"/>
<menuitem id="modifySelected" data-l10n-id="config-modify" default="true"
oncommand="ModifySelected();"/>
<menupopup id="configContext">
<menuitem id="toggleSelected" data-l10n-id="config-toggle" default="true"/>
<menuitem id="modifySelected" data-l10n-id="config-modify" default="true"/>
<menuseparator/>
<menuitem id="copyPref" data-l10n-id="config-copy-pref" oncommand="copyPref();"/>
<menuitem id="copyName" data-l10n-id="config-copy-name" oncommand="copyName();"/>
<menuitem id="copyValue" data-l10n-id="config-copy-value" oncommand="copyValue();"/>
<menuitem id="copyPref" data-l10n-id="config-copy-pref"/>
<menuitem id="copyName" data-l10n-id="config-copy-name"/>
<menuitem id="copyValue" data-l10n-id="config-copy-value"/>
<menu data-l10n-id="config-new">
<menupopup>
<menuitem data-l10n-id="config-string" oncommand="NewPref(nsIPrefBranch.PREF_STRING);"/>
<menuitem data-l10n-id="config-integer" oncommand="NewPref(nsIPrefBranch.PREF_INT);"/>
<menuitem data-l10n-id="config-boolean" oncommand="NewPref(nsIPrefBranch.PREF_BOOL);"/>
<menuitem id="configString" data-l10n-id="config-string"/>
<menuitem id="configInt" data-l10n-id="config-integer"/>
<menuitem id="configBool" data-l10n-id="config-boolean"/>
</menupopup>
</menu>
<menuitem id="resetSelected" data-l10n-id="config-reset" oncommand="ResetSelected();"/>
<menuitem id="resetSelected" data-l10n-id="config-reset"/>
</menupopup>
<keyset id="configTreeKeyset" disabled="true">
<key keycode="VK_RETURN" oncommand="ModifySelected();"/>
<key modifiers="accel" data-l10n-id="config-focus-search" oncommand="document.getElementById('textbox').focus();"/>
<key modifiers="accel" data-l10n-id="config-focus-search-2" oncommand="document.getElementById('textbox').focus();"/>
<key id="keyVKReturn" keycode="VK_RETURN"/>
<key id="configFocuSearch" modifiers="accel" data-l10n-id="config-focus-search"/>
<key id="configFocuSearch2" modifiers="accel" data-l10n-id="config-focus-search-2"/>
</keyset>
<deck id="configDeck" flex="1">
<vbox id="warningScreen" flex="1" align="center" style="overflow: auto;">
@ -61,7 +58,7 @@
<label id="warningText" data-l10n-id="config-about-warning-text"></label>
<checkbox id="showWarningNextTime" data-l10n-id="config-about-warning-checkbox" checked="true"/>
<hbox class="button-container">
<button id="warningButton" data-l10n-id="config-about-warning-button" class="primary" oncommand="ShowPrefs();"/>
<button id="warningButton" data-l10n-id="config-about-warning-button" class="primary"/>
</hbox>
</vbox>
</vbox>
@ -71,12 +68,9 @@
<hbox id="filterRow" align="center">
<label data-l10n-id="config-search-prefs" control="textbox"/>
<textbox id="textbox" flex="1" is="search-textbox"
aria-controls="configTree"
oncommand="FilterPrefs();"/>
aria-controls="configTree"/>
</hbox>
<tree id="configTree" flex="1" seltype="single"
onselect="updateCommands('select');"
enableColumnDrag="true" context="configContext">
<treecols>
<treecol id="prefCol" data-l10n-id="config-pref-column" flex="7"
@ -93,7 +87,7 @@
persist="hidden width ordinal sortDirection"/>
</treecols>
<treechildren id="configTreeBody" ondblclick="if (event.button == 0) ModifySelected();"/>
<treechildren id="configTreeBody"/>
</tree>
</vbox>
</deck>