Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1325623 - Fix most no-undef eslint issues in toolkit/components. …
Browse files Browse the repository at this point in the history
…r=mossop

MozReview-Commit-ID: DYJa1uNVagw
  • Loading branch information
Standard8 committed Dec 23, 2016
1 parent 264f8fb commit 5856abc
Show file tree
Hide file tree
Showing 80 changed files with 196 additions and 95 deletions.
3 changes: 3 additions & 0 deletions testing/mochitest/mochitest.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module.exports = {

// All globals made available in the test environment.
"globals": {
// $ is defined in SimpleTest.js
"$": false,
"add_task": false,
"Assert": false,
"EventUtils": false,
Expand All @@ -25,6 +27,7 @@ module.exports = {
"is": false,
"isDeeply": false,
"isnot": false,
"netscape": false,
"ok": false,
"promise": false,
"registerCleanupFunction": false,
Expand Down
7 changes: 7 additions & 0 deletions testing/xpcshell/xpcshell.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ module.exports = {

// All globals made available in the test environment.
"globals": {
"_TEST_FILE": false,
"add_task": false,
"add_test": false,
"Assert": false,
"deepEqual": false,
"do_await_remote_message": false,
"do_check_eq": false,
"do_check_false": false,
"do_check_matches": false,
Expand All @@ -30,6 +32,7 @@ module.exports = {
"do_print": false,
"do_register_cleanup": false,
"do_report_unexpected_exception": false,
"do_send_remote_message": false,
"do_test_finished": false,
"do_test_pending": false,
"do_throw": false,
Expand All @@ -45,6 +48,7 @@ module.exports = {
"notEqual": false,
"notStrictEqual": false,
"ok": false,
"runningInParent": false,
"run_next_test": false,
"run_test": false,
"run_test_in_child": false,
Expand All @@ -53,5 +57,8 @@ module.exports = {
"todo": false,
"todo_check_false": false,
"todo_check_true": false,
// Firefox specific function.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval
"uneval": false,
}
};
1 change: 1 addition & 0 deletions toolkit/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,6 @@ module.exports = {
"dump": true,
"openDialog": false,
"sizeToContent": false,
"ChromeWorker": false,
}
};
7 changes: 7 additions & 0 deletions toolkit/components/contextualidentity/tests/unit/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
"extends": [
"../../../../../testing/xpcshell/xpcshell.eslintrc.js"
]
};
2 changes: 1 addition & 1 deletion toolkit/components/cookie/content/cookieAcceptDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function onload()
// use childnodes here, the text can wrap
for (var i = 1; i < messageParagraphs.length; i++) {
var descriptionNode = document.createElement("description");
text = document.createTextNode(messageParagraphs[i]);
let text = document.createTextNode(messageParagraphs[i]);
descriptionNode.appendChild(text);
messageParent.appendChild(descriptionNode);
}
Expand Down
7 changes: 3 additions & 4 deletions toolkit/components/ctypes/tests/unit/test_finalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function run_test()
// if we want to avoid tests overlapping.
function test_cycles(size, tc) {
// Now, restart this with unreferenced cycles
for (i = 0; i < size / 2; ++i) {
for (let i = 0; i < size / 2; ++i) {
let a = {
a: ctypes.CDataFinalizer(tc.acquire(i * 2), tc.release),
b: {
Expand Down Expand Up @@ -325,7 +325,7 @@ function test_result_dispose(size, tc, cleanup) {
}
do_check_eq(count_finalized(size, tc), 0);

for (i = 0; i < size; ++i) {
for (let i = 0; i < size; ++i) {
let witness = ref[i].dispose();
ref[i] = null;
if (!tc.released(i, witness)) {
Expand Down Expand Up @@ -367,7 +367,7 @@ function test_executing_dispose(size, tc, cleanup)
ref = [];

// Re-acquire data and make sure that everything has been reinialized
for (i = 0; i < size; ++i) {
for (let i = 0; i < size; ++i) {
tc.acquire(i);
}

Expand Down Expand Up @@ -449,4 +449,3 @@ function test_do_not_execute_finalizers_on_referenced_stuff(size, tc, cleanup)
// Check that _nothing_ has been finalized
do_check_eq(count_finalized(size, tc), 0);
}

28 changes: 14 additions & 14 deletions toolkit/components/ctypes/tests/unit/test_jsctypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ try {
} catch (e) {
}

CTYPES_TEST_LIB = ctypes.libraryName("jsctypes-test");
CTYPES_UNICODE_LIB = ctypes.libraryName("jsctyp\u00E8s-t\u00EB\u00DFt");
const CTYPES_TEST_LIB = ctypes.libraryName("jsctypes-test");
const CTYPES_UNICODE_LIB = ctypes.libraryName("jsctyp\u00E8s-t\u00EB\u00DFt");

function do_check_throws(f, type, stack)
{
Expand Down Expand Up @@ -72,9 +72,9 @@ function run_test()
run_float_tests(library, ctypes.double, "double", 8);

// Test the wrapped integer types.
s64limits = ["-9223372036854775808", "9223372036854775807",
"-9223372036854775809", "9223372036854775808"];
u64limits = ["0", "18446744073709551615", "-1", "18446744073709551616"];
const s64limits = ["-9223372036854775808", "9223372036854775807",
"-9223372036854775809", "9223372036854775808"];
const u64limits = ["0", "18446744073709551615", "-1", "18446744073709551616"];

run_wrapped_integer_tests(library, ctypes.int64_t, "int64_t", 8, true,
ctypes.Int64, "ctypes.Int64", s64limits);
Expand All @@ -85,8 +85,8 @@ function run_test()
run_wrapped_integer_tests(library, ctypes.unsigned_long_long, "unsigned_long_long", 8, false,
ctypes.UInt64, "ctypes.UInt64", u64limits);

s32limits = [-0x80000000, 0x7fffffff, -0x80000001, 0x80000000];
u32limits = [0, 0xffffffff, -1, 0x100000000];
const s32limits = [-0x80000000, 0x7fffffff, -0x80000001, 0x80000000];
const u32limits = [0, 0xffffffff, -1, 0x100000000];

let slimits, ulimits;
if (ctypes.long.size == 8) {
Expand Down Expand Up @@ -1771,7 +1771,7 @@ function run_PointerType_tests() {
" can be converted to " + item_type + " array");

// Convert ArrayBuffer to array of the right size and check contents
c_array = array_type(c_arraybuffer);
let c_array = array_type(c_arraybuffer);
for (let k = 0; k < number_of_items; ++k) {
do_check_eq(c_array[k], view[k]);
}
Expand Down Expand Up @@ -2690,14 +2690,14 @@ function run_variadic_tests(library) {

do_check_eq(result.value, 3 + 5 + 7 + 11);

result = ctypes.int32_t.array(3)([1, 1, 1]),
v1 = ctypes.int32_t.array(4)([1, 2, 3, 5]),
v2 = ctypes.int32_t.array(3)([7, 11, 13]),
vector_add_va = library.declare("test_vector_add_va_cdecl",
result = ctypes.int32_t.array(3)([1, 1, 1]);
let v1 = ctypes.int32_t.array(4)([1, 2, 3, 5]);
let v2 = ctypes.int32_t.array(3)([7, 11, 13]);
let vector_add_va = library.declare("test_vector_add_va_cdecl",
ctypes.default_abi, ctypes.int32_t.ptr,
ctypes.uint8_t, ctypes.uint8_t, "..."),
ctypes.uint8_t, ctypes.uint8_t, "...");
// Note that vector_add_va zeroes out result first.
vec_sum = vector_add_va(2, 3, result, v1, v2);
let vec_sum = vector_add_va(2, 3, result, v1, v2);
do_check_eq(vec_sum.contents, 8);
do_check_eq(result[0], 8);
do_check_eq(result[1], 13);
Expand Down
1 change: 0 additions & 1 deletion toolkit/components/extensions/test/mochitest/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = { // eslint-disable-line no-undef
},

"globals": {
"ChromeWorker": false,
"onmessage": true,
"sendAsyncMessage": false,

Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/feeds/FeedProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function bagHasKey(bag, key) {
function makePropGetter(key) {
return function FeedPropGetter(bag) {
try {
return value = bag.getProperty(key);
return bag.getProperty(key);
}
catch (e) {
}
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/filepicker/nsFilePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

const DEBUG = false; /* set to true to enable debug messages */
var debug;

const LOCAL_FILE_CONTRACTID = "@mozilla.org/file/local;1";
const APPSHELL_SERV_CONTRACTID = "@mozilla.org/appshell/appShellService;1";
Expand Down
4 changes: 3 additions & 1 deletion toolkit/components/formautofill/test/xpcshell/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
/*
* Initialization specific to Form Autofill xpcshell tests.
*
* This file is loaded by "loader.js".
* This file is loaded alongside loader.js.
*/

/* import-globals-from loader.js */

"use strict";

// The testing framework is fully initialized at this point, you can add
Expand Down
2 changes: 2 additions & 0 deletions toolkit/components/formautofill/test/xpcshell/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/Services.jsm", this);

/* import-globals-from ../loader_common.js */
Services.scriptloader.loadSubScript(
Services.io.newFileURI(do_get_file("loader_common.js")).spec, this);

Expand All @@ -33,6 +34,7 @@ var add_task_in_parent_process = add_task;
var add_task_in_child_process = function() {};
var add_task_in_both_processes = add_task;

/* import-globals-from ../head_common.js */
Services.scriptloader.loadSubScript(
Services.io.newFileURI(do_get_file("head_common.js")).spec, this);

Expand Down
1 change: 1 addition & 0 deletions toolkit/components/jsdownloads/src/DownloadCore.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "gPrintSettingsService",
"@mozilla.org/gfx/printsettings-service;1",
Ci.nsIPrintSettingsService);

/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(this, "DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm");

Expand Down
1 change: 1 addition & 0 deletions toolkit/components/jsdownloads/src/Downloads.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Promise",
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");

/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(this, "DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* the "copy" and "legacy" saver implementations.
*/

/* import-globals-from head.js */
/* global gUseLegacySaver */

"use strict";

// Globals
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/jsdownloads/test/unit/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "gExternalHelperAppService",
"@mozilla.org/uriloader/external-helper-app-service;1",
Ci.nsIExternalHelperAppService);

/* global DownloadIntegration */
Integration.downloads.defineModuleGetter(this, "DownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm");

Expand Down
7 changes: 7 additions & 0 deletions toolkit/components/mozintl/test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
"extends": [
"../../../../testing/xpcshell/xpcshell.eslintrc.js"
]
};
2 changes: 1 addition & 1 deletion toolkit/components/places/nsPlacesExpiration.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ nsPlacesExpiration.prototype = {
memSizeBytes = Services.sysinfo.getProperty("memsize");
} catch (ex) {}
if (memSizeBytes <= 0) {
memsize = MEMSIZE_FALLBACK_BYTES;
memSizeBytes = MEMSIZE_FALLBACK_BYTES;
}

let diskAvailableBytes = DISKSIZE_FALLBACK_BYTES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Cu.import("resource://gre/modules/Services.jsm");

// Import common head.
{
/* import-globals-from ../head_common.js */
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ add_task(function* test_same_date_diff_hash() {
let backupFile = OS.Path.join(backupFolder, filename);
yield OS.File.move(tempPath, backupFile);
yield PlacesBackups.create(); // Force compressed backup
mostRecentBackupFile = yield PlacesBackups.getMostRecentBackup();
let mostRecentBackupFile = yield PlacesBackups.getMostRecentBackup();

// Decode lz4 compressed file to json and check if json is valid
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ add_task(function*() {
// backup will replace the existing one.
yield PlacesBackups.create(undefined, true);
do_check_eq(backupFiles.length, 1);
recentBackup = yield PlacesBackups.getMostRecentBackup();
let recentBackup = yield PlacesBackups.getMostRecentBackup();
do_check_neq(recentBackup, OS.Path.join(backupFolder, oldBackupName));
matches = OS.Path.basename(recentBackup).match(PlacesBackups.filenamesRegex);
do_check_eq(matches[1], PlacesBackups.toISODateString(new Date()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ add_task(function* test_saveBookmarksToJSONFile_and_create()
yield PlacesBackups.create();
do_check_eq((yield PlacesBackups.getBackupFiles()).length, 1);

mostRecentBackupFile = yield PlacesBackups.getMostRecentBackup();
let mostRecentBackupFile = yield PlacesBackups.getMostRecentBackup();
do_check_neq(mostRecentBackupFile, null);
matches = OS.Path.basename(recentBackup).match(PlacesBackups.filenamesRegex);
do_check_eq(matches[2], nodeCount);
Expand All @@ -54,4 +54,3 @@ add_task(function* test_saveBookmarksToJSONFile_and_create()
yield PlacesBackups.create(0);
PlacesUtils.bookmarks.removeItem(bookmarkId);
});

Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ add_task(function* test_bookmarks() {
bs.removeFolderChildren(tmpFolder);
// 4) confirm that folder has 0 children
try {
result = hs.executeQuery(query, options);
let result = hs.executeQuery(query, options);
let rootNode = result.root;
rootNode.containerOpen = true;
do_check_eq(rootNode.childCount, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ add_task(function* test_eraseEverything() {
// Bug 1306445 will eventually remove the mobile root anno.
Assert.equal(annoAttrs.length, 1);
Assert.equal(annoAttrs[0].getResultByName("name"), PlacesUtils.MOBILE_ROOT_ANNO);
let annos = rows = yield conn.execute(`SELECT item_id, anno_attribute_id FROM moz_items_annos`);
let annos = yield conn.execute(`SELECT item_id, anno_attribute_id FROM moz_items_annos`);
Assert.equal(annos.length, 1);
Assert.equal(annos[0].getResultByName("item_id"), PlacesUtils.mobileFolderId);
Assert.equal(annos[0].getResultByName("anno_attribute_id"), annoAttrs[0].getResultByName("id"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ add_task(function* remove_bookmark_orphans() {
// Bug 1306445 will eventually remove the mobile root anno.
Assert.equal(annoAttrs.length, 1);
Assert.equal(annoAttrs[0].getResultByName("name"), PlacesUtils.MOBILE_ROOT_ANNO);
let annos = rows = yield conn.execute(`SELECT item_id, anno_attribute_id FROM moz_items_annos`);
let annos = yield conn.execute(`SELECT item_id, anno_attribute_id FROM moz_items_annos`);
Assert.equal(annos.length, 1);
Assert.equal(annos[0].getResultByName("item_id"), PlacesUtils.mobileFolderId);
Assert.equal(annos[0].getResultByName("anno_attribute_id"), annoAttrs[0].getResultByName("id"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Cu.import("resource://gre/modules/Services.jsm");

// Import common head.
{
/* import-globals-from ../head_common.js */
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ add_task(function* test_notifications_onDeleteURI() {
}

// Observe history.
historyObserver = {
let historyObserver = {
onBeginUpdateBatch: function PEX_onBeginUpdateBatch() {},
onEndUpdateBatch: function PEX_onEndUpdateBatch() {},
onClearHistory: function() {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ add_task(function* test_notifications_onDeleteVisits() {
}

// Observe history.
historyObserver = {
let historyObserver = {
onBeginUpdateBatch: function PEX_onBeginUpdateBatch() {},
onEndUpdateBatch: function PEX_onEndUpdateBatch() {},
onClearHistory: function() {},
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/places/tests/favicons/head_favicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Cu.import("resource://gre/modules/Services.jsm");

// Import common head.
{
/* import-globals-from ../head_common.js */
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
Expand Down
1 change: 1 addition & 0 deletions toolkit/components/places/tests/history/head_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Cu.import("resource://gre/modules/Services.jsm");

// Import common head.
{
/* import-globals-from ../head_common.js */
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Cu.import("resource://gre/modules/Services.jsm");

// Import common head.
{
/* import-globals-from ../head_common.js */
let commonFile = do_get_file("../head_common.js", false);
let uri = Services.io.newFileURI(commonFile);
Services.scriptloader.loadSubScript(uri.spec, this);
Expand Down
Loading

0 comments on commit 5856abc

Please sign in to comment.