Bug 1207498 - Part 2: Remove use of expression closure from tests in toolkit/components/. r=Gijs

This commit is contained in:
Tooru Fujisawa 2015-09-24 20:36:01 +09:00
parent b059a24532
commit b62bbe1e0c
57 changed files with 436 additions and 419 deletions

View File

@ -226,7 +226,7 @@ function getGlobalOK(args, expectedVal) {
function getOKEx(methodName, args, expectedPrefs, strict, context) {
let actualPrefs = [];
args.push(makeCallback({
handleResult: function (pref) actualPrefs.push(pref)
handleResult: pref => actualPrefs.push(pref)
}));
yield cps[methodName].apply(cps, args);
arraysOfArraysOK([actualPrefs], [expectedPrefs], function (actual, expected) {
@ -343,7 +343,7 @@ function dbOK(expectedRows) {
handleResult: function (results) {
let row = null;
while (row = results.getNextRow()) {
actualRows.push(cols.map(function (c) row.getResultByName(c)));
actualRows.push(cols.map(c => row.getResultByName(c)));
}
},
handleError: function (err) {
@ -368,7 +368,7 @@ function on(event, names, dontRemove) {
names.forEach(function (name) {
let obs = {};
["onContentPrefSet", "onContentPrefRemoved"].forEach(function (meth) {
obs[meth] = function () do_throw(meth + " should not be called");
obs[meth] = () => do_throw(meth + " should not be called");
});
obs["onContentPref" + event] = function () {
args[name].push(Array.slice(arguments));
@ -381,7 +381,7 @@ function on(event, names, dontRemove) {
do_execute_soon(function () {
if (!dontRemove)
names.forEach(function (n) cps.removeObserverForName(n, observers[n]));
names.forEach(n => cps.removeObserverForName(n, observers[n]));
next(args);
});
}

View File

@ -71,16 +71,12 @@ var tests = [
},
function erroneous() {
do_check_throws(function ()
cps.getCachedByDomainAndName(null, "foo", null));
do_check_throws(function ()
cps.getCachedByDomainAndName("", "foo", null));
do_check_throws(function ()
cps.getCachedByDomainAndName("a.com", "", null));
do_check_throws(function ()
cps.getCachedByDomainAndName("a.com", null, null));
do_check_throws(function () cps.getCachedGlobal("", null));
do_check_throws(function () cps.getCachedGlobal(null, null));
do_check_throws(() => cps.getCachedByDomainAndName(null, "foo", null));
do_check_throws(() => cps.getCachedByDomainAndName("", "foo", null));
do_check_throws(() => cps.getCachedByDomainAndName("a.com", "", null));
do_check_throws(() => cps.getCachedByDomainAndName("a.com", null, null));
do_check_throws(() => cps.getCachedGlobal("", null));
do_check_throws(() => cps.getCachedGlobal(null, null));
yield true;
},

View File

@ -177,14 +177,10 @@ var tests = [
},
function erroneous() {
do_check_throws(function ()
cps.getCachedBySubdomainAndName(null, "foo", null));
do_check_throws(function ()
cps.getCachedBySubdomainAndName("", "foo", null));
do_check_throws(function ()
cps.getCachedBySubdomainAndName("a.com", "", null));
do_check_throws(function ()
cps.getCachedBySubdomainAndName("a.com", null, null));
do_check_throws(() => cps.getCachedBySubdomainAndName(null, "foo", null));
do_check_throws(() => cps.getCachedBySubdomainAndName("", "foo", null));
do_check_throws(() => cps.getCachedBySubdomainAndName("a.com", "", null));
do_check_throws(() => cps.getCachedBySubdomainAndName("a.com", null, null));
yield true;
},
];

View File

@ -58,16 +58,11 @@ var tests = [
},
function erroneous() {
do_check_throws(function ()
cps.getBySubdomainAndName(null, "foo", null, {}));
do_check_throws(function ()
cps.getBySubdomainAndName("", "foo", null, {}));
do_check_throws(function ()
cps.getBySubdomainAndName("a.com", "", null, {}));
do_check_throws(function ()
cps.getBySubdomainAndName("a.com", null, null, {}));
do_check_throws(function ()
cps.getBySubdomainAndName("a.com", "foo", null, null));
do_check_throws(() => cps.getBySubdomainAndName(null, "foo", null, {}));
do_check_throws(() => cps.getBySubdomainAndName("", "foo", null, {}));
do_check_throws(() => cps.getBySubdomainAndName("a.com", "", null, {}));
do_check_throws(() => cps.getBySubdomainAndName("a.com", null, null, {}));
do_check_throws(() => cps.getBySubdomainAndName("a.com", "foo", null, null));
yield true;
},
];

View File

@ -177,18 +177,18 @@ var tests = [
},
function erroneous() {
do_check_throws(function () cps.removeByDomainAndName(null, "foo", null));
do_check_throws(function () cps.removeByDomainAndName("", "foo", null));
do_check_throws(function () cps.removeByDomainAndName("a.com", "foo", null,
"bogus"));
do_check_throws(function () cps.removeBySubdomainAndName(null, "foo",
null));
do_check_throws(function () cps.removeBySubdomainAndName("", "foo", null));
do_check_throws(function () cps.removeBySubdomainAndName("a.com", "foo",
null, "bogus"));
do_check_throws(function () cps.removeGlobal("", null));
do_check_throws(function () cps.removeGlobal(null, null));
do_check_throws(function () cps.removeGlobal("foo", null, "bogus"));
do_check_throws(() => cps.removeByDomainAndName(null, "foo", null));
do_check_throws(() => cps.removeByDomainAndName("", "foo", null));
do_check_throws(() => cps.removeByDomainAndName("a.com", "foo", null,
"bogus"));
do_check_throws(() => cps.removeBySubdomainAndName(null, "foo",
null));
do_check_throws(() => cps.removeBySubdomainAndName("", "foo", null));
do_check_throws(() => cps.removeBySubdomainAndName("a.com", "foo",
null, "bogus"));
do_check_throws(() => cps.removeGlobal("", null));
do_check_throws(() => cps.removeGlobal(null, null));
do_check_throws(() => cps.removeGlobal("foo", null, "bogus"));
yield true;
},

View File

@ -67,7 +67,7 @@ var tests = [
},
function erroneous() {
do_check_throws(function () cps.removeAllDomains(null, "bogus"));
do_check_throws(() => cps.removeAllDomains(null, "bogus"));
yield true;
},

View File

@ -84,7 +84,7 @@ var tests = [
},
function erroneous() {
do_check_throws(function () cps.removeAllDomainsSince(null, "bogus"));
do_check_throws(() => cps.removeAllDomainsSince(null, "bogus"));
yield true;
},

View File

@ -150,13 +150,13 @@ var tests = [
},
function erroneous() {
do_check_throws(function () cps.removeByDomain(null, null));
do_check_throws(function () cps.removeByDomain("", null));
do_check_throws(function () cps.removeByDomain("a.com", null, "bogus"));
do_check_throws(function () cps.removeBySubdomain(null, null));
do_check_throws(function () cps.removeBySubdomain("", null));
do_check_throws(function () cps.removeBySubdomain("a.com", null, "bogus"));
do_check_throws(function () cps.removeAllGlobals(null, "bogus"));
do_check_throws(() => cps.removeByDomain(null, null));
do_check_throws(() => cps.removeByDomain("", null));
do_check_throws(() => cps.removeByDomain("a.com", null, "bogus"));
do_check_throws(() => cps.removeBySubdomain(null, null));
do_check_throws(() => cps.removeBySubdomain("", null));
do_check_throws(() => cps.removeBySubdomain("a.com", null, "bogus"));
do_check_throws(() => cps.removeAllGlobals(null, "bogus"));
yield true;
},

View File

@ -77,9 +77,9 @@ var tests = [
},
function erroneous() {
do_check_throws(function () cps.removeByName("", null));
do_check_throws(function () cps.removeByName(null, null));
do_check_throws(function () cps.removeByName("foo", null, "bogus"));
do_check_throws(() => cps.removeByName("", null));
do_check_throws(() => cps.removeByName(null, null));
do_check_throws(() => cps.removeByName("foo", null, "bogus"));
yield true;
},

View File

@ -109,30 +109,28 @@ var tests = [
},
function set_erroneous() {
do_check_throws(function () cps.set(null, "foo", 1, null));
do_check_throws(function () cps.set("", "foo", 1, null));
do_check_throws(function () cps.set("a.com", "", 1, null));
do_check_throws(function () cps.set("a.com", null, 1, null));
do_check_throws(function () cps.set("a.com", "foo", undefined, null));
do_check_throws(function () cps.set("a.com", "foo", 1, null, "bogus"));
do_check_throws(function () cps.setGlobal("", 1, null));
do_check_throws(function () cps.setGlobal(null, 1, null));
do_check_throws(function () cps.setGlobal("foo", undefined, null));
do_check_throws(function () cps.setGlobal("foo", 1, null, "bogus"));
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));
do_check_throws(() => cps.set("a.com", null, 1, null));
do_check_throws(() => cps.set("a.com", "foo", undefined, null));
do_check_throws(() => cps.set("a.com", "foo", 1, null, "bogus"));
do_check_throws(() => cps.setGlobal("", 1, null));
do_check_throws(() => cps.setGlobal(null, 1, null));
do_check_throws(() => cps.setGlobal("foo", undefined, null));
do_check_throws(() => cps.setGlobal("foo", 1, null, "bogus"));
yield true;
},
function get_erroneous() {
do_check_throws(function () cps.getByDomainAndName(null, "foo", null, {}));
do_check_throws(function () cps.getByDomainAndName("", "foo", null, {}));
do_check_throws(function () cps.getByDomainAndName("a.com", "", null, {}));
do_check_throws(function ()
cps.getByDomainAndName("a.com", null, null, {}));
do_check_throws(function ()
cps.getByDomainAndName("a.com", "foo", null, null));
do_check_throws(function () cps.getGlobal("", null, {}));
do_check_throws(function () cps.getGlobal(null, null, {}));
do_check_throws(function () cps.getGlobal("foo", null, null));
do_check_throws(() => cps.getByDomainAndName(null, "foo", null, {}));
do_check_throws(() => cps.getByDomainAndName("", "foo", null, {}));
do_check_throws(() => cps.getByDomainAndName("a.com", "", null, {}));
do_check_throws(() => cps.getByDomainAndName("a.com", null, null, {}));
do_check_throws(() => cps.getByDomainAndName("a.com", "foo", null, null));
do_check_throws(() => cps.getGlobal("", null, {}));
do_check_throws(() => cps.getGlobal(null, null, {}));
do_check_throws(() => cps.getGlobal("foo", null, null));
yield true;
},

View File

@ -95,7 +95,7 @@ function test() {
let win = OpenBrowserWindow({private: aIsPrivate});
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
executeSoon(function() aCallback(win));
executeSoon(() => aCallback(win));
}, false);
}
@ -103,7 +103,7 @@ function test() {
let browser = aWin.gBrowser.selectedBrowser;
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
executeSoon(function() aCallback(browser.contentDocument));
executeSoon(() => aCallback(browser.contentDocument));
}, true);
browser.loadURI(aURL);
}

View File

@ -44,7 +44,7 @@ function run_test()
do_check_eq(Win.normalize("\\a\\b\\c\\\\\\"), "\\a\\b\\c");
do_check_eq(Win.normalize("\\a\\b\\c\\..\\..\\..\\d\\e\\f"), "\\d\\e\\f");
do_check_eq(Win.normalize("a\\b\\c\\..\\..\\..\\d\\e\\f"), "d\\e\\f");
do_check_fail(function() Win.normalize("\\a\\b\\c\\..\\..\\..\\..\\d\\e\\f"));
do_check_fail(() => Win.normalize("\\a\\b\\c\\..\\..\\..\\..\\d\\e\\f"));
do_check_eq(Win.join("\\tmp", "foo", "bar"), "\\tmp\\foo\\bar", "join \\tmp,foo,bar");
do_check_eq(Win.join("\\tmp", "\\foo", "bar"), "\\foo\\bar", "join \\tmp,\\foo,bar");
@ -78,7 +78,7 @@ function run_test()
do_check_eq(Win.normalize("c:\\a\\b\\c\\\\\\"), "c:\\a\\b\\c");
do_check_eq(Win.normalize("c:\\a\\b\\c\\..\\..\\..\\d\\e\\f"), "c:\\d\\e\\f");
do_check_eq(Win.normalize("c:a\\b\\c\\..\\..\\..\\d\\e\\f"), "c:\\d\\e\\f");
do_check_fail(function() Win.normalize("c:\\a\\b\\c\\..\\..\\..\\..\\d\\e\\f"));
do_check_fail(() => Win.normalize("c:\\a\\b\\c\\..\\..\\..\\..\\d\\e\\f"));
do_check_eq(Win.join("c:\\", "foo"), "c:\\foo", "join c:\,foo");
do_check_eq(Win.join("c:\\tmp", "foo", "bar"), "c:\\tmp\\foo\\bar", "join c:\\tmp,foo,bar");
@ -120,7 +120,7 @@ function run_test()
do_check_eq(Win.normalize("\\\\a\\b\\\\\\\\c"), "\\\\a\\b\\c");
do_check_eq(Win.normalize("\\\\a\\b\\c\\\\\\"), "\\\\a\\b\\c");
do_check_eq(Win.normalize("\\\\a\\b\\c\\..\\..\\d\\e\\f"), "\\\\a\\d\\e\\f");
do_check_fail(function() Win.normalize("\\\\a\\b\\c\\..\\..\\..\\d\\e\\f"));
do_check_fail(() => Win.normalize("\\\\a\\b\\c\\..\\..\\..\\d\\e\\f"));
do_check_eq(Win.join("\\\\a\\tmp", "foo", "bar"), "\\\\a\\tmp\\foo\\bar");
do_check_eq(Win.join("\\\\a\\tmp", "\\foo", "bar"), "\\\\a\\foo\\bar");
@ -143,7 +143,7 @@ function run_test()
do_check_eq(Unix.normalize("/a/b/c///"), "/a/b/c");
do_check_eq(Unix.normalize("/a/b/c/../../../d/e/f"), "/d/e/f");
do_check_eq(Unix.normalize("a/b/c/../../../d/e/f"), "d/e/f");
do_check_fail(function() Unix.normalize("/a/b/c/../../../../d/e/f"));
do_check_fail(() => Unix.normalize("/a/b/c/../../../../d/e/f"));
do_check_eq(Unix.join("/tmp", "foo", "bar"), "/tmp/foo/bar", "join /tmp,foo,bar");
do_check_eq(Unix.join("/tmp", "/foo", "bar"), "/foo/bar", "join /tmp,/foo,bar");

View File

@ -24,7 +24,7 @@ function test() {
new nsLoginInfo(urls[3], urls[3], null, "array of", "logins", "u4", "p4"),
new nsLoginInfo(urls[4], urls[4], null, "then", "i wrote the test", "u5", "p5")
];
logins.forEach(function (login) Services.logins.addLogin(login));
logins.forEach(login => Services.logins.addLogin(login));
// Open the password manager dialog
const PWMGR_DLG = "chrome://passwordmgr/content/passwordManager.xul";

View File

@ -36,7 +36,7 @@ function test() {
new nsLoginInfo(urls[8], urls[8], null, "my user name", "mozilla", "u9", "p9"),
new nsLoginInfo(urls[9], urls[9], null, "my username", "mozilla.com", "u10", "p10"),
];
logins.forEach(function (login) pwmgr.addLogin(login));
logins.forEach(login => pwmgr.addLogin(login));
// Open the password manager dialog
const PWMGR_DLG = "chrome://passwordmgr/content/passwordManager.xul";

View File

@ -40,7 +40,7 @@ is(logins.length, 0, "ensure no remaining logins");
// Remove any disabled hosts
var disabledHosts = pwmgr.getAllDisabledHosts();
ok(disabledHosts != null, "getAllDisabledHosts()");
disabledHosts.forEach(function(host) pwmgr.setLoginSavingEnabled(host, true));
disabledHosts.forEach(host => pwmgr.setLoginSavingEnabled(host, true));
disabledHosts = pwmgr.getAllDisabledHosts();
ok(disabledHosts != null, "getAllDisabledHosts()");

View File

@ -44,7 +44,7 @@ AutoCompleteInput.prototype = {
onSearchComplete: function() {},
setSelectedIndex: function() {},
get searchCount() { return this.searches.length; },
getSearchAt: function(aIndex) this.searches[aIndex],
getSearchAt: function(aIndex) { return this.searches[aIndex]; },
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIAutoCompleteInput,
Ci.nsIAutoCompletePopup,
@ -105,7 +105,7 @@ function ensure_results(aSearch, aExpected)
uri = toURI(kURIs[uri]).spec;
title = kTitles[title];
if (tags && appendTags)
title += " \u2013 " + tags.map(function(aTag) kTitles[aTag]);
title += " \u2013 " + tags.map(aTag => kTitles[aTag]);
print("Checking against expected '" + uri + "', '" + title + "'...");
// Got a match on both uri and title?
@ -235,7 +235,7 @@ function* task_addPageBook(aURI, aTitle, aBook, aTags, aKey, aTransitionType, aN
// Add tags if we need to
if (aTags != undefined && aTags.length > 0) {
// Convert each tag index into the title
let tags = aTags.map(function(aTag) kTitles[aTag]);
let tags = aTags.map(aTag => kTitles[aTag]);
tagsvc.tagURI(uri, tags);
out.push("\ntags=" + tags);
}
@ -280,7 +280,7 @@ function run_test() {
// should return reliable resultsets, thus we have to wait.
yield PlacesTestUtils.promiseAsyncUpdates();
}).then(function () ensure_results(search, expected),
}).then(() => ensure_results(search, expected),
do_report_unexpected_exception);
}

View File

@ -23,9 +23,9 @@ var gTests = [
["1: plain search",
"url", [0]],
["2: search disabled",
"url", [], function() setSearch(0)],
"url", [], () => setSearch(0)],
["3: resume normal search",
"url", [0], function() setSearch(1)],
"url", [0], () => setSearch(1)],
];
function setSearch(aSearch) {

View File

@ -26,7 +26,7 @@ var gTests = [
// Tests after this one will match at the beginning
["0: Match at the beginning of titles",
"a", [0],
function() setBehavior(3)],
() => setBehavior(3)],
["1: Match at the beginning of titles",
"b", [1]],
["2: Match at the beginning of urls",
@ -37,7 +37,7 @@ var gTests = [
// Tests after this one will match against word boundaries and anywhere
["4: Sanity check that matching anywhere finds more",
"a", [0,1],
function() setBehavior(1)],
() => setBehavior(1)],
];
function setBehavior(aType) {

View File

@ -78,31 +78,31 @@ var gTests = [
["6.1: foo ^ -> history",
"foo ^", [1,2,3,5,10]],
["6.2: foo | -> history (change pref)",
"foo |", [1,2,3,5,10], function() { changeRestrict("history", "|"); }],
"foo |", [1,2,3,5,10], () => changeRestrict("history", "|")],
["7.1: foo * -> is star",
"foo *", [5,6,7,8,9,10,11], function() resetRestrict("history")],
"foo *", [5,6,7,8,9,10,11], () => resetRestrict("history")],
["7.2: foo | -> is star (change pref)",
"foo |", [5,6,7,8,9,10,11], function() changeRestrict("bookmark", "|")],
"foo |", [5,6,7,8,9,10,11], () => changeRestrict("bookmark", "|")],
["8.1: foo # -> in title",
"foo #", [1,3,5,7,8,9,10,11], function() resetRestrict("bookmark")],
"foo #", [1,3,5,7,8,9,10,11], () => resetRestrict("bookmark")],
["8.2: foo | -> in title (change pref)",
"foo |", [1,3,5,7,8,9,10,11], function() changeRestrict("title", "|")],
"foo |", [1,3,5,7,8,9,10,11], () => changeRestrict("title", "|")],
["9.1: foo @ -> in url",
"foo @", [2,3,6,7,10,11], function() resetRestrict("title")],
"foo @", [2,3,6,7,10,11], () => resetRestrict("title")],
["9.2: foo | -> in url (change pref)",
"foo |", [2,3,6,7,10,11], function() changeRestrict("url", "|")],
"foo |", [2,3,6,7,10,11], () => changeRestrict("url", "|")],
["10: foo + -> is tag",
"foo +", [8,9,10,11], function() resetRestrict("url")],
"foo +", [8,9,10,11], () => resetRestrict("url")],
["10.2: foo | -> is tag (change pref)",
"foo |", [8,9,10,11], function() changeRestrict("tag", "|")],
"foo |", [8,9,10,11], () => changeRestrict("tag", "|")],
["10.3: foo ~ -> is typed",
"foo ~", [3,10], function() resetRestrict("tag")],
"foo ~", [3,10], () => resetRestrict("tag")],
["10.4: foo | -> is typed (change pref)",
"foo |", [3,10], function() changeRestrict("typed", "|")],
"foo |", [3,10], () => changeRestrict("typed", "|")],
// Test various pairs of special searches
["11: foo ^ * -> history, is star",
"foo ^ *", [5,10], function() resetRestrict("typed")],
"foo ^ *", [5,10], () => resetRestrict("typed")],
["12: foo ^ # -> history, in title",
"foo ^ #", [1,3,5,10]],
["13: foo ^ @ -> history, in url",
@ -136,9 +136,9 @@ var gTests = [
["21: foo -> default history",
"foo", [1,2,3,5,10], function () { setPref({ history: true }); }],
["22: foo -> default history or is star",
"foo", [1,2,3,5,6,7,8,9,10,11], function() setPref({ history: true, bookmark: true })],
"foo", [1,2,3,5,6,7,8,9,10,11], () => setPref({ history: true, bookmark: true })],
["22.1: foo -> default history or is star, is typed",
"foo", [3,10], function() setPref({ history: true, bookmark: true, "history.onlyTyped": true })],
"foo", [3,10], () => setPref({ history: true, bookmark: true, "history.onlyTyped": true })],
];

