--- a/toolkit/components/satchel/.eslintrc.js
+++ b/toolkit/components/satchel/.eslintrc.js
@@ -36,10 +36,11 @@ module.exports = {
"block-scoped-var": "error",
"no-use-before-define": ["error", {
functions: false,
}],
complexity: ["error", {
max: 20,
}],
"dot-location": ["error", "property"],
+ "max-len": ["error", 100],
},
};
--- a/toolkit/components/satchel/FormHistory.jsm
+++ b/toolkit/components/satchel/FormHistory.jsm
@@ -271,27 +271,29 @@ function makeSearchStatement(aSearchData
if (queryTerms) {
query += " WHERE " + queryTerms;
}
return dbCreateAsyncStatement(query, aSearchData);
}
function makeAddStatement(aNewData, aNow, aBindingArrays) {
- let query = "INSERT INTO moz_formhistory (fieldname, value, timesUsed, firstUsed, lastUsed, guid) " +
+ let query = "INSERT INTO moz_formhistory " +
+ "(fieldname, value, timesUsed, firstUsed, lastUsed, guid) " +
"VALUES (:fieldname, :value, :timesUsed, :firstUsed, :lastUsed, :guid)";
aNewData.timesUsed = aNewData.timesUsed || 1;
aNewData.firstUsed = aNewData.firstUsed || aNow;
aNewData.lastUsed = aNewData.lastUsed || aNow;
return dbCreateAsyncStatement(query, aNewData, aBindingArrays);
}
function makeBumpStatement(aGuid, aNow, aBindingArrays) {
- let query = "UPDATE moz_formhistory SET timesUsed = timesUsed + 1, lastUsed = :lastUsed WHERE guid = :guid";
+ let query = "UPDATE moz_formhistory " +
+ "SET timesUsed = timesUsed + 1, lastUsed = :lastUsed WHERE guid = :guid";
let queryParams = {
lastUsed: aNow,
guid: aGuid,
};
return dbCreateAsyncStatement(query, queryParams, aBindingArrays);
}
@@ -707,17 +709,21 @@ function updateFormHistoryWrite(aChanges
if (aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED) {
for (let [notification, param] of notifications) {
// We're either sending a GUID or nothing at all.
sendNotification(notification, param);
}
}
if (aCallbacks && aCallbacks.handleCompletion) {
- aCallbacks.handleCompletion(aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ? 0 : 1);
+ aCallbacks.handleCompletion(
+ aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ?
+ 0 :
+ 1
+ );
}
},
handleError(aError) {
if (aCallbacks && aCallbacks.handleError) {
aCallbacks.handleError(aError);
}
},
handleResult: NOOP
@@ -818,17 +824,21 @@ this.FormHistory = {
handleError(aError) {
if (aCallbacks && aCallbacks.handleError) {
aCallbacks.handleError(aError);
}
},
handleCompletion(aReason) {
if (aCallbacks && aCallbacks.handleCompletion) {
- aCallbacks.handleCompletion(aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ? 0 : 1);
+ aCallbacks.handleCompletion(
+ aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ?
+ 0 :
+ 1
+ );
}
}
};
stmt.executeAsync(handlers);
},
count(aSearchData, aCallbacks) {
@@ -846,33 +856,38 @@ this.FormHistory = {
handleError(aError) {
if (aCallbacks && aCallbacks.handleError) {
aCallbacks.handleError(aError);
}
},
handleCompletion(aReason) {
if (aCallbacks && aCallbacks.handleCompletion) {
- aCallbacks.handleCompletion(aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ? 0 : 1);
+ aCallbacks.handleCompletion(
+ aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ?
+ 0 :
+ 1
+ );
}
}
};
stmt.executeAsync(handlers);
},
update(aChanges, aCallbacks) {
// Used to keep track of how many searches have been started. When that number
// are finished, updateFormHistoryWrite can be called.
let numSearches = 0;
let completedSearches = 0;
let searchFailed = false;
function validIdentifier(change) {
- // The identifier is only valid if one of either the guid or the (fieldname/value) are set (so an X-OR)
+ // The identifier is only valid if one of either the guid
+ // or the (fieldname/value) are set (so an X-OR)
return Boolean(change.guid) != Boolean(change.fieldname && change.value);
}
if (!("length" in aChanges)) {
aChanges = [aChanges];
}
let isRemoveOperation = aChanges.every(change => change && change.op && change.op == "remove");
@@ -1086,17 +1101,21 @@ this.FormHistory = {
handleError(aError) {
if (aCallbacks && aCallbacks.handleError) {
aCallbacks.handleError(aError);
}
},
handleCompletion(aReason) {
if (aCallbacks && aCallbacks.handleCompletion) {
- aCallbacks.handleCompletion(aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ? 0 : 1);
+ aCallbacks.handleCompletion(
+ aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED ?
+ 0 :
+ 1
+ );
}
}
});
return pending;
},
get schemaVersion() {
return dbConnection.schemaVersion;
--- a/toolkit/components/satchel/nsFormAutoComplete.js
+++ b/toolkit/components/satchel/nsFormAutoComplete.js
@@ -452,17 +452,18 @@ FormAutoComplete.prototype = {
let finalComments = historyComments.concat(comments);
// This is ugly: there are two FormAutoCompleteResult classes in the
// tree, one in a module and one in this file. Datalist results need to
// use the one defined in the module but the rest of this file assumes
// that we use the one defined here. To get around that, we explicitly
// import the module here, out of the way of the other uses of
// FormAutoCompleteResult.
- let {FormAutoCompleteResult} = Cu.import("resource://gre/modules/nsFormAutoCompleteResult.jsm", {});
+ let {FormAutoCompleteResult} = Cu.import("resource://gre/modules/nsFormAutoCompleteResult.jsm",
+ {});
return new FormAutoCompleteResult(datalistResult.searchString,
Ci.nsIAutoCompleteResult.RESULT_SUCCESS,
0,
"",
finalValues,
finalLabels,
finalComments,
historyResult);
--- a/toolkit/components/satchel/test/browser/browser_popup_mouseover.js
+++ b/toolkit/components/satchel/test/browser/browser_popup_mouseover.js
@@ -11,17 +11,20 @@ add_task(async function test() {
const {autoCompletePopup, autoCompletePopup: {richlistbox: itemsBox}} = browser;
const mockHistory = [
{op: "add", fieldname: "field1", value: "value1"},
{op: "add", fieldname: "field1", value: "value2"},
{op: "add", fieldname: "field1", value: "value3"},
{op: "add", fieldname: "field1", value: "value4"},
];
- await new Promise(resolve => FormHistory.update([{op: "remove"}, ...mockHistory], {handleCompletion: resolve}));
+ await new Promise(resolve =>
+ FormHistory.update([{op: "remove"}, ...mockHistory],
+ {handleCompletion: resolve})
+ );
await ContentTask.spawn(browser, {}, async function() {
const input = content.document.querySelector("input");
input.focus();
});
// show popup
await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
--- a/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js
+++ b/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.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/. */
-var FormHistory = (Components.utils.import("resource://gre/modules/FormHistory.jsm", {})).FormHistory;
+var {FormHistory} = (Components.utils.import("resource://gre/modules/FormHistory.jsm", {}));
/** Test for Bug 472396 **/
add_task(async function test() {
// initialization
let windowsToClose = [];
let testURI =
"http://example.com/tests/toolkit/components/satchel/test/subtst_privbrowsing.html";
--- a/toolkit/components/satchel/test/parent_utils.js
+++ b/toolkit/components/satchel/test/parent_utils.js
@@ -80,17 +80,18 @@ var ParentUtils = {
try {
return gAutocompletePopup.view.matchCount === expectedCount &&
(!expectedFirstValue ||
expectedCount <= 1 ||
gAutocompletePopup.view.getValueAt(0) === expectedFirstValue);
} catch (e) {
return false;
}
- }, "Waiting for row count change: " + expectedCount + " First value: " + expectedFirstValue).then(() => {
+ }, "Waiting for row count change: " + expectedCount + " First value: " + expectedFirstValue)
+ .then(() => {
let results = this.getMenuEntries();
sendAsyncMessage("gotMenuChange", { results });
});
},
checkSelectedIndex(expectedIndex) {
ContentTaskUtils.waitForCondition(() => {
return gAutocompletePopup.popupOpen &&
--- a/toolkit/components/satchel/test/test_bug_511615.html
+++ b/toolkit/components/satchel/test/test_bug_511615.html
@@ -113,21 +113,21 @@ function doKeyUnprivileged(key) {
input.dispatchEvent(upEvent);
}
function doClickWithMouseEventUnprivileged() {
let dnEvent = document.createEvent("MouseEvent");
let upEvent = document.createEvent("MouseEvent");
let ckEvent = document.createEvent("MouseEvent");
- /* eslint-disable no-multi-spaces */
+ /* eslint-disable no-multi-spaces, max-len */
dnEvent.initMouseEvent("mousedown", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
upEvent.initMouseEvent("mouseup", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
ckEvent.initMouseEvent("mouseclick", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
- /* eslint-enable no-multi-spaces */
+ /* eslint-enable no-multi-spaces, max-len */
input.dispatchEvent(dnEvent);
input.dispatchEvent(upEvent);
input.dispatchEvent(ckEvent);
}
add_task(async function test_initialize() {
await new Promise(resolve => updateFormHistory([
--- a/toolkit/components/satchel/test/test_form_autocomplete.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete.html
@@ -169,20 +169,24 @@ function setupFormHistory(aCallback) {
{ op: "add", fieldname: "field5", value: "12" },
{ op: "add", fieldname: "field5", value: "123" },
{ op: "add", fieldname: "field5", value: "1234" },
{ op: "add", fieldname: "field6", value: "value" },
{ op: "add", fieldname: "field7", value: "value" },
{ op: "add", fieldname: "field8", value: "value" },
{ op: "add", fieldname: "field9", value: "value" },
{ op: "add", fieldname: "field10", value: "42" },
- { op: "add", fieldname: "field11", value: "2010-10-10" }, // not used, since type=date doesn't have autocomplete currently
- { op: "add", fieldname: "field12", value: "21:21" }, // not used, since type=time doesn't have autocomplete currently
- { op: "add", fieldname: "field13", value: "32" }, // not used, since type=range doesn't have a drop down menu
- { op: "add", fieldname: "field14", value: "#ffffff" }, // not used, since type=color doesn't have autocomplete currently
+ // not used, since type=date doesn't have autocomplete currently
+ { op: "add", fieldname: "field11", value: "2010-10-10" },
+ // not used, since type=time doesn't have autocomplete currently
+ { op: "add", fieldname: "field12", value: "21:21" },
+ // not used, since type=range doesn't have a drop down menu
+ { op: "add", fieldname: "field13", value: "32" },
+ // not used, since type=color doesn't have autocomplete currently
+ { op: "add", fieldname: "field14", value: "#ffffff" },
{ op: "add", fieldname: "field15", value: "2016-08" },
{ op: "add", fieldname: "field16", value: "2016-W32" },
{ op: "add", fieldname: "field17", value: "2016-10-21T10:10" },
{ op: "add", fieldname: "searchbar-history", value: "blacklist test" },
], aCallback);
}
function setForm(value) {
@@ -221,18 +225,20 @@ function popupShownListener() {
registerPopupShownListener(popupShownListener);
/*
* Main section of test...
*
* 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
+ * - 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
* - addEntry calls runs the test when an entry has been added
* - some tests scroll the window. This is because the form fill controller happens to scroll
* the field into view near the end of the search, and there isn't any other good notification
* to listen to for when the search is complete.
* - some items still use setTimeout
*/
function runTest() { // eslint-disable-line complexity
testNum++;
--- a/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
+++ b/toolkit/components/satchel/test/test_form_autocomplete_with_list.html
@@ -96,17 +96,18 @@ function popupShownListener() {
registerPopupShownListener(popupShownListener);
/*
* Main section of test...
*
* 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
+* - call waitForMenuChange(x) to run the next test when the autocomplete popup
+* to have x items in it
*/
function runTest() {
testNum++;
info("Starting test #" + testNum);
switch (testNum) {
case 1:
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -296,18 +296,24 @@ function startTest() {
$_(5, "test1").value = "";
$_(6, "test1").value = "dontSaveThis";
// Form 7 deliberately left untouched.
// Form 8 has an input with no name or input attribute.
let input = document.getElementById("form8").elements[0];
is(input.type, "text", "checking we got unidentified input");
input.value = "dontSaveThis";
// Form 9 has nothing to modify.
- $_(10, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890").value = "dontSaveThis";
- $_(11, "test1").value = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
+ $_(10, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456" +
+ "789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456" +
+ "789012345678901234567890123456789012345678901234567890123456789012345678901234567890").value
+ = "dontSaveThis";
+ $_(11, "test1").value = "123456789012345678901234567890123456789012345678901234567890123456789" +
+ "012345678901234567890123456789012345678901234567890123456789012345678" +
+ "901234567890123456789012345678901234567890123456789012345678901234567" +
+ "89012345678901234567890123456789012345678901234567890";
$_(12, "test1").value = " ";
$_(13, "test1").value = "dontSaveThis";
$_(14, "test1").type = "password";
$_(14, "test1").value = "dontSaveThis";
var testData = ccNumbers.valid16;
for (let i = 0; i != testData.length; i++) {
$_(15, "test" + (i + 1)).value = testData[i];
@@ -394,20 +400,22 @@ function checkSubmit(formNum) {
break;
case 102:
checkForSave("test2", "savedValue", "checking saved value");
break;
case 103:
checkForSave("test3", "savedValue", "checking saved value");
break;
case 104:
- checkForSave("test4", "trimTrailingAndLeadingSpace", "checking saved value is trimmed on both sides");
+ checkForSave("test4", "trimTrailingAndLeadingSpace",
+ "checking saved value is trimmed on both sides");
break;
case 105:
- checkForSave("test5", "trimTrailingAndLeadingWhitespace", "checking saved value is trimmed on both sides");
+ checkForSave("test5", "trimTrailingAndLeadingWhitespace",
+ "checking saved value is trimmed on both sides");
break;
case 106:
checkForSave("test6", "00000000109181", "checking saved value");
break;
case 107:
for (let i = 0; i != ccNumbers.invalid16.length; i++) {
checkForSave("test7_" + (i + 1), ccNumbers.invalid16[i], "checking saved value");
}
@@ -460,17 +468,18 @@ function submitForm(formNum) {
setTimeout(function() {
checkObserver.waitForChecks(function() {
var 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);
+ SpecialPowers.wrap(document.getElementById("iframe").contentWindow)
+ .wrappedJSObject.clickButton(nextFormNum);
} else {
var button = getFormSubmitButton(nextFormNum);
button.click();
}
});
}, 0);
return false; // cancel current form submission
--- a/toolkit/components/satchel/test/test_form_submission_cap2.html
+++ b/toolkit/components/satchel/test/test_form_submission_cap2.html
@@ -161,17 +161,19 @@ function checkCountEntries(formNum, inde
}
// Called by each form's onsubmit handler.
function checkSubmit(formNum) {
ok(true, "form " + formNum + " submitted");
numSubmittedForms++;
// make sure that the field # numInputFields was saved
- checkForSave("test" + numInputFields, numInputFields + " changed", "checking saved value " + numInputFields);
+ checkForSave("test" + numInputFields,
+ numInputFields + " changed",
+ "checking saved value " + numInputFields);
checkCountEntries(formNum, 1, checkSubmitCounted);
return false; // cancel current form submission
}
function checkSubmitCounted(formNum) {
is(numSubmittedForms, 1, "Ensuring all forms were submitted.");
--- a/toolkit/components/satchel/test/unit/test_history_api.js
+++ b/toolkit/components/satchel/test/unit/test_history_api.js
@@ -4,17 +4,18 @@
var testnum = 0;
var dbConnection; // used for deleted table tests
Cu.import("resource://gre/modules/Promise.jsm");
function countDeletedEntries(expected) {
return new Promise((resolve, reject) => {
- let stmt = dbConnection.createAsyncStatement("SELECT COUNT(*) AS numEntries FROM moz_deleted_formhistory");
+ let stmt = dbConnection
+ .createAsyncStatement("SELECT COUNT(*) AS numEntries FROM moz_deleted_formhistory");
stmt.executeAsync({
handleResult(resultSet) {
do_check_eq(expected, resultSet.getNextRow().getResultByName("numEntries"));
resolve();
},
handleError(error) {
do_throw("Error occurred counting deleted entries: " + error);
reject();
@@ -23,17 +24,19 @@ function countDeletedEntries(expected) {
stmt.finalize();
}
});
});
}
function checkTimeDeleted(guid, checkFunction) {
return new Promise((resolve, reject) => {
- let stmt = dbConnection.createAsyncStatement("SELECT timeDeleted FROM moz_deleted_formhistory WHERE guid = :guid");
+ let stmt = dbConnection
+ .createAsyncStatement("SELECT timeDeleted FROM moz_deleted_formhistory " +
+ "WHERE guid = :guid");
stmt.params.guid = guid;
stmt.executeAsync({
handleResult(resultSet) {
checkFunction(resultSet.getNextRow().getResultByName("timeDeleted"));
resolve();
},
handleError(error) {
do_throw("Error occurred getting deleted entries: " + error);
@@ -161,17 +164,18 @@ add_task(async function() {
await promiseCountEntries("", null, checkNotExists);
await promiseCountEntries("name-A", "blah", checkNotExists);
await promiseCountEntries("name-A", "", checkNotExists);
await promiseCountEntries("name-A", null, checkExists);
await promiseCountEntries("blah", "value-A", checkNotExists);
await promiseCountEntries("", "value-A", checkNotExists);
await promiseCountEntries(null, "value-A", checkExists);
- // Cannot use promiseCountEntries when name and value are null because it treats null values as not set
+ // Cannot use promiseCountEntries when name and value are null
+ // because it treats null values as not set
// and here a search should be done explicity for null.
deferred = Promise.defer();
await FormHistory.count({ fieldname: null, value: null },
{ handleResult: result => checkNotExists(result),
handleError(error) {
do_throw("Error occurred searching form history: " + error);
},
handleCompletion(reason) {
--- a/toolkit/components/satchel/test/unit/test_notify.js
+++ b/toolkit/components/satchel/test/unit/test_notify.js
@@ -142,26 +142,30 @@ function* run_test_steps() {
/* ========== 8 ========== */
testnum++;
testdesc = "removeEntriesByTimeframe";
expectedNotification = "formhistory-remove";
expectedData = [10, 99999999999];
- yield FormHistory.update({ op: "remove", firstUsedStart: expectedData[0], firstUsedEnd: expectedData[1] },
- { handleCompletion(reason) {
- if (!reason) {
- next_test();
- }
- },
- handleErrors(error) {
- do_throw("Error occurred updating form history: " + error);
- }
- });
+ yield FormHistory.update({
+ op: "remove",
+ firstUsedStart: expectedData[0],
+ firstUsedEnd: expectedData[1]
+ }, {
+ handleCompletion(reason) {
+ if (!reason) {
+ next_test();
+ }
+ },
+ handleErrors(error) {
+ do_throw("Error occurred updating form history: " + error);
+ },
+ });
do_check_eq(expectedNotification, null);
os.removeObserver(TestObserver, "satchel-storage-changed");
do_test_finished();
} catch (e) {