Skip to content

Commit 609faad

Browse files
evilpiencalexan
authored andcommitted
Bug 2052011 - Remove inline JS from about:config in GeckoView. r=geckoview-reviewers,nalexander
Differential Revision: https://phabricator.services.mozilla.com/D310051
1 parent 01eeeca commit 609faad

2 files changed

Lines changed: 53 additions & 24 deletions

File tree

mobile/shared/chrome/geckoview/config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,28 @@ var NewPrefDialog = {
7373
this._intValue = document.getElementById("new-pref-value-int");
7474

7575
this._positiveButton = document.getElementById("positive-button");
76+
77+
document
78+
.getElementById("new-pref-toggle-button")
79+
.addEventListener("click", () => this.toggleShowHide());
80+
document
81+
.getElementById("pref-toggle-button")
82+
.addEventListener("click", () => this.toggleBoolValue());
83+
document
84+
.getElementById("negative-button")
85+
.addEventListener("click", () => this.hide());
86+
this._positiveButton.addEventListener("click", () => this.create());
87+
88+
this._prefNameInputElt.addEventListener("focus", event =>
89+
this.focusName(event)
90+
);
91+
this._prefNameInputElt.addEventListener("input", event =>
92+
this.updateName(event)
93+
);
94+
95+
this._prefTypeSelectElt.addEventListener("change", event => {
96+
this.type = event.target.value;
97+
});
7698
},
7799

78100
// Called to update positive button to display text ("Create"/"Change), and enabled/disabled status
@@ -235,6 +257,21 @@ var AboutConfig = {
235257

236258
// Setup the prefs observers
237259
Services.prefs.addObserver("", this);
260+
261+
this.filterInput.addEventListener("input", () =>
262+
AboutConfig.bufferFilterInput()
263+
);
264+
265+
document.getElementById("content").addEventListener("touchstart", () => {
266+
this.filterInput.blur();
267+
});
268+
269+
document
270+
.getElementById("copy-pref-name")
271+
.addEventListener("click", () => this.clipboardCopy("name"));
272+
document
273+
.getElementById("copy-pref-value")
274+
.addEventListener("click", () => this.clipboardCopy("value"));
238275
},
239276

240277
// Uninit the main AboutConfig dialog
@@ -711,3 +748,12 @@ Pref.prototype = {
711748
}
712749
},
713750
};
751+
752+
window.addEventListener("load", () => {
753+
NewPrefDialog.init();
754+
AboutConfig.init();
755+
});
756+
757+
window.addEventListener("unload", () => {
758+
AboutConfig.uninit();
759+
});

mobile/shared/chrome/geckoview/config.xhtml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,10 @@
2424
></script>
2525
</head>
2626

27-
<body
28-
onload="
29-
NewPrefDialog.init();
30-
AboutConfig.init();
31-
"
32-
onunload="AboutConfig.uninit()"
33-
>
27+
<body>
3428
<div class="toolbar">
3529
<div class="toolbar-container">
36-
<div
37-
id="new-pref-toggle-button"
38-
onclick="NewPrefDialog.toggleShowHide()"
39-
/>
30+
<div id="new-pref-toggle-button" />
4031

4132
<div class="toolbar-item" id="filter-container">
4233
<div id="filter-search-button" />
@@ -45,13 +36,12 @@
4536
type="search"
4637
data-l10n-id="config-toolbar-search"
4738
value=""
48-
oninput="AboutConfig.bufferFilterInput()"
4939
/>
5040
</div>
5141
</div>
5242
</div>
5343

54-
<div id="content" ontouchstart="AboutConfig.filterInput.blur();">
44+
<div id="content">
5545
<div id="new-pref-container">
5646
<li class="pref-item" id="new-pref-item">
5747
<div class="pref-item-line">
@@ -60,13 +50,8 @@
6050
id="new-pref-name"
6151
type="text"
6252
data-l10n-id="config-new-pref-name"
63-
onfocus="NewPrefDialog.focusName(event)"
64-
oninput="NewPrefDialog.updateName(event)"
6553
/>
66-
<select
67-
id="new-pref-type"
68-
onchange="NewPrefDialog.type = event.target.value"
69-
>
54+
<select id="new-pref-type">
7055
<option
7156
value="boolean"
7257
data-l10n-id="config-new-pref-value-boolean"
@@ -90,7 +75,7 @@
9075
/>
9176
<div
9277
class="pref-button toggle"
93-
onclick="NewPrefDialog.toggleBoolValue()"
78+
id="pref-toggle-button"
9479
data-l10n-id="config-pref-toggle-button"
9580
></div>
9681
</div>
@@ -113,13 +98,11 @@
11398
<div
11499
class="pref-button cancel"
115100
id="negative-button"
116-
onclick="NewPrefDialog.hide()"
117101
data-l10n-id="config-new-pref-cancel-button"
118102
></div>
119103
<div
120104
class="pref-button create"
121105
id="positive-button"
122-
onclick="NewPrefDialog.create(event)"
123106
data-l10n-id="config-new-pref-create-button"
124107
></div>
125108
</div>
@@ -135,12 +118,12 @@
135118

136119
<menu type="context" id="prefs-context-menu">
137120
<menuitem
121+
id="copy-pref-name"
138122
data-l10n-id="config-context-menu-copy-pref-name"
139-
onclick="AboutConfig.clipboardCopy('name')"
140123
></menuitem>
141124
<menuitem
125+
id="copy-pref-value"
142126
data-l10n-id="config-context-menu-copy-pref-value"
143-
onclick="AboutConfig.clipboardCopy('value')"
144127
></menuitem>
145128
</menu>
146129
</body>

0 commit comments

Comments
 (0)