View File

@ -63,7 +63,7 @@ var gTests = [
// Tests after this one will match only on word boundaries
["0: Match 'match' at the beginning or after / or on a CamelCase",
"match", [0,2,4,9],
function() setBehavior(2)],
() => setBehavior(2)],
["1: Match 'dont' at the beginning or after /",
"dont", [1,3,5]],
["2: Match '2' after the slash and after a word (in tags too)",
@ -97,7 +97,7 @@ var gTests = [
// Tests after this one will match against word boundaries and anywhere
["14: Match on word boundaries as well as anywhere (bug 429531)",
"tch", [0,1,2,3,4,5,9],
function() setBehavior(1)],
() => setBehavior(1)],
];
function setBehavior(aType) {

View File

@ -12,8 +12,8 @@ function run_test() {
}
let observer = {
onBeginUpdateBatch: function() forceBookmarkCaching(itemId1),
onEndUpdateBatch: function() forceBookmarkCaching(itemId1),
onBeginUpdateBatch: () => forceBookmarkCaching(itemId1),
onEndUpdateBatch: () => forceBookmarkCaching(itemId1),
onItemAdded: forceBookmarkCaching,
onItemChanged: forceBookmarkCaching,
onItemMoved: forceBookmarkCaching,

View File

@ -14,8 +14,8 @@ function run_test() {
}
let observer = {
onBeginUpdateBatch: function () forceBookmarkCaching(itemId1),
onEndUpdateBatch: function () forceBookmarkCaching(itemId1),
onBeginUpdateBatch: () => forceBookmarkCaching(itemId1),
onEndUpdateBatch: () => forceBookmarkCaching(itemId1),
onItemAdded: forceBookmarkCaching,
onItemChanged: forceBookmarkCaching,
onItemMoved: forceBookmarkCaching,

View File

@ -67,15 +67,15 @@ add_test(function onItemAdded_bookmark() {
gBookmarksObserver.expected = [
{ name: "onItemAdded",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: function (v) v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "title", check: function (v) v === TITLE },
{ name: "dateAdded", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "title", check: v => v === TITLE },
{ name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
@ -87,15 +87,15 @@ add_test(function onItemAdded_separator() {
gBookmarksObserver.expected = [
{ name: "onItemAdded",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: function (v) v === 1 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
{ name: "uri", check: function (v) v === null },
{ name: "title", check: function (v) v === null },
{ name: "dateAdded", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: v => v === 1 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
{ name: "uri", check: v => v === null },
{ name: "title", check: v => v === null },
{ name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesUtils.bookmarks.insertSeparator(PlacesUtils.unfiledBookmarksFolderId,
@ -107,15 +107,15 @@ add_test(function onItemAdded_folder() {
gBookmarksObserver.expected = [
{ name: "onItemAdded",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: function (v) v === 2 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: function (v) v === null },
{ name: "title", check: function (v) v === TITLE },
{ name: "dateAdded", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: v => v === 2 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: v => v === null },
{ name: "title", check: v => v === TITLE },
{ name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesUtils.bookmarks.createFolder(PlacesUtils.unfiledBookmarksFolderId,
@ -130,16 +130,16 @@ add_test(function onItemChanged_title_bookmark() {
gBookmarksObserver.expected = [
{ name: "onItemChanged", // This is an unfortunate effect of bug 653910.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "property", check: function (v) v === "title" },
{ name: "isAnno", check: function (v) v === false },
{ name: "newValue", check: function (v) v === TITLE },
{ name: "lastModified", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "property", check: v => v === "title" },
{ name: "isAnno", check: v => v === false },
{ name: "newValue", check: v => v === TITLE },
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: v => typeof(v) == "string" },
] },
];
PlacesUtils.bookmarks.setItemTitle(id, TITLE);
@ -153,73 +153,73 @@ add_test(function onItemChanged_tags_bookmark() {
gBookmarksObserver.expected = [
{ name: "onItemAdded", // This is the tag folder.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) v === PlacesUtils.tagsFolderId },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: function (v) v === null },
{ name: "title", check: function (v) v === TAG },
{ name: "dateAdded", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => v === PlacesUtils.tagsFolderId },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: v => v === null },
{ name: "title", check: v => v === TAG },
{ name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
{ name: "onItemAdded", // This is the tag.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: function (v) v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "title", check: function (v) v === null },
{ name: "dateAdded", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => typeof(v) == "number" && v > 0 },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "title", check: v => v === null },
{ name: "dateAdded", check: v => typeof(v) == "number" && v > 0 },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
{ name: "onItemChanged",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "property", check: function (v) v === "tags" },
{ name: "isAnno", check: function (v) v === false },
{ name: "newValue", check: function (v) v === "" },
{ name: "lastModified", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "property", check: v => v === "tags" },
{ name: "isAnno", check: v => v === false },
{ name: "newValue", check: v => v === "" },
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: v => typeof(v) == "string" },
] },
{ name: "onItemRemoved", // This is the tag.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: function (v) v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => typeof(v) == "number" && v > 0 },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
{ name: "onItemRemoved", // This is the tag folder.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) v === PlacesUtils.tagsFolderId },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: function (v) v === null },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => v === PlacesUtils.tagsFolderId },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: v => v === null },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
{ name: "onItemChanged",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "property", check: function (v) v === "tags" },
{ name: "isAnno", check: function (v) v === false },
{ name: "newValue", check: function (v) v === "" },
{ name: "lastModified", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "property", check: v => v === "tags" },
{ name: "isAnno", check: v => v === false },
{ name: "newValue", check: v => v === "" },
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: v => typeof(v) == "string" },
] },
];
PlacesUtils.tagging.tagURI(uri, [TAG]);
@ -232,27 +232,27 @@ add_test(function onItemMoved_bookmark() {
gBookmarksObserver.expected = [
{ name: "onItemMoved",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "oldParentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "oldIndex", check: function (v) v === 0 },
{ name: "newParentId", check: function (v) v === PlacesUtils.toolbarFolderId },
{ name: "newIndex", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldParentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "newParentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "oldParentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "oldIndex", check: v => v === 0 },
{ name: "newParentId", check: v => v === PlacesUtils.toolbarFolderId },
{ name: "newIndex", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldParentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "newParentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
{ name: "onItemMoved",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "oldParentId", check: function (v) v === PlacesUtils.toolbarFolderId },
{ name: "oldIndex", check: function (v) v === 0 },
{ name: "newParentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "newIndex", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldParentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "newParentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "oldParentId", check: v => v === PlacesUtils.toolbarFolderId },
{ name: "oldIndex", check: v => v === 0 },
{ name: "newParentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "newIndex", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldParentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "newParentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesUtils.bookmarks.moveItem(id, PlacesUtils.toolbarFolderId, 0);
@ -265,14 +265,14 @@ add_test(function onItemMoved_bookmark() {
gBookmarksObserver.expected = [
{ name: "onItemVisited",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "visitId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "time", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "transitionType", check: function (v) v === PlacesUtils.history.TRANSITION_TYPED },
{ name: "uri", check: function (v) v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "visitId", check: v => typeof(v) == "number" && v > 0 },
{ name: "time", check: v => typeof(v) == "number" && v > 0 },
{ name: "transitionType", check: v => v === PlacesUtils.history.TRANSITION_TYPED },
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesTestUtils.addVisits({ uri: uri, transition: TRANSITION_TYPED });
@ -284,26 +284,26 @@ add_test(function onItemRemoved_bookmark() {
gBookmarksObserver.expected = [
{ name: "onItemChanged", // This is an unfortunate effect of bug 653910.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "property", check: function (v) v === "" },
{ name: "isAnno", check: function (v) v === true },
{ name: "newValue", check: function (v) v === "" },
{ name: "lastModified", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "property", check: v => v === "" },
{ name: "isAnno", check: v => v === true },
{ name: "newValue", check: v => v === "" },
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: v => typeof(v) == "string" },
] },
{ name: "onItemRemoved",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: function (v) v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => v === PlacesUtils.unfiledBookmarksFolderId },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_BOOKMARK },
{ name: "uri", check: v => v instanceof Ci.nsIURI && v.equals(uri) },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesUtils.bookmarks.removeItem(id);
@ -314,26 +314,26 @@ add_test(function onItemRemoved_separator() {
gBookmarksObserver.expected = [
{ name: "onItemChanged", // This is an unfortunate effect of bug 653910.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "property", check: function (v) v === "" },
{ name: "isAnno", check: function (v) v === true },
{ name: "newValue", check: function (v) v === "" },
{ name: "lastModified", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "property", check: v => v === "" },
{ name: "isAnno", check: v => v === true },
{ name: "newValue", check: v => v === "" },
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
{ name: "parentId", check: v => typeof(v) == "number" && v > 0 },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: v => typeof(v) == "string" },
] },
{ name: "onItemRemoved",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
{ name: "uri", check: function (v) v === null },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => typeof(v) == "number" && v > 0 },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_SEPARATOR },
{ name: "uri", check: v => v === null },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesUtils.bookmarks.removeItem(id);
@ -345,26 +345,26 @@ add_test(function onItemRemoved_folder() {
gBookmarksObserver.expected = [
{ name: "onItemChanged", // This is an unfortunate effect of bug 653910.
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "property", check: function (v) v === "" },
{ name: "isAnno", check: function (v) v === true },
{ name: "newValue", check: function (v) v === "" },
{ name: "lastModified", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: function (v) typeof(v) == "string" },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "property", check: v => v === "" },
{ name: "isAnno", check: v => v === true },
{ name: "newValue", check: v => v === "" },
{ name: "lastModified", check: v => typeof(v) == "number" && v > 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "parentId", check: v => typeof(v) == "number" && v > 0 },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "oldValue", check: v => typeof(v) == "string" },
] },
{ name: "onItemRemoved",
args: [
{ name: "itemId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "parentId", check: function (v) typeof(v) == "number" && v > 0 },
{ name: "index", check: function (v) v === 0 },
{ name: "itemType", check: function (v) v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: function (v) v === null },
{ name: "guid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: function (v) typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "itemId", check: v => typeof(v) == "number" && v > 0 },
{ name: "parentId", check: v => typeof(v) == "number" && v > 0 },
{ name: "index", check: v => v === 0 },
{ name: "itemType", check: v => v === PlacesUtils.bookmarks.TYPE_FOLDER },
{ name: "uri", check: v => v === null },
{ name: "guid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
{ name: "parentGuid", check: v => typeof(v) == "string" && /^[a-zA-Z0-9\-_]{12}$/.test(v) },
] },
];
PlacesUtils.bookmarks.removeItem(id);

View File

@ -18,7 +18,7 @@ function test() {
function testOnWindow(aIsPrivate, aCallback) {
whenNewWindowLoaded({private: aIsPrivate}, function(aWin) {
windowsToClose.push(aWin);
executeSoon(function() aCallback(aWin));
executeSoon(() => aCallback(aWin));
});
};

View File

@ -18,7 +18,7 @@ function test() {
function testOnWindow(aOptions, aCallback) {
whenNewWindowLoaded(aOptions, function(aWin) {
windowsToClose.push(aWin);
executeSoon(function() aCallback(aWin));
executeSoon(() => aCallback(aWin));
});
};

View File

@ -27,7 +27,7 @@ function test() {
function testOnWindow(aOptions, aCallback) {
whenNewWindowLoaded(aOptions, function(aWin) {
windowsToClose.push(aWin);
executeSoon(function() aCallback(aWin));
executeSoon(() => aCallback(aWin));
});
};

View File

@ -59,7 +59,7 @@ function test() {
// execute should only be called when need, like when you are opening
// web pages on the test. If calling executeSoon() is not necesary, then
// call whenNewWindowLoaded() instead of testOnWindow() on your test.
executeSoon(function() aCallback(aWin));
executeSoon(() => aCallback(aWin));
});
};

View File

@ -82,7 +82,9 @@ clearDB();
* @param aSpec
* URLString of the uri.
*/
function uri(aSpec) NetUtil.newURI(aSpec);
function uri(aSpec) {
return NetUtil.newURI(aSpec);
}
/**
@ -730,11 +732,11 @@ function do_compare_arrays(a1, a2, sorted)
return false;
if (sorted) {
return a1.every(function (e, i) e == a2[i]);
return a1.every((e, i) => e == a2[i]);
}
else {
return a1.filter(function (e) a2.indexOf(e) == -1).length == 0 &&
a2.filter(function (e) a1.indexOf(e) == -1).length == 0;
return a1.filter(e => a2.indexOf(e) == -1).length == 0 &&
a2.filter(e => a1.indexOf(e) == -1).length == 0;
}
}

View File

@ -54,8 +54,8 @@ AutoCompleteInput.prototype = {
this._selEnd = aEnd;
},
onTextEntered: function() false,
onTextReverted: function() false,
onTextEntered: () => false,
onTextReverted: () => false,
get searchCount() {
return this.searches.length;

View File

@ -95,7 +95,7 @@ function cartProd(aSequences, aCallback)
// For each sequence in aSequences, we maintain a pointer (an array index,
// really) to the element we're currently enumerating in that sequence
var seqEltPtrs = aSequences.map(function (i) 0);
var seqEltPtrs = aSequences.map(i => 0);
var numProds = 0;
var done = false;
@ -396,7 +396,7 @@ add_task(function test_containersQueries_sorting()
var visitCount = 0;
var dayOffset = 0;
var visits = [];
pages.forEach(function (aPageUrl) visits.push(
pages.forEach(aPageUrl => visits.push(
{ isVisit: true,
isBookmark: true,
transType: Ci.nsINavHistoryService.TRANSITION_TYPED,

View File

@ -503,7 +503,7 @@ function cartProd(aSequences, aCallback)
// For each sequence in aSequences, we maintain a pointer (an array index,
// really) to the element we're currently enumerating in that sequence
var seqEltPtrs = aSequences.map(function (i) 0);
var seqEltPtrs = aSequences.map(i => 0);
var numProds = 0;
var done = false;
@ -574,7 +574,7 @@ function choose(aSet, aHowMany, aCallback)
var done = false;
while (!done) {
numFound++;
aCallback(ptrs.map(function (p) aSet[p]));
aCallback(ptrs.map(p => aSet[p]));
// The next subset to be chosen differs from the current one by just a
// single element. Determine which element that is. Advance the "rightmost"

View File

@ -133,7 +133,7 @@ function cartProd(aSequences, aCallback)
// For each sequence in aSequences, we maintain a pointer (an array index,
// really) to the element we're currently enumerating in that sequence
let seqEltPtrs = aSequences.map(function (i) 0);
let seqEltPtrs = aSequences.map(i => 0);
let numProds = 0;
let done = false;
@ -210,7 +210,7 @@ add_task(function test_add_visits_to_database()
];
// we add a visit for each of the above transition types.
t.forEach(function (transition) visits.push(
t.forEach(transition => visits.push(
{ isVisit: true,
transType: transition,
uri: "http://" + transition + ".example.com/",
@ -222,7 +222,7 @@ add_task(function test_add_visits_to_database()
isInQuery: true }));
// Add a REDIRECT_TEMPORARY layer of visits for each of the above visits.
t.forEach(function (transition) visits.push(
t.forEach(transition => visits.push(
{ isVisit: true,
transType: Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY,
uri: "http://" + transition + ".redirect.temp.example.com/",
@ -234,7 +234,7 @@ add_task(function test_add_visits_to_database()
isInQuery: true }));
// Add a REDIRECT_PERMANENT layer of visits for each of the above redirects.
t.forEach(function (transition) visits.push(
t.forEach(transition => visits.push(
{ isVisit: true,
transType: Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT,
uri: "http://" + transition + ".redirect.perm.example.com/",
@ -257,7 +257,7 @@ add_task(function test_add_visits_to_database()
do_throw("Unknown uri.");
return null;
}
t.forEach(function (transition) visits.push(
t.forEach(transition => visits.push(
{ isVisit: true,
transType: Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT,
uri: "http://" + transition + ".example.com/",

View File

@ -162,7 +162,7 @@ add_task(function test_sort_date_site_grouping()
testData.push(visit);
leveledTestData[i][j].push(oldLength);
compareArrayToResult(leveledTestData[i][j].
map(function(x) testData[x]), roots[i][j]);
map(x => testData[x]), roots[i][j]);
});
for (let i = 0; i < roots.length; i++) {
@ -219,7 +219,7 @@ function checkSecondLevel(index, secondIndex, child, roots) {
// results.
root.containerOpen = true;
compareArrayToResult(leveledTestData[index][secondIndex].
map(function(x) testData[x]), root);
map(x => testData[x]), root);
// We close |root|'s container later so that we can test live
// updates into it.
}

View File

@ -568,7 +568,7 @@ function* task_cleanDatabase(aCallback) {
* The query's tagsAreNot property will be set to this
*/
function checkQueryURI(aTags, aTagsAreNot) {
var pairs = (aTags || []).sort().map(function (t) QUERY_KEY_TAG + "=" + encodeTag(t));
var pairs = (aTags || []).sort().map(t => QUERY_KEY_TAG + "=" + encodeTag(t));
if (aTagsAreNot)
pairs.push(QUERY_KEY_NOT_TAGS + "=1");
var expURI = "place:" + pairs.join("&");
@ -627,7 +627,7 @@ function* task_doWithVisit(aTags, aCallback) {
function encodeTag(aTag) {
return encodeURIComponent(aTag).
replace(/[-_.!~*'()]/g, //'
function (s) "%" + s.charCodeAt(0).toString(16));
s => "%" + s.charCodeAt(0).toString(16));
}
/**
@ -735,8 +735,8 @@ function setsAreEqual(aArr1, aArr2, aIsOrdered) {
}
}
else {
aArr1.forEach(function (u) do_check_true(aArr2.indexOf(u) >= 0));
aArr2.forEach(function (u) do_check_true(aArr1.indexOf(u) >= 0));
aArr1.forEach(u => do_check_true(aArr2.indexOf(u) >= 0));
aArr2.forEach(u => do_check_true(aArr1.indexOf(u) >= 0));
}
}

View File

@ -97,7 +97,7 @@ function loadNextTest() {
else
observer.expectURL(prefix + subtests[0]);
waitForTrue(function() observer.resolved, function() {
waitForTrue(() => observer.resolved, function() {
// And the nodes get notified after the "link-visited" topic, so
// we need to execute soon...
SimpleTest.executeSoon(handleLoad);

View File

@ -102,8 +102,8 @@ AutoCompleteInput.prototype = {
onSearchBegin: function () {},
onSearchComplete: function () {},
onTextEntered: function() false,
onTextReverted: function() false,
onTextEntered: () => false,
onTextReverted: () => false,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteInput])
}

View File

@ -209,7 +209,7 @@ add_task(function test_frecency()
}
// sort results by frecency
results.sort(function(a,b) b[1] - a[1]);
results.sort((a,b) => b[1] - a[1]);
// Make sure there's enough results returned
prefs.setIntPref("browser.urlbar.maxRichResults", results.length);
@ -258,7 +258,7 @@ add_task(function test_frecency()
// frecency just in the wrong "order" (order of same frecency is
// undefined), so check if frecency matches. This is okay because we
// can still ensure the correct number of expected frecencies.
let getFrecency = function(aURL) aURL.match(/frecency:(-?\d+)$/)[1];
let getFrecency = aURL => aURL.match(/frecency:(-?\d+)$/)[1];
print("### checking for same frecency between '" + searchURL +
"' and '" + expectURL + "'");
do_check_eq(getFrecency(searchURL), getFrecency(expectURL));

View File

@ -98,7 +98,7 @@ function ensure_tag_results(uris, searchTerm)
do_check_eq(controller.getStyleAt(i), "tag");
}
// Sort the results then check if we have the right items
vals.sort().forEach(function(val, i) do_check_eq(val, uris[i].spec))
vals.sort().forEach((val, i) => do_check_eq(val, uris[i].spec))
if (current_test < (tests.length - 1)) {
current_test++;

View File

@ -24,22 +24,40 @@ function AutoCompleteInput(aSearches) {
AutoCompleteInput.prototype = {
constructor: AutoCompleteInput,
get minResultsForPopup() 0,
get timeout() 10,
get searchParam() "",
get textValue() "",
get disableAutoComplete() false,
get completeDefaultIndex() false,
get minResultsForPopup() {
return 0;
},
get timeout() {
return 10;
},
get searchParam() {
return "";
},
get textValue() {
return "";
},
get disableAutoComplete() {
return false;
},
get completeDefaultIndex() {
return false;
},
get searchCount() this.searches.length,
getSearchAt: function (aIndex) this.searches[aIndex],
get searchCount() {
return this.searches.length;
},
getSearchAt: function (aIndex) {
return this.searches[aIndex];
},
onSearchBegin: function () {},
onSearchComplete: function() {},
get popupOpen() false,
get popupOpen() {
return false;
},
popup: {
set selectedIndex(aIndex) aIndex,
set selectedIndex(aIndex) {},
invalidate: function () {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompletePopup])
},
@ -94,11 +112,17 @@ function task_setCountRank(aURI, aCount, aRank, aSearch, aBookmark)
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAutoCompleteInput,
Ci.nsIAutoCompletePopup,
Ci.nsIAutoCompleteController]),
get popup() thing,
get controller() thing,
get popup() {
return thing;
},
get controller() {
return thing;
},
popupOpen: true,
selectedIndex: 0,
getValueAt: function() aURI.spec,
getValueAt: function() {
return aURI.spec;
},
searchString: aSearch
};

View File

@ -116,7 +116,7 @@ function addAdaptiveFeedback(aUrl, aSearch, aCallback) {
get controller() { return thing; },
popupOpen: true,
selectedIndex: 0,
getValueAt: function() aUrl,
getValueAt: () => aUrl,
searchString: aSearch
};

View File

@ -1250,7 +1250,9 @@ add_task(function* test_annotate_multiple() {
this.expires = Ci.nsIAnnotationService.EXPIRE_NEVER;
}
function annos(a = null, b = null) [new AnnoObj("A", a), new AnnoObj("B", b)]
function annos(a = null, b = null) {
return [new AnnoObj("A", a), new AnnoObj("B", b)];
}
function verifyAnnoValues(a = null, b = null) {
let currentAnnos = PlacesUtils.getAnnotationsForItem(itemId);

View File

@ -38,5 +38,5 @@ var tests = [
];
function run_test()
{
tests.forEach(function(test) test());
tests.forEach(test => test());
}

View File

@ -288,10 +288,10 @@ var obssvc = Cc["@mozilla.org/observer-service;1"].
* Adds some bookmarks for the URIs in |uris|.
*/
function addBookmarks() {
uris.forEach(function (u) bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,
uri(u),
bmsvc.DEFAULT_INDEX,
u));
uris.forEach(u => bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,
uri(u),
bmsvc.DEFAULT_INDEX,
u));
checkBookmarksExist();
}

View File

@ -23,7 +23,7 @@ add_task(function* test_removePages() {
pages.push(NetUtil.newURI(TEST_URI.spec + i));
}
yield PlacesTestUtils.addVisits(pages.map(function (uri) ({ uri: uri })));
yield PlacesTestUtils.addVisits(pages.map(uri => ({ uri: uri })));
// Bookmarked item should not be removed from moz_places.
const ANNO_INDEX = 1;
const ANNO_NAME = "testAnno";

View File

@ -101,7 +101,7 @@ function ensure_tag_results(uris, searchTerm)
do_check_eq(controller.getStyleAt(i), "tag");
}
// Sort the results then check if we have the right items
vals.sort().forEach(function(val, i) do_check_eq(val, uris[i].spec))
vals.sort().forEach((val, i) => do_check_eq(val, uris[i].spec))
if (current_test < (tests.length - 1)) {
current_test++;
@ -122,30 +122,30 @@ var uri5 = uri("http://site.tld/5/aaa");
var uri6 = uri("http://site.tld/6/bbb");
var tests = [
function() ensure_tag_results([uri1, uri4, uri6], "foo"),
function() ensure_tag_results([uri1], "foo aaa"),
function() ensure_tag_results([uri4, uri6], "foo bbb"),
function() ensure_tag_results([uri2, uri4, uri5, uri6], "bar"),
function() ensure_tag_results([uri5], "bar aaa"),
function() ensure_tag_results([uri2, uri4, uri6], "bar bbb"),
function() ensure_tag_results([uri3, uri5, uri6], "cheese"),
function() ensure_tag_results([uri3, uri5], "chees aaa"),
function() ensure_tag_results([uri6], "chees bbb"),
function() ensure_tag_results([uri4, uri6], "fo bar"),
function() ensure_tag_results([], "fo bar aaa"),
function() ensure_tag_results([uri4, uri6], "fo bar bbb"),
function() ensure_tag_results([uri4, uri6], "ba foo"),
function() ensure_tag_results([], "ba foo aaa"),
function() ensure_tag_results([uri4, uri6], "ba foo bbb"),
function() ensure_tag_results([uri5, uri6], "ba chee"),
function() ensure_tag_results([uri5], "ba chee aaa"),
function() ensure_tag_results([uri6], "ba chee bbb"),
function() ensure_tag_results([uri5, uri6], "cheese bar"),
function() ensure_tag_results([uri5], "cheese bar aaa"),
function() ensure_tag_results([uri6], "chees bar bbb"),
function() ensure_tag_results([uri6], "cheese bar foo"),
function() ensure_tag_results([], "foo bar cheese aaa"),
function() ensure_tag_results([uri6], "foo bar cheese bbb"),
() => ensure_tag_results([uri1, uri4, uri6], "foo"),
() => ensure_tag_results([uri1], "foo aaa"),
() => ensure_tag_results([uri4, uri6], "foo bbb"),
() => ensure_tag_results([uri2, uri4, uri5, uri6], "bar"),
() => ensure_tag_results([uri5], "bar aaa"),
() => ensure_tag_results([uri2, uri4, uri6], "bar bbb"),
() => ensure_tag_results([uri3, uri5, uri6], "cheese"),
() => ensure_tag_results([uri3, uri5], "chees aaa"),
() => ensure_tag_results([uri6], "chees bbb"),
() => ensure_tag_results([uri4, uri6], "fo bar"),
() => ensure_tag_results([], "fo bar aaa"),
() => ensure_tag_results([uri4, uri6], "fo bar bbb"),
() => ensure_tag_results([uri4, uri6], "ba foo"),
() => ensure_tag_results([], "ba foo aaa"),
() => ensure_tag_results([uri4, uri6], "ba foo bbb"),
() => ensure_tag_results([uri5, uri6], "ba chee"),
() => ensure_tag_results([uri5], "ba chee aaa"),
() => ensure_tag_results([uri6], "ba chee bbb"),
() => ensure_tag_results([uri5, uri6], "cheese bar"),
() => ensure_tag_results([uri5], "cheese bar aaa"),
() => ensure_tag_results([uri6], "chees bar bbb"),
() => ensure_tag_results([uri6], "cheese bar foo"),
() => ensure_tag_results([], "foo bar cheese aaa"),
() => ensure_tag_results([uri6], "foo bar cheese bbb"),
];
/**

View File

@ -6,22 +6,22 @@
Components.utils.import("resource://gre/modules/PlacesDBUtils.jsm");
var histograms = {
PLACES_PAGES_COUNT: function (val) do_check_eq(val, 1),
PLACES_BOOKMARKS_COUNT: function (val) do_check_eq(val, 1),
PLACES_TAGS_COUNT: function (val) do_check_eq(val, 1),
PLACES_KEYWORDS_COUNT: function (val) do_check_eq(val, 1),
PLACES_SORTED_BOOKMARKS_PERC: function (val) do_check_eq(val, 100),
PLACES_TAGGED_BOOKMARKS_PERC: function (val) do_check_eq(val, 100),
PLACES_DATABASE_FILESIZE_MB: function (val) do_check_true(val > 0),
PLACES_DATABASE_PAGESIZE_B: function (val) do_check_eq(val, 32768),
PLACES_DATABASE_SIZE_PER_PAGE_B: function (val) do_check_true(val > 0),
PLACES_EXPIRATION_STEPS_TO_CLEAN2: function (val) do_check_true(val > 1),
//PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS: function (val) do_check_true(val > 1),
PLACES_IDLE_FRECENCY_DECAY_TIME_MS: function (val) do_check_true(val > 0),
PLACES_IDLE_MAINTENANCE_TIME_MS: function (val) do_check_true(val > 0),
PLACES_ANNOS_BOOKMARKS_COUNT: function (val) do_check_eq(val, 1),
PLACES_ANNOS_PAGES_COUNT: function (val) do_check_eq(val, 1),
PLACES_MAINTENANCE_DAYSFROMLAST: function (val) do_check_true(val >= 0),
PLACES_PAGES_COUNT: val => do_check_eq(val, 1),
PLACES_BOOKMARKS_COUNT: val => do_check_eq(val, 1),
PLACES_TAGS_COUNT: val => do_check_eq(val, 1),
PLACES_KEYWORDS_COUNT: val => do_check_eq(val, 1),
PLACES_SORTED_BOOKMARKS_PERC: val => do_check_eq(val, 100),
PLACES_TAGGED_BOOKMARKS_PERC: val => do_check_eq(val, 100),
PLACES_DATABASE_FILESIZE_MB: val => do_check_true(val > 0),
PLACES_DATABASE_PAGESIZE_B: val => do_check_eq(val, 32768),
PLACES_DATABASE_SIZE_PER_PAGE_B: val => do_check_true(val > 0),
PLACES_EXPIRATION_STEPS_TO_CLEAN2: val => do_check_true(val > 1),
//PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS: val => do_check_true(val > 1),
PLACES_IDLE_FRECENCY_DECAY_TIME_MS: val => do_check_true(val > 0),
PLACES_IDLE_MAINTENANCE_TIME_MS: val => do_check_true(val > 0),
PLACES_ANNOS_BOOKMARKS_COUNT: val => do_check_eq(val, 1),
PLACES_ANNOS_PAGES_COUNT: val => do_check_eq(val, 1),
PLACES_MAINTENANCE_DAYSFROMLAST: val => do_check_true(val >= 0),
}
function run_test()
@ -97,7 +97,7 @@ add_task(function test_execute()
onSearchComplete: function() {},
setSelectedIndex: function() {},
get searchCount() { return this.searches.length; },
getSearchAt: function(aIndex) this.searches[aIndex],
getSearchAt: function(aIndex) { return this.searches[aIndex]; },
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIAutoCompleteInput,
Ci.nsIAutoCompletePopup,
@ -121,7 +121,7 @@ add_task(function test_execute()
let validate = histograms[histogramId];
let snapshot = Services.telemetry.getHistogramById(histogramId).snapshot();
validate(snapshot.sum);
do_check_true(snapshot.counts.reduce(function(a, b) a + b) > 0);
do_check_true(snapshot.counts.reduce((a, b) => a + b) > 0);
}
});

View File

@ -57,7 +57,7 @@ function test() {
function testOnWindow(aOptions, aCallback) {
whenNewWindowLoaded(aOptions, function(aWin) {
windowsToClose.push(aWin);
executeSoon(function() aCallback(aWin));
executeSoon(() => aCallback(aWin));
});
};

View File

@ -70,7 +70,7 @@ function setupFormHistory() {
{ op : "remove" },
{ op : "add", fieldname : "field1", value : "value1" },
{ op : "add", fieldname : "field1", value : "value2" },
], function() runTest(1));
], () => runTest(1));
}
function checkForm(expectedValue) {

View File

@ -39,7 +39,7 @@ const isGUID = /[A-Za-z0-9\+\/]{16}/;
// Find form history entries.
function searchEntries(terms, params, iter) {
let results = [];
FormHistory.search(terms, params, { handleResult: function (result) results.push(result),
FormHistory.search(terms, params, { handleResult: result => results.push(result),
handleError: function (error) {
do_throw("Error occurred searching form history: " + error);
},
@ -57,7 +57,7 @@ function countEntries(name, value, then) {
obj.value = value;
let count = 0;
FormHistory.count(obj, { handleResult: function (result) count = result,
FormHistory.count(obj, { handleResult: result => count = result,
handleError: function (error) {
do_throw("Error occurred searching form history: " + error);
},

View File

@ -76,7 +76,7 @@ function promiseSearchEntries(terms, params)
let deferred = Promise.defer();
let results = [];
FormHistory.search(terms, params,
{ handleResult: function(result) results.push(result),
{ handleResult: result => results.push(result),
handleError: function (error) {
do_throw("Error occurred searching form history: " + error);
deferred.reject(error);
@ -165,7 +165,7 @@ add_task(function ()
// and here a search should be done explicity for null.
deferred = Promise.defer();
yield FormHistory.count({ fieldname: null, value: null },
{ handleResult: function(result) checkNotExists(result),
{ handleResult: result => checkNotExists(result),
handleError: function (error) {
do_throw("Error occurred searching form history: " + error);
},
@ -269,7 +269,7 @@ add_task(function ()
do_check_eq(1, timesUsed);
do_check_true(firstUsed > 0);
do_check_true(lastUsed > 0);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 1));
yield promiseCountEntries(null, null, num => do_check_eq(num, 1));
// ===== 11 =====
// Add another single entry
@ -277,7 +277,7 @@ add_task(function ()
yield promiseUpdateEntry("add", "field1", "value1b");
yield promiseCountEntries("field1", "value1", checkExists);
yield promiseCountEntries("field1", "value1b", checkExists);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 2));
yield promiseCountEntries(null, null, num => do_check_eq(num, 2));
// ===== 12 =====
// Update a single entry
@ -290,7 +290,7 @@ add_task(function ()
yield promiseCountEntries("field1", "modifiedValue", checkExists);
yield promiseCountEntries("field1", "value1", checkNotExists);
yield promiseCountEntries("field1", "value1b", checkExists);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 2));
yield promiseCountEntries(null, null, num => do_check_eq(num, 2));
// ===== 13 =====
// Add a single entry with times
@ -305,7 +305,7 @@ add_task(function ()
do_check_eq(20, timesUsed);
do_check_eq(100, firstUsed);
do_check_eq(500, lastUsed);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 3));
yield promiseCountEntries(null, null, num => do_check_eq(num, 3));
// ===== 14 =====
// Bump an entry, which updates its lastUsed field
@ -318,7 +318,7 @@ add_task(function ()
do_check_eq(21, timesUsed);
do_check_eq(100, firstUsed);
do_check_true(lastUsed > 500);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 3));
yield promiseCountEntries(null, null, num => do_check_eq(num, 3));
// ===== 15 =====
// Bump an entry that does not exist
@ -331,7 +331,7 @@ add_task(function ()
do_check_eq(10, timesUsed);
do_check_eq(50, firstUsed);
do_check_eq(400, lastUsed);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 4));
yield promiseCountEntries(null, null, num => do_check_eq(num, 4));
// ===== 16 =====
// Bump an entry with a guid
@ -345,7 +345,7 @@ add_task(function ()
do_check_eq(11, timesUsed);
do_check_eq(50, firstUsed);
do_check_true(lastUsed > 400);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 4));
yield promiseCountEntries(null, null, num => do_check_eq(num, 4));
// ===== 17 =====
// Remove an entry
@ -358,17 +358,17 @@ add_task(function ()
yield promiseUpdate({ op : "remove", guid: guid});
yield promiseCountEntries("field1", "modifiedValue", checkExists);
yield promiseCountEntries("field1", "value1b", checkNotExists);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 3));
yield promiseCountEntries(null, null, num => do_check_eq(num, 3));
yield countDeletedEntries(8);
yield checkTimeDeleted(guid, function (timeDeleted) do_check_true(timeDeleted > 10000));
yield checkTimeDeleted(guid, timeDeleted => do_check_true(timeDeleted > 10000));
// ===== 18 =====
// Add yet another single entry
testnum++;
yield promiseUpdate({ op : "add", fieldname: "field4", value: "value4",
timesUsed: 5, firstUsed: 230, lastUsed: 600 });
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 4));
yield promiseCountEntries(null, null, num => do_check_eq(num, 4));
// ===== 19 =====
// Remove an entry by time
@ -378,7 +378,7 @@ add_task(function ()
yield promiseCountEntries("field2", "value2", checkNotExists);
yield promiseCountEntries("field3", "value3", checkExists);
yield promiseCountEntries("field4", "value4", checkNotExists);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 2));
yield promiseCountEntries(null, null, num => do_check_eq(num, 2));
yield countDeletedEntries(10);
// ===== 20 =====
@ -389,7 +389,7 @@ add_task(function ()
timesUsed: 5, firstUsed: 230, lastUsed: 600 },
{ op : "add", fieldname: "field6", value: "value6",
timesUsed: 12, firstUsed: 430, lastUsed: 700 }]);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 4));
yield promiseCountEntries(null, null, num => do_check_eq(num, 4));
yield promiseUpdate([
{ op : "bump", fieldname: "field5", value: "value5" },
@ -403,7 +403,7 @@ add_task(function ()
do_check_true(results[2].lastUsed > 600);
do_check_true(results[3].lastUsed > 700);
yield promiseCountEntries(null, null, function(num) do_check_eq(num, 4));
yield promiseCountEntries(null, null, num => do_check_eq(num, 4));
} catch (e) {
throw "FAILED in test #" + testnum + " -- " + e;
@ -414,4 +414,6 @@ add_task(function ()
}
});
function run_test() run_next_test();
function run_test() {
return run_next_test();
}

View File

@ -76,7 +76,7 @@ function initApp() {
function AsyncRunner() {
do_test_pending();
do_register_cleanup((function () this.destroy()).bind(this));
do_register_cleanup(() => this.destroy());
this._callbacks = {
done: do_test_finished,

View File

@ -74,7 +74,7 @@ function testGetProviderList(manifests, next) {
let providers = yield SocialService.getProviderList(next);
do_check_true(providers.length >= manifests.length);
for (let i = 0; i < manifests.length; i++) {
let providerIdx = providers.map(function (p) p.origin).indexOf(manifests[i].origin);
let providerIdx = providers.map(p => p.origin).indexOf(manifests[i].origin);
let provider = providers[providerIdx];
do_check_true(!!provider);
do_check_false(provider.enabled);

View File

@ -17,11 +17,11 @@ var originalCount1, originalCount2;
function run_test() {
let histogram = Telemetry.getHistogramById(HIST_NAME);
let snapshot = histogram.snapshot();
originalCount1 = snapshot.counts.reduce(function (a,b) a += b);
originalCount1 = snapshot.counts.reduce((a,b) => a += b);
histogram = Telemetry.getHistogramById(HIST_NAME2);
snapshot = histogram.snapshot();
originalCount2 = snapshot.counts.reduce(function (a,b) a += b);
originalCount2 = snapshot.counts.reduce((a,b) => a += b);
do_check_false(TelemetryStopwatch.start(3));
do_check_false(TelemetryStopwatch.start({}));
@ -103,13 +103,13 @@ function run_test() {
function finishTest() {
let histogram = Telemetry.getHistogramById(HIST_NAME);
let snapshot = histogram.snapshot();
let newCount = snapshot.counts.reduce(function (a,b) a += b);
let newCount = snapshot.counts.reduce((a,b) => a += b);
do_check_eq(newCount - originalCount1, 5, "The correct number of histograms were added for histogram 1.");
histogram = Telemetry.getHistogramById(HIST_NAME2);
snapshot = histogram.snapshot();
newCount = snapshot.counts.reduce(function (a,b) a += b);
newCount = snapshot.counts.reduce((a,b) => a += b);
do_check_eq(newCount - originalCount2, 3, "The correct number of histograms were added for histogram 2.");
}

View File

@ -264,13 +264,13 @@ function test_addons() {
var fake_addon_id = "fake-addon";
var name1 = "testing-histogram1";
var register = Telemetry.registerAddonHistogram;
expect_success(function ()
expect_success(() =>
register(addon_id, name1, Telemetry.HISTOGRAM_LINEAR, 1, 5, 6));
// Can't register the same histogram multiple times.
expect_fail(function ()
register(addon_id, name1, Telemetry.HISTOGRAM_LINEAR, 1, 5, 6));
expect_fail(() =>
register(addon_id, name1, Telemetry.HISTOGRAM_LINEAR, 1, 5, 6));
// Make sure we can't get at it with another name.
expect_fail(function () Telemetry.getAddonHistogram(fake_addon_id, name1));
expect_fail(() => Telemetry.getAddonHistogram(fake_addon_id, name1));
// Check for reflection capabilities.
var h1 = Telemetry.getAddonHistogram(addon_id, name1);
@ -287,7 +287,7 @@ function test_addons() {
do_check_eq(s1.counts[3], 1);
var name2 = "testing-histogram2";
expect_success(function ()
expect_success(() =>
register(addon_id, name2, Telemetry.HISTOGRAM_LINEAR, 2, 4, 4));
var h2 = Telemetry.getAddonHistogram(addon_id, name2);
@ -303,16 +303,16 @@ function test_addons() {
// Check that we can register histograms for a different addon with
// identical names.
var extra_addon = "testing-extra-addon";
expect_success(function ()
register(extra_addon, name1, Telemetry.HISTOGRAM_BOOLEAN));
expect_success(() =>
register(extra_addon, name1, Telemetry.HISTOGRAM_BOOLEAN));
// Check that we can register flag histograms.
var flag_addon = "testing-flag-addon";
var flag_histogram = "flag-histogram";
expect_success(function()
register(flag_addon, flag_histogram, Telemetry.HISTOGRAM_FLAG))
expect_success(function()
register(flag_addon, name2, Telemetry.HISTOGRAM_LINEAR, 2, 4, 4));
expect_success(() =>
register(flag_addon, flag_histogram, Telemetry.HISTOGRAM_FLAG));
expect_success(() =>
register(flag_addon, name2, Telemetry.HISTOGRAM_LINEAR, 2, 4, 4));
// Check that we reflect registered addons and histograms.
snapshots = Telemetry.addonHistogramSnapshots;
@ -882,8 +882,8 @@ function run_test()
test_histogram(histogram_type, "test::"+histogram_type, min, max, bucket_count);
const nh = Telemetry.newHistogram;
expect_fail(function () nh("test::min", "never", histogram_type, 0, max, bucket_count));
expect_fail(function () nh("test::bucket_count", "never", histogram_type, min, max, 1));
expect_fail(() => nh("test::min", "never", histogram_type, 0, max, bucket_count));
expect_fail(() => nh("test::bucket_count", "never", histogram_type, min, max, 1));
}
// Instantiate the storage for this histogram and make sure it doesn't

View File

@ -225,7 +225,7 @@ function promiseAddVisitsAndRepopulateNewTabLinks(aPlaceInfo) {
function whenFileExists(aURL, aCallback = next) {
let callback = aCallback;
if (!thumbnailExists(aURL)) {
callback = function () whenFileExists(aURL, aCallback);
callback = () => whenFileExists(aURL, aCallback);
}
executeSoon(callback);
@ -242,7 +242,7 @@ function whenFileExists(aURL, aCallback = next) {
function whenFileRemoved(aFile, aCallback) {
let callback = aCallback;
if (aFile.exists()) {
callback = function () whenFileRemoved(aFile, aCallback);
callback = () => whenFileRemoved(aFile, aCallback);
}
executeSoon(callback || next);
@ -316,7 +316,9 @@ function bgAddCrashObserver() {
}
}, 'ipc:content-shutdown', false);
return {
get crashed() crashed
get crashed() {
return crashed;
}
};
}

View File

@ -308,7 +308,7 @@ callback.prototype = {
completion._completed = true;
if (this._completion.completions.every(function(x) x._completed))
if (this._completion.completions.every(x => x._completed))
this._completed = true;
break;

View File

@ -37,7 +37,7 @@ function checkContents(pset, prefixes) {
outset = pset.getPrefixes(outcount);
let inset = prefixes;
do_check_eq(inset.length, outset.length);
inset.sort(function(x,y) x - y);
inset.sort((x,y) => x - y);
for (let i = 0; i < inset.length; i++) {
do_check_eq(inset[i], outset[i]);
}
@ -149,7 +149,7 @@ function testLoadSaveLargeSet() {
arr.push(randInt);
}
arr.sort(function(x,y) x - y);
arr.sort((x,y) => x - y);
let pset = newPset();
pset.setPrefixes(arr, arr.length);