Bug 1311345 - Enable eslint of browser/components/privatebrowsing/; r?standard8
MozReview-Commit-ID: AD112cmtsk3
--- a/.eslintignore
+++ b/.eslintignore
@@ -60,17 +60,16 @@ browser/app/**
browser/base/content/browser-social.js
browser/base/content/nsContextMenu.js
browser/base/content/sanitizeDialog.js
browser/base/content/test/general/file_csp_block_all_mixedcontent.html
browser/base/content/test/urlbar/file_blank_but_not_blank.html
browser/base/content/newtab/**
browser/components/downloads/**
browser/components/feeds/**
-browser/components/privatebrowsing/**
browser/components/sessionstore/**
browser/components/tabview/**
browser/components/translation/**
# generated files in cld2
browser/components/translation/cld2/cld-worker.js
browser/extensions/pdfjs/**
# generated or library files in pocket
browser/extensions/pocket/content/panels/js/tmpl.js
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_DownloadLastDirWithCPS.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_DownloadLastDirWithCPS.js
@@ -15,18 +15,20 @@ function test() {
* ================
* Helper functions
* ================
*/
function moveAlong(aResult) {
try {
gTests.send(aResult);
- } catch (x if x instanceof StopIteration) {
- finish();
+ } catch (x) {
+ if (x instanceof StopIteration) {
+ finish();
+ }
}
}
function createWindow(aOptions) {
whenNewWindowLoaded(aOptions, function(win) {
moveAlong(win);
});
}
@@ -48,17 +50,17 @@ function clearHistoryAndWait() {
}
/*
* ===================
* Function with tests
* ===================
*/
-function runTest() {
+function* runTest() {
let FileUtils =
Cu.import("resource://gre/modules/FileUtils.jsm", {}).FileUtils;
let DownloadLastDir =
Cu.import("resource://gre/modules/DownloadLastDir.jsm", {}).DownloadLastDir;
let tmpDir = FileUtils.getDir("TmpD", [], true);
let dir1 = newDirectory();
let dir2 = newDirectory();
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent.js
@@ -6,22 +6,22 @@
// Ensure that values from one don't leak into the other, and that values from
// earlier private storage sessions aren't visible later.
// Step 1: create new tab, load a page that sets test=value in non-private storage
// Step 2: create a new tab, load a page that sets test2=value2 in private storage
// Step 3: load a page in the tab from step 1 that checks the value of test2 is value2 and the total count in non-private storage is 1
// Step 4: load a page in the tab from step 2 that checks the value of test is value and the total count in private storage is 1
-add_task(function test() {
+add_task(function* test() {
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html';
function getElts(browser) {
return browser.contentTitle.split('|');
- };
+ }
// Step 1
let non_private_browser = gBrowser.selectedBrowser;
non_private_browser.loadURI(prefix + '?action=set&name=test&value=value&initial=true');
yield BrowserTestUtils.browserLoaded(non_private_browser);
// Step 2
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html
@@ -1,20 +1,20 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
- var oGetVars = {};
-
- if (window.location.search.length > 1) {
+ var oGetVars = {};
+
+ if (window.location.search.length > 1) {
for (var aItKey, nKeyId = 0, aCouples = window.location.search.substr(1).split("&");
nKeyId < aCouples.length;
- nKeyId++) {
- aItKey = aCouples[nKeyId].split("=");
- oGetVars[unescape(aItKey[0])] = aItKey.length > 1 ? unescape(aItKey[1]) : "";
- }
+ nKeyId++) {
+ aItKey = aCouples[nKeyId].split("=");
+ oGetVars[unescape(aItKey[0])] = aItKey.length > 1 ? unescape(aItKey[1]) : "";
+ }
}
if (oGetVars.initial == 'true') {
localStorage.clear();
}
if (oGetVars.action == 'set') {
localStorage.setItem(oGetVars.name, oGetVars.value);
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_crh.js
@@ -1,25 +1,25 @@
/* 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/. */
-// This test makes sure that the Clear Recent History menu item and command
+// This test makes sure that the Clear Recent History menu item and command
// is disabled inside the private browsing mode.
-add_task(function test() {
+add_task(function* test() {
function checkDisableOption(aPrivateMode, aWindow) {
let crhCommand = aWindow.document.getElementById("Tools:Sanitize");
ok(crhCommand, "The clear recent history command should exist");
is(PrivateBrowsingUtils.isWindowPrivate(aWindow), aPrivateMode,
"PrivateBrowsingUtils should report the correct per-window private browsing status");
is(crhCommand.hasAttribute("disabled"), aPrivateMode,
"Clear Recent History command should be disabled according to the private browsing mode");
- };
+ }
let testURI = "http://mochi.test:8888/";
let privateWin = yield BrowserTestUtils.openNewBrowserWindow({private: true});
let privateBrowser = privateWin.gBrowser.selectedBrowser;
privateBrowser.loadURI(testURI);
yield BrowserTestUtils.browserLoaded(privateBrowser);
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_toggle.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_downloadLastDir_toggle.js
@@ -71,17 +71,17 @@ add_task(function* test_downloads_last_d
* An nsIFile for what we expect the last download directory
* should be. The nsIFile is not compared directly - only
* paths are compared. If expectedDir is not set, then the
* last download directory is expected to be null.
*
* @returns Promise
*/
function testHelper(options) {
- return new Task.spawn(function() {
+ return new Task.spawn(function* () {
let win = yield BrowserTestUtils.openNewBrowserWindow(options);
let gDownloadLastDir = new DownloadLastDir(win);
if (options.clearHistory) {
clearHistory();
}
if (options.setDir) {
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js
@@ -157,17 +157,17 @@ function waitOnFaviconLoaded(aFaviconURL
}
},
};
PlacesUtils.history.addObserver(observer, false);
});
}
-function* assignCookies(aBrowser, aURL, aCookieValue){
+function* assignCookies(aBrowser, aURL, aCookieValue) {
let tabInfo = yield openTab(aBrowser, aURL);
yield ContentTask.spawn(tabInfo.browser, aCookieValue, function* (value) {
content.document.cookie = value;
});
yield BrowserTestUtils.removeTab(tabInfo.tab);
}
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt.js
@@ -12,32 +12,32 @@ add_task(function* test() {
function checkGeolocation(aPrivateMode, aWindow) {
return Task.spawn(function* () {
aWindow.gBrowser.selectedTab = aWindow.gBrowser.addTab(testPageURL);
yield BrowserTestUtils.browserLoaded(aWindow.gBrowser.selectedBrowser);
let notification = aWindow.PopupNotifications.getNotification("geolocation");
// Wait until the notification is available.
- while (!notification){
+ while (!notification) {
yield new Promise(resolve => { executeSoon(resolve); });
let notification = aWindow.PopupNotifications.getNotification("geolocation");
}
if (aPrivateMode) {
// Make sure the notification is correctly displayed without a remember control
is(notification.secondaryActions.length, 0, "Secondary actions shouldn't exist (always/never remember)");
} else {
ok(notification.secondaryActions.length > 1, "Secondary actions should exist (always/never remember)");
}
notification.remove();
aWindow.gBrowser.removeCurrentTab();
});
- };
+ }
let win = yield BrowserTestUtils.openNewBrowserWindow();
let browser = win.gBrowser.selectedBrowser;
browser.loadURI(testPageURL);
yield BrowserTestUtils.browserLoaded(browser);
yield checkGeolocation(false, win);
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage.js
@@ -1,13 +1,13 @@
/* 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/. */
- add_task(function test() {
+ add_task(function* test() {
requestLongerTimeout(2);
const page1 = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page1.html'
let win = yield BrowserTestUtils.openNewBrowserWindow({private: true});
let tab = win.gBrowser.selectedTab = win.gBrowser.addTab(page1);
let browser = win.gBrowser.selectedBrowser;
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_localStorage_before_after.js
@@ -5,17 +5,17 @@
// Ensure that a storage instance used by both private and public sessions at different times does not
// allow any data to leak due to cached values.
// Step 1: Load browser_privatebrowsing_localStorage_before_after_page.html in a private tab, causing a storage
// item to exist. Close the tab.
// Step 2: Load the same page in a non-private tab, ensuring that the storage instance reports only one item
// existing.
-add_task(function test() {
+add_task(function* test() {
let testURI = "about:blank";
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/';
// Step 1.
let privateWin = yield BrowserTestUtils.openNewBrowserWindow({private: true});
let privateBrowser = privateWin.gBrowser.addTab(
prefix + 'browser_privatebrowsing_localStorage_before_after_page.html').linkedBrowser;
yield BrowserTestUtils.browserLoaded(privateBrowser);
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_opendir.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_opendir.js
@@ -77,17 +77,17 @@ function test() {
setupCleanSlate(privateWindow);
// Test 2: the user first tries to open a file inside the private browsing mode
// test the private window
ok(!privateWindow.gLastOpenDirectory.path,
"No original path should exist inside the private browsing mode");
privateWindow.gLastOpenDirectory.path = dir1;
- is(privateWindow.gLastOpenDirectory.path.path, dir1.path,
+ is(privateWindow.gLastOpenDirectory.path.path, dir1.path,
"The path should be successfully set inside the private browsing mode");
// test the non-private window
ok(!nonPrivateWindow.gLastOpenDirectory.path,
"The path set inside the private browsing mode should not leak when leaving that mode");
setupCleanSlate(nonPrivateWindow);
setupCleanSlate(privateWindow);
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_placesTitleNoUpdate.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_placesTitleNoUpdate.js
@@ -29,17 +29,17 @@ add_task(function* test() {
onClearHistory: function () {},
onPageChanged: function () {},
onDeleteVisits: function() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
};
PlacesUtils.history.addObserver(historyObserver, false);
});
- };
+ }
yield PlacesTestUtils.clearHistory();
let tabToClose = gBrowser.selectedTab = gBrowser.addTab(TEST_URL);
yield waitForTitleChanged();
is(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_1, "The title matches the orignal title after first visit");
let place = {
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_ui.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_ui.js
@@ -30,42 +30,42 @@ function test() {
is(PrivateBrowsingUtils.isWindowPrivate(aWindow), aIsPrivateMode,
"PrivateBrowsingUtils should report the correct per-window private browsing status (privateBrowsing should be " +
aIsPrivateMode + ")");
aCallback();
}, true);
aWindow.gBrowser.selectedBrowser.loadURI(testURI);
- };
+ }
function openPrivateBrowsingModeByUI(aWindow, aCallback) {
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
aSubject.addEventListener("load", function() {
aSubject.removeEventListener("load", arguments.callee);
Services.obs.removeObserver(observer, "domwindowopened");
windowsToClose.push(aSubject);
aCallback(aSubject);
}, false);
}, "domwindowopened", false);
cmd = aWindow.document.getElementById("Tools:PrivateBrowsing");
var func = new Function("", cmd.getAttribute("oncommand"));
func.call(cmd);
- };
+ }
function testOnWindow(aOptions, aCallback) {
whenNewWindowLoaded(aOptions, function(aWin) {
windowsToClose.push(aWin);
// execute should only be called when need, like when you are opening
// web pages on the test. If calling executeSoon() is not necesary, then
// call whenNewWindowLoaded() instead of testOnWindow() on your test.
executeSoon(() => aCallback(aWin));
});
- };
+ }
// this function is called after calling finish() on the test.
registerCleanupFunction(function() {
windowsToClose.forEach(function(aWin) {
aWin.close();
});
});
--- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
+++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle.js
@@ -1,16 +1,16 @@
/* 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/. */
// This test makes sure that the window title changes correctly while switching
// from and to private browsing mode.
-add_task(function test() {
+add_task(function* test() {
const testPageURL = "http://mochi.test:8888/browser/" +
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle_page.html";
requestLongerTimeout(2);
// initialization of expected titles
let test_title = "Test title";
let app_name = document.documentElement.getAttribute("title");
const isOSX = ("nsILocalFileMac" in Ci);