Bug 1245916: Add additional browser window scripts to eslint globals. r=felipe

This adds more of the scripts that browser.js relies on and also makes
browser-chrome head files import the browser.js globals.

The MOZ_JSDOWNLOADS block in contentAreaUtils only seems to hide a single
function, I don't see any need to keep hiding that now we're on by default.

MozReview-Commit-ID: 5zvF3JtJrZG
This commit is contained in:
Dave Townsend 2016-02-05 12:16:39 -08:00
parent 00ec37e011
commit 9d4c7a1cd4
6 changed files with 41 additions and 22 deletions

View File

@ -187,7 +187,6 @@ toolkit/components/osfile/**
toolkit/components/passwordmgr/** toolkit/components/passwordmgr/**
# Uses preprocessing # Uses preprocessing
toolkit/content/contentAreaUtils.js
toolkit/content/widgets/videocontrols.xml toolkit/content/widgets/videocontrols.xml
toolkit/content/widgets/wizard.xml toolkit/content/widgets/wizard.xml
toolkit/components/jsdownloads/src/DownloadIntegration.jsm toolkit/components/jsdownloads/src/DownloadIntegration.jsm

View File

@ -83,6 +83,7 @@ if (AppConstants.platform != "macosx") {
var gEditUIVisible = true; var gEditUIVisible = true;
} }
/*globals gBrowser, gNavToolbox, gURLBar, gNavigatorBundle*/
[ [
["gBrowser", "content"], ["gBrowser", "content"],
["gNavToolbox", "navigator-toolbox"], ["gNavToolbox", "navigator-toolbox"],

View File

@ -303,6 +303,22 @@ module.exports = {
return true; return true;
}, },
/**
* Check whether we might be in a test head file.
*
* @param {RuleContext} scope
* You should pass this from within a rule
* e.g. helpers.getIsBrowserMochitest(this)
*
* @return {Boolean}
* True or false
*/
getIsHeadFile: function(scope) {
var pathAndFilename = scope.getFilename();
return /.*[\\/]head(_.+)?\.js$/.test(pathAndFilename);
},
/** /**
* Check whether we are in a browser mochitest. * Check whether we are in a browser mochitest.
* *

View File

@ -18,6 +18,9 @@ var helpers = require("../helpers");
var globals = require("../globals"); var globals = require("../globals");
const SCRIPTS = [ const SCRIPTS = [
//"browser/base/content/nsContextMenu.js",
"toolkit/content/contentAreaUtils.js",
"browser/components/places/content/editBookmarkOverlay.js",
"toolkit/components/printing/content/printUtils.js", "toolkit/components/printing/content/printUtils.js",
"toolkit/content/viewZoomOverlay.js", "toolkit/content/viewZoomOverlay.js",
"browser/components/places/content/browserPlacesViews.js", "browser/components/places/content/browserPlacesViews.js",
@ -47,13 +50,14 @@ const SCRIPTS = [
"browser/base/content/browser-thumbnails.js", "browser/base/content/browser-thumbnails.js",
"browser/base/content/browser-trackingprotection.js", "browser/base/content/browser-trackingprotection.js",
"browser/base/content/browser-data-submission-info-bar.js", "browser/base/content/browser-data-submission-info-bar.js",
"browser/base/content/browser-fxaccounts.js", "browser/base/content/browser-fxaccounts.js"
]; ];
module.exports = function(context) { module.exports = function(context) {
return { return {
Program: function(node) { Program: function(node) {
if (!helpers.getIsBrowserMochitest(this)) { if (!helpers.getIsBrowserMochitest(this) &&
!helpers.getIsHeadFile(this)) {
return; return;
} }

View File

@ -1,7 +1,6 @@
# -*- indent-tabs-mode: nil; js-indent-level: 2 -*- /* This Source Code Form is subject to the terms of the Mozilla Public
# 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,
# License, v. 2.0. If a copy of the MPL was not distributed with this * You can obtain one at http://mozilla.org/MPL/2.0/. */
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -25,6 +24,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm"); "resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated", XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm"); "resource://gre/modules/Deprecated.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
var ContentAreaUtils = { var ContentAreaUtils = {
@ -351,7 +352,7 @@ XPCOMUtils.defineConstant(this, "kSaveAsType_Text", kSaveAsType_Text);
* @param aDocument * @param aDocument
* The document to be saved * The document to be saved
* @param aDefaultFileName * @param aDefaultFileName
* The caller-provided suggested filename if we don't * The caller-provided suggested filename if we don't
* find a better one * find a better one
* @param aContentDisposition * @param aContentDisposition
* The caller-provided content-disposition header to use. * The caller-provided content-disposition header to use.
@ -593,7 +594,7 @@ function AutoChosen(aFileAutoChosen, aUriAutoChosen) {
* Structure for holding info about a URL and the target filename it should be * Structure for holding info about a URL and the target filename it should be
* saved to. This structure is populated by initFileInfo(...). * saved to. This structure is populated by initFileInfo(...).
* @param aSuggestedFileName This is used by initFileInfo(...) when it * @param aSuggestedFileName This is used by initFileInfo(...) when it
* cannot 'discover' the filename from the url * cannot 'discover' the filename from the url
* @param aFileName The target filename * @param aFileName The target filename
* @param aFileBaseName The filename without the file extension * @param aFileBaseName The filename without the file extension
* @param aFileExt The extension of the filename * @param aFileExt The extension of the filename
@ -652,7 +653,7 @@ function initFileInfo(aFI, aURL, aURLCharset, aDocument,
} }
} }
/** /**
* Given the Filepicker Parameters (aFpP), show the file picker dialog, * Given the Filepicker Parameters (aFpP), show the file picker dialog,
* prompting the user to confirm (or change) the fileName. * prompting the user to confirm (or change) the fileName.
* @param aFpP * @param aFpP
@ -667,7 +668,7 @@ function initFileInfo(aFI, aURL, aURLCharset, aDocument,
* is set, but ask for the target explicitly. * is set, but ask for the target explicitly.
* @param aRelatedURI * @param aRelatedURI
* An nsIURI associated with the download. The last used * An nsIURI associated with the download. The last used
* directory of the picker is retrieved from/stored in the * directory of the picker is retrieved from/stored in the
* Content Pref Service using this URI. * Content Pref Service using this URI.
* @return Promise * @return Promise
* @resolve a boolean. When true, it indicates that the file picker dialog * @resolve a boolean. When true, it indicates that the file picker dialog
@ -675,7 +676,7 @@ function initFileInfo(aFI, aURL, aURLCharset, aDocument,
*/ */
function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRelatedURI) function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRelatedURI)
{ {
return Task.spawn(function() { return Task.spawn(function*() {
let downloadLastDir = new DownloadLastDir(window); let downloadLastDir = new DownloadLastDir(window);
let prefBranch = Services.prefs.getBranch("browser.download."); let prefBranch = Services.prefs.getBranch("browser.download.");
let useDownloadDir = prefBranch.getBoolPref("useDownloadDir"); let useDownloadDir = prefBranch.getBoolPref("useDownloadDir");
@ -693,7 +694,7 @@ function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRel
dir.append(getNormalizedLeafName(aFpP.fileInfo.fileName, dir.append(getNormalizedLeafName(aFpP.fileInfo.fileName,
aFpP.fileInfo.fileExt)); aFpP.fileInfo.fileExt));
aFpP.file = uniqueFile(dir); aFpP.file = uniqueFile(dir);
throw new Task.Result(true); return true;
} }
// We must prompt for the file name explicitly. // We must prompt for the file name explicitly.
@ -748,7 +749,7 @@ function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRel
}); });
let result = yield deferComplete.promise; let result = yield deferComplete.promise;
if (result == Components.interfaces.nsIFilePicker.returnCancel || !fp.file) { if (result == Components.interfaces.nsIFilePicker.returnCancel || !fp.file) {
throw new Task.Result(false); return false;
} }
if (aFpP.saveMode != SAVEMODE_FILEONLY) if (aFpP.saveMode != SAVEMODE_FILEONLY)
@ -763,7 +764,7 @@ function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRel
aFpP.file = fp.file; aFpP.file = fp.file;
aFpP.fileURL = fp.fileURL; aFpP.fileURL = fp.fileURL;
throw new Task.Result(true); return true;
}); });
} }
@ -795,7 +796,6 @@ function uniqueFile(aLocalFile)
return aLocalFile; return aLocalFile;
} }
#ifdef MOZ_JSDOWNLOADS
/** /**
* Download a URL using the new jsdownloads API. * Download a URL using the new jsdownloads API.
* *
@ -841,7 +841,6 @@ function DownloadURL(aURL, aFileName, aInitiatingDocument) {
list.add(download); list.add(download);
}).then(null, Components.utils.reportError); }).then(null, Components.utils.reportError);
} }
#endif
// We have no DOM, and can only save the URL as is. // We have no DOM, and can only save the URL as is.
const SAVEMODE_FILEONLY = 0x00; const SAVEMODE_FILEONLY = 0x00;
@ -1157,10 +1156,10 @@ function getNormalizedLeafName(aFile, aDefaultExtension)
if (!aDefaultExtension) if (!aDefaultExtension)
return aFile; return aFile;
#ifdef XP_WIN if (AppConstants.platform == "win") {
// Remove trailing dots and spaces on windows // Remove trailing dots and spaces on windows
aFile = aFile.replace(/[\s.]+$/, ""); aFile = aFile.replace(/[\s.]+$/, "");
#endif }
// Remove leading dots // Remove leading dots
aFile = aFile.replace(/^\.+/, ""); aFile = aFile.replace(/^\.+/, "");

View File

@ -43,7 +43,7 @@ toolkit.jar:
content/global/browser-child.js content/global/browser-child.js
content/global/browser-content.js content/global/browser-content.js
* content/global/buildconfig.html * content/global/buildconfig.html
* content/global/contentAreaUtils.js content/global/contentAreaUtils.js
#ifndef MOZ_FENNEC #ifndef MOZ_FENNEC
content/global/customizeToolbar.css content/global/customizeToolbar.css
content/global/customizeToolbar.js content/global/customizeToolbar.js