Skip to content

Commit e5c2eff

Browse files
committed
code review to fix "javascript.options.strict" warnings in browser console of Firefox
1 parent 7884cf7 commit e5c2eff

4 files changed

Lines changed: 30 additions & 28 deletions

File tree

platform/firefox/vapi-background.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
3-
µBlock - a browser extension to block requests.
4-
Copyright (C) 2014 The µBlock authors
3+
uBlock Origin - a browser extension to block requests.
4+
Copyright (C) 2014-2106 The uBlock Origin authors
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -62,7 +62,7 @@ var deferUntil = function(testFn, mainFn, details) {
6262
vAPI.setTimeout(check, next);
6363
};
6464

65-
if ( details.async === false ) {
65+
if ( 'sync' in details && details.sync === true ) {
6666
check();
6767
} else {
6868
vAPI.setTimeout(check, 1);
@@ -829,7 +829,7 @@ vAPI.tabs.get = function(tabId, callback) {
829829
id: tabId,
830830
index: tabWatcher.indexFromTarget(browser),
831831
windowId: winWatcher.idFromWindow(win),
832-
active: browser === tabBrowser.selectedBrowser,
832+
active: tabBrowser !== null && browser === tabBrowser.selectedBrowser,
833833
url: browser.currentURI.asciiSpec,
834834
title: browser.contentTitle
835835
});
@@ -921,6 +921,9 @@ vAPI.tabs.open = function(details) {
921921

922922
var win = winWatcher.getCurrentWindow();
923923
var tabBrowser = getTabBrowser(win);
924+
if ( tabBrowser === null ) {
925+
return;
926+
}
924927

925928
if ( vAPI.fennec ) {
926929
tabBrowser.addTab(details.url, {
@@ -1430,7 +1433,7 @@ vAPI.setIcon = function(tabId, iconStatus, badge) {
14301433
: winWatcher.getCurrentWindow();
14311434
var curTabId;
14321435
var tabBrowser = getTabBrowser(win);
1433-
if ( tabBrowser ) {
1436+
if ( tabBrowser !== null ) {
14341437
curTabId = tabWatcher.tabIdFromTarget(tabBrowser.selectedTab);
14351438
}
14361439
var tb = vAPI.toolbarButton;
@@ -2038,12 +2041,12 @@ var httpObserver = {
20382041
return false;
20392042
}
20402043

2041-
if ( result.cancel === true ) {
2044+
if ( 'cancel' in result && result.cancel === true ) {
20422045
channel.cancel(this.ABORT);
20432046
return true;
20442047
}
20452048

2046-
if ( result.redirectUrl ) {
2049+
if ( 'redirectUrl' in result ) {
20472050
channel.redirectionLimit = 1;
20482051
channel.redirectTo(Services.io.newURI(result.redirectUrl, null, null));
20492052
return true;

platform/firefox/vapi-client.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
3-
µBlock - a browser extension to block requests.
4-
Copyright (C) 2014 The µBlock authors
3+
uBlock Origin - a browser extension to block requests.
4+
Copyright (C) 2014-2016 The uBlock Origin authors
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -131,12 +131,15 @@ vAPI.messaging = {
131131
return;
132132
}
133133
var details = msg.details;
134-
if ( details.allFrames !== true && window !== window.top ) {
134+
// Whether to inject in all child frames. Default to only top frame.
135+
var allFrames = details.allFrames || false;
136+
if ( allFrames !== true && window !== window.top ) {
135137
return;
136138
}
137139
// https://github.com/gorhill/uBlock/issues/876
138140
// Enforce `details.runAt`. Default to `document_end`.
139-
if ( details.runAt === 'document_start' || document.readyState !== 'loading' ) {
141+
var runAt = details.runAt || 'document_end';
142+
if ( runAt === 'document_start' || document.readyState !== 'loading' ) {
140143
self.injectScript(details.file);
141144
return;
142145
}

src/js/messaging.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
3-
uBlock - a browser extension to block requests.
4-
Copyright (C) 2014-2015 Raymond Hill
3+
uBlock Origin - a browser extension to block requests.
4+
Copyright (C) 2014-2016 Raymond Hill
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -131,7 +131,7 @@ var onMessage = function(request, sender, callback) {
131131
case 'launchElementPicker':
132132
// Launched from some auxiliary pages, clear context menu coords.
133133
µb.mouseX = µb.mouseY = -1;
134-
µb.elementPickerExec(request.tabId, request.targetURL);
134+
µb.elementPickerExec(request.tabId, request.targetURL || '');
135135
break;
136136

137137
case 'gotoURL':

src/js/pagestore.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*******************************************************************************
22
3-
uBlock - a browser extension to block requests.
4-
Copyright (C) 2014-2015 Raymond Hill
3+
uBlock Origin - a browser extension to block requests.
4+
Copyright (C) 2014-2016 Raymond Hill
55
66
This program is free software: you can redistribute it and/or modify
77
it under the terms of the GNU General Public License as published by
@@ -19,8 +19,6 @@
1919
Home: https://github.com/gorhill/uBlock
2020
*/
2121

22-
/* global µBlock */
23-
2422
/*******************************************************************************
2523
2624
A PageRequestStore object is used to store net requests in two ways:
@@ -229,25 +227,23 @@ var frameStoreJunkyardMax = 50;
229227

230228
/******************************************************************************/
231229

232-
var FrameStore = function(rootHostname, frameURL) {
233-
this.init(rootHostname, frameURL);
230+
var FrameStore = function(frameURL) {
231+
this.init(frameURL);
234232
};
235233

236234
/******************************************************************************/
237235

238-
FrameStore.factory = function(rootHostname, frameURL) {
236+
FrameStore.factory = function(frameURL) {
239237
var entry = frameStoreJunkyard.pop();
240238
if ( entry === undefined ) {
241-
entry = new FrameStore(rootHostname, frameURL);
242-
} else {
243-
entry.init(rootHostname, frameURL);
239+
return new FrameStore(frameURL);
244240
}
245-
return entry;
241+
return entry.init(frameURL);
246242
};
247243

248244
/******************************************************************************/
249245

250-
FrameStore.prototype.init = function(rootHostname, frameURL) {
246+
FrameStore.prototype.init = function(frameURL) {
251247
var µburi = µb.URI;
252248
this.pageHostname = µburi.hostnameFromURI(frameURL);
253249
this.pageDomain = µburi.domainFromHostname(this.pageHostname) || this.pageHostname;
@@ -423,9 +419,9 @@ PageStore.prototype.getFrame = function(frameId) {
423419
PageStore.prototype.setFrame = function(frameId, frameURL) {
424420
var frameStore = this.frames[frameId];
425421
if ( frameStore ) {
426-
frameStore.init(this.rootHostname, frameURL);
422+
frameStore.init(frameURL);
427423
} else {
428-
this.frames[frameId] = FrameStore.factory(this.rootHostname, frameURL);
424+
this.frames[frameId] = FrameStore.factory(frameURL);
429425
}
430426
};
431427

0 commit comments

Comments
 (0)