Skip to content

Commit 1ba8317

Browse files
committed
Merge pull request EFForg#1308 from MarkCSmith/bug12218_01
Bug 12218: toolbar_button.js should do more null checks.
2 parents 062f508 + d7c7b36 commit 1ba8317

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/chrome/content/toolbar_button.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,21 @@ httpsEverywhere.toolbarButton = {
6565
// make sure the checkbox for showing counter is properly set
6666
var showCounter = tb.shouldShowCounter();
6767
var counterItem = document.getElementById('https-everywhere-counter-item');
68-
counterItem.setAttribute('checked', showCounter ? 'true' : 'false');
68+
if (counterItem) {
69+
counterItem.setAttribute('checked', showCounter ? 'true' : 'false');
70+
}
6971

7072
// make sure UI for HTTP Nowhere mode is properly set
7173
var httpNowhereItem = document.getElementById('http-nowhere-item');
7274
var showHttpNowhere = tb.shouldShowHttpNowhere();
7375
var toolbarbutton = document.getElementById('https-everywhere-button');
74-
httpNowhereItem.setAttribute('checked', showHttpNowhere ? 'true' : 'false');
75-
toolbarbutton.setAttribute('http_nowhere',
76-
showHttpNowhere ? 'true' : 'false');
76+
if (httpNowhereItem) {
77+
httpNowhereItem.setAttribute('checked', showHttpNowhere ? 'true' : 'false');
78+
}
79+
if (toolbarbutton) {
80+
toolbarbutton.setAttribute('http_nowhere',
81+
showHttpNowhere ? 'true' : 'false');
82+
}
7783

7884
// make sure UI is set depending on whether HTTPS-E is enabled
7985
toggleEnabledUI();
@@ -163,6 +169,10 @@ httpsEverywhere.toolbarButton = {
163169
*/
164170
updateRulesetsApplied: function() {
165171
var toolbarbutton = document.getElementById('https-everywhere-button');
172+
if (!toolbarbutton) {
173+
return;
174+
}
175+
166176
var enabled = HTTPSEverywhere.prefs.getBoolPref("globalEnabled");
167177
var showCounter = httpsEverywhere.toolbarButton.shouldShowCounter();
168178
if (!enabled || !showCounter) {
@@ -363,7 +373,9 @@ function toggleEnabledUI() {
363373

364374
// Change icon depending on enabled state
365375
var toolbarbutton = document.getElementById('https-everywhere-button');
366-
toolbarbutton.setAttribute('status', enabled ? 'enabled' : 'disabled');
376+
if (toolbarbutton) {
377+
toolbarbutton.setAttribute('status', enabled ? 'enabled' : 'disabled');
378+
}
367379
}
368380

369381
function open_in_tab(url) {

0 commit comments

Comments
 (0)