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/**
# Uses preprocessing
toolkit/content/contentAreaUtils.js
toolkit/content/widgets/videocontrols.xml
toolkit/content/widgets/wizard.xml
toolkit/components/jsdownloads/src/DownloadIntegration.jsm

View File

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

View File

@ -303,6 +303,22 @@ module.exports = {
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.
*

View File

@ -18,6 +18,9 @@ var helpers = require("../helpers");
var globals = require("../globals");
const SCRIPTS = [
//"browser/base/content/nsContextMenu.js",
"toolkit/content/contentAreaUtils.js",
"browser/components/places/content/editBookmarkOverlay.js",
"toolkit/components/printing/content/printUtils.js",
"toolkit/content/viewZoomOverlay.js",
"browser/components/places/content/browserPlacesViews.js",
@ -47,13 +50,14 @@ const SCRIPTS = [
"browser/base/content/browser-thumbnails.js",
"browser/base/content/browser-trackingprotection.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) {
return {
Program: function(node) {
if (!helpers.getIsBrowserMochitest(this)) {
if (!helpers.getIsBrowserMochitest(this) &&
!helpers.getIsHeadFile(this)) {
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
# 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 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/. */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@ -25,6 +24,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
var ContentAreaUtils = {
@ -351,7 +352,7 @@ XPCOMUtils.defineConstant(this, "kSaveAsType_Text", kSaveAsType_Text);
* @param aDocument
* The document to be saved
* @param aDefaultFileName
* The caller-provided suggested filename if we don't
* The caller-provided suggested filename if we don't
* find a better one
* @param aContentDisposition
* 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
* saved to. This structure is populated by initFileInfo(...).
* @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 aFileBaseName The filename without the file extension
* @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,
* prompting the user to confirm (or change) the fileName.
* @param aFpP
@ -667,7 +668,7 @@ function initFileInfo(aFI, aURL, aURLCharset, aDocument,
* is set, but ask for the target explicitly.
* @param aRelatedURI
* 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.
* @return Promise
* @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)
{
return Task.spawn(function() {
return Task.spawn(function*() {
let downloadLastDir = new DownloadLastDir(window);
let prefBranch = Services.prefs.getBranch("browser.download.");
let useDownloadDir = prefBranch.getBoolPref("useDownloadDir");
@ -693,7 +694,7 @@ function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRel
dir.append(getNormalizedLeafName(aFpP.fileInfo.fileName,
aFpP.fileInfo.fileExt));
aFpP.file = uniqueFile(dir);
throw new Task.Result(true);
return true;
}
// We must prompt for the file name explicitly.
@ -748,7 +749,7 @@ function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRel
});
let result = yield deferComplete.promise;
if (result == Components.interfaces.nsIFilePicker.returnCancel || !fp.file) {
throw new Task.Result(false);
return false;
}
if (aFpP.saveMode != SAVEMODE_FILEONLY)
@ -763,7 +764,7 @@ function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRel
aFpP.file = fp.file;
aFpP.fileURL = fp.fileURL;
throw new Task.Result(true);
return true;
});
}
@ -795,7 +796,6 @@ function uniqueFile(aLocalFile)
return aLocalFile;
}
#ifdef MOZ_JSDOWNLOADS
/**
* Download a URL using the new jsdownloads API.
*
@ -841,7 +841,6 @@ function DownloadURL(aURL, aFileName, aInitiatingDocument) {
list.add(download);
}).then(null, Components.utils.reportError);
}
#endif
// We have no DOM, and can only save the URL as is.
const SAVEMODE_FILEONLY = 0x00;
@ -1157,10 +1156,10 @@ function getNormalizedLeafName(aFile, aDefaultExtension)
if (!aDefaultExtension)
return aFile;
#ifdef XP_WIN
// Remove trailing dots and spaces on windows
aFile = aFile.replace(/[\s.]+$/, "");
#endif
if (AppConstants.platform == "win") {
// Remove trailing dots and spaces on windows
aFile = aFile.replace(/[\s.]+$/, "");
}
// Remove leading dots
aFile = aFile.replace(/^\.+/, "");

View File

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