--- a/toolkit/components/satchel/.eslintrc.js
+++ b/toolkit/components/satchel/.eslintrc.js
@@ -1,12 +1,14 @@
"use strict";
module.exports = {
rules: {
+ "mozilla/var-only-at-top-level": "error",
+
curly: ["error", "all"],
indent: ["error", 2, {
SwitchCase: 1,
CallExpression: {
arguments: "first",
},
FunctionExpression: {
parameters: "first",
--- a/toolkit/components/satchel/formSubmitListener.js
+++ b/toolkit/components/satchel/formSubmitListener.js
@@ -6,17 +6,17 @@
(function() {
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
-var satchelFormListener = {
+let satchelFormListener = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIFormSubmitObserver,
Ci.nsIObserver,
Ci.nsISupportsWeakReference
]),
debug: true,
enabled: true,
--- a/toolkit/components/satchel/test/satchel_common.js
+++ b/toolkit/components/satchel/test/satchel_common.js
@@ -8,23 +8,23 @@ var gPopupShownExpected = false;
var gPopupShownListener;
var gLastAutoCompleteResults;
var gChromeScript;
/*
* Returns the element with the specified |name| attribute.
*/
function $_(formNum, name) {
- var form = document.getElementById("form" + formNum);
+ let form = document.getElementById("form" + formNum);
if (!form) {
ok(false, "$_ couldn't find requested form " + formNum);
return null;
}
- var element = form.elements.namedItem(name);
+ let element = form.elements.namedItem(name);
if (!element) {
ok(false, "$_ couldn't find requested element " + name);
return null;
}
// Note that namedItem is a bit stupid, and will prefer an
// |id| attribute over a |name| attribute when looking for
// the element.
@@ -35,26 +35,26 @@ function $_(formNum, name) {
}
return element;
}
// Mochitest gives us a sendKey(), but it's targeted to a specific element.
// This basically sends an untargeted key event, to whatever's focused.
function doKey(aKey, modifier) {
- var keyName = "DOM_VK_" + aKey.toUpperCase();
- var key = SpecialPowers.Ci.nsIDOMKeyEvent[keyName];
+ let keyName = "DOM_VK_" + aKey.toUpperCase();
+ let key = SpecialPowers.Ci.nsIDOMKeyEvent[keyName];
// undefined --> null
if (!modifier) {
modifier = null;
}
// Window utils for sending fake key events.
- var wutils = SpecialPowers.getDOMWindowUtils(window);
+ let wutils = SpecialPowers.getDOMWindowUtils(window);
if (wutils.sendKeyEvent("keydown", key, 0, modifier)) {
wutils.sendKeyEvent("keypress", key, 0, modifier);
}
wutils.sendKeyEvent("keyup", key, 0, modifier);
}
function registerPopupShownListener(listener) {
@@ -65,24 +65,24 @@ function registerPopupShownListener(list
gPopupShownListener = listener;
}
function getMenuEntries() {
if (!gLastAutoCompleteResults) {
throw new Error("no autocomplete results");
}
- var results = gLastAutoCompleteResults;
+ let results = gLastAutoCompleteResults;
gLastAutoCompleteResults = null;
return results;
}
function checkArrayValues(actualValues, expectedValues, msg) {
is(actualValues.length, expectedValues.length, "Checking array values: " + msg);
- for (var i = 0; i < expectedValues.length; i++) {
+ for (let i = 0; i < expectedValues.length; i++) {
is(actualValues[i], expectedValues[i], msg + " Checking array entry #" + i);
}
}
var checkObserver = {
verifyStack: [],
callback: null,
@@ -113,41 +113,41 @@ var checkObserver = {
// more. Here it is assumed that for every entry satchel saves or modifies, a
// message is sent.
//
// We don't actually check the content of the message, but just that the right
// quantity of messages is received.
// - if there are too few messages, test will time out
// - if there are too many messages, test will error out here
//
- var expected = this.verifyStack.shift();
+ let expected = this.verifyStack.shift();
countEntries(expected.name, expected.value,
function(num) {
ok(num > 0, expected.message);
if (checkObserver.verifyStack.length == 0) {
- var callback = checkObserver.callback;
+ let callback = checkObserver.callback;
checkObserver.callback = null;
callback();
}
});
}
};
function checkForSave(name, value, message) {
checkObserver.verifyStack.push({ name, value, message });
}
function getFormSubmitButton(formNum) {
- var form = $("form" + formNum); // by id, not name
+ let form = $("form" + formNum); // by id, not name
ok(form != null, "getting form " + formNum);
// we can't just call form.submit(), because that doesn't seem to
// invoke the form onsubmit handler.
- var button = form.firstChild;
+ let button = form.firstChild;
while (button && button.type != "submit") { button = button.nextSibling; }
ok(button != null, "getting form submit button");
return button;
}
// Count the number of entries with the given name and value, and call then(number)
// when done. If name or value is null, then the value of that field does not matter.
@@ -257,17 +257,17 @@ function promiseACShown() {
gPopupShownListener = ({ results }) => {
gPopupShownExpected = false;
resolve(results);
};
});
}
function satchelCommonSetup() {
- var chromeURL = SimpleTest.getTestFileURL("parent_utils.js");
+ let chromeURL = SimpleTest.getTestFileURL("parent_utils.js");
gChromeScript = SpecialPowers.loadChromeScript(chromeURL);
gChromeScript.addMessageListener("onpopupshown", ({ results }) => {
gLastAutoCompleteResults = results;
if (gPopupShownListener) {
gPopupShownListener({results});
}
});
--- a/toolkit/components/satchel/test/subtst_privbrowsing.html
+++ b/toolkit/components/satchel/test/subtst_privbrowsing.html
@@ -1,17 +1,17 @@
<html>
<head>
<meta charset=UTF-8>
<title>Subtest for bug 472396</title>
<script>
function submitForm() {
if (location.search.indexOf("field") == -1) {
- var form = document.getElementById("form");
- var field = document.getElementById("field");
+ let form = document.getElementById("form");
+ let field = document.getElementById("field");
field.value = "value";
form.submit();
}
}
</script>
</head>
<body onload="submitForm();">
<h2>Subtest for bug 472396</h2>
--- a/toolkit/components/satchel/test/test_bug_787624.html
+++ b/toolkit/components/satchel/test/test_bug_787624.html
@@ -57,31 +57,31 @@ Form History Layout test: form field aut
var resolvePopupShownListener;
registerPopupShownListener(() => resolvePopupShownListener());
function waitForNextPopup() {
return new Promise(resolve => { resolvePopupShownListener = resolve; });
}
add_task(async function test_popup_not_move_input() {
- var input = $_(1, "field1");
- var rect = input.getBoundingClientRect();
+ let input = $_(1, "field1");
+ let rect = input.getBoundingClientRect();
await new Promise(resolve => updateFormHistory([
{ op: "remove" },
{ op: "add", fieldname: "field1", value: "value1" },
{ op: "add", fieldname: "field1", value: "value2" },
], resolve));
let popupShown = waitForNextPopup();
input.focus();
doKey("down");
await popupShown;
- var newRect = input.getBoundingClientRect();
+ let newRect = input.getBoundingClientRect();
is(newRect.left, rect.left,
"autocomplete popup does not disturb the input position");
is(newRect.top, rect.top,
"autocomplete popup does not disturb the input position");
});
</script>
</pre>
--- a/toolkit/components/satchel/test/test_datalist_with_caching.html
+++ b/toolkit/components/satchel/test/test_datalist_with_caching.html
@@ -29,17 +29,17 @@ Form History test: form field autocomple
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/* import-globals-from ../../../../testing/mochitest/tests/SimpleTest/EventUtils.js */
/* import-globals-from ../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from satchel_common.js */
-var input = $_(1, "field1");
+let input = $_(1, "field1");
function setupFormHistory(aCallback) {
updateFormHistory([
{ op: "remove" },
{ op: "add", fieldname: "field1", value: "Sec" },
], () => {
spawn_task(aCallback);
});
@@ -52,17 +52,17 @@ function setForm(value) {
// Restore the form to the default state.
function restoreForm() {
setForm("");
}
// Check for expected form data.
function checkForm(expectedValue) {
- var formID = input.parentNode.id;
+ let formID = input.parentNode.id;
is(input.value, expectedValue, "Checking " + formID + " input");
}
SimpleTest.waitForExplicitFinish();
var expectingPopup = null;
function expectPopup() {
@@ -88,19 +88,19 @@ function waitForMenuChange(expectedCount
return new Promise(resolve => {
notifyMenuChanged(expectedCount, null, resolve);
});
}
registerPopupShownListener(popupShownListener);
function checkMenuEntries(expectedValues) {
- var actualValues = getMenuEntries();
+ let actualValues = getMenuEntries();
is(actualValues.length, expectedValues.length, testNum + " Checking length of expected menu");
- for (var i = 0; i < expectedValues.length; i++) {
+ for (let i = 0; i < expectedValues.length; i++) {
is(actualValues[i], expectedValues[i], testNum + " Checking menu entry #" + i);
}
}
async function runTests() {
testNum++;
restoreForm();
doKey("down");
--- a/toolkit/components/satchel/test/test_form_autocomplete.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete.html
@@ -196,17 +196,17 @@ function setForm(value) {
// Restore the form to the default state.
function restoreForm() {
setForm("");
}
// Check for expected form data.
function checkForm(expectedValue) {
- var formID = input.parentNode.id;
+ let formID = input.parentNode.id;
is(input.value, expectedValue, "Checking " + formID + " input");
}
var testNum = 0;
var expectingPopup = false;
function expectPopup() {
info("expecting popup for test " + testNum);
@@ -1048,19 +1048,19 @@ function waitForScroll() {
}, false);
}
function waitForMenuChange(expectedCount, expectedFirstValue) {
notifyMenuChanged(expectedCount, expectedFirstValue, runTest);
}
function checkMenuEntries(expectedValues, testNumber) {
- var actualValues = getMenuEntries();
+ let actualValues = getMenuEntries();
is(actualValues.length, expectedValues.length, testNumber + " Checking length of expected menu");
- for (var i = 0; i < expectedValues.length; i++) {
+ for (let i = 0; i < expectedValues.length; i++) {
is(actualValues[i], expectedValues[i], testNumber + " Checking menu entry #" + i);
}
}
function startTest() {
setupFormHistory(function() {
runTest();
});
--- a/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
@@ -65,17 +65,17 @@ function setForm(value) {
// Restore the form to the default state.
function restoreForm() {
setForm("");
}
// Check for expected form data.
function checkForm(expectedValue) {
- var formID = input.parentNode.id;
+ let formID = input.parentNode.id;
is(input.value, expectedValue, "Checking " + formID + " input");
}
var testNum = 0;
var prevValue;
var expectingPopup = false;
function expectPopup() {
@@ -101,16 +101,17 @@ registerPopupShownListener(popupShownLis
* This is a bit hacky, as many operations happen asynchronously.
* Various mechanisms call runTests as a result of operations:
* - set expectingPopup to true, and the next test will occur when the autocomplete popup is shown
* - call waitForMenuChange(x) to run the next test when the autocomplete popup
* to have x items in it
*/
function runTest() {
testNum++;
+ let datalist;
info("Starting test #" + testNum);
switch (testNum) {
case 1:
// Make sure initial form is empty.
checkForm("");
// Trigger autocomplete popup
@@ -323,18 +324,18 @@ function runTest() {
// Test dynamic updates.
// For some reasons, when there is an update of the list, the selection is
// lost so we need to go down like if we were at the beginning of the list
// again.
case 200:
// Removing the second element while on the first then going down and
// push enter. Value should be one from the third suggesion.
doKey("down");
- var datalist = document.getElementById("suggest");
- var toRemove = datalist.children[1];
+ datalist = document.getElementById("suggest");
+ let toRemove = datalist.children[1];
datalist.removeChild(toRemove);
SimpleTest.executeSoon(function() {
doKey("down");
doKey("down");
doKey("return");
checkForm("final");
@@ -346,17 +347,17 @@ function runTest() {
});
break;
case 201:
// Adding an attribute after the first one while on the first then going
// down and push enter. Value should be the on from the new suggestion.
doKey("down");
datalist = document.getElementById("suggest");
- var added = new Option("Foo");
+ let added = new Option("Foo");
datalist.insertBefore(added, datalist.children[1]);
waitForMenuChange(4);
break;
case 202:
doKey("down");
doKey("down");
doKey("return");
@@ -483,19 +484,19 @@ function runTest() {
}
}
function waitForMenuChange(expectedCount) {
notifyMenuChanged(expectedCount, null, runTest);
}
function checkMenuEntries(expectedValues, testNumber) {
- var actualValues = getMenuEntries();
+ let actualValues = getMenuEntries();
is(actualValues.length, expectedValues.length, testNumber + " Checking length of expected menu");
- for (var i = 0; i < expectedValues.length; i++) {
+ for (let i = 0; i < expectedValues.length; i++) {
is(actualValues[i], expectedValues[i], testNumber + " Checking menu entry #" + i);
}
}
function startTest() {
setupFormHistory(runTest);
}
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -309,17 +309,17 @@ function startTest() {
"012345678901234567890123456789012345678901234567890123456789012345678" +
"901234567890123456789012345678901234567890123456789012345678901234567" +
"89012345678901234567890123456789012345678901234567890";
$_(12, "test1").value = " ";
$_(13, "test1").value = "dontSaveThis";
$_(14, "test1").type = "password";
$_(14, "test1").value = "dontSaveThis";
- var testData = ccNumbers.valid16;
+ let testData = ccNumbers.valid16;
for (let i = 0; i != testData.length; i++) {
$_(15, "test" + (i + 1)).value = testData[i];
}
testData = ccNumbers.valid15;
for (let i = 0; i != testData.length; i++) {
$_(16, "test" + (i + 1)).value = testData[i];
}
@@ -345,17 +345,17 @@ function startTest() {
testData = ccNumbers.invalid15;
for (let i = 0; i != testData.length; i++) {
$_(108, "test8_" + (i + 1)).value = testData[i];
}
$_(109, "test9").value = "savedValue";
// submit the first form.
- var button = getFormSubmitButton(1);
+ let button = getFormSubmitButton(1);
button.click();
}
// Called by each form's onsubmit handler.
function checkSubmit(formNum) {
ok(true, "form " + formNum + " submitted");
numSubmittedForms++;
@@ -461,26 +461,26 @@ function submitForm(formNum) {
// chain of submits will happen recursively since the submit is dispatched
// immediately.
//
// This in itself is fine, but if there are errors in the code, mochitests
// will in some cases give you "server too busy", which is hard to debug!
//
setTimeout(function() {
checkObserver.waitForChecks(function() {
- var nextFormNum = formNum == 22 ? 100 : (formNum + 1);
+ let nextFormNum = formNum == 22 ? 100 : (formNum + 1);
// Submit the next form. Special cases are Forms 21 and 100, which happen
// from an HTTPS domain in an iframe.
if (nextFormNum == 100) {
ok(true, "submitting iframe test " + nextFormNum);
SpecialPowers.wrap(document.getElementById("iframe").contentWindow)
.wrappedJSObject.clickButton(nextFormNum);
} else {
- var button = getFormSubmitButton(nextFormNum);
+ let button = getFormSubmitButton(nextFormNum);
button.click();
}
});
}, 0);
return false; // cancel current form submission
}
--- a/toolkit/components/satchel/test/test_form_submission_cap.html
+++ b/toolkit/components/satchel/test/test_form_submission_cap.html
@@ -33,33 +33,33 @@ function checkInitialState() {
countEntries(null, null,
function(num) {
ok(!num, "checking for initially empty storage");
startTest();
});
}
function startTest() {
- var form = document.getElementById("form1");
+ let form = document.getElementById("form1");
for (let i = 1; i <= numInputFields; i++) {
- var newField = document.createElement("input");
+ let newField = document.createElement("input");
newField.setAttribute("type", "text");
newField.setAttribute("name", "test" + i);
form.appendChild(newField);
}
// Fill in values for the various fields. We could just set the <input>'s
// value attribute, but we don't save default form values (and we want to
// ensure unsaved values are because of autocomplete=off or whatever).
for (let i = 1; i <= numInputFields; i++) {
$_(1, "test" + i).value = i;
}
// submit the first form.
- var button = getFormSubmitButton(1);
+ let button = getFormSubmitButton(1);
button.click();
}
// Called by each form's onsubmit handler.
function checkSubmit(formNum) {
ok(true, "form " + formNum + " submitted");
numSubmittedForms++;
--- a/toolkit/components/satchel/test/test_form_submission_cap2.html
+++ b/toolkit/components/satchel/test/test_form_submission_cap2.html
@@ -137,17 +137,17 @@ function checkInitialState() {
function startTest() {
// Fill in values for the various fields. We could just set the <input>'s
// value attribute, but we don't save default form values (and we want to
// ensure unsaved values are because of autocomplete=off or whatever).
$_(1, "test" + numInputFields).value = numInputFields + " changed";
// submit the first form.
- var button = getFormSubmitButton(1);
+ let button = getFormSubmitButton(1);
button.click();
}
// Make sure that the first (numInputFields - 1) were not saved (as they were not changed).
// Call done() when finished.
function checkCountEntries(formNum, index, done) {
countEntries("test" + index, index,
function(num) {
--- a/toolkit/components/satchel/test/test_popup_direction.html
+++ b/toolkit/components/satchel/test/test_popup_direction.html
@@ -27,17 +27,17 @@ Test for Popup Direction
var resolvePopupShownListener;
registerPopupShownListener(() => resolvePopupShownListener());
function waitForNextPopup() {
return new Promise(resolve => { resolvePopupShownListener = resolve; });
}
add_task(async function test_popup_direction() {
- var input = $_(1, "field1");
+ let input = $_(1, "field1");
await new Promise(resolve => updateFormHistory([
{ op: "remove" },
{ op: "add", fieldname: "field1", value: "value1" },
{ op: "add", fieldname: "field1", value: "value2" },
], resolve));
for (let direction of ["ltr", "rtl"]) {
--- a/toolkit/components/satchel/test/unit/head_satchel.js
+++ b/toolkit/components/satchel/test/unit/head_satchel.js
@@ -17,20 +17,20 @@ var dirSvc = Cc["@mozilla.org/file/direc
// Send the profile-after-change notification to the form history component to ensure
// that it has been initialized.
var formHistoryStartup = Cc["@mozilla.org/satchel/form-history-startup;1"]
.getService(Ci.nsIObserver);
formHistoryStartup.observe(null, "profile-after-change", null);
function getDBVersion(dbfile) {
- var ss = Cc["@mozilla.org/storage/service;1"]
+ let ss = Cc["@mozilla.org/storage/service;1"]
.getService(Ci.mozIStorageService);
- var dbConnection = ss.openDatabase(dbfile);
- var version = dbConnection.schemaVersion;
+ let dbConnection = ss.openDatabase(dbfile);
+ let version = dbConnection.schemaVersion;
dbConnection.close();
return version;
}
const isGUID = /[A-Za-z0-9\+\/]{16}/;
// Find form history entries.
@@ -47,17 +47,17 @@ function searchEntries(terms, params, it
}
}
});
}
// Count the number of entries with the given name and value, and call then(number)
// when done. If name or value is null, then the value of that field does not matter.
function countEntries(name, value, then) {
- var obj = {};
+ let obj = {};
if (name !== null) {
obj.fieldname = name;
}
if (value !== null) {
obj.value = value;
}
let count = 0;
@@ -71,17 +71,17 @@ function countEntries(name, value, then)
then(count);
}
}
});
}
// Perform a single form history update and call then() when done.
function updateEntry(op, name, value, then) {
- var obj = { op };
+ let obj = { op };
if (name !== null) {
obj.fieldname = name;
}
if (value !== null) {
obj.value = value;
}
updateFormHistory(obj, then);
}
--- a/toolkit/components/satchel/test/unit/test_async_expire.js
+++ b/toolkit/components/satchel/test/unit/test_async_expire.js
@@ -46,18 +46,18 @@ function run_test() {
function next_test() {
iter.next();
}
function* tests() {
Services.obs.addObserver(TestObserver, "satchel-storage-changed", true);
// ===== test init =====
- var testfile = do_get_file("asyncformhistory_expire.sqlite");
- var profileDir = do_get_profile();
+ let testfile = do_get_file("asyncformhistory_expire.sqlite");
+ let profileDir = do_get_profile();
// Cleanup from any previous tests or failures.
dbFile = profileDir.clone();
dbFile.append("formhistory.sqlite");
if (dbFile.exists()) {
dbFile.remove(false);
}
@@ -75,17 +75,17 @@ function* tests() {
do_check_eq(CURRENT_SCHEMA, FormHistory.schemaVersion);
// Add a new entry
yield countEntries("name-C", "value-C", checkNotExists);
yield addEntry("name-C", "value-C", next_test);
yield countEntries("name-C", "value-C", checkExists);
// Update some existing entries to have ages relative to when the test runs.
- var now = 1000 * Date.now();
+ let now = 1000 * Date.now();
let updateLastUsed = function updateLastUsedFn(results, age) {
let lastUsed = now - age * 24 * PR_HOURS;
let changes = [ ];
for (let r = 0; r < results.length; r++) {
changes.push({ op: "update", lastUsed, guid: results[r].guid });
}
--- a/toolkit/components/satchel/test/unit/test_autocomplete.js
+++ b/toolkit/components/satchel/test/unit/test_autocomplete.js
@@ -8,55 +8,55 @@ var testnum = 0;
var fac;
var prefs;
var numRecords, timeGroupingSize, now;
const DEFAULT_EXPIRE_DAYS = 180;
function padLeft(number, length) {
- var str = number + "";
+ let str = number + "";
while (str.length < length) {
str = "0" + str;
}
return str;
}
function getFormExpiryDays() {
if (prefs.prefHasUserValue("browser.formfill.expire_days")) {
return prefs.getIntPref("browser.formfill.expire_days");
}
return DEFAULT_EXPIRE_DAYS;
}
function run_test() {
// ===== test init =====
- var testfile = do_get_file("formhistory_autocomplete.sqlite");
- var profileDir = dirSvc.get("ProfD", Ci.nsIFile);
+ let testfile = do_get_file("formhistory_autocomplete.sqlite");
+ let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
- var destFile = profileDir.clone();
+ let destFile = profileDir.clone();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
testfile.copyTo(profileDir, "formhistory.sqlite");
fac = Cc["@mozilla.org/satchel/form-autocomplete;1"].getService(Ci.nsIFormAutoComplete);
prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
timeGroupingSize = prefs.getIntPref("browser.formfill.timeGroupingSize") * 1000 * 1000;
run_next_test();
}
add_test(function test0() {
- var maxTimeGroupings = prefs.getIntPref("browser.formfill.maxTimeGroupings");
- var bucketSize = prefs.getIntPref("browser.formfill.bucketSize");
+ let maxTimeGroupings = prefs.getIntPref("browser.formfill.maxTimeGroupings");
+ let bucketSize = prefs.getIntPref("browser.formfill.bucketSize");
// ===== Tests with constant timesUsed and varying lastUsed date =====
// insert 2 records per bucket to check alphabetical sort within
now = 1000 * Date.now();
numRecords = Math.ceil(maxTimeGroupings / bucketSize) * 2;
let changes = [ ];
for (let i = 0; i < numRecords; i += 2) {
--- a/toolkit/components/satchel/test/unit/test_db_update_v4.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v4.js
@@ -10,21 +10,21 @@ function run_test() {
do_test_pending();
iter = next_test();
iter.next();
}
function* next_test() {
try {
// ===== test init =====
- var testfile = do_get_file("formhistory_v3.sqlite");
- var profileDir = dirSvc.get("ProfD", Ci.nsIFile);
+ let testfile = do_get_file("formhistory_v3.sqlite");
+ let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
- var destFile = profileDir.clone();
+ let destFile = profileDir.clone();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
testfile.copyTo(profileDir, "formhistory.sqlite");
do_check_eq(3, getDBVersion(testfile));
--- a/toolkit/components/satchel/test/unit/test_db_update_v4b.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v4b.js
@@ -10,21 +10,21 @@ function run_test() {
do_test_pending();
iter = next_test();
iter.next();
}
function* next_test() {
try {
// ===== test init =====
- var testfile = do_get_file("formhistory_v3v4.sqlite");
- var profileDir = dirSvc.get("ProfD", Ci.nsIFile);
+ let testfile = do_get_file("formhistory_v3v4.sqlite");
+ let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
- var destFile = profileDir.clone();
+ let destFile = profileDir.clone();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
testfile.copyTo(profileDir, "formhistory.sqlite");
do_check_eq(3, getDBVersion(testfile));
--- a/toolkit/components/satchel/test/unit/test_db_update_v999a.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v999a.js
@@ -18,25 +18,25 @@ function run_test() {
iter.next();
}
function next_test() {
iter.next();
}
function* tests() {
- var testnum = 0;
+ let testnum = 0;
try {
// ===== test init =====
- var testfile = do_get_file("formhistory_v999a.sqlite");
- var profileDir = dirSvc.get("ProfD", Ci.nsIFile);
+ let testfile = do_get_file("formhistory_v999a.sqlite");
+ let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
- var destFile = profileDir.clone();
+ let destFile = profileDir.clone();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
testfile.copyTo(profileDir, "formhistory.sqlite");
do_check_eq(999, getDBVersion(testfile));
--- a/toolkit/components/satchel/test/unit/test_db_update_v999b.js
+++ b/toolkit/components/satchel/test/unit/test_db_update_v999b.js
@@ -18,31 +18,31 @@ function run_test() {
iter.next();
}
function next_test() {
iter.next();
}
function* tests() {
- var testnum = 0;
+ let testnum = 0;
try {
// ===== test init =====
- var testfile = do_get_file("formhistory_v999b.sqlite");
- var profileDir = dirSvc.get("ProfD", Ci.nsIFile);
+ let testfile = do_get_file("formhistory_v999b.sqlite");
+ let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
- var destFile = profileDir.clone();
+ let destFile = profileDir.clone();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
- var bakFile = profileDir.clone();
+ let bakFile = profileDir.clone();
bakFile.append("formhistory.sqlite.corrupt");
if (bakFile.exists()) {
bakFile.remove(false);
}
testfile.copyTo(profileDir, "formhistory.sqlite");
do_check_eq(999, getDBVersion(testfile));
--- a/toolkit/components/satchel/test/unit/test_history_api.js
+++ b/toolkit/components/satchel/test/unit/test_history_api.js
@@ -45,17 +45,17 @@ function checkTimeDeleted(guid, checkFun
handleCompletion() {
stmt.finalize();
}
});
});
}
function promiseUpdateEntry(op, name, value) {
- var change = { op };
+ let change = { op };
if (name !== null) {
change.fieldname = name;
}
if (value !== null) {
change.value = value;
}
return promiseUpdate(change);
}
@@ -102,21 +102,21 @@ function promiseCountEntries(name, value
}
add_task(async function() {
let oldSupportsDeletedTable = FormHistory._supportsDeletedTable;
FormHistory._supportsDeletedTable = true;
try {
// ===== test init =====
- var testfile = do_get_file("formhistory_apitest.sqlite");
- var profileDir = dirSvc.get("ProfD", Ci.nsIFile);
+ let testfile = do_get_file("formhistory_apitest.sqlite");
+ let profileDir = dirSvc.get("ProfD", Ci.nsIFile);
// Cleanup from any previous tests or failures.
- var destFile = profileDir.clone();
+ let destFile = profileDir.clone();
destFile.append("formhistory.sqlite");
if (destFile.exists()) {
destFile.remove(false);
}
testfile.copyTo(profileDir, "formhistory.sqlite");
function checkExists(num) { do_check_true(num > 0); }
--- a/toolkit/components/satchel/test/unit/test_notify.js
+++ b/toolkit/components/satchel/test/unit/test_notify.js
@@ -1,19 +1,19 @@
/*
* Test suite for satchel notifications
*
* Tests notifications dispatched when modifying form history.
*
*/
-var expectedNotification;
-var expectedData;
+let expectedNotification;
+let expectedData;
-var TestObserver = {
+let TestObserver = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
observe(subject, topic, data) {
do_check_eq(topic, "satchel-storage-changed");
do_check_eq(data, expectedNotification);
switch (data) {
case "formhistory-add":
@@ -28,47 +28,47 @@ var TestObserver = {
do_throw("Unhandled notification: " + data + " / " + topic);
}
expectedNotification = null;
expectedData = null;
}
};
-var testIterator = null;
+let testIterator = null;
function run_test() {
do_test_pending();
testIterator = run_test_steps();
testIterator.next();
}
function next_test() {
testIterator.next();
}
function* run_test_steps() {
- var testnum = 0;
- var testdesc = "Setup of test form history entries";
+ let testnum = 0;
+ let testdesc = "Setup of test form history entries";
try {
- var entry1 = ["entry1", "value1"];
+ let entry1 = ["entry1", "value1"];
/* ========== 1 ========== */
testnum = 1;
testdesc = "Initial connection to storage module";
yield updateEntry("remove", null, null, next_test);
yield countEntries(null, null, function(num) {
do_check_false(num, "Checking initial DB is empty");
next_test();
});
// Add the observer
- var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
+ let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
os.addObserver(TestObserver, "satchel-storage-changed");
/* ========== 2 ========== */
testnum++;
testdesc = "addEntry";
expectedNotification = "formhistory-add";
expectedData = entry1;