Bug 1229519: Fix toolkit/components/contentprefs to pass eslint checks. r=mconley

This commit is contained in:
Dave Townsend 2015-12-03 10:00:06 -08:00
parent b4bb245ff3
commit 9b94f1132f
14 changed files with 95 additions and 96 deletions

View File

@ -1070,7 +1070,9 @@ ContentPrefService.prototype = {
}
// If the connection isn't ready after we open the database, that means
// the database has been corrupted, so we back it up and then recreate it.
catch (e if e.result == Cr.NS_ERROR_FILE_CORRUPTED) {
catch (e) {
if (e.result != Cr.NS_ERROR_FILE_CORRUPTED)
throw e;
dbConnection = this._dbBackUpAndRecreate(dbService, dbFile,
dbConnection);
}

View File

@ -24,33 +24,30 @@ AsyncRunner.prototype = {
this._iteratorQueue.push(iter);
},
next: function AR_next(/* ... */) {
next: function AR_next(arg) {
if (!this._iteratorQueue.length) {
this.destroy();
this._callbacks.done();
return;
}
// send() discards all arguments after the first, so there's no choice here
// but to send only one argument to the yielder.
let args = [arguments.length <= 1 ? arguments[0] : Array.slice(arguments)];
try {
var val = this._iteratorQueue[0].send.apply(this._iteratorQueue[0], args);
}
catch (err if err instanceof StopIteration) {
var { done, value } = this._iteratorQueue[0].next(arg);
if (done) {
this._iteratorQueue.shift();
this.next();
return;
}
}
catch (err) {
this._callbacks.error(err);
}
// val is truthy => call next
// val is an iterator => prepend it to the queue and start on it
if (val) {
if (typeof(val) != "boolean")
this._iteratorQueue.unshift(val);
if (value) {
if (typeof(value) != "boolean")
this._iteratorQueue.unshift(value);
this.next();
}
},

View File

@ -62,7 +62,7 @@ function runAsyncTests(tests, dontResetBefore = false) {
});
tests.forEach(function (test) {
function gen() {
function* gen() {
do_print("Running " + test.name);
yield test();
yield reset();
@ -196,7 +196,7 @@ function prefOK(actual, expected, strict) {
equal(actual.value, expected.value);
}
function getOK(args, expectedVal, expectedGroup, strict) {
function* getOK(args, expectedVal, expectedGroup, strict) {
if (args.length == 2)
args.push(undefined);
let expectedPrefs = expectedVal === undefined ? [] :
@ -206,7 +206,7 @@ function getOK(args, expectedVal, expectedGroup, strict) {
yield getOKEx("getByDomainAndName", args, expectedPrefs, strict);
}
function getSubdomainsOK(args, expectedGroupValPairs) {
function* getSubdomainsOK(args, expectedGroupValPairs) {
if (args.length == 2)
args.push(undefined);
let expectedPrefs = expectedGroupValPairs.map(function ([group, val]) {
@ -215,7 +215,7 @@ function getSubdomainsOK(args, expectedGroupValPairs) {
yield getOKEx("getBySubdomainAndName", args, expectedPrefs);
}
function getGlobalOK(args, expectedVal) {
function* getGlobalOK(args, expectedVal) {
if (args.length == 1)
args.push(undefined);
let expectedPrefs = expectedVal === undefined ? [] :
@ -223,7 +223,7 @@ function getGlobalOK(args, expectedVal) {
yield getOKEx("getGlobal", args, expectedPrefs);
}
function getOKEx(methodName, args, expectedPrefs, strict, context) {
function* getOKEx(methodName, args, expectedPrefs, strict, context) {
let actualPrefs = [];
args.push(makeCallback({
handleResult: pref => actualPrefs.push(pref)

View File

@ -8,19 +8,19 @@ function run_test() {
var tests = [
function nonexistent() {
function* nonexistent() {
getCachedOK(["a.com", "foo"], false, undefined);
getCachedGlobalOK(["foo"], false, undefined);
yield true;
},
function isomorphicDomains() {
function* isomorphicDomains() {
yield set("a.com", "foo", 1);
getCachedOK(["a.com", "foo"], true, 1);
getCachedOK(["http://a.com/huh", "foo"], true, 1, "a.com");
},
function names() {
function* names() {
yield set("a.com", "foo", 1);
getCachedOK(["a.com", "foo"], true, 1);
@ -40,14 +40,14 @@ var tests = [
getCachedGlobalOK(["bar"], true, 4);
},
function subdomains() {
function* subdomains() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
getCachedOK(["a.com", "foo"], true, 1);
getCachedOK(["b.a.com", "foo"], true, 2);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -70,7 +70,7 @@ var tests = [
getCachedOK(["b.com", "foo"], true, 5);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.getCachedByDomainAndName(null, "foo", null));
do_check_throws(() => cps.getCachedByDomainAndName("", "foo", null));
do_check_throws(() => cps.getCachedByDomainAndName("a.com", "", null));
@ -80,7 +80,7 @@ var tests = [
yield true;
},
function casts() {
function* casts() {
// SQLite casts booleans to integers. This makes sure the values stored in
// the cache are the same as the casted values in the database.

View File

@ -8,18 +8,18 @@ function run_test() {
var tests = [
function nonexistent() {
function* nonexistent() {
getCachedSubdomainsOK(["a.com", "foo"], []);
yield true;
},
function isomorphicDomains() {
function* isomorphicDomains() {
yield set("a.com", "foo", 1);
getCachedSubdomainsOK(["a.com", "foo"], [["a.com", 1]]);
getCachedSubdomainsOK(["http://a.com/huh", "foo"], [["a.com", 1]]);
},
function names() {
function* names() {
yield set("a.com", "foo", 1);
getCachedSubdomainsOK(["a.com", "foo"], [["a.com", 1]]);
@ -39,14 +39,14 @@ var tests = [
getCachedGlobalOK(["bar"], true, 4);
},
function subdomains() {
function* subdomains() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
getCachedSubdomainsOK(["a.com", "foo"], [["a.com", 1], ["b.a.com", 2]]);
getCachedSubdomainsOK(["b.a.com", "foo"], [["b.a.com", 2]]);
},
function populateViaGet() {
function* populateViaGet() {
yield cps.getByDomainAndName("a.com", "foo", null, makeCallback());
getCachedSubdomainsOK(["a.com", "foo"], [["a.com", undefined]]);
@ -55,12 +55,12 @@ var tests = [
getCachedGlobalOK(["foo"], true, undefined);
},
function populateViaGetSubdomains() {
function* populateViaGetSubdomains() {
yield cps.getBySubdomainAndName("a.com", "foo", null, makeCallback());
getCachedSubdomainsOK(["a.com", "foo"], [["a.com", undefined]]);
},
function populateViaRemove() {
function* populateViaRemove() {
yield cps.removeByDomainAndName("a.com", "foo", null, makeCallback());
getCachedSubdomainsOK(["a.com", "foo"], [["a.com", undefined]]);
@ -97,7 +97,7 @@ var tests = [
getCachedSubdomainsOK(["b.a.com", "foo"], [["b.a.com", undefined]]);
},
function populateViaRemoveByDomain() {
function* populateViaRemoveByDomain() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield set("b.a.com", "foo", 3);
@ -123,7 +123,7 @@ var tests = [
getCachedGlobalOK(["bar"], true, undefined);
},
function populateViaRemoveAllDomains() {
function* populateViaRemoveAllDomains() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield set("b.com", "foo", 3);
@ -135,7 +135,7 @@ var tests = [
getCachedSubdomainsOK(["b.com", "bar"], [["b.com", undefined]]);
},
function populateViaRemoveByName() {
function* populateViaRemoveByName() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -153,7 +153,7 @@ var tests = [
getCachedGlobalOK(["bar"], true, undefined);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -176,7 +176,7 @@ var tests = [
getCachedSubdomainsOK(["b.com", "foo"], [["b.com", 5]]);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.getCachedBySubdomainAndName(null, "foo", null));
do_check_throws(() => cps.getCachedBySubdomainAndName("", "foo", null));
do_check_throws(() => cps.getCachedBySubdomainAndName("a.com", "", null));

View File

@ -8,17 +8,17 @@ function run_test() {
var tests = [
function get_nonexistent() {
function* get_nonexistent() {
yield getSubdomainsOK(["a.com", "foo"], []);
},
function isomorphicDomains() {
function* isomorphicDomains() {
yield set("a.com", "foo", 1);
yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]);
yield getSubdomainsOK(["http://a.com/huh", "foo"], [["a.com", 1]]);
},
function names() {
function* names() {
yield set("a.com", "foo", 1);
yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]);
@ -31,14 +31,14 @@ var tests = [
yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]);
},
function subdomains() {
function* subdomains() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1], ["b.a.com", 2]]);
yield getSubdomainsOK(["b.a.com", "foo"], [["b.a.com", 2]]);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -57,7 +57,7 @@ var tests = [
yield getSubdomainsOK(["b.com", "foo"], [["b.com", 5]]);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.getBySubdomainAndName(null, "foo", null, {}));
do_check_throws(() => cps.getBySubdomainAndName("", "foo", null, {}));
do_check_throws(() => cps.getBySubdomainAndName("a.com", "", null, {}));

View File

@ -55,7 +55,7 @@ function run_test() {
// the fact that we ContentPrefService constructor is run only once per test file
// and so migration will be run only once.
var tests = [
function testMigration() {
function* testMigration() {
// Test migrated db content.
schemaVersionIs(4);
let dbExpectedState = [

View File

@ -8,7 +8,7 @@ function run_test() {
var tests = [
function observerForName_set() {
function* observerForName_set() {
yield set("a.com", "foo", 1);
let args = yield on("Set", ["foo", null, "bar"]);
observerArgsOK(args.foo, [["a.com", "foo", 1]]);
@ -22,7 +22,7 @@ var tests = [
observerArgsOK(args.bar, []);
},
function observerForName_remove() {
function* observerForName_remove() {
yield set("a.com", "foo", 1);
yield setGlobal("foo", 2);
@ -45,7 +45,7 @@ var tests = [
observerArgsOK(args.bar, []);
},
function observerForName_removeByDomain() {
function* observerForName_removeByDomain() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -69,7 +69,7 @@ var tests = [
observerArgsOK(args.bar, []);
},
function observerForName_removeAllDomainsSince() {
function* observerForName_removeAllDomainsSince() {
yield setWithDate("a.com", "foo", 1, 100);
yield setWithDate("b.com", "foo", 2, 200);
yield setWithDate("c.com", "foo", 3, 300);
@ -88,7 +88,7 @@ var tests = [
observerArgsOK(args.null, [["b.com", "foo"], ["c.com", "bar"], ["c.com", "foo"]]);
},
function observerForName_removeAllDomains() {
function* observerForName_removeAllDomains() {
yield set("a.com", "foo", 1);
yield setGlobal("foo", 2);
yield set("b.com", "bar", 3);
@ -100,7 +100,7 @@ var tests = [
observerArgsOK(args.bar, [["b.com", "bar"]]);
},
function observerForName_removeByName() {
function* observerForName_removeByName() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -118,7 +118,7 @@ var tests = [
observerArgsOK(args.bar, []);
},
function removeObserverForName() {
function* removeObserverForName() {
let args = yield on("Set", ["foo", null, "bar"], true);
cps.removeObserverForName("foo", args.foo.observer);

View File

@ -8,7 +8,7 @@ function run_test() {
var tests = [
function nonexistent() {
function* nonexistent() {
yield set("a.com", "foo", 1);
yield setGlobal("foo", 2);
@ -45,7 +45,7 @@ var tests = [
yield getGlobalOK(["foo"], 2);
},
function isomorphicDomains() {
function* isomorphicDomains() {
yield set("a.com", "foo", 1);
yield cps.removeByDomainAndName("a.com", "foo", null, makeCallback());
yield dbOK([]);
@ -58,7 +58,7 @@ var tests = [
yield getOK(["a.com", "foo"], undefined);
},
function names() {
function* names() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -103,7 +103,7 @@ var tests = [
yield getGlobalOK(["bar"], undefined);
},
function subdomains() {
function* subdomains() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
yield cps.removeByDomainAndName("a.com", "foo", null, makeCallback());
@ -138,7 +138,7 @@ var tests = [
yield getSubdomainsOK(["b.a.com", "foo"], []);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -176,7 +176,7 @@ var tests = [
yield getOK(["b.com", "bar"], 7);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.removeByDomainAndName(null, "foo", null));
do_check_throws(() => cps.removeByDomainAndName("", "foo", null));
do_check_throws(() => cps.removeByDomainAndName("a.com", "foo", null,
@ -192,7 +192,7 @@ var tests = [
yield true;
},
function removeByDomainAndName_invalidateCache() {
function* removeByDomainAndName_invalidateCache() {
yield set("a.com", "foo", 1);
getCachedOK(["a.com", "foo"], true, 1);
cps.removeByDomainAndName("a.com", "foo", null, makeCallback());
@ -200,7 +200,7 @@ var tests = [
yield;
},
function removeBySubdomainAndName_invalidateCache() {
function* removeBySubdomainAndName_invalidateCache() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
getCachedSubdomainsOK(["a.com", "foo"], [
@ -212,7 +212,7 @@ var tests = [
yield;
},
function removeGlobal_invalidateCache() {
function* removeGlobal_invalidateCache() {
yield setGlobal("foo", 1);
getCachedGlobalOK(["foo"], true, 1);
cps.removeGlobal("foo", null, makeCallback());

View File

@ -8,7 +8,7 @@ function run_test() {
var tests = [
function nonexistent() {
function* nonexistent() {
yield setGlobal("foo", 1);
yield cps.removeAllDomains(null, makeCallback());
yield dbOK([
@ -17,7 +17,7 @@ var tests = [
yield getGlobalOK(["foo"], 1);
},
function domains() {
function* domains() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -38,7 +38,7 @@ var tests = [
yield getOK(["b.com", "bar"], undefined);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -66,12 +66,12 @@ var tests = [
yield getOK(["b.com", "foo"], undefined);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.removeAllDomains(null, "bogus"));
yield true;
},
function invalidateCache() {
function* invalidateCache() {
yield set("a.com", "foo", 1);
yield set("b.com", "bar", 2);
yield setGlobal("baz", 3);

View File

@ -8,13 +8,13 @@ function run_test() {
var tests = [
function nonexistent() {
function* nonexistent() {
yield setGlobal("foo", 1);
yield cps.removeAllDomainsSince(0, null, makeCallback());
yield getGlobalOK(["foo"], 1);
},
function domainsAll() {
function* domainsAll() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -35,7 +35,7 @@ var tests = [
yield getOK(["b.com", "bar"], undefined);
},
function domainsWithDate() {
function* domainsWithDate() {
yield setWithDate("a.com", "foobar", 0, 0);
yield setWithDate("a.com", "foo", 1, 1000);
yield setWithDate("a.com", "bar", 2, 4000);
@ -55,7 +55,7 @@ var tests = [
]);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -83,12 +83,12 @@ var tests = [
yield getOK(["b.com", "foo"], undefined);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.removeAllDomainsSince(null, "bogus"));
yield true;
},
function invalidateCache() {
function* invalidateCache() {
yield setWithDate("a.com", "foobar", 0, 0);
yield setWithDate("a.com", "foo", 1, 1000);
yield setWithDate("a.com", "bar", 2, 4000);

View File

@ -8,7 +8,7 @@ function run_test() {
var tests = [
function nonexistent() {
function* nonexistent() {
yield set("a.com", "foo", 1);
yield setGlobal("foo", 2);
@ -29,7 +29,7 @@ var tests = [
yield getGlobalOK(["foo"], 2);
},
function isomorphicDomains() {
function* isomorphicDomains() {
yield set("a.com", "foo", 1);
yield cps.removeByDomain("a.com", null, makeCallback());
yield dbOK([]);
@ -41,7 +41,7 @@ var tests = [
yield getOK(["a.com", "foo"], undefined);
},
function domains() {
function* domains() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -86,7 +86,7 @@ var tests = [
yield getOK(["b.com", "bar"], undefined);
},
function subdomains() {
function* subdomains() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
yield cps.removeByDomain("a.com", null, makeCallback());
@ -121,7 +121,7 @@ var tests = [
yield getSubdomainsOK(["b.a.com", "foo"], []);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -149,7 +149,7 @@ var tests = [
yield getOK(["b.com", "foo"], 5);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.removeByDomain(null, null));
do_check_throws(() => cps.removeByDomain("", null));
do_check_throws(() => cps.removeByDomain("a.com", null, "bogus"));
@ -160,7 +160,7 @@ var tests = [
yield true;
},
function removeByDomain_invalidateCache() {
function* removeByDomain_invalidateCache() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
getCachedOK(["a.com", "foo"], true, 1);
@ -171,7 +171,7 @@ var tests = [
yield;
},
function removeBySubdomain_invalidateCache() {
function* removeBySubdomain_invalidateCache() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
getCachedSubdomainsOK(["a.com", "foo"], [
@ -183,7 +183,7 @@ var tests = [
yield;
},
function removeAllGlobals_invalidateCache() {
function* removeAllGlobals_invalidateCache() {
yield setGlobal("foo", 1);
yield setGlobal("bar", 2);
getCachedGlobalOK(["foo"], true, 1);

View File

@ -8,7 +8,7 @@ function run_test() {
var tests = [
function nonexistent() {
function* nonexistent() {
yield set("a.com", "foo", 1);
yield setGlobal("foo", 2);
@ -21,7 +21,7 @@ var tests = [
yield getGlobalOK(["foo"], 2);
},
function names() {
function* names() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -43,7 +43,7 @@ var tests = [
yield getOK(["b.com", "bar"], 6);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -76,14 +76,14 @@ var tests = [
yield getOK(["b.com", "bar"], undefined);
},
function erroneous() {
function* erroneous() {
do_check_throws(() => cps.removeByName("", null));
do_check_throws(() => cps.removeByName(null, null));
do_check_throws(() => cps.removeByName("foo", null, "bogus"));
yield true;
},
function invalidateCache() {
function* invalidateCache() {
yield set("a.com", "foo", 1);
yield set("b.com", "foo", 2);
getCachedOK(["a.com", "foo"], true, 1);

View File

@ -8,12 +8,12 @@ function run_test() {
var tests = [
function get_nonexistent() {
function* get_nonexistent() {
yield getOK(["a.com", "foo"], undefined);
yield getGlobalOK(["foo"], undefined);
},
function isomorphicDomains() {
function* isomorphicDomains() {
yield set("a.com", "foo", 1);
yield dbOK([
["a.com", "foo", 1],
@ -29,7 +29,7 @@ var tests = [
yield getOK(["http://a.com/yeah", "foo"], 2, "a.com");
},
function names() {
function* names() {
yield set("a.com", "foo", 1);
yield dbOK([
["a.com", "foo", 1],
@ -67,7 +67,7 @@ var tests = [
yield getGlobalOK(["bar"], 4);
},
function subdomains() {
function* subdomains() {
yield set("a.com", "foo", 1);
yield set("b.a.com", "foo", 2);
yield dbOK([
@ -78,7 +78,7 @@ var tests = [
yield getOK(["b.a.com", "foo"], 2);
},
function privateBrowsing() {
function* privateBrowsing() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield setGlobal("foo", 3);
@ -108,7 +108,7 @@ var tests = [
yield getOK(["b.com", "foo"], 5);
},
function set_erroneous() {
function* set_erroneous() {
do_check_throws(() => cps.set(null, "foo", 1, null));
do_check_throws(() => cps.set("", "foo", 1, null));
do_check_throws(() => cps.set("a.com", "", 1, null));
@ -122,7 +122,7 @@ var tests = [
yield true;
},
function get_erroneous() {
function* get_erroneous() {
do_check_throws(() => cps.getByDomainAndName(null, "foo", null, {}));
do_check_throws(() => cps.getByDomainAndName("", "foo", null, {}));
do_check_throws(() => cps.getByDomainAndName("a.com", "", null, {}));
@ -134,7 +134,7 @@ var tests = [
yield true;
},
function set_invalidateCache() {
function* set_invalidateCache() {
// (1) Set a pref and wait for it to finish.
yield set("a.com", "foo", 1);
@ -169,7 +169,7 @@ var tests = [
yield;
},
function get_nameOnly() {
function* get_nameOnly() {
yield set("a.com", "foo", 1);
yield set("a.com", "bar", 2);
yield set("b.com", "foo", 3);
@ -191,7 +191,7 @@ var tests = [
]);
},
function setSetsCurrentDate() {
function* setSetsCurrentDate() {
// Because Date.now() is not guaranteed to be monotonically increasing
// we just do here rough sanity check with one minute tolerance.
const MINUTE = 60 * 1000;