forked from mirrors/gecko-dev
Bug 1330014 - Add .eslintrc.js file to /services and run eslint --fix to automatically fix most of the errors. --fix brings the error count down from 4083 to 321 errors. r=markh,standard8
MozReview-Commit-ID: EjyAssqiQk8 --HG-- extra : rebase_source : d783829bc7fced3044d0d076c4786a6957d29bb6
This commit is contained in:
parent
2797c83264
commit
81cb5e57b9
199 changed files with 1827 additions and 1873 deletions
|
|
@ -184,6 +184,12 @@ mobile/android/modules/HomeProvider.jsm
|
|||
# Uses `#filter substitution`
|
||||
services/sync/modules/constants.js
|
||||
|
||||
# Third party services
|
||||
services/sync/tps/extensions/mozmill/resource/stdlib/json2.js
|
||||
services/common/kinto-http-client.js
|
||||
services/common/kinto-offline-client.js
|
||||
services/sync/tps/extensions/mozmill
|
||||
|
||||
# toolkit/ exclusions
|
||||
|
||||
# Not part of the default build
|
||||
|
|
|
|||
29
services/.eslintrc.js
Normal file
29
services/.eslintrc.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"../toolkit/.eslintrc.js"
|
||||
],
|
||||
rules: {
|
||||
/* These rules are only set to warn temporarily
|
||||
until they get fixed, at which point their
|
||||
respective line in this file should be removed. */
|
||||
"brace-style": "warn",
|
||||
"consistent-return": "warn",
|
||||
"no-cond-assign": "warn",
|
||||
"no-else-return": "warn",
|
||||
"no-empty": "warn",
|
||||
"no-ex-assign": "warn",
|
||||
"no-func-assign": "warn",
|
||||
"no-irregular-whitespace": "warn",
|
||||
"no-mixed-spaces-and-tabs": "warn",
|
||||
"no-native-reassign": "warn",
|
||||
"no-nested-ternary": "warn",
|
||||
"no-octal": "warn",
|
||||
"no-redeclare": "warn",
|
||||
"no-unreachable": "warn",
|
||||
"no-unsafe-finally": "warn",
|
||||
"no-unused-vars": "warn",
|
||||
"no-useless-call": "warn"
|
||||
}
|
||||
};
|
||||
|
|
@ -73,7 +73,7 @@ this.CloudSync = function CloudSync () {
|
|||
};
|
||||
|
||||
Object.defineProperty(CloudSync, "ready", {
|
||||
get: function () {
|
||||
get() {
|
||||
return _cloudSyncInternal.ready;
|
||||
}
|
||||
});
|
||||
|
|
@ -86,4 +86,4 @@ var _cloudSyncInternal = {
|
|||
XPCOMUtils.defineLazyGetter(_cloudSyncInternal, "instance", function() {
|
||||
_cloudSyncInternal.ready = true;
|
||||
return new _CloudSync();
|
||||
}.bind(this));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ this.Adapters = function () {
|
|||
Services.obs.removeObserver(observer, "cloudsync:user-sync");
|
||||
suspended = true;
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let resume = function() {
|
||||
if (suspended) {
|
||||
Services.obs.addObserver(observer, "cloudsync:user-sync", false);
|
||||
suspended = false;
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let eventSource = new EventSource(eventTypes, suspend, resume);
|
||||
let registeredAdapters = new Map();
|
||||
|
|
@ -65,7 +65,7 @@ this.Adapters = function () {
|
|||
}
|
||||
|
||||
let observer = {
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "cloudsync:user-sync":
|
||||
eventSource.emit("sync");
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ var Record = function (params) {
|
|||
|
||||
let annos = params.annos || {};
|
||||
Object.defineProperty(this, "annos", {
|
||||
get: function () {
|
||||
get() {
|
||||
return annos;
|
||||
},
|
||||
enumerable: false
|
||||
|
|
@ -230,14 +230,14 @@ var RootFolder = function (rootId, rootName) {
|
|||
PlacesUtils.bookmarks.removeObserver(observer);
|
||||
suspended = true;
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let resume = function() {
|
||||
if (suspended) {
|
||||
PlacesUtils.bookmarks.addObserver(observer, false);
|
||||
suspended = false;
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let eventTypes = [
|
||||
"add",
|
||||
|
|
@ -578,7 +578,7 @@ var RootFolder = function (rootId, rootName) {
|
|||
} else {
|
||||
newFolderRoots.push(guid);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let promises = [];
|
||||
for (let guid of newFolderRoots) {
|
||||
|
|
@ -718,13 +718,13 @@ var RootFolder = function (rootId, rootName) {
|
|||
};
|
||||
|
||||
let observer = {
|
||||
onBeginBatchUpdate: function () {
|
||||
onBeginBatchUpdate() {
|
||||
},
|
||||
|
||||
onEndBatchUpdate: function () {
|
||||
onEndBatchUpdate() {
|
||||
},
|
||||
|
||||
onItemAdded: function (id, parent, index, type, uri, title, dateAdded, guid, parentGuid) {
|
||||
onItemAdded(id, parent, index, type, uri, title, dateAdded, guid, parentGuid) {
|
||||
if (ignore(id, parent)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -732,7 +732,7 @@ var RootFolder = function (rootId, rootName) {
|
|||
asyncCallback(this, handleItemAdded, Array.prototype.slice.call(arguments));
|
||||
},
|
||||
|
||||
onItemRemoved: function (id, parent, index, type, uri, guid, parentGuid) {
|
||||
onItemRemoved(id, parent, index, type, uri, guid, parentGuid) {
|
||||
if (ignore(id, parent)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -740,7 +740,7 @@ var RootFolder = function (rootId, rootName) {
|
|||
asyncCallback(this, handleItemRemoved, Array.prototype.slice.call(arguments));
|
||||
},
|
||||
|
||||
onItemChanged: function (id, property, isAnnotation, newValue, lastModified, type, parent, guid, parentGuid) {
|
||||
onItemChanged(id, property, isAnnotation, newValue, lastModified, type, parent, guid, parentGuid) {
|
||||
if (ignore(id, parent)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -748,7 +748,7 @@ var RootFolder = function (rootId, rootName) {
|
|||
asyncCallback(this, handleItemChanged, Array.prototype.slice.call(arguments));
|
||||
},
|
||||
|
||||
onItemMoved: function (id, oldParent, oldIndex, newParent, newIndex, type, guid, oldParentGuid, newParentGuid) {
|
||||
onItemMoved(id, oldParent, oldIndex, newParent, newIndex, type, guid, oldParentGuid, newParentGuid) {
|
||||
if (ignore(id, oldParent) && ignore(id, newParent)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ var FolderCache = function () {
|
|||
}
|
||||
|
||||
FolderCache.prototype = {
|
||||
has: function (id) {
|
||||
has(id) {
|
||||
return this.cache.has(id);
|
||||
},
|
||||
|
||||
insert: function (id, parentId) {
|
||||
insert(id, parentId) {
|
||||
if (this.cache.has(id)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ FolderCache.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
remove: function (id) {
|
||||
remove(id) {
|
||||
if (!(this.cache.has(id))) {
|
||||
throw new Error("remote :: id not found in cache: " + id);
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ FolderCache.prototype = {
|
|||
this.cache.delete(id);
|
||||
},
|
||||
|
||||
setParent: function (id, parentId) {
|
||||
setParent(id, parentId) {
|
||||
if (!(this.cache.has(id))) {
|
||||
throw new Error("setParent :: id not found in cache: " + id);
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ FolderCache.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
getParent: function (id) {
|
||||
getParent(id) {
|
||||
if (this.cache.has(id)) {
|
||||
return this.cache.get(id).parent;
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ FolderCache.prototype = {
|
|||
throw new Error("getParent :: id not found in cache: " + id);
|
||||
},
|
||||
|
||||
getChildren: function (id) {
|
||||
getChildren(id) {
|
||||
if (this.cache.has(id)) {
|
||||
return this.cache.get(id).children;
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ FolderCache.prototype = {
|
|||
throw new Error("getChildren :: id not found in cache: " + id);
|
||||
},
|
||||
|
||||
setChildren: function (id, children) {
|
||||
setChildren(id, children) {
|
||||
for (let child of children) {
|
||||
if (!this.cache.has(child)) {
|
||||
this.insert(child, id);
|
||||
|
|
@ -97,7 +97,7 @@ FolderCache.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
dump: function () {
|
||||
dump() {
|
||||
dump("FolderCache: " + JSON.stringify(this.cache) + "\n");
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ var EventSource = function (types, suspendFunc, resumeFunc) {
|
|||
};
|
||||
|
||||
EventSource.prototype = {
|
||||
addEventListener: function (type, listener) {
|
||||
addEventListener(type, listener) {
|
||||
if (!this.listeners.has(type)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ EventSource.prototype = {
|
|||
this.resume();
|
||||
},
|
||||
|
||||
removeEventListener: function (type, listener) {
|
||||
removeEventListener(type, listener) {
|
||||
if (!this.listeners.has(type)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ EventSource.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
hasListeners: function () {
|
||||
hasListeners() {
|
||||
for (let l of this.listeners.values()) {
|
||||
if (l.size > 0) {
|
||||
return true;
|
||||
|
|
@ -47,7 +47,7 @@ EventSource.prototype = {
|
|||
return false;
|
||||
},
|
||||
|
||||
emit: function (type, arg) {
|
||||
emit(type, arg) {
|
||||
if (!this.listeners.has(type)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ var PlacesQueries = function () {
|
|||
PlacesQueries.prototype = {
|
||||
cachedStmts: {},
|
||||
|
||||
getQuery: function (queryString) {
|
||||
getQuery(queryString) {
|
||||
if (queryString in this.cachedStmts) {
|
||||
return this.cachedStmts[queryString];
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ var PlacesWrapper = function () {
|
|||
PlacesWrapper.prototype = {
|
||||
placesQueries: new PlacesQueries(),
|
||||
|
||||
guidToLocalId: function (guid) {
|
||||
guidToLocalId(guid) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let stmt = "SELECT id AS item_id " +
|
||||
|
|
@ -58,7 +58,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
localIdToGuid: function (id) {
|
||||
localIdToGuid(id) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let stmt = "SELECT guid " +
|
||||
|
|
@ -80,7 +80,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
getItemsById: function (ids, types) {
|
||||
getItemsById(ids, types) {
|
||||
let deferred = Promise.defer();
|
||||
let stmt = "SELECT b.id, b.type, b.parent, b.position, b.title, b.guid, b.dateAdded, b.lastModified, p.url " +
|
||||
"FROM moz_bookmarks b " +
|
||||
|
|
@ -95,7 +95,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
getItemsByParentId: function (parents, types) {
|
||||
getItemsByParentId(parents, types) {
|
||||
let deferred = Promise.defer();
|
||||
let stmt = "SELECT b.id, b.type, b.parent, b.position, b.title, b.guid, b.dateAdded, b.lastModified, p.url " +
|
||||
"FROM moz_bookmarks b " +
|
||||
|
|
@ -110,7 +110,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
getItemsByGuid: function (guids, types) {
|
||||
getItemsByGuid(guids, types) {
|
||||
let deferred = Promise.defer();
|
||||
guids = guids.map(JSON.stringify);
|
||||
let stmt = "SELECT b.id, b.type, b.parent, b.position, b.title, b.guid, b.dateAdded, b.lastModified, p.url " +
|
||||
|
|
@ -126,7 +126,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
updateCachedFolderIds: function (folderCache, folder) {
|
||||
updateCachedFolderIds(folderCache, folder) {
|
||||
let deferred = Promise.defer();
|
||||
let stmt = "SELECT id, guid " +
|
||||
"FROM moz_bookmarks " +
|
||||
|
|
@ -175,7 +175,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
getLocalIdsWithAnnotation: function (anno) {
|
||||
getLocalIdsWithAnnotation(anno) {
|
||||
let deferred = Promise.defer();
|
||||
let stmt = "SELECT a.item_id " +
|
||||
"FROM moz_anno_attributes n " +
|
||||
|
|
@ -198,7 +198,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
getItemAnnotationsForLocalId: function (id) {
|
||||
getItemAnnotationsForLocalId(id) {
|
||||
let deferred = Promise.defer();
|
||||
let stmt = "SELECT a.name, b.content " +
|
||||
"FROM moz_anno_attributes a " +
|
||||
|
|
@ -221,7 +221,7 @@ PlacesWrapper.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
insertBookmark: function (parent, uri, index, title, guid) {
|
||||
insertBookmark(parent, uri, index, title, guid) {
|
||||
let parsedURI;
|
||||
try {
|
||||
parsedURI = CommonUtils.makeURI(uri)
|
||||
|
|
@ -237,7 +237,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
setItemAnnotation: function (item, anno, value, flags, exp) {
|
||||
setItemAnnotation(item, anno, value, flags, exp) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.annotations.setItemAnnotation(item, anno, value, flags, exp));
|
||||
} catch (e) {
|
||||
|
|
@ -245,7 +245,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
itemHasAnnotation: function (item, anno) {
|
||||
itemHasAnnotation(item, anno) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.annotations.itemHasAnnotation(item, anno));
|
||||
} catch (e) {
|
||||
|
|
@ -253,7 +253,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
createFolder: function (parent, name, index, guid) {
|
||||
createFolder(parent, name, index, guid) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.createFolder(parent, name, index, guid));
|
||||
} catch (e) {
|
||||
|
|
@ -261,7 +261,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
removeFolderChildren: function (folder) {
|
||||
removeFolderChildren(folder) {
|
||||
try {
|
||||
PlacesUtils.bookmarks.removeFolderChildren(folder);
|
||||
return Promise.resolve();
|
||||
|
|
@ -270,7 +270,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
insertSeparator: function (parent, index, guid) {
|
||||
insertSeparator(parent, index, guid) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.insertSeparator(parent, index, guid));
|
||||
} catch (e) {
|
||||
|
|
@ -278,7 +278,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
removeItem: function (item) {
|
||||
removeItem(item) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.removeItem(item));
|
||||
} catch (e) {
|
||||
|
|
@ -286,7 +286,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
setItemDateAdded: function (item, dateAdded) {
|
||||
setItemDateAdded(item, dateAdded) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.setItemDateAdded(item, dateAdded));
|
||||
} catch (e) {
|
||||
|
|
@ -294,7 +294,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
setItemLastModified: function (item, lastModified) {
|
||||
setItemLastModified(item, lastModified) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.setItemLastModified(item, lastModified));
|
||||
} catch (e) {
|
||||
|
|
@ -302,7 +302,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
setItemTitle: function (item, title) {
|
||||
setItemTitle(item, title) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.setItemTitle(item, title));
|
||||
} catch (e) {
|
||||
|
|
@ -310,7 +310,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
changeBookmarkURI: function (item, uri) {
|
||||
changeBookmarkURI(item, uri) {
|
||||
try {
|
||||
uri = CommonUtils.makeURI(uri);
|
||||
return Promise.resolve(PlacesUtils.bookmarks.changeBookmarkURI(item, uri));
|
||||
|
|
@ -319,7 +319,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
moveItem: function (item, parent, index) {
|
||||
moveItem(item, parent, index) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.moveItem(item, parent, index));
|
||||
} catch (e) {
|
||||
|
|
@ -327,7 +327,7 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
setItemIndex: function (item, index) {
|
||||
setItemIndex(item, index) {
|
||||
try {
|
||||
return Promise.resolve(PlacesUtils.bookmarks.setItemIndex(item, index));
|
||||
} catch (e) {
|
||||
|
|
@ -335,11 +335,11 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
asyncQuery: function (query, names) {
|
||||
asyncQuery(query, names) {
|
||||
let deferred = Promise.defer();
|
||||
let storageCallback = {
|
||||
results: [],
|
||||
handleResult: function (results) {
|
||||
handleResult(results) {
|
||||
if (!names) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -354,11 +354,11 @@ PlacesWrapper.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
handleError: function (error) {
|
||||
handleError(error) {
|
||||
deferred.reject(error);
|
||||
},
|
||||
|
||||
handleCompletion: function (reason) {
|
||||
handleCompletion(reason) {
|
||||
if (REASON_ERROR == reason) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ var ClientRecord = function (params) {
|
|||
ClientRecord.prototype = {
|
||||
version: DATA_VERSION,
|
||||
|
||||
update: function (params) {
|
||||
update(params) {
|
||||
if (this.id !== params.id) {
|
||||
throw new Error("expected " + this.id + " to equal " + params.id);
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ var TabRecord = function (params) {
|
|||
TabRecord.prototype = {
|
||||
version: DATA_VERSION,
|
||||
|
||||
update: function (params) {
|
||||
update(params) {
|
||||
if (this.url && this.url !== params.url) {
|
||||
throw new Error("expected " + this.url + " to equal " + params.url);
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ var TabCache = function () {
|
|||
};
|
||||
|
||||
TabCache.prototype = {
|
||||
merge: function (client, tabs) {
|
||||
merge(client, tabs) {
|
||||
if (!client || !client.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ TabCache.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
clear: function (client) {
|
||||
clear(client) {
|
||||
if (client) {
|
||||
this.clients.delete(client.id);
|
||||
} else {
|
||||
|
|
@ -122,7 +122,7 @@ TabCache.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
get: function () {
|
||||
get() {
|
||||
let results = [];
|
||||
for (let client of this.clients.values()) {
|
||||
results.push(client);
|
||||
|
|
@ -130,7 +130,7 @@ TabCache.prototype = {
|
|||
return results;
|
||||
},
|
||||
|
||||
isEmpty: function () {
|
||||
isEmpty() {
|
||||
return 0 == this.clients.size;
|
||||
},
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ this.Tabs = function () {
|
|||
};
|
||||
|
||||
let observer = {
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "domwindowopened":
|
||||
let onLoad = () => {
|
||||
|
|
@ -200,7 +200,7 @@ this.Tabs = function () {
|
|||
registerListenersForWindow(wins.getNext());
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let suspend = function() {
|
||||
if (!suspended) {
|
||||
|
|
@ -210,7 +210,7 @@ this.Tabs = function () {
|
|||
unregisterListenersForWindow(wins.getNext());
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let eventTypes = [
|
||||
"change",
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ function kintoClient(connection, bucket) {
|
|||
|
||||
let config = {
|
||||
remote: base,
|
||||
bucket: bucket,
|
||||
bucket,
|
||||
adapter: FirefoxAdapter,
|
||||
adapterOptions: {sqliteHandle: connection},
|
||||
};
|
||||
|
|
@ -301,8 +301,6 @@ function* updatePinningList(records) {
|
|||
// 1254099.
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +318,7 @@ function* updateJSONBlocklist(filename, records) {
|
|||
yield OS.File.writeAtomic(path, serialized, {tmpPath: path + ".tmp"});
|
||||
|
||||
// Notify change to `nsBlocklistService`
|
||||
const eventData = {filename: filename};
|
||||
const eventData = {filename};
|
||||
Services.cpmm.sendAsyncMessage("Blocklist:reload-from-disk", eventData);
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ this.HawkClient.prototype = {
|
|||
* @param error
|
||||
* A string or object describing the error
|
||||
*/
|
||||
_constructError: function(restResponse, error) {
|
||||
_constructError(restResponse, error) {
|
||||
let errorObj = {
|
||||
error: error,
|
||||
error,
|
||||
// This object is likely to be JSON.stringify'd, but neither Error()
|
||||
// objects nor Components.Exception objects do the right thing there,
|
||||
// so we add a new element which is simply the .toString() version of
|
||||
|
|
@ -156,7 +156,7 @@ this.HawkClient.prototype = {
|
|||
* For HAWK clock skew and replay protection, see
|
||||
* https://github.com/hueniverse/hawk#replay-protection
|
||||
*/
|
||||
_updateClockOffset: function(dateString) {
|
||||
_updateClockOffset(dateString) {
|
||||
try {
|
||||
let serverDateMsec = Date.parse(dateString);
|
||||
this._localtimeOffsetMsec = serverDateMsec - this.now();
|
||||
|
|
@ -180,7 +180,7 @@ this.HawkClient.prototype = {
|
|||
/*
|
||||
* return current time in milliseconds
|
||||
*/
|
||||
now: function() {
|
||||
now() {
|
||||
return Date.now();
|
||||
},
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ this.HawkClient.prototype = {
|
|||
* as JSON and contains an 'error' property, the promise will be
|
||||
* rejected with this JSON-parsed response.
|
||||
*/
|
||||
request: function(path, method, credentials=null, payloadObj={}, extraHeaders = {},
|
||||
request(path, method, credentials = null, payloadObj = {}, extraHeaders = {},
|
||||
retryOK = true) {
|
||||
method = method.toLowerCase();
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ this.HawkClient.prototype = {
|
|||
// It's up to the caller to know how to decode the response.
|
||||
// We just return the whole response.
|
||||
deferred.resolve(this.response);
|
||||
};
|
||||
}
|
||||
|
||||
function onComplete(error) {
|
||||
try {
|
||||
|
|
@ -319,7 +319,7 @@ this.HawkClient.prototype = {
|
|||
observerPrefix: null,
|
||||
|
||||
// Given an optional header value, notify that a backoff has been requested.
|
||||
_maybeNotifyBackoff: function (response, headerName) {
|
||||
_maybeNotifyBackoff(response, headerName) {
|
||||
if (!this.observerPrefix || !response.headers) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ this.HawkClient.prototype = {
|
|||
},
|
||||
|
||||
// override points for testing.
|
||||
newHAWKAuthenticatedRESTRequest: function(uri, credentials, extra) {
|
||||
newHAWKAuthenticatedRESTRequest(uri, credentials, extra) {
|
||||
return new HAWKAuthenticatedRESTRequest(uri, credentials, extra);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ HAWKAuthenticatedRESTRequest.prototype = {
|
|||
localtimeOffsetMsec: this.localtimeOffsetMsec,
|
||||
credentials: this.credentials,
|
||||
payload: data && JSON.stringify(data) || "",
|
||||
contentType: contentType,
|
||||
contentType,
|
||||
};
|
||||
let header = CryptoUtils.computeHAWK(this.uri, method, options);
|
||||
this.setHeader("Authorization", header.field);
|
||||
|
|
@ -157,19 +157,19 @@ this.Intl = function Intl() {
|
|||
};
|
||||
|
||||
this.Intl.prototype = {
|
||||
init: function() {
|
||||
init() {
|
||||
Services.prefs.addObserver("intl.accept_languages", this, false);
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
uninit() {
|
||||
Services.prefs.removeObserver("intl.accept_languages", this);
|
||||
},
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
this.readPref();
|
||||
},
|
||||
|
||||
readPref: function() {
|
||||
readPref() {
|
||||
this._everRead = true;
|
||||
try {
|
||||
this._accepted = Services.prefs.getComplexValue(
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ class FirefoxAdapter extends Kinto.adapters.BaseAdapter {
|
|||
yield connection.executeTransaction(function* doImport() {
|
||||
for (let record of records) {
|
||||
const params = {
|
||||
collection_name: collection_name,
|
||||
collection_name,
|
||||
record_id: record.id,
|
||||
record: JSON.stringify(record),
|
||||
};
|
||||
|
|
@ -337,7 +337,7 @@ class FirefoxAdapter extends Kinto.adapters.BaseAdapter {
|
|||
}
|
||||
const lastModified = Math.max(...records.map(record => record.last_modified));
|
||||
const params = {
|
||||
collection_name: collection_name,
|
||||
collection_name,
|
||||
};
|
||||
const previousLastModified = yield connection.execute(
|
||||
statements.getLastModified, params).then(result => {
|
||||
|
|
@ -347,7 +347,7 @@ class FirefoxAdapter extends Kinto.adapters.BaseAdapter {
|
|||
});
|
||||
if (lastModified > previousLastModified) {
|
||||
const params = {
|
||||
collection_name: collection_name,
|
||||
collection_name,
|
||||
last_modified: lastModified,
|
||||
};
|
||||
yield connection.execute(statements.saveLastModified, params);
|
||||
|
|
@ -400,8 +400,7 @@ class FirefoxAdapter extends Kinto.adapters.BaseAdapter {
|
|||
if (record._status === "deleted") {
|
||||
// Garbage collect deleted records.
|
||||
promises.push(conn.execute(statements.deleteData, { collection_name, record_id }));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
const newRecord = Object.assign({}, record, {
|
||||
_status: "created",
|
||||
last_modified: undefined,
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ StorageServerCollection.prototype = {
|
|||
failed[record.id] = "Exception when processing.";
|
||||
}
|
||||
}
|
||||
return {success: success, failed: failed};
|
||||
return {success, failed};
|
||||
},
|
||||
|
||||
delete: function delete_(options) {
|
||||
|
|
@ -996,7 +996,7 @@ StorageServer.prototype = {
|
|||
|
||||
this._log.info("Registering new user with server: " + username);
|
||||
this.users[username] = {
|
||||
password: password,
|
||||
password,
|
||||
collections: {},
|
||||
quota: this.DEFAULT_QUOTA,
|
||||
};
|
||||
|
|
@ -1192,12 +1192,12 @@ StorageServer.prototype = {
|
|||
let deleteCollections = this.deleteCollections.bind(this, username);
|
||||
let quota = this.getQuota.bind(this, username);
|
||||
return {
|
||||
collection: collection,
|
||||
createCollection: createCollection,
|
||||
createContents: createContents,
|
||||
deleteCollections: deleteCollections,
|
||||
modified: modified,
|
||||
quota: quota,
|
||||
collection,
|
||||
createCollection,
|
||||
createContents,
|
||||
deleteCollections,
|
||||
modified,
|
||||
quota,
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ this.Observers = {
|
|||
*
|
||||
* @returns the observer
|
||||
*/
|
||||
add: function(topic, callback, thisObject) {
|
||||
add(topic, callback, thisObject) {
|
||||
let observer = new Observer(topic, callback, thisObject);
|
||||
this._cache.push(observer);
|
||||
this._service.addObserver(observer, topic, true);
|
||||
|
|
@ -53,7 +53,7 @@ this.Observers = {
|
|||
* @param thisObject {Object} [optional]
|
||||
* the object being used as |this| when calling a Function callback
|
||||
*/
|
||||
remove: function(topic, callback, thisObject) {
|
||||
remove(topic, callback, thisObject) {
|
||||
// This seems fairly inefficient, but I'm not sure how much better
|
||||
// we can make it. We could index by topic, but we can't index by callback
|
||||
// or thisObject, as far as I know, since the keys to JavaScript hashes
|
||||
|
|
@ -83,7 +83,7 @@ this.Observers = {
|
|||
* the observer, wrap them in an object and pass them via the subject
|
||||
* parameter (i.e.: { foo: 1, bar: "some string", baz: myObject })
|
||||
*/
|
||||
notify: function(topic, subject, data) {
|
||||
notify(topic, subject, data) {
|
||||
subject = (typeof subject == "undefined") ? null : new Subject(subject);
|
||||
data = (typeof data == "undefined") ? null : data;
|
||||
this._service.notifyObservers(subject, topic, data);
|
||||
|
|
@ -114,7 +114,7 @@ function Observer(topic, callback, thisObject) {
|
|||
|
||||
Observer.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
observe: function(subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
// Extract the wrapped object for subjects that are one of our wrappers
|
||||
// around a JS object. This way we support both wrapped subjects created
|
||||
// using this module and those that are real XPCOM components.
|
||||
|
|
@ -128,8 +128,7 @@ Observer.prototype = {
|
|||
this.callback.call(this.thisObject, subject, data);
|
||||
else
|
||||
this.callback(subject, data);
|
||||
}
|
||||
else // typeof this.callback == "object" (nsIObserver)
|
||||
} else // typeof this.callback == "object" (nsIObserver)
|
||||
this.callback.observe(subject, topic, data);
|
||||
}
|
||||
}
|
||||
|
|
@ -140,11 +139,11 @@ function Subject(object) {
|
|||
// as one of our wrappers to distinguish between subjects that are one of our
|
||||
// wrappers (which we should unwrap when notifying our observers) and those
|
||||
// that are real JS XPCOM components (which we should pass through unaltered).
|
||||
this.wrappedJSObject = { observersModuleSubjectWrapper: true, object: object };
|
||||
this.wrappedJSObject = { observersModuleSubjectWrapper: true, object };
|
||||
}
|
||||
|
||||
Subject.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([]),
|
||||
getScriptableHelper: function() {},
|
||||
getInterfaces: function() {}
|
||||
getScriptableHelper() {},
|
||||
getInterfaces() {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@ RESTRequest.prototype = {
|
|||
|
||||
/** * nsIInterfaceRequestor ***/
|
||||
|
||||
getInterface: function(aIID) {
|
||||
getInterface(aIID) {
|
||||
return this.QueryInterface(aIID);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ StringBundle.prototype = {
|
|||
return Cc["@mozilla.org/intl/nslocaleservice;1"].
|
||||
getService(Ci.nsILocaleService).
|
||||
getApplicationLocale();
|
||||
}
|
||||
catch(ex) {
|
||||
} catch (ex) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
|
@ -90,7 +89,7 @@ StringBundle.prototype = {
|
|||
*
|
||||
* @returns {String} the value of the string
|
||||
*/
|
||||
get: function(key, args) {
|
||||
get(key, args) {
|
||||
if (args)
|
||||
return this.stringBundle.formatStringFromName(key, args, args.length);
|
||||
else
|
||||
|
|
@ -103,7 +102,7 @@ StringBundle.prototype = {
|
|||
* @returns {Array}
|
||||
* an array of objects with key and value properties
|
||||
*/
|
||||
getAll: function() {
|
||||
getAll() {
|
||||
let strings = [];
|
||||
|
||||
// FIXME: for performance, return an enumerable array that wraps the string
|
||||
|
|
@ -170,7 +169,7 @@ StringBundle.prototype = {
|
|||
* @returns {String}
|
||||
* the value of the string
|
||||
*/
|
||||
getString: function(key) {
|
||||
getString(key) {
|
||||
return this.get(key);
|
||||
},
|
||||
|
||||
|
|
@ -186,7 +185,7 @@ StringBundle.prototype = {
|
|||
* @returns {String}
|
||||
* the formatted value of the string
|
||||
*/
|
||||
getFormattedString: function(key, args) {
|
||||
getFormattedString(key, args) {
|
||||
return this.get(key, args);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -7,17 +7,17 @@ function run_test() {
|
|||
_("Chain a few async methods, making sure the 'this' object is correct.");
|
||||
|
||||
let methods = {
|
||||
save: function(x, callback) {
|
||||
save(x, callback) {
|
||||
this.x = x;
|
||||
callback(x);
|
||||
},
|
||||
addX: function(x, callback) {
|
||||
addX(x, callback) {
|
||||
callback(x + this.x);
|
||||
},
|
||||
double: function(x, callback) {
|
||||
double(x, callback) {
|
||||
callback(x * 2);
|
||||
},
|
||||
neg: function(x, callback) {
|
||||
neg(x, callback) {
|
||||
callback(-x);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ function run_test() {
|
|||
_("Generate an execution error");
|
||||
let query = "INSERT INTO moz_formhistory (fieldname, value) VALUES ('one', NULL)";
|
||||
let stmt = Svc.Form.DBConnection.createStatement(query);
|
||||
let r11, except; ;
|
||||
let r11, except;
|
||||
try {
|
||||
r11 = Async.querySpinningly(stmt);
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ Cu.import("resource://testing-common/AppInfo.jsm", this);
|
|||
updateAppInfo({
|
||||
name: appName,
|
||||
ID: id,
|
||||
version: version,
|
||||
version,
|
||||
platformVersion: platformVersion ? platformVersion : "1.0",
|
||||
crashReporter: true,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ function* checkRecordCount(count) {
|
|||
const sqliteHandle = yield FirefoxAdapter.openConnection({path: kintoFilename});
|
||||
const config = {
|
||||
remote: base,
|
||||
bucket: bucket,
|
||||
bucket,
|
||||
adapter: FirefoxAdapter,
|
||||
adapterOptions: {sqliteHandle},
|
||||
};
|
||||
|
|
@ -97,7 +97,7 @@ add_task(function* test_check_signatures(){
|
|||
public_key: "fake",
|
||||
"content-signature": `x5u=http://localhost:${port}/test_blocklist_signatures/test_cert_chain.pem;p384ecdsa=${signature}`,
|
||||
signature_encoding: "rs_base64url",
|
||||
signature: signature,
|
||||
signature,
|
||||
hash_algorithm: "sha384",
|
||||
ref: "1yryrnmzou5rf31ou80znpnq8n"
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ add_task(function* test_check_signatures(){
|
|||
|
||||
function makeMetaResponse(eTag, body, comment) {
|
||||
return {
|
||||
comment: comment,
|
||||
comment,
|
||||
sampleHeaders: [
|
||||
"Content-Type: application/json; charset=UTF-8",
|
||||
`ETag: \"${eTag}\"`
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ add_task(function* test_retry_request_on_fail() {
|
|||
let message = "i love you!!!";
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.bodyOutputStream.write(message, message.length);
|
||||
return;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -461,7 +461,7 @@ add_task(function* test_401_then_500() {
|
|||
let message = "Cannot get ye flask.";
|
||||
response.setStatusLine(request.httpVersion, 500, "Internal server error");
|
||||
response.bodyOutputStream.write(message, message.length);
|
||||
return;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ add_test(function test_intl_accept_language() {
|
|||
do_print("Checked " + testCount + " languages. Removing checkLanguagePref as pref observer.");
|
||||
Services.prefs.removeObserver("intl.accept_languages", checkLanguagePref);
|
||||
run_next_test();
|
||||
return;
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ add_test(function test_function_observer() {
|
|||
add_test(function test_method_observer() {
|
||||
let obj = {
|
||||
foo: false,
|
||||
onFoo: function(subject, data) {
|
||||
onFoo(subject, data) {
|
||||
this.foo = !this.foo;
|
||||
do_check_eq(subject, gSubject);
|
||||
do_check_eq(data, "some data");
|
||||
|
|
@ -59,7 +59,7 @@ add_test(function test_method_observer() {
|
|||
add_test(function test_object_observer() {
|
||||
let obj = {
|
||||
foo: false,
|
||||
observe: function(subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
this.foo = !this.foo;
|
||||
|
||||
do_check_eq(subject, gSubject);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ add_test(function test_get() {
|
|||
|
||||
do_check_true(!!(this.channel.loadFlags & Ci.nsIRequest.LOAD_BYPASS_CACHE));
|
||||
do_check_true(!!(this.channel.loadFlags & Ci.nsIRequest.INHIBIT_CACHING));
|
||||
};
|
||||
}
|
||||
|
||||
function onComplete(error) {
|
||||
do_check_eq(error, null);
|
||||
|
|
@ -163,7 +163,7 @@ add_test(function test_get() {
|
|||
do_check_eq(request.onProgress, null);
|
||||
server.stop(run_next_test);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
do_check_eq(request.get(onComplete, onProgress), request);
|
||||
do_check_eq(request.status, request.SENT);
|
||||
|
|
@ -324,7 +324,7 @@ function check_posting_data(method) {
|
|||
onProgress_called = true;
|
||||
do_check_eq(this.status, request.IN_PROGRESS);
|
||||
do_check_true(this.response.body.length > 0);
|
||||
};
|
||||
}
|
||||
|
||||
function onComplete(error) {
|
||||
do_check_eq(error, null);
|
||||
|
|
@ -344,7 +344,7 @@ function check_posting_data(method) {
|
|||
do_check_eq(request.onProgress, null);
|
||||
server.stop(run_next_test);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
do_check_eq(request[funcName]("Hullo?", onComplete, onProgress), request);
|
||||
do_check_eq(request.status, request.SENT);
|
||||
|
|
@ -394,7 +394,7 @@ add_test(function test_delete() {
|
|||
onProgress_called = true;
|
||||
do_check_eq(this.status, request.IN_PROGRESS);
|
||||
do_check_true(this.response.body.length > 0);
|
||||
};
|
||||
}
|
||||
|
||||
function onComplete(error) {
|
||||
do_check_eq(error, null);
|
||||
|
|
@ -411,7 +411,7 @@ add_test(function test_delete() {
|
|||
do_check_eq(request.onProgress, null);
|
||||
server.stop(run_next_test);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
do_check_eq(request.delete(onComplete, onProgress), request);
|
||||
do_check_eq(request.status, request.SENT);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ add_test(function test_authenticated_request() {
|
|||
|
||||
let nonce = btoa(CryptoUtils.generateRandomBytes(16));
|
||||
let ts = Math.floor(Date.now() / 1000);
|
||||
let extra = {ts: ts, nonce: nonce};
|
||||
let extra = {ts, nonce};
|
||||
|
||||
let auth;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ add_test(function test_authenticated_request() {
|
|||
let sig = CryptoUtils.computeHTTPMACSHA1(id, key, method, uri, extra);
|
||||
auth = sig.getHeader();
|
||||
|
||||
let req = new TokenAuthenticatedRESTRequest(uri, {id: id, key: key}, extra);
|
||||
let req = new TokenAuthenticatedRESTRequest(uri, {id, key}, extra);
|
||||
let cb = Async.makeSpinningCallback();
|
||||
req.get(cb);
|
||||
let result = cb.wait();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ add_test(function test_working_bid_exchange() {
|
|||
key: "key",
|
||||
api_endpoint: service,
|
||||
uid: "uid",
|
||||
duration: duration,
|
||||
duration,
|
||||
});
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ add_test(function test_conditions_required_response_handling() {
|
|||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
let body = JSON.stringify({
|
||||
errors: [{description: description, location: "body", name: ""}],
|
||||
errors: [{description, location: "body", name: ""}],
|
||||
urls: {tos: tosURL}
|
||||
});
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
|
|
@ -221,7 +221,7 @@ add_test(function test_send_extra_headers() {
|
|||
key: "key",
|
||||
api_endpoint: "http://example.com/",
|
||||
uid: "uid",
|
||||
duration: duration,
|
||||
duration,
|
||||
});
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
}
|
||||
|
|
@ -408,7 +408,7 @@ add_test(function test_rich_media_types() {
|
|||
key: "key",
|
||||
api_endpoint: "foo",
|
||||
uid: "uid",
|
||||
duration: duration,
|
||||
duration,
|
||||
});
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
}
|
||||
|
|
@ -437,7 +437,7 @@ add_test(function test_exception_during_callback() {
|
|||
key: "key",
|
||||
api_endpoint: "foo",
|
||||
uid: "uid",
|
||||
duration: duration,
|
||||
duration,
|
||||
});
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ add_test(function test_writeJSON_readJSON() {
|
|||
do_check_eq(contents.d, json.d);
|
||||
do_check_eq(contents.e, json.e);
|
||||
run_next_test();
|
||||
};
|
||||
}
|
||||
|
||||
function doRead() {
|
||||
CommonUtils.readJSON(path)
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ TokenServerClient.prototype = {
|
|||
observerPrefix: null,
|
||||
|
||||
// Given an optional header value, notify that a backoff has been requested.
|
||||
_maybeNotifyBackoff: function (response, headerName) {
|
||||
_maybeNotifyBackoff(response, headerName) {
|
||||
if (!this.observerPrefix) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -456,7 +456,7 @@ TokenServerClient.prototype = {
|
|||
},
|
||||
|
||||
// override points for testing.
|
||||
newRESTRequest: function(url) {
|
||||
newRESTRequest(url) {
|
||||
return new RESTRequest(url);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ this.CommonUtils = {
|
|||
/**
|
||||
* Return elements of `a` or `b`.
|
||||
*/
|
||||
union: function (a, b) {
|
||||
union(a, b) {
|
||||
let out = new Set(a);
|
||||
for (let x of b) {
|
||||
out.add(x);
|
||||
|
|
@ -32,7 +32,7 @@ this.CommonUtils = {
|
|||
/**
|
||||
* Return elements of `a` that are not present in `b`.
|
||||
*/
|
||||
difference: function (a, b) {
|
||||
difference(a, b) {
|
||||
let out = new Set(a);
|
||||
for (let x of b) {
|
||||
out.delete(x);
|
||||
|
|
@ -43,7 +43,7 @@ this.CommonUtils = {
|
|||
/**
|
||||
* Return elements of `a` that are also in `b`.
|
||||
*/
|
||||
intersection: function (a, b) {
|
||||
intersection(a, b) {
|
||||
let out = new Set();
|
||||
for (let x of a) {
|
||||
if (b.has(x)) {
|
||||
|
|
@ -57,7 +57,7 @@ this.CommonUtils = {
|
|||
* Return true if `a` and `b` are the same size, and
|
||||
* every element of `a` is in `b`.
|
||||
*/
|
||||
setEqual: function (a, b) {
|
||||
setEqual(a, b) {
|
||||
if (a.size != b.size) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ this.CommonUtils = {
|
|||
* accumulation and prevents callers from accidentally relying on
|
||||
* same-tick promise resolution.
|
||||
*/
|
||||
laterTickResolvingPromise: function (value, prototype) {
|
||||
laterTickResolvingPromise(value, prototype) {
|
||||
let deferred = Promise.defer(prototype);
|
||||
this.nextTick(deferred.resolve.bind(deferred, value));
|
||||
return deferred.promise;
|
||||
|
|
@ -142,7 +142,7 @@ this.CommonUtils = {
|
|||
this.nextTick(cb);
|
||||
Async.waitForSyncCallback(cb);
|
||||
|
||||
return;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -380,7 +380,7 @@ this.CommonUtils = {
|
|||
* @param path the file to read. Will be passed to `OS.File.read()`.
|
||||
* @return a promise that resolves to the JSON contents of the named file.
|
||||
*/
|
||||
readJSON: function(path) {
|
||||
readJSON(path) {
|
||||
return OS.File.read(path, { encoding: "utf-8" }).then((data) => {
|
||||
return JSON.parse(data);
|
||||
});
|
||||
|
|
@ -393,7 +393,7 @@ this.CommonUtils = {
|
|||
* @param path the path of the file to write.
|
||||
* @return a promise, as produced by OS.File.writeAtomic.
|
||||
*/
|
||||
writeJSON: function(contents, path) {
|
||||
writeJSON(contents, path) {
|
||||
let data = JSON.stringify(contents);
|
||||
return OS.File.writeAtomic(path, data, {encoding: "utf-8", tmpPath: path + ".tmp"});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ WeaveCrypto.prototype = {
|
|||
? crypto.subtle.encrypt
|
||||
: crypto.subtle.decrypt)
|
||||
.bind(crypto.subtle);
|
||||
let algo = { name: CRYPT_ALGO, iv: iv };
|
||||
let algo = { name: CRYPT_ALGO, iv };
|
||||
|
||||
|
||||
return Async.promiseSpinningly(
|
||||
|
|
@ -245,7 +245,7 @@ WeaveCrypto.prototype = {
|
|||
let importAlgo = { name: KEY_DERIVATION_ALGO };
|
||||
let deriveAlgo = {
|
||||
name: KEY_DERIVATION_ALGO,
|
||||
salt: salt,
|
||||
salt,
|
||||
iterations: KEY_DERIVATION_ITERATIONS,
|
||||
hash: { name: KEY_DERIVATION_HASHING_ALGO },
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ this.CryptoUtils = {
|
|||
* with a single hasher, but eventually you must extract the result
|
||||
* yourself.
|
||||
*/
|
||||
updateUTF8: function(message, hasher) {
|
||||
updateUTF8(message, hasher) {
|
||||
let bytes = this._utf8Converter.convertToByteArray(message, {});
|
||||
hasher.update(bytes, bytes.length);
|
||||
},
|
||||
|
|
@ -261,8 +261,7 @@ this.CryptoUtils = {
|
|||
forceJS) {
|
||||
if (Svc.Crypto.deriveKeyFromPassphrase && !forceJS) {
|
||||
return Svc.Crypto.deriveKeyFromPassphrase(passphrase, salt, keyLength);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Fall back to JS implementation.
|
||||
// 4096 is hardcoded in WeaveCrypto, so do so here.
|
||||
return CryptoUtils.pbkdf2Generate(passphrase, atob(salt), 4096,
|
||||
|
|
@ -351,16 +350,16 @@ this.CryptoUtils = {
|
|||
}
|
||||
|
||||
return {
|
||||
identifier: identifier,
|
||||
key: key,
|
||||
identifier,
|
||||
key,
|
||||
method: usedMethod,
|
||||
hostname: host,
|
||||
port: port,
|
||||
mac: mac,
|
||||
nonce: nonce,
|
||||
ts: ts,
|
||||
ext: ext,
|
||||
getHeader: getHeader
|
||||
port,
|
||||
mac,
|
||||
nonce,
|
||||
ts,
|
||||
ext,
|
||||
getHeader
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -399,7 +398,7 @@ this.CryptoUtils = {
|
|||
* Given an HTTP header value, strip out any attributes.
|
||||
*/
|
||||
|
||||
stripHeaderAttributes: function(value) {
|
||||
stripHeaderAttributes(value) {
|
||||
value = value || "";
|
||||
let i = value.indexOf(";");
|
||||
return value.substring(0, (i >= 0) ? i : undefined).trim().toLowerCase();
|
||||
|
|
@ -458,7 +457,7 @@ this.CryptoUtils = {
|
|||
* ext - (string) app-specific data
|
||||
* MAC - (string) request MAC (base64)
|
||||
*/
|
||||
computeHAWK: function(uri, method, options) {
|
||||
computeHAWK(uri, method, options) {
|
||||
let credentials = options.credentials;
|
||||
let ts = options.ts || Math.floor(((options.now || Date.now()) +
|
||||
(options.localtimeOffsetMsec || 0))
|
||||
|
|
@ -487,7 +486,7 @@ this.CryptoUtils = {
|
|||
}
|
||||
|
||||
let artifacts = {
|
||||
ts: ts,
|
||||
ts,
|
||||
nonce: options.nonce || btoa(CryptoUtils.generateRandomBytes(8)),
|
||||
method: method.toUpperCase(),
|
||||
resource: uri.path, // This includes both path and search/queryarg.
|
||||
|
|
@ -544,7 +543,7 @@ this.CryptoUtils = {
|
|||
(artifacts.ext ? ('ext="' + escape(artifacts.ext) + '", ') : "") +
|
||||
'mac="' + artifacts.mac + '"');
|
||||
return {
|
||||
artifacts: artifacts,
|
||||
artifacts,
|
||||
field: header,
|
||||
};
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||
try {
|
||||
// In the context of xpcshell tests, there won't be a default AppInfo
|
||||
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
|
||||
}
|
||||
catch(ex) {
|
||||
} catch (ex) {
|
||||
|
||||
// Make sure to provide the right OS so crypto loads the right binaries
|
||||
var OS = "XPCShell";
|
||||
|
|
@ -26,7 +25,7 @@ updateAppInfo({
|
|||
ID: "{3e3ba16c-1675-4e88-b9c8-afef81b3d2ef}",
|
||||
version: "1",
|
||||
platformVersion: "",
|
||||
OS: OS,
|
||||
OS,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ add_test(function test_hawk() {
|
|||
let uri_http = CommonUtils.makeURI("http://example.net/somewhere/over/the/rainbow");
|
||||
let sha1_opts = { credentials: credentials_sha1,
|
||||
ext: "Bazinga!",
|
||||
ts: ts,
|
||||
nonce: nonce,
|
||||
ts,
|
||||
nonce,
|
||||
payload: "something to write about",
|
||||
};
|
||||
result = compute(uri_http, method, sha1_opts);
|
||||
|
|
@ -60,8 +60,8 @@ add_test(function test_hawk() {
|
|||
let uri_https = CommonUtils.makeURI("https://example.net/somewhere/over/the/rainbow");
|
||||
let sha256_opts = { credentials: credentials_sha256,
|
||||
ext: "Bazinga!",
|
||||
ts: ts,
|
||||
nonce: nonce,
|
||||
ts,
|
||||
nonce,
|
||||
payload: "something to write about",
|
||||
contentType: "text/plain",
|
||||
};
|
||||
|
|
@ -83,8 +83,8 @@ add_test(function test_hawk() {
|
|||
do_check_eq(result.artifacts.ext, "Bazinga!");
|
||||
|
||||
let sha256_opts_noext = { credentials: credentials_sha256,
|
||||
ts: ts,
|
||||
nonce: nonce,
|
||||
ts,
|
||||
nonce,
|
||||
payload: "something to write about",
|
||||
contentType: "text/plain",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ add_test(function test_sha1() {
|
|||
let uri = CommonUtils.makeURI("http://10.250.2.176/alias/");
|
||||
|
||||
let result = CryptoUtils.computeHTTPMACSHA1(id, key, method, uri,
|
||||
{ts: ts, nonce: nonce});
|
||||
{ts, nonce});
|
||||
|
||||
do_check_eq(btoa(result.mac), "jzh5chjQc2zFEvLbyHnPdX11Yck=");
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ add_test(function test_sha1() {
|
|||
let ext = "EXTRA DATA; foo,bar=1";
|
||||
|
||||
result = CryptoUtils.computeHTTPMACSHA1(id, key, method, uri,
|
||||
{ts: ts, nonce: nonce, ext: ext});
|
||||
{ts, nonce, ext});
|
||||
do_check_eq(btoa(result.mac), "bNf4Fnt5k6DnhmyipLPkuZroH68=");
|
||||
do_check_eq(result.getHeader(),
|
||||
'MAC id="vmo1txkttblmn51u2p3zk2xiy16hgvm5ok8qiv1yyi86ffjzy9zj0ez9x6wnvbx7", ' +
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ this.Credentials = Object.freeze({
|
|||
* Make constants accessible to tests
|
||||
*/
|
||||
constants: {
|
||||
PROTOCOL_VERSION: PROTOCOL_VERSION,
|
||||
PBKDF2_ROUNDS: PBKDF2_ROUNDS,
|
||||
STRETCHED_PW_LENGTH_BYTES: STRETCHED_PW_LENGTH_BYTES,
|
||||
HKDF_SALT: HKDF_SALT,
|
||||
HKDF_LENGTH: HKDF_LENGTH,
|
||||
HMAC_ALGORITHM: HMAC_ALGORITHM,
|
||||
HMAC_LENGTH: HMAC_LENGTH,
|
||||
PROTOCOL_VERSION,
|
||||
PBKDF2_ROUNDS,
|
||||
STRETCHED_PW_LENGTH_BYTES,
|
||||
HKDF_SALT,
|
||||
HKDF_LENGTH,
|
||||
HMAC_ALGORITHM,
|
||||
HMAC_LENGTH,
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -72,7 +72,7 @@ this.Credentials = Object.freeze({
|
|||
* Note that PROTOCOL_VERSION does not refer in any way to the version of the
|
||||
* Firefox Accounts API.
|
||||
*/
|
||||
keyWord: function(context) {
|
||||
keyWord(context) {
|
||||
return CommonUtils.stringToBytes(PROTOCOL_VERSION + context);
|
||||
},
|
||||
|
||||
|
|
@ -89,11 +89,11 @@ this.Credentials = Object.freeze({
|
|||
* Note that PROTOCOL_VERSION does not refer in any way to the version of the
|
||||
* Firefox Accounts API.
|
||||
*/
|
||||
keyWordExtended: function(name, email) {
|
||||
keyWordExtended(name, email) {
|
||||
return CommonUtils.stringToBytes(PROTOCOL_VERSION + name + ':' + email);
|
||||
},
|
||||
|
||||
setup: function(emailInput, passwordInput, options={}) {
|
||||
setup(emailInput, passwordInput, options = {}) {
|
||||
let deferred = Promise.defer();
|
||||
log.debug("setup credentials for " + emailInput);
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ AccountState.prototype = {
|
|||
return this.storageManager.updateAccountData(updatedFields);
|
||||
},
|
||||
|
||||
resolve: function(result) {
|
||||
resolve(result) {
|
||||
if (!this.isCurrent) {
|
||||
log.info("An accountState promise was resolved, but was actually rejected" +
|
||||
" due to a different user being signed in. Originally resolved" +
|
||||
|
|
@ -176,7 +176,7 @@ AccountState.prototype = {
|
|||
return Promise.resolve(result);
|
||||
},
|
||||
|
||||
reject: function(error) {
|
||||
reject(error) {
|
||||
// It could be argued that we should just let it reject with the original
|
||||
// error - but this runs the risk of the error being (eg) a 401, which
|
||||
// might cause the consumer to attempt some remediation and cause other
|
||||
|
|
@ -393,7 +393,7 @@ FxAccountsInternal.prototype = {
|
|||
let profileServerUrl = Services.urlFormatter.formatURLPref("identity.fxaccounts.remote.profile.uri");
|
||||
this._profile = new FxAccountsProfile({
|
||||
fxa: this,
|
||||
profileServerUrl: profileServerUrl,
|
||||
profileServerUrl,
|
||||
});
|
||||
}
|
||||
return this._profile;
|
||||
|
|
@ -411,7 +411,7 @@ FxAccountsInternal.prototype = {
|
|||
*
|
||||
* @return Promise
|
||||
*/
|
||||
notifyDevices: function(deviceIds, payload, TTL) {
|
||||
notifyDevices(deviceIds, payload, TTL) {
|
||||
if (!Array.isArray(deviceIds)) {
|
||||
deviceIds = [deviceIds];
|
||||
}
|
||||
|
|
@ -433,11 +433,11 @@ FxAccountsInternal.prototype = {
|
|||
* Return the current time in milliseconds as an integer. Allows tests to
|
||||
* manipulate the date to simulate certificate expiration.
|
||||
*/
|
||||
now: function() {
|
||||
now() {
|
||||
return this.fxAccountsClient.now();
|
||||
},
|
||||
|
||||
getAccountsClient: function() {
|
||||
getAccountsClient() {
|
||||
return this.fxAccountsClient;
|
||||
},
|
||||
|
||||
|
|
@ -714,7 +714,7 @@ FxAccountsInternal.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
checkVerificationStatus: function() {
|
||||
checkVerificationStatus() {
|
||||
log.trace('checkVerificationStatus');
|
||||
let currentState = this.currentAccountState;
|
||||
return currentState.getUserAccountData().then(data => {
|
||||
|
|
@ -731,7 +731,7 @@ FxAccountsInternal.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
_destroyOAuthToken: function(tokenData) {
|
||||
_destroyOAuthToken(tokenData) {
|
||||
let client = new FxAccountsOAuthGrantClient({
|
||||
serverURL: tokenData.server,
|
||||
client_id: FX_OAUTH_CLIENT_ID
|
||||
|
|
@ -739,7 +739,7 @@ FxAccountsInternal.prototype = {
|
|||
return client.destroyToken(tokenData.token)
|
||||
},
|
||||
|
||||
_destroyAllOAuthTokens: function(tokenInfos) {
|
||||
_destroyAllOAuthTokens(tokenInfos) {
|
||||
// let's just destroy them all in parallel...
|
||||
let promises = [];
|
||||
for (let [key, tokenInfo] of Object.entries(tokenInfos || {})) {
|
||||
|
|
@ -864,7 +864,7 @@ FxAccountsInternal.prototype = {
|
|||
* }
|
||||
* or null if no user is signed in
|
||||
*/
|
||||
getKeys: function() {
|
||||
getKeys() {
|
||||
let currentState = this.currentAccountState;
|
||||
return currentState.getUserAccountData().then((userData) => {
|
||||
if (!userData) {
|
||||
|
|
@ -900,7 +900,7 @@ FxAccountsInternal.prototype = {
|
|||
).then(result => currentState.resolve(result));
|
||||
},
|
||||
|
||||
fetchAndUnwrapKeys: function(keyFetchToken) {
|
||||
fetchAndUnwrapKeys(keyFetchToken) {
|
||||
if (logPII) {
|
||||
log.debug("fetchAndUnwrapKeys: token: " + keyFetchToken);
|
||||
}
|
||||
|
|
@ -951,7 +951,7 @@ FxAccountsInternal.prototype = {
|
|||
}.bind(this)).then(result => currentState.resolve(result));
|
||||
},
|
||||
|
||||
getAssertionFromCert: function(data, keyPair, cert, audience) {
|
||||
getAssertionFromCert(data, keyPair, cert, audience) {
|
||||
log.debug("getAssertionFromCert");
|
||||
let payload = {};
|
||||
let d = Promise.defer();
|
||||
|
|
@ -978,7 +978,7 @@ FxAccountsInternal.prototype = {
|
|||
return d.promise.then(result => currentState.resolve(result));
|
||||
},
|
||||
|
||||
getCertificateSigned: function(sessionToken, serializedPublicKey, lifetime) {
|
||||
getCertificateSigned(sessionToken, serializedPublicKey, lifetime) {
|
||||
log.debug("getCertificateSigned: " + !!sessionToken + " " + !!serializedPublicKey);
|
||||
if (logPII) {
|
||||
log.debug("getCertificateSigned: " + sessionToken + " " + serializedPublicKey);
|
||||
|
|
@ -1074,11 +1074,11 @@ FxAccountsInternal.prototype = {
|
|||
}
|
||||
return {
|
||||
keyPair: keyPair.rawKeyPair,
|
||||
certificate: certificate,
|
||||
certificate,
|
||||
}
|
||||
}),
|
||||
|
||||
getUserAccountData: function() {
|
||||
getUserAccountData() {
|
||||
return this.currentAccountState.getUserAccountData();
|
||||
},
|
||||
|
||||
|
|
@ -1089,7 +1089,7 @@ FxAccountsInternal.prototype = {
|
|||
/**
|
||||
* Setup for and if necessary do email verification polling.
|
||||
*/
|
||||
loadAndPoll: function() {
|
||||
loadAndPoll() {
|
||||
let currentState = this.currentAccountState;
|
||||
return currentState.getUserAccountData()
|
||||
.then(data => {
|
||||
|
|
@ -1103,7 +1103,7 @@ FxAccountsInternal.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
startVerifiedCheck: function(data) {
|
||||
startVerifiedCheck(data) {
|
||||
log.debug("startVerifiedCheck", data && data.verified);
|
||||
if (logPII) {
|
||||
log.debug("startVerifiedCheck with user data", data);
|
||||
|
|
@ -1125,7 +1125,7 @@ FxAccountsInternal.prototype = {
|
|||
);
|
||||
},
|
||||
|
||||
whenVerified: function(data) {
|
||||
whenVerified(data) {
|
||||
let currentState = this.currentAccountState;
|
||||
if (data.verified) {
|
||||
log.debug("already verified");
|
||||
|
|
@ -1140,7 +1140,7 @@ FxAccountsInternal.prototype = {
|
|||
);
|
||||
},
|
||||
|
||||
notifyObservers: function(topic, data) {
|
||||
notifyObservers(topic, data) {
|
||||
log.debug("Notifying observers of " + topic);
|
||||
Services.obs.notifyObservers(null, topic, data);
|
||||
},
|
||||
|
|
@ -1217,7 +1217,7 @@ FxAccountsInternal.prototype = {
|
|||
},
|
||||
|
||||
// Poll email status using truncated exponential back-off.
|
||||
pollEmailStatusAgain: function (currentState, sessionToken, timeoutMs) {
|
||||
pollEmailStatusAgain(currentState, sessionToken, timeoutMs) {
|
||||
let ageMs = Date.now() - this.pollStartDate;
|
||||
if (ageMs >= this.POLL_SESSION) {
|
||||
if (currentState.whenVerifiedDeferred) {
|
||||
|
|
@ -1238,7 +1238,7 @@ FxAccountsInternal.prototype = {
|
|||
}, timeoutMs);
|
||||
},
|
||||
|
||||
requiresHttps: function() {
|
||||
requiresHttps() {
|
||||
let allowHttp = false;
|
||||
try {
|
||||
allowHttp = Services.prefs.getBoolPref("identity.fxaccounts.allowHttp");
|
||||
|
|
@ -1280,7 +1280,7 @@ FxAccountsInternal.prototype = {
|
|||
// the current account's profile image.
|
||||
// if settingToEdit is set, the profile page should hightlight that setting
|
||||
// for the user to edit.
|
||||
promiseAccountsChangeProfileURI: function(entrypoint, settingToEdit = null) {
|
||||
promiseAccountsChangeProfileURI(entrypoint, settingToEdit = null) {
|
||||
let url = Services.urlFormatter.formatURLPref("identity.fxaccounts.settings.uri");
|
||||
|
||||
if (settingToEdit) {
|
||||
|
|
@ -1309,7 +1309,7 @@ FxAccountsInternal.prototype = {
|
|||
|
||||
// Returns a promise that resolves with the URL to use to manage the current
|
||||
// user's FxA acct.
|
||||
promiseAccountsManageURI: function(entrypoint) {
|
||||
promiseAccountsManageURI(entrypoint) {
|
||||
let url = Services.urlFormatter.formatURLPref("identity.fxaccounts.settings.uri");
|
||||
if (this.requiresHttps() && !/^https:/.test(url)) { // Comment to un-break emacs js-mode highlighting
|
||||
throw new Error("Firefox Accounts server must use HTTPS");
|
||||
|
|
@ -1397,7 +1397,7 @@ FxAccountsInternal.prototype = {
|
|||
let token = result.access_token;
|
||||
// If we got one, cache it.
|
||||
if (token) {
|
||||
let entry = {token: token, server: oAuthURL};
|
||||
let entry = {token, server: oAuthURL};
|
||||
// But before we do, check the cache again - if we find one now, it
|
||||
// means someone else concurrently requested the same scope and beat
|
||||
// us to the cache write. To be nice to the server, we revoke the one
|
||||
|
|
@ -1465,7 +1465,7 @@ FxAccountsInternal.prototype = {
|
|||
* NO_ACCOUNT
|
||||
* UNVERIFIED_ACCOUNT
|
||||
*/
|
||||
_errorToErrorClass: function (aError) {
|
||||
_errorToErrorClass(aError) {
|
||||
if (aError.errno) {
|
||||
let error = SERVER_ERRNO_TO_ERROR[aError.errno];
|
||||
return this._error(ERROR_TO_GENERAL_ERROR_CLASS[error] || ERROR_UNKNOWN, aError);
|
||||
|
|
@ -1479,7 +1479,7 @@ FxAccountsInternal.prototype = {
|
|||
return this._error(ERROR_UNKNOWN, aError);
|
||||
},
|
||||
|
||||
_error: function(aError, aDetails) {
|
||||
_error(aError, aDetails) {
|
||||
log.error("FxA rejecting with error ${aError}, details: ${aDetails}", {aError, aDetails});
|
||||
let reason = new Error(aError);
|
||||
if (aDetails) {
|
||||
|
|
@ -1510,7 +1510,7 @@ FxAccountsInternal.prototype = {
|
|||
* AUTH_ERROR
|
||||
* UNKNOWN_ERROR
|
||||
*/
|
||||
getSignedInUserProfile: function () {
|
||||
getSignedInUserProfile() {
|
||||
let currentState = this.currentAccountState;
|
||||
return this.profile.getProfile().then(
|
||||
profileData => {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ this.FxAccountsClient.prototype = {
|
|||
* Not used by this module, but made available to the FxAccounts.jsm
|
||||
* that uses this client.
|
||||
*/
|
||||
now: function() {
|
||||
now() {
|
||||
return this.hawk.now();
|
||||
},
|
||||
|
||||
|
|
@ -87,12 +87,12 @@ this.FxAccountsClient.prototype = {
|
|||
* email
|
||||
* }
|
||||
*/
|
||||
_createSession: function(path, email, password, getKeys=false,
|
||||
_createSession(path, email, password, getKeys = false,
|
||||
retryOK = true) {
|
||||
return Credentials.setup(email, password).then((creds) => {
|
||||
let data = {
|
||||
authPW: CommonUtils.bytesAsHex(creds.authPW),
|
||||
email: email,
|
||||
email,
|
||||
};
|
||||
let keys = getKeys ? "?keys=true" : "";
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ this.FxAccountsClient.prototype = {
|
|||
* password (not revealed to the FxA server)
|
||||
* }
|
||||
*/
|
||||
signUp: function(email, password, getKeys=false) {
|
||||
signUp(email, password, getKeys = false) {
|
||||
return this._createSession(SIGNUP, email, password, getKeys,
|
||||
false /* no retry */);
|
||||
},
|
||||
|
|
@ -191,7 +191,7 @@ this.FxAccountsClient.prototype = {
|
|||
* @return Promise
|
||||
* Resolves with a boolean indicating if the session is still valid
|
||||
*/
|
||||
sessionStatus: function (sessionTokenHex) {
|
||||
sessionStatus(sessionTokenHex) {
|
||||
return this._request("/session/status", "GET",
|
||||
deriveHawkCredentials(sessionTokenHex, "sessionToken")).then(
|
||||
() => Promise.resolve(true),
|
||||
|
|
@ -211,7 +211,7 @@ this.FxAccountsClient.prototype = {
|
|||
* The session token encoded in hex
|
||||
* @return Promise
|
||||
*/
|
||||
signOut: function (sessionTokenHex, options = {}) {
|
||||
signOut(sessionTokenHex, options = {}) {
|
||||
let path = "/session/destroy";
|
||||
if (options.service) {
|
||||
path += "?service=" + encodeURIComponent(options.service);
|
||||
|
|
@ -227,7 +227,7 @@ this.FxAccountsClient.prototype = {
|
|||
* The current session token encoded in hex
|
||||
* @return Promise
|
||||
*/
|
||||
recoveryEmailStatus: function (sessionTokenHex, options = {}) {
|
||||
recoveryEmailStatus(sessionTokenHex, options = {}) {
|
||||
let path = "/recovery_email/status";
|
||||
if (options.reason) {
|
||||
path += "?reason=" + encodeURIComponent(options.reason);
|
||||
|
|
@ -244,7 +244,7 @@ this.FxAccountsClient.prototype = {
|
|||
* The current token encoded in hex
|
||||
* @return Promise
|
||||
*/
|
||||
resendVerificationEmail: function(sessionTokenHex) {
|
||||
resendVerificationEmail(sessionTokenHex) {
|
||||
return this._request("/recovery_email/resend_code", "POST",
|
||||
deriveHawkCredentials(sessionTokenHex, "sessionToken"));
|
||||
},
|
||||
|
|
@ -262,7 +262,7 @@ this.FxAccountsClient.prototype = {
|
|||
* user's password (bytes)
|
||||
* }
|
||||
*/
|
||||
accountKeys: function (keyFetchTokenHex) {
|
||||
accountKeys(keyFetchTokenHex) {
|
||||
let creds = deriveHawkCredentials(keyFetchTokenHex, "keyFetchToken");
|
||||
let keyRequestKey = creds.extra.slice(0, 32);
|
||||
let morecreds = CryptoUtils.hkdf(keyRequestKey, undefined,
|
||||
|
|
@ -311,7 +311,7 @@ this.FxAccountsClient.prototype = {
|
|||
* wrapping any of these HTTP code/errno pairs:
|
||||
* https://github.com/mozilla/fxa-auth-server/blob/master/docs/api.md#response-12
|
||||
*/
|
||||
signCertificate: function (sessionTokenHex, serializedPublicKey, lifetime) {
|
||||
signCertificate(sessionTokenHex, serializedPublicKey, lifetime) {
|
||||
let creds = deriveHawkCredentials(sessionTokenHex, "sessionToken");
|
||||
|
||||
let body = { publicKey: serializedPublicKey,
|
||||
|
|
@ -334,7 +334,7 @@ this.FxAccountsClient.prototype = {
|
|||
* The promise resolves to true if the account exists, or false
|
||||
* if it doesn't. The promise is rejected on other errors.
|
||||
*/
|
||||
accountExists: function (email) {
|
||||
accountExists(email) {
|
||||
return this.signIn(email, "").then(
|
||||
(cantHappen) => {
|
||||
throw new Error("How did I sign in with an empty password?");
|
||||
|
|
@ -362,7 +362,7 @@ this.FxAccountsClient.prototype = {
|
|||
*
|
||||
* Used for differentiating between password change and account deletion.
|
||||
*/
|
||||
accountStatus: function(uid) {
|
||||
accountStatus(uid) {
|
||||
return this._request("/account/status?uid=" + uid, "GET").then(
|
||||
(result) => {
|
||||
return result.exists;
|
||||
|
|
@ -540,7 +540,7 @@ this.FxAccountsClient.prototype = {
|
|||
return this._request(path, "GET", creds, {});
|
||||
},
|
||||
|
||||
_clearBackoff: function() {
|
||||
_clearBackoff() {
|
||||
this.backoffError = null;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ XPCOMUtils.defineLazyServiceGetter(this, "permissionManager",
|
|||
|
||||
this.FxAccountsManager = {
|
||||
|
||||
init: function() {
|
||||
init() {
|
||||
Services.obs.addObserver(this, ONLOGOUT_NOTIFICATION, false);
|
||||
Services.obs.addObserver(this, ON_FXA_UPDATE_NOTIFICATION, false);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
observe(aSubject, aTopic, aData) {
|
||||
// Both topics indicate our cache is invalid
|
||||
this._activeSession = null;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ this.FxAccountsManager = {
|
|||
}
|
||||
},
|
||||
|
||||
_error: function(aError, aDetails) {
|
||||
_error(aError, aDetails) {
|
||||
log.error(aError);
|
||||
let reason = {
|
||||
error: aError
|
||||
|
|
@ -78,7 +78,7 @@ this.FxAccountsManager = {
|
|||
return Promise.reject(reason);
|
||||
},
|
||||
|
||||
_getError: function(aServerResponse) {
|
||||
_getError(aServerResponse) {
|
||||
if (!aServerResponse || !aServerResponse.error || !aServerResponse.error.errno) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ this.FxAccountsManager = {
|
|||
return error;
|
||||
},
|
||||
|
||||
_serverError: function(aServerResponse) {
|
||||
_serverError(aServerResponse) {
|
||||
let error = this._getError({ error: aServerResponse });
|
||||
return this._error(error ? error : ERROR_SERVER_ERROR, aServerResponse);
|
||||
},
|
||||
|
|
@ -96,11 +96,11 @@ this.FxAccountsManager = {
|
|||
// client used by the fxAccounts object because deep down they should have
|
||||
// access to the same hawk request object which will enable them to share
|
||||
// local clock skeq data.
|
||||
_getFxAccountsClient: function() {
|
||||
_getFxAccountsClient() {
|
||||
return this._fxAccounts.getAccountsClient();
|
||||
},
|
||||
|
||||
_signInSignUp: function(aMethod, aEmail, aPassword, aFetchKeys) {
|
||||
_signInSignUp(aMethod, aEmail, aPassword, aFetchKeys) {
|
||||
if (Services.io.offline) {
|
||||
return this._error(ERROR_OFFLINE);
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ this.FxAccountsManager = {
|
|||
let error = this._getError(user);
|
||||
if (!user || !user.uid || !user.sessionToken || error) {
|
||||
return this._error(error ? error : ERROR_INTERNAL_INVALID_USER, {
|
||||
user: user
|
||||
user
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ this.FxAccountsManager = {
|
|||
* FxAccountsClient.signCertificate()
|
||||
* See the latter method for possible (error code, errno) pairs.
|
||||
*/
|
||||
_handleGetAssertionError: function(reason, aAudience, aPrincipal) {
|
||||
_handleGetAssertionError(reason, aAudience, aPrincipal) {
|
||||
log.debug("FxAccountsManager._handleGetAssertionError()");
|
||||
let errno = (reason ? reason.errno : NaN) || NaN;
|
||||
// If the previously valid email/password pair is no longer valid ...
|
||||
|
|
@ -236,7 +236,7 @@ this.FxAccountsManager = {
|
|||
return Promise.reject(reason.message ? { error: reason.message } : reason);
|
||||
},
|
||||
|
||||
_getAssertion: function(aAudience, aPrincipal) {
|
||||
_getAssertion(aAudience, aPrincipal) {
|
||||
return this._fxAccounts.getAssertion(aAudience).then(
|
||||
(result) => {
|
||||
if (aPrincipal) {
|
||||
|
|
@ -260,7 +260,7 @@ this.FxAccountsManager = {
|
|||
* 2) The person typing can't prove knowledge of the password used
|
||||
* to log in. Failure should do nothing.
|
||||
*/
|
||||
_refreshAuthentication: function(aAudience, aEmail, aPrincipal,
|
||||
_refreshAuthentication(aAudience, aEmail, aPrincipal,
|
||||
logoutOnFailure = false) {
|
||||
this._refreshing = true;
|
||||
return this._uiRequest(UI_REQUEST_REFRESH_AUTH,
|
||||
|
|
@ -283,11 +283,11 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
_localSignOut: function() {
|
||||
_localSignOut() {
|
||||
return this._fxAccounts.signOut(true);
|
||||
},
|
||||
|
||||
_signOut: function() {
|
||||
_signOut() {
|
||||
if (!this._activeSession) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
_uiRequest: function(aRequest, aAudience, aPrincipal, aParams) {
|
||||
_uiRequest(aRequest, aAudience, aPrincipal, aParams) {
|
||||
if (Services.io.offline) {
|
||||
return this._error(ERROR_OFFLINE);
|
||||
}
|
||||
|
|
@ -358,7 +358,7 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
_addPermission: function(aPrincipal) {
|
||||
_addPermission(aPrincipal) {
|
||||
// This will fail from tests cause we are running them in the child
|
||||
// process until we have chrome tests in b2g. Bug 797164.
|
||||
try {
|
||||
|
|
@ -371,15 +371,15 @@ this.FxAccountsManager = {
|
|||
|
||||
// -- API --
|
||||
|
||||
signIn: function(aEmail, aPassword, aFetchKeys) {
|
||||
signIn(aEmail, aPassword, aFetchKeys) {
|
||||
return this._signInSignUp("signIn", aEmail, aPassword, aFetchKeys);
|
||||
},
|
||||
|
||||
signUp: function(aEmail, aPassword, aFetchKeys) {
|
||||
signUp(aEmail, aPassword, aFetchKeys) {
|
||||
return this._signInSignUp("signUp", aEmail, aPassword, aFetchKeys);
|
||||
},
|
||||
|
||||
signOut: function() {
|
||||
signOut() {
|
||||
if (!this._activeSession) {
|
||||
// If there is no cached active session, we try to get it from the
|
||||
// account storage.
|
||||
|
|
@ -395,7 +395,7 @@ this.FxAccountsManager = {
|
|||
return this._signOut();
|
||||
},
|
||||
|
||||
resendVerificationEmail: function() {
|
||||
resendVerificationEmail() {
|
||||
return this._fxAccounts.resendVerificationEmail().then(
|
||||
(result) => {
|
||||
return result;
|
||||
|
|
@ -406,7 +406,7 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
getAccount: function() {
|
||||
getAccount() {
|
||||
// We check first if we have session details cached.
|
||||
if (this._activeSession) {
|
||||
// If our cache says that the account is not yet verified,
|
||||
|
|
@ -452,7 +452,7 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
queryAccount: function(aEmail) {
|
||||
queryAccount(aEmail) {
|
||||
log.debug("queryAccount " + aEmail);
|
||||
if (Services.io.offline) {
|
||||
return this._error(ERROR_OFFLINE);
|
||||
|
|
@ -481,7 +481,7 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
verificationStatus: function() {
|
||||
verificationStatus() {
|
||||
log.debug("verificationStatus");
|
||||
if (!this._activeSession || !this._activeSession.sessionToken) {
|
||||
this._error(ERROR_NO_TOKEN_SESSION);
|
||||
|
|
@ -545,7 +545,7 @@ this.FxAccountsManager = {
|
|||
* silent - (bool) Prevent any UI interaction.
|
||||
* I.e., try to get an automatic assertion.
|
||||
*/
|
||||
getAssertion: function(aAudience, aPrincipal, aOptions) {
|
||||
getAssertion(aAudience, aPrincipal, aOptions) {
|
||||
if (!aAudience) {
|
||||
return this._error(ERROR_INVALID_AUDIENCE);
|
||||
}
|
||||
|
|
@ -561,7 +561,7 @@ this.FxAccountsManager = {
|
|||
// Three have-user cases to consider. First: are we unverified?
|
||||
if (!user.verified) {
|
||||
return this._error(ERROR_UNVERIFIED_ACCOUNT, {
|
||||
user: user
|
||||
user
|
||||
});
|
||||
}
|
||||
// Second case: do we need to refresh?
|
||||
|
|
@ -620,7 +620,7 @@ this.FxAccountsManager = {
|
|||
);
|
||||
},
|
||||
|
||||
getKeys: function() {
|
||||
getKeys() {
|
||||
let syncEnabled = false;
|
||||
try {
|
||||
syncEnabled = Services.prefs.getBoolPref("services.sync.enabled");
|
||||
|
|
@ -641,7 +641,7 @@ this.FxAccountsManager = {
|
|||
|
||||
if (!user.verified) {
|
||||
return this._error(ERROR_UNVERIFIED_ACCOUNT, {
|
||||
user: user
|
||||
user
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ this.FxAccountsOAuthClient.prototype = {
|
|||
* Opens a tab at "this._fxaOAuthStartUrl".
|
||||
* Registers a WebChannel listener and sets up a callback if needed.
|
||||
*/
|
||||
launchWebFlow: function () {
|
||||
launchWebFlow() {
|
||||
if (!this._channelCallback) {
|
||||
this._registerChannel();
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ this.FxAccountsOAuthClient.prototype = {
|
|||
/**
|
||||
* Release all resources that are in use.
|
||||
*/
|
||||
tearDown: function() {
|
||||
tearDown() {
|
||||
this.onComplete = null;
|
||||
this.onError = null;
|
||||
this._complete = true;
|
||||
|
|
@ -145,7 +145,7 @@ this.FxAccountsOAuthClient.prototype = {
|
|||
*
|
||||
* @private
|
||||
*/
|
||||
_configureChannel: function() {
|
||||
_configureChannel() {
|
||||
this._webChannelId = "oauth_" + this.parameters.client_id;
|
||||
|
||||
// if this.parameters.content_uri is present but not a valid URI, then this will throw an error.
|
||||
|
|
@ -160,7 +160,7 @@ this.FxAccountsOAuthClient.prototype = {
|
|||
* Create a new channel with the WebChannelBroker, setup a callback listener
|
||||
* @private
|
||||
*/
|
||||
_registerChannel: function() {
|
||||
_registerChannel() {
|
||||
/**
|
||||
* Processes messages that are called back from the FxAccountsChannel
|
||||
*
|
||||
|
|
@ -251,7 +251,7 @@ this.FxAccountsOAuthClient.prototype = {
|
|||
* OAuth client options
|
||||
* @private
|
||||
*/
|
||||
_validateOptions: function (options) {
|
||||
_validateOptions(options) {
|
||||
if (!options || !options.parameters) {
|
||||
throw new Error("Missing 'parameters' configuration option");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ this.FxAccountsOAuthGrantClient.prototype = {
|
|||
* @return Promise
|
||||
* Resolves: {Object} Object with access_token property
|
||||
*/
|
||||
getTokenFromAssertion: function (assertion, scope) {
|
||||
getTokenFromAssertion(assertion, scope) {
|
||||
if (!assertion) {
|
||||
throw new Error("Missing 'assertion' parameter");
|
||||
}
|
||||
|
|
@ -67,9 +67,9 @@ this.FxAccountsOAuthGrantClient.prototype = {
|
|||
throw new Error("Missing 'scope' parameter");
|
||||
}
|
||||
let params = {
|
||||
scope: scope,
|
||||
scope,
|
||||
client_id: this.parameters.client_id,
|
||||
assertion: assertion,
|
||||
assertion,
|
||||
response_type: "token"
|
||||
};
|
||||
|
||||
|
|
@ -84,12 +84,12 @@ this.FxAccountsOAuthGrantClient.prototype = {
|
|||
* Resolves: {Object} with the server response, which is typically
|
||||
* ignored.
|
||||
*/
|
||||
destroyToken: function (token) {
|
||||
destroyToken(token) {
|
||||
if (!token) {
|
||||
throw new Error("Missing 'token' parameter");
|
||||
}
|
||||
let params = {
|
||||
token: token,
|
||||
token,
|
||||
};
|
||||
|
||||
return this._createRequest(DESTROY_ENDPOINT, "POST", params);
|
||||
|
|
@ -102,7 +102,7 @@ this.FxAccountsOAuthGrantClient.prototype = {
|
|||
* OAuth client options
|
||||
* @private
|
||||
*/
|
||||
_validateOptions: function (options) {
|
||||
_validateOptions(options) {
|
||||
if (!options) {
|
||||
throw new Error("Missing configuration options");
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ this.FxAccountsOAuthGrantClient.prototype = {
|
|||
* Rejects: {FxAccountsOAuthGrantClientError} Profile client error.
|
||||
* @private
|
||||
*/
|
||||
_createRequest: function(path, method = "POST", params) {
|
||||
_createRequest(path, method = "POST", params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let profileDataUrl = this.serverURL + path;
|
||||
let request = new this._Request(profileDataUrl);
|
||||
|
|
|
|||
|
|
@ -106,20 +106,20 @@ this.FxAccountsProfile.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
tearDown: function () {
|
||||
tearDown() {
|
||||
this.fxa = null;
|
||||
this.client = null;
|
||||
this._cachedProfile = null;
|
||||
Services.obs.removeObserver(this, ON_PROFILE_CHANGE_NOTIFICATION);
|
||||
},
|
||||
|
||||
_getCachedProfile: function () {
|
||||
_getCachedProfile() {
|
||||
// The cached profile will end up back in the generic accountData
|
||||
// once bug 1157529 is fixed.
|
||||
return Promise.resolve(this._cachedProfile);
|
||||
},
|
||||
|
||||
_notifyProfileChange: function (uid) {
|
||||
_notifyProfileChange(uid) {
|
||||
this._isNotifying = true;
|
||||
Services.obs.notifyObservers(null, ON_PROFILE_CHANGE_NOTIFICATION, uid);
|
||||
this._isNotifying = false;
|
||||
|
|
@ -127,7 +127,7 @@ this.FxAccountsProfile.prototype = {
|
|||
|
||||
// Cache fetched data if it is different from what's in the cache.
|
||||
// Send out a notification if it has changed so that UI can update.
|
||||
_cacheProfile: function (profileData) {
|
||||
_cacheProfile(profileData) {
|
||||
if (!hasChanged(this._cachedProfile, profileData)) {
|
||||
log.debug("fetched profile matches cached copy");
|
||||
return Promise.resolve(null); // indicates no change (but only tests care)
|
||||
|
|
@ -142,7 +142,7 @@ this.FxAccountsProfile.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
_fetchAndCacheProfile: function () {
|
||||
_fetchAndCacheProfile() {
|
||||
if (!this._currentFetchPromise) {
|
||||
this._currentFetchPromise = this.client.fetchProfile().then(profile => {
|
||||
return this._cacheProfile(profile).then(() => {
|
||||
|
|
@ -162,7 +162,7 @@ this.FxAccountsProfile.prototype = {
|
|||
// Returns cached data right away if available, then fetches the latest profile
|
||||
// data in the background. After data is fetched a notification will be sent
|
||||
// out if the profile has changed.
|
||||
getProfile: function () {
|
||||
getProfile() {
|
||||
return this._getCachedProfile()
|
||||
.then(cachedProfile => {
|
||||
if (cachedProfile) {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ this.FxAccountsProfileClient.prototype = {
|
|||
* Rejects: {FxAccountsProfileClientError} Profile client error.
|
||||
* @private
|
||||
*/
|
||||
_rawRequest: function(path, method, token) {
|
||||
_rawRequest(path, method, token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let profileDataUrl = this.serverURL + path;
|
||||
let request = new this._Request(profileDataUrl);
|
||||
|
|
@ -192,7 +192,7 @@ this.FxAccountsProfileClient.prototype = {
|
|||
* Resolves: {Object} Successful response from the '/profile' endpoint.
|
||||
* Rejects: {FxAccountsProfileClientError} profile client error.
|
||||
*/
|
||||
fetchProfile: function () {
|
||||
fetchProfile() {
|
||||
log.debug("FxAccountsProfileClient: Requested profile");
|
||||
return this._createRequest("/profile", "GET");
|
||||
},
|
||||
|
|
@ -204,7 +204,7 @@ this.FxAccountsProfileClient.prototype = {
|
|||
* Resolves: {Object} Successful response from the '/avatar' endpoint.
|
||||
* Rejects: {FxAccountsProfileClientError} profile client error.
|
||||
*/
|
||||
fetchProfileImage: function () {
|
||||
fetchProfileImage() {
|
||||
log.debug("FxAccountsProfileClient: Requested avatar");
|
||||
return this._createRequest("/avatar", "GET");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -444,10 +444,10 @@ this.FxAccountsStorageManager.prototype = {
|
|||
function JSONStorage(options) {
|
||||
this.baseDir = options.baseDir;
|
||||
this.path = OS.Path.join(options.baseDir, options.filename);
|
||||
};
|
||||
}
|
||||
|
||||
JSONStorage.prototype = {
|
||||
set: function(contents) {
|
||||
set(contents) {
|
||||
log.trace("starting write of json user data", contents ? Object.keys(contents.accountData) : "null");
|
||||
let start = Date.now();
|
||||
return OS.File.makeDir(this.baseDir, {ignoreExisting: true})
|
||||
|
|
@ -458,7 +458,7 @@ JSONStorage.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
get: function() {
|
||||
get() {
|
||||
log.trace("starting fetch of json user data");
|
||||
let start = Date.now();
|
||||
return CommonUtils.readJSON(this.path).then(result => {
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ this.FxAccountsWebChannel.prototype = {
|
|||
let canLinkAccount = this._helpers.shouldAllowRelink(data.email);
|
||||
|
||||
let response = {
|
||||
command: command,
|
||||
command,
|
||||
messageId: message.messageId,
|
||||
data: { ok: canLinkAccount }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ function MockFxAccounts() {
|
|||
_getCertificateSigned_calls: [],
|
||||
_d_signCertificate: Promise.defer(),
|
||||
_now_is: new Date(),
|
||||
now: function () {
|
||||
now() {
|
||||
return this._now_is;
|
||||
},
|
||||
newAccountState(credentials) {
|
||||
|
|
@ -158,7 +158,7 @@ function MockFxAccounts() {
|
|||
storage.initialize(credentials);
|
||||
return new AccountState(storage);
|
||||
},
|
||||
getCertificateSigned: function (sessionToken, serializedPublicKey) {
|
||||
getCertificateSigned(sessionToken, serializedPublicKey) {
|
||||
_("mock getCertificateSigned\n");
|
||||
this._getCertificateSigned_calls.push([sessionToken, serializedPublicKey]);
|
||||
return this._d_signCertificate.promise;
|
||||
|
|
@ -1086,7 +1086,7 @@ add_test(function test_getOAuthToken() {
|
|||
|
||||
fxa.setSignedInUser(alice).then(
|
||||
() => {
|
||||
fxa.getOAuthToken({ scope: "profile", client: client }).then(
|
||||
fxa.getOAuthToken({ scope: "profile", client }).then(
|
||||
(result) => {
|
||||
do_check_true(getTokenFromAssertionCalled);
|
||||
do_check_eq(result, "token");
|
||||
|
|
@ -1119,7 +1119,7 @@ add_test(function test_getOAuthTokenScoped() {
|
|||
|
||||
fxa.setSignedInUser(alice).then(
|
||||
() => {
|
||||
fxa.getOAuthToken({ scope: ["foo", "bar"], client: client }).then(
|
||||
fxa.getOAuthToken({ scope: ["foo", "bar"], client }).then(
|
||||
(result) => {
|
||||
do_check_true(getTokenFromAssertionCalled);
|
||||
do_check_eq(result, "token");
|
||||
|
|
@ -1150,16 +1150,16 @@ add_task(function* test_getOAuthTokenCached() {
|
|||
};
|
||||
|
||||
yield fxa.setSignedInUser(alice);
|
||||
let result = yield fxa.getOAuthToken({ scope: "profile", client: client, service: "test-service" });
|
||||
let result = yield fxa.getOAuthToken({ scope: "profile", client, service: "test-service" });
|
||||
do_check_eq(numTokenFromAssertionCalls, 1);
|
||||
do_check_eq(result, "token");
|
||||
|
||||
// requesting it again should not re-fetch the token.
|
||||
result = yield fxa.getOAuthToken({ scope: "profile", client: client, service: "test-service" });
|
||||
result = yield fxa.getOAuthToken({ scope: "profile", client, service: "test-service" });
|
||||
do_check_eq(numTokenFromAssertionCalls, 1);
|
||||
do_check_eq(result, "token");
|
||||
// But requesting the same service and a different scope *will* get a new one.
|
||||
result = yield fxa.getOAuthToken({ scope: "something-else", client: client, service: "test-service" });
|
||||
result = yield fxa.getOAuthToken({ scope: "something-else", client, service: "test-service" });
|
||||
do_check_eq(numTokenFromAssertionCalls, 2);
|
||||
do_check_eq(result, "token");
|
||||
});
|
||||
|
|
@ -1183,20 +1183,20 @@ add_task(function* test_getOAuthTokenCachedScopeNormalization() {
|
|||
};
|
||||
|
||||
yield fxa.setSignedInUser(alice);
|
||||
let result = yield fxa.getOAuthToken({ scope: ["foo", "bar"], client: client, service: "test-service" });
|
||||
let result = yield fxa.getOAuthToken({ scope: ["foo", "bar"], client, service: "test-service" });
|
||||
do_check_eq(numTokenFromAssertionCalls, 1);
|
||||
do_check_eq(result, "token");
|
||||
|
||||
// requesting it again with the scope array in a different order not re-fetch the token.
|
||||
result = yield fxa.getOAuthToken({ scope: ["bar", "foo"], client: client, service: "test-service" });
|
||||
result = yield fxa.getOAuthToken({ scope: ["bar", "foo"], client, service: "test-service" });
|
||||
do_check_eq(numTokenFromAssertionCalls, 1);
|
||||
do_check_eq(result, "token");
|
||||
// requesting it again with the scope array in different case not re-fetch the token.
|
||||
result = yield fxa.getOAuthToken({ scope: ["Bar", "Foo"], client: client, service: "test-service" });
|
||||
result = yield fxa.getOAuthToken({ scope: ["Bar", "Foo"], client, service: "test-service" });
|
||||
do_check_eq(numTokenFromAssertionCalls, 1);
|
||||
do_check_eq(result, "token");
|
||||
// But requesting with a new entry in the array does fetch one.
|
||||
result = yield fxa.getOAuthToken({ scope: ["foo", "bar", "etc"], client: client, service: "test-service" });
|
||||
result = yield fxa.getOAuthToken({ scope: ["foo", "bar", "etc"], client, service: "test-service" });
|
||||
do_check_eq(numTokenFromAssertionCalls, 2);
|
||||
do_check_eq(result, "token");
|
||||
});
|
||||
|
|
@ -1283,7 +1283,7 @@ add_test(function test_getOAuthToken_network_error() {
|
|||
};
|
||||
|
||||
fxa.setSignedInUser(alice).then(() => {
|
||||
fxa.getOAuthToken({ scope: "profile", client: client })
|
||||
fxa.getOAuthToken({ scope: "profile", client })
|
||||
.then(null, err => {
|
||||
do_check_eq(err.message, "NETWORK_ERROR");
|
||||
do_check_eq(err.details.errno, ERRNO_NETWORK);
|
||||
|
|
@ -1312,7 +1312,7 @@ add_test(function test_getOAuthToken_auth_error() {
|
|||
};
|
||||
|
||||
fxa.setSignedInUser(alice).then(() => {
|
||||
fxa.getOAuthToken({ scope: "profile", client: client })
|
||||
fxa.getOAuthToken({ scope: "profile", client })
|
||||
.then(null, err => {
|
||||
do_check_eq(err.message, "AUTH_ERROR");
|
||||
do_check_eq(err.details.errno, ERRNO_INVALID_FXA_ASSERTION);
|
||||
|
|
@ -1338,7 +1338,7 @@ add_test(function test_getOAuthToken_unknown_error() {
|
|||
};
|
||||
|
||||
fxa.setSignedInUser(alice).then(() => {
|
||||
fxa.getOAuthToken({ scope: "profile", client: client })
|
||||
fxa.getOAuthToken({ scope: "profile", client })
|
||||
.then(null, err => {
|
||||
do_check_eq(err.message, "UNKNOWN_ERROR");
|
||||
run_next_test();
|
||||
|
|
@ -1351,10 +1351,10 @@ add_test(function test_getSignedInUserProfile() {
|
|||
alice.verified = true;
|
||||
|
||||
let mockProfile = {
|
||||
getProfile: function () {
|
||||
getProfile() {
|
||||
return Promise.resolve({ avatar: "image" });
|
||||
},
|
||||
tearDown: function() {},
|
||||
tearDown() {},
|
||||
};
|
||||
let fxa = new FxAccounts({
|
||||
_signOutServer() { return Promise.resolve(); },
|
||||
|
|
@ -1384,10 +1384,10 @@ add_test(function test_getSignedInUserProfile_error_uses_account_data() {
|
|||
let teardownCalled = false;
|
||||
fxa.setSignedInUser(alice).then(() => {
|
||||
fxa.internal._profile = {
|
||||
getProfile: function () {
|
||||
getProfile() {
|
||||
return Promise.reject("boom");
|
||||
},
|
||||
tearDown: function() {
|
||||
tearDown() {
|
||||
teardownCalled = true;
|
||||
}
|
||||
};
|
||||
|
|
@ -1469,11 +1469,11 @@ function expandHex(two_hex) {
|
|||
let eight_hex = two_hex + two_hex + two_hex + two_hex;
|
||||
let thirtytwo_hex = eight_hex + eight_hex + eight_hex + eight_hex;
|
||||
return thirtytwo_hex + thirtytwo_hex;
|
||||
};
|
||||
}
|
||||
|
||||
function expandBytes(two_hex) {
|
||||
return CommonUtils.hexToBytes(expandHex(two_hex));
|
||||
};
|
||||
}
|
||||
|
||||
function getTestUser(name) {
|
||||
return {
|
||||
|
|
@ -1493,7 +1493,7 @@ function makeObserver(aObserveTopic, aObserveFunc) {
|
|||
// nsIObserver is to be an observer
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]),
|
||||
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
observe(aSubject, aTopic, aData) {
|
||||
log.debug("observed " + aTopic + " " + aData);
|
||||
if (aTopic == aObserveTopic) {
|
||||
removeMe();
|
||||
|
|
@ -1511,8 +1511,7 @@ function makeObserver(aObserveTopic, aObserveFunc) {
|
|||
return removeMe;
|
||||
}
|
||||
|
||||
function do_check_throws(func, result, stack)
|
||||
{
|
||||
function do_check_throws(func, result, stack) {
|
||||
if (!stack)
|
||||
stack = Components.stack.caller;
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ function MockFxAccounts(device = {}) {
|
|||
return new Promise((resolve) => {
|
||||
resolve({
|
||||
endpoint: "http://mochi.test:8888",
|
||||
getKey: function(type) {
|
||||
getKey(type) {
|
||||
return ChromeUtils.base64URLDecode(
|
||||
type === "auth" ? BOGUS_AUTHKEY : BOGUS_PUBLICKEY,
|
||||
{ padding: "ignore" });
|
||||
|
|
@ -506,11 +506,11 @@ function expandHex(two_hex) {
|
|||
let eight_hex = two_hex + two_hex + two_hex + two_hex;
|
||||
let thirtytwo_hex = eight_hex + eight_hex + eight_hex + eight_hex;
|
||||
return thirtytwo_hex + thirtytwo_hex;
|
||||
};
|
||||
}
|
||||
|
||||
function expandBytes(two_hex) {
|
||||
return CommonUtils.hexToBytes(expandHex(two_hex));
|
||||
};
|
||||
}
|
||||
|
||||
function getTestUser(name) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -279,29 +279,26 @@ add_task(function* test_signIn() {
|
|||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.bodyOutputStream.write(sessionMessage_noKey,
|
||||
sessionMessage_noKey.length);
|
||||
return;
|
||||
}
|
||||
else if (jsonBody.email == "you@example.com") {
|
||||
|
||||
} else if (jsonBody.email == "you@example.com") {
|
||||
do_check_eq("keys=true", request._queryString);
|
||||
do_check_eq(jsonBody.authPW, "93d20ec50304d496d0707ec20d7e8c89459b6396ec5dd5b9e92809c5e42856c7");
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.bodyOutputStream.write(sessionMessage_withKey,
|
||||
sessionMessage_withKey.length);
|
||||
return;
|
||||
}
|
||||
else if (jsonBody.email == "You@example.com") {
|
||||
|
||||
} else if (jsonBody.email == "You@example.com") {
|
||||
// Error trying to sign in with a wrong capitalization
|
||||
response.setStatusLine(request.httpVersion, 400, "Bad request");
|
||||
response.bodyOutputStream.write(errorMessage_wrongCap,
|
||||
errorMessage_wrongCap.length);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
// Error trying to sign in to nonexistent account
|
||||
response.setStatusLine(request.httpVersion, 400, "Bad request");
|
||||
response.bodyOutputStream.write(errorMessage_notExistent,
|
||||
errorMessage_notExistent.length);
|
||||
return;
|
||||
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -357,7 +354,7 @@ add_task(function* test_signOut() {
|
|||
// Error trying to sign out of nonexistent account
|
||||
response.setStatusLine(request.httpVersion, 400, "Bad request");
|
||||
response.bodyOutputStream.write(errorMessage, errorMessage.length);
|
||||
return;
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -396,7 +393,7 @@ add_task(function* test_recoveryEmailStatus() {
|
|||
// Second call gets an error trying to query a nonexistent account
|
||||
response.setStatusLine(request.httpVersion, 400, "Bad request");
|
||||
response.bodyOutputStream.write(errorMessage, errorMessage.length);
|
||||
return;
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -425,7 +422,7 @@ add_task(function* test_recoveryEmailStatusWithReason() {
|
|||
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.bodyOutputStream.write(emailStatus, emailStatus.length);
|
||||
return;
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -455,7 +452,7 @@ add_task(function* test_resendVerificationEmail() {
|
|||
// Second call gets an error trying to query a nonexistent account
|
||||
response.setStatusLine(request.httpVersion, 400, "Bad request");
|
||||
response.bodyOutputStream.write(errorMessage, errorMessage.length);
|
||||
return;
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -578,7 +575,7 @@ add_task(function* test_signCertificate() {
|
|||
// Second attempt, trigger error
|
||||
response.setStatusLine(request.httpVersion, 400, "Bad request");
|
||||
response.bodyOutputStream.write(errorMessage, errorMessage.length);
|
||||
return;
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ const STATUS_SUCCESS = 200;
|
|||
var mockResponse = function(response) {
|
||||
return function() {
|
||||
return {
|
||||
setHeader: function () {},
|
||||
post: function () {
|
||||
setHeader() {},
|
||||
post() {
|
||||
this.response = response;
|
||||
this.onComplete();
|
||||
}
|
||||
|
|
@ -41,8 +41,8 @@ var mockResponse = function (response) {
|
|||
var mockResponseError = function(error) {
|
||||
return function() {
|
||||
return {
|
||||
setHeader: function () {},
|
||||
post: function () {
|
||||
setHeader() {},
|
||||
post() {
|
||||
this.onComplete(error);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ function MockFxAccounts(mockGrantClient) {
|
|||
storage.initialize(credentials);
|
||||
return new AccountState(storage);
|
||||
},
|
||||
_destroyOAuthToken: function(tokenData) {
|
||||
_destroyOAuthToken(tokenData) {
|
||||
// somewhat sad duplication of _destroyOAuthToken, but hard to avoid.
|
||||
return mockGrantClient.destroyToken(tokenData.token).then( () => {
|
||||
Services.obs.notifyObservers(null, "testhelper-fxa-revoke-complete", null);
|
||||
|
|
@ -156,7 +156,7 @@ MockFxAccountsOAuthGrantClient.prototype = {
|
|||
|
||||
add_task(function* testRevoke() {
|
||||
let client = new MockFxAccountsOAuthGrantClient();
|
||||
let tokenOptions = { scope: "test-scope", client: client };
|
||||
let tokenOptions = { scope: "test-scope", client };
|
||||
let fxa = yield createMockFxA(client);
|
||||
|
||||
// get our first token and check we hit the mock.
|
||||
|
|
@ -186,13 +186,13 @@ add_task(function* testSignOutDestroysTokens() {
|
|||
let fxa = yield createMockFxA(client);
|
||||
|
||||
// get our first token and check we hit the mock.
|
||||
let token1 = yield fxa.getOAuthToken({ scope: "test-scope", client: client });
|
||||
let token1 = yield fxa.getOAuthToken({ scope: "test-scope", client });
|
||||
equal(client.numTokenFetches, 1);
|
||||
equal(client.activeTokens.size, 1);
|
||||
ok(token1, "got a token");
|
||||
|
||||
// get another
|
||||
let token2 = yield fxa.getOAuthToken({ scope: "test-scope-2", client: client });
|
||||
let token2 = yield fxa.getOAuthToken({ scope: "test-scope-2", client });
|
||||
equal(client.numTokenFetches, 2);
|
||||
equal(client.activeTokens.size, 2);
|
||||
ok(token2, "got a token");
|
||||
|
|
@ -222,10 +222,10 @@ add_task(function* testTokenRaces() {
|
|||
promiseNotification("testhelper-fxa-revoke-complete"),
|
||||
]);
|
||||
let results = yield Promise.all([
|
||||
fxa.getOAuthToken({scope: "test-scope", client: client}),
|
||||
fxa.getOAuthToken({scope: "test-scope", client: client}),
|
||||
fxa.getOAuthToken({scope: "test-scope-2", client: client}),
|
||||
fxa.getOAuthToken({scope: "test-scope-2", client: client}),
|
||||
fxa.getOAuthToken({scope: "test-scope", client}),
|
||||
fxa.getOAuthToken({scope: "test-scope", client}),
|
||||
fxa.getOAuthToken({scope: "test-scope-2", client}),
|
||||
fxa.getOAuthToken({scope: "test-scope-2", client}),
|
||||
]);
|
||||
|
||||
equal(client.numTokenFetches, 4, "should have fetched 4 tokens.");
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ var mockResponse = function (response) {
|
|||
// Store the request uri so tests can inspect it
|
||||
Request._requestUri = requestUri;
|
||||
return {
|
||||
setHeader: function () {},
|
||||
head: function () {
|
||||
setHeader() {},
|
||||
head() {
|
||||
this.response = response;
|
||||
this.onComplete();
|
||||
}
|
||||
|
|
@ -44,8 +44,8 @@ var mockResponse = function (response) {
|
|||
var mockResponseError = function(error) {
|
||||
return function() {
|
||||
return {
|
||||
setHeader: function () {},
|
||||
head: function () {
|
||||
setHeader() {},
|
||||
head() {
|
||||
this.onComplete(error);
|
||||
}
|
||||
};
|
||||
|
|
@ -55,7 +55,7 @@ var mockResponseError = function (error) {
|
|||
var mockClient = function(fxa) {
|
||||
let options = {
|
||||
serverURL: "http://127.0.0.1:1111/v1",
|
||||
fxa: fxa,
|
||||
fxa,
|
||||
}
|
||||
return new FxAccountsProfileClient(options);
|
||||
};
|
||||
|
|
@ -74,7 +74,7 @@ FxaMock.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
getSignedInUser: function () {
|
||||
getSignedInUser() {
|
||||
return Promise.resolve(ACCOUNT_DATA);
|
||||
}
|
||||
};
|
||||
|
|
@ -88,7 +88,7 @@ function CreateFxAccountsProfile(fxa = null, client = null) {
|
|||
fxa = mockFxa();
|
||||
}
|
||||
let options = {
|
||||
fxa: fxa,
|
||||
fxa,
|
||||
profileServerUrl: "http://127.0.0.1:1111/v1"
|
||||
}
|
||||
if (client) {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ var mockResponse = function (response) {
|
|||
// Store the request uri so tests can inspect it
|
||||
Request._requestUri = requestUri;
|
||||
return {
|
||||
setHeader: function () {},
|
||||
get: function () {
|
||||
setHeader() {},
|
||||
get() {
|
||||
this.response = response;
|
||||
this.onComplete();
|
||||
}
|
||||
|
|
@ -54,8 +54,8 @@ const PROFILE_OPTIONS = {
|
|||
var mockResponseError = function(error) {
|
||||
return function() {
|
||||
return {
|
||||
setHeader: function () {},
|
||||
get: function () {
|
||||
setHeader() {},
|
||||
get() {
|
||||
this.onComplete(error);
|
||||
}
|
||||
};
|
||||
|
|
@ -171,13 +171,13 @@ add_test(function server401ResponseThenSuccess () {
|
|||
// Like mockResponse but we want access to headers etc.
|
||||
client._Request = function(requestUri) {
|
||||
return {
|
||||
setHeader: function (name, value) {
|
||||
setHeader(name, value) {
|
||||
if (name == "Authorization") {
|
||||
numAuthHeaders++;
|
||||
do_check_eq(value, "Bearer " + lastToken);
|
||||
}
|
||||
},
|
||||
get: function () {
|
||||
get() {
|
||||
this.response = responses[numRequests];
|
||||
++numRequests;
|
||||
this.onComplete();
|
||||
|
|
@ -235,13 +235,13 @@ add_test(function server401ResponsePersists () {
|
|||
let numAuthHeaders = 0;
|
||||
client._Request = function(requestUri) {
|
||||
return {
|
||||
setHeader: function (name, value) {
|
||||
setHeader(name, value) {
|
||||
if (name == "Authorization") {
|
||||
numAuthHeaders++;
|
||||
do_check_eq(value, "Bearer " + lastToken);
|
||||
}
|
||||
},
|
||||
get: function () {
|
||||
get() {
|
||||
this.response = response;
|
||||
++numRequests;
|
||||
this.onComplete();
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ add_task(function* unsubscribeFailure() {
|
|||
|
||||
add_test(function observeLogout() {
|
||||
let customLog = Object.assign(mockLog, {
|
||||
trace: function (msg) {
|
||||
trace(msg) {
|
||||
if (msg === "FxAccountsPushService unsubscribe") {
|
||||
// logout means we unsubscribe
|
||||
run_next_test();
|
||||
|
|
@ -124,12 +124,12 @@ add_test(function observeLogout() {
|
|||
|
||||
add_test(function observePushTopicVerify() {
|
||||
let emptyMsg = {
|
||||
QueryInterface: function() {
|
||||
QueryInterface() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
let customAccounts = Object.assign(mockFxAccounts, {
|
||||
checkVerificationStatus: function () {
|
||||
checkVerificationStatus() {
|
||||
// checking verification status on push messages without data
|
||||
run_next_test();
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ add_test(function observePushTopicDeviceConnected() {
|
|||
}
|
||||
})
|
||||
},
|
||||
QueryInterface: function() {
|
||||
QueryInterface() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
|
@ -182,12 +182,12 @@ add_test(function observePushTopicDeviceDisconnected() {
|
|||
}
|
||||
})
|
||||
},
|
||||
QueryInterface: function() {
|
||||
QueryInterface() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
let customAccounts = Object.assign(mockFxAccounts, {
|
||||
handleDeviceDisconnection: function () {
|
||||
handleDeviceDisconnection() {
|
||||
// checking verification status on push messages without data
|
||||
run_next_test();
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ add_test(function observePushTopicPasswordChanged() {
|
|||
command: ON_PASSWORD_CHANGED_NOTIFICATION
|
||||
})
|
||||
},
|
||||
QueryInterface: function() {
|
||||
QueryInterface() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
|
@ -231,7 +231,7 @@ add_test(function observePushTopicPasswordReset() {
|
|||
command: ON_PASSWORD_RESET_NOTIFICATION
|
||||
})
|
||||
},
|
||||
QueryInterface: function() {
|
||||
QueryInterface() {
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
|
@ -249,7 +249,7 @@ add_test(function observePushTopicPasswordReset() {
|
|||
|
||||
add_test(function observeSubscriptionChangeTopic() {
|
||||
let customAccounts = Object.assign(mockFxAccounts, {
|
||||
updateDeviceRegistration: function () {
|
||||
updateDeviceRegistration() {
|
||||
// subscription change means updating the device registration
|
||||
run_next_test();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ function MockedPlainStorage(accountData) {
|
|||
if (accountData) {
|
||||
data = {
|
||||
version: DATA_FORMAT_VERSION,
|
||||
accountData: accountData,
|
||||
accountData,
|
||||
}
|
||||
}
|
||||
this.data = data;
|
||||
|
|
@ -45,7 +45,7 @@ function MockedSecureStorage(accountData) {
|
|||
if (accountData) {
|
||||
data = {
|
||||
version: DATA_FORMAT_VERSION,
|
||||
accountData: accountData,
|
||||
accountData,
|
||||
}
|
||||
}
|
||||
this.data = data;
|
||||
|
|
@ -55,7 +55,7 @@ function MockedSecureStorage(accountData) {
|
|||
MockedSecureStorage.prototype = {
|
||||
fetchCount: 0,
|
||||
locked: false,
|
||||
STORAGE_LOCKED: function() {},
|
||||
STORAGE_LOCKED() {},
|
||||
get: Task.async(function* (uid, email) {
|
||||
this.fetchCount++;
|
||||
if (this.locked) {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ add_test(function test_login_message() {
|
|||
channel_id: WEBCHANNEL_ID,
|
||||
content_uri: URL_STRING,
|
||||
helpers: {
|
||||
login: function (accountData) {
|
||||
login(accountData) {
|
||||
do_check_eq(accountData.email, 'testuser@testuser.com');
|
||||
run_next_test();
|
||||
return Promise.resolve();
|
||||
|
|
@ -162,7 +162,7 @@ add_test(function test_logout_message() {
|
|||
channel_id: WEBCHANNEL_ID,
|
||||
content_uri: URL_STRING,
|
||||
helpers: {
|
||||
logout: function (uid) {
|
||||
logout(uid) {
|
||||
do_check_eq(uid, 'foo');
|
||||
run_next_test();
|
||||
return Promise.resolve();
|
||||
|
|
@ -183,7 +183,7 @@ add_test(function test_delete_message() {
|
|||
channel_id: WEBCHANNEL_ID,
|
||||
content_uri: URL_STRING,
|
||||
helpers: {
|
||||
logout: function (uid) {
|
||||
logout(uid) {
|
||||
do_check_eq(uid, 'foo');
|
||||
run_next_test();
|
||||
return Promise.resolve();
|
||||
|
|
@ -204,7 +204,7 @@ add_test(function test_can_link_account_message() {
|
|||
channel_id: WEBCHANNEL_ID,
|
||||
content_uri: URL_STRING,
|
||||
helpers: {
|
||||
shouldAllowRelink: function (email) {
|
||||
shouldAllowRelink(email) {
|
||||
do_check_eq(email, 'testuser@testuser.com');
|
||||
run_next_test();
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ add_test(function test_sync_preferences_message() {
|
|||
channel_id: WEBCHANNEL_ID,
|
||||
content_uri: URL_STRING,
|
||||
helpers: {
|
||||
openSyncPreferences: function (browser, entryPoint) {
|
||||
openSyncPreferences(browser, entryPoint) {
|
||||
do_check_eq(entryPoint, 'fxa:verification_complete');
|
||||
do_check_eq(browser, mockSendingContext.browser);
|
||||
run_next_test();
|
||||
|
|
@ -279,7 +279,7 @@ add_test(function test_helpers_should_allow_relink_different_email() {
|
|||
add_task(function* test_helpers_login_without_customize_sync() {
|
||||
let helpers = new FxAccountsWebChannelHelpers({
|
||||
fxAccounts: {
|
||||
setSignedInUser: function(accountData) {
|
||||
setSignedInUser(accountData) {
|
||||
return new Promise(resolve => {
|
||||
// ensure fxAccounts is informed of the new user being signed in.
|
||||
do_check_eq(accountData.email, 'testuser@testuser.com');
|
||||
|
|
@ -315,7 +315,7 @@ add_task(function* test_helpers_login_without_customize_sync() {
|
|||
add_task(function* test_helpers_login_with_customize_sync() {
|
||||
let helpers = new FxAccountsWebChannelHelpers({
|
||||
fxAccounts: {
|
||||
setSignedInUser: function(accountData) {
|
||||
setSignedInUser(accountData) {
|
||||
return new Promise(resolve => {
|
||||
// ensure fxAccounts is informed of the new user being signed in.
|
||||
do_check_eq(accountData.email, 'testuser@testuser.com');
|
||||
|
|
@ -345,7 +345,7 @@ add_task(function* test_helpers_login_with_customize_sync() {
|
|||
add_task(function* test_helpers_login_with_customize_sync_and_declined_engines() {
|
||||
let helpers = new FxAccountsWebChannelHelpers({
|
||||
fxAccounts: {
|
||||
setSignedInUser: function(accountData) {
|
||||
setSignedInUser(accountData) {
|
||||
return new Promise(resolve => {
|
||||
// ensure fxAccounts is informed of the new user being signed in.
|
||||
do_check_eq(accountData.email, 'testuser@testuser.com');
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ WeaveService.prototype = {
|
|||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
ensureLoaded: function () {
|
||||
ensureLoaded() {
|
||||
// If we are loaded and not using FxA, load the migration module.
|
||||
if (!this.fxAccountsEnabled) {
|
||||
Cu.import("resource://services-sync/FxaMigrator.jsm");
|
||||
|
|
@ -83,7 +83,7 @@ WeaveService.prototype = {
|
|||
Weave.Service;
|
||||
},
|
||||
|
||||
whenLoaded: function() {
|
||||
whenLoaded() {
|
||||
if (this.ready) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ WeaveService.prototype = {
|
|||
return prefs.prefHasUserValue("username");
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "app-startup":
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
|
|
@ -172,11 +172,11 @@ AboutWeaveLog.prototype = {
|
|||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
getURIFlags: function(aURI) {
|
||||
getURIFlags(aURI) {
|
||||
return 0;
|
||||
},
|
||||
|
||||
newChannel: function(aURI, aLoadInfo) {
|
||||
newChannel(aURI, aLoadInfo) {
|
||||
let dir = FileUtils.getDir("ProfD", ["weave", "logs"], true);
|
||||
let uri = Services.io.newFileURI(dir);
|
||||
let channel = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo);
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ this.initializeIdentityWithTokenServerResponse = function(response) {
|
|||
}
|
||||
|
||||
// A mock request object.
|
||||
function MockRESTRequest(url) {};
|
||||
function MockRESTRequest(url) {}
|
||||
MockRESTRequest.prototype = {
|
||||
_log: requestLog,
|
||||
setHeader: function() {},
|
||||
get: function(callback) {
|
||||
setHeader() {},
|
||||
get(callback) {
|
||||
this.response = response;
|
||||
callback.call(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ this.configureFxAccountIdentity = function(authService,
|
|||
fxa.internal._fxAccountsClient = mockFxAClient;
|
||||
|
||||
let mockTSC = { // TokenServerClient
|
||||
getTokenFromBrowserIDAssertion: function(uri, assertion, cb) {
|
||||
getTokenFromBrowserIDAssertion(uri, assertion, cb) {
|
||||
config.fxaccount.token.uid = config.username;
|
||||
cb(null, config.fxaccount.token);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ let SyncedTabsInternal = {
|
|||
} catch (ex) {
|
||||
log.error("Sync failed", ex);
|
||||
reject(ex);
|
||||
};
|
||||
}
|
||||
}, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -252,8 +252,7 @@ AddonsReconciler.prototype = {
|
|||
for (let [k, v] of Object.entries(record)) {
|
||||
if (k == "modified") {
|
||||
state.addons[id][k] = v.getTime();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
state.addons[id][k] = v;
|
||||
}
|
||||
}
|
||||
|
|
@ -427,9 +426,9 @@ AddonsReconciler.prototype = {
|
|||
|
||||
if (!(id in this._addons)) {
|
||||
let record = {
|
||||
id: id,
|
||||
guid: guid,
|
||||
enabled: enabled,
|
||||
id,
|
||||
guid,
|
||||
enabled,
|
||||
installed: true,
|
||||
modified: now,
|
||||
type: addon.type,
|
||||
|
|
@ -634,8 +633,7 @@ AddonsReconciler.prototype = {
|
|||
this.saveState(null, cb);
|
||||
cb.wait();
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
} catch (ex) {
|
||||
this._log.warn("Exception", ex);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -127,17 +127,17 @@ AddonUtilsInternal.prototype = {
|
|||
install.addon.userDisabled = true;
|
||||
}
|
||||
},
|
||||
onInstallEnded: function(install, addon) {
|
||||
onInstallEnded(install, addon) {
|
||||
install.removeListener(listener);
|
||||
|
||||
cb(null, {id: addon.id, install: install, addon: addon});
|
||||
cb(null, {id: addon.id, install, addon});
|
||||
},
|
||||
onInstallFailed: function(install) {
|
||||
onInstallFailed(install) {
|
||||
install.removeListener(listener);
|
||||
|
||||
cb(new Error("Install failed: " + install.error), null);
|
||||
},
|
||||
onDownloadFailed: function(install) {
|
||||
onDownloadFailed(install) {
|
||||
install.removeListener(listener);
|
||||
|
||||
cb(new Error("Download failed: " + install.error), null);
|
||||
|
|
@ -145,8 +145,7 @@ AddonUtilsInternal.prototype = {
|
|||
};
|
||||
install.addListener(listener);
|
||||
install.install();
|
||||
}
|
||||
catch (ex) {
|
||||
} catch (ex) {
|
||||
this._log.error("Error installing add-on", ex);
|
||||
cb(ex, null);
|
||||
}
|
||||
|
|
@ -164,7 +163,7 @@ AddonUtilsInternal.prototype = {
|
|||
*/
|
||||
uninstallAddon: function uninstallAddon(addon, cb) {
|
||||
let listener = {
|
||||
onUninstalling: function(uninstalling, needsRestart) {
|
||||
onUninstalling(uninstalling, needsRestart) {
|
||||
if (addon.id != uninstalling.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -180,7 +179,7 @@ AddonUtilsInternal.prototype = {
|
|||
AddonManager.removeAddonListener(listener);
|
||||
cb(null, addon);
|
||||
},
|
||||
onUninstalled: function(uninstalled) {
|
||||
onUninstalled(uninstalled) {
|
||||
if (addon.id != uninstalled.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -273,7 +272,7 @@ AddonUtilsInternal.prototype = {
|
|||
cb(null, ourResult);
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
let toInstall = [];
|
||||
|
||||
|
|
@ -494,7 +493,7 @@ AddonUtilsInternal.prototype = {
|
|||
|
||||
if (!addon.appDisabled) {
|
||||
cb(null, addon);
|
||||
return;
|
||||
|
||||
}
|
||||
// Else the listener will handle invoking the callback.
|
||||
},
|
||||
|
|
|
|||
|
|
@ -337,12 +337,10 @@ class BookmarkValidator {
|
|||
}
|
||||
if (record.deleted) {
|
||||
deletedItemIds.add(record.id);
|
||||
} else {
|
||||
if (idToRecord.has(record.id)) {
|
||||
} else if (idToRecord.has(record.id)) {
|
||||
problemData.duplicates.push(record.id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
idToRecord.set(record.id, record);
|
||||
|
||||
if (record.children) {
|
||||
|
|
@ -778,7 +776,7 @@ class BookmarkValidator {
|
|||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
BookmarkValidator.prototype.version = BOOKMARK_VALIDATOR_VERSION;
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ function AuthenticationError(details, source) {
|
|||
}
|
||||
|
||||
AuthenticationError.prototype = {
|
||||
toString: function() {
|
||||
toString() {
|
||||
return "AuthenticationError(" + this.details + ")";
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ this.BrowserIDManager.prototype = {
|
|||
return this._signedInUser && this._signedInUser.deviceId;
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
initialize() {
|
||||
for (let topic of OBSERVER_TOPICS) {
|
||||
Services.obs.addObserver(this, topic, false);
|
||||
}
|
||||
|
|
@ -157,7 +157,7 @@ this.BrowserIDManager.prototype = {
|
|||
* Ensure the user is logged in. Returns a promise that resolves when
|
||||
* the user is logged in, or is rejected if the login attempt has failed.
|
||||
*/
|
||||
ensureLoggedIn: function() {
|
||||
ensureLoggedIn() {
|
||||
if (!this._shouldHaveSyncKeyBundle && this.whenReadyToAuthenticate) {
|
||||
// We are already in the process of logging in.
|
||||
return this.whenReadyToAuthenticate.promise;
|
||||
|
|
@ -181,7 +181,7 @@ this.BrowserIDManager.prototype = {
|
|||
return this.whenReadyToAuthenticate.promise;
|
||||
},
|
||||
|
||||
finalize: function() {
|
||||
finalize() {
|
||||
// After this is called, we can expect Service.identity != this.
|
||||
for (let topic of OBSERVER_TOPICS) {
|
||||
Services.obs.removeObserver(this, topic);
|
||||
|
|
@ -190,7 +190,7 @@ this.BrowserIDManager.prototype = {
|
|||
this._signedInUser = null;
|
||||
},
|
||||
|
||||
offerSyncOptions: function () {
|
||||
offerSyncOptions() {
|
||||
// If the user chose to "Customize sync options" when signing
|
||||
// up with Firefox Accounts, ask them to choose what to sync.
|
||||
const url = "chrome://browser/content/sync/customize.xul";
|
||||
|
|
@ -203,7 +203,7 @@ this.BrowserIDManager.prototype = {
|
|||
return data;
|
||||
},
|
||||
|
||||
initializeWithCurrentIdentity: function(isInitialSync=false) {
|
||||
initializeWithCurrentIdentity(isInitialSync = false) {
|
||||
// While this function returns a promise that resolves once we've started
|
||||
// the auth process, that process is complete when
|
||||
// this.whenReadyToAuthenticate.promise resolves.
|
||||
|
|
@ -284,7 +284,7 @@ this.BrowserIDManager.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
_updateSignedInUser: function(userData) {
|
||||
_updateSignedInUser(userData) {
|
||||
// This object should only ever be used for a single user. It is an
|
||||
// error to update the data if the user changes (but updates are still
|
||||
// necessary, as each call may add more attributes to the user).
|
||||
|
|
@ -295,7 +295,7 @@ this.BrowserIDManager.prototype = {
|
|||
this._signedInUser = userData;
|
||||
},
|
||||
|
||||
logout: function() {
|
||||
logout() {
|
||||
// This will be called when sync fails (or when the account is being
|
||||
// unlinked etc). It may have failed because we got a 401 from a sync
|
||||
// server, so we nuke the token. Next time sync runs and wants an
|
||||
|
|
@ -304,7 +304,7 @@ this.BrowserIDManager.prototype = {
|
|||
this._token = null;
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
this._log.debug("observed " + topic);
|
||||
switch (topic) {
|
||||
case fxAccountsCommon.ONLOGIN_NOTIFICATION:
|
||||
|
|
@ -338,7 +338,7 @@ this.BrowserIDManager.prototype = {
|
|||
/**
|
||||
* Compute the sha256 of the message bytes. Return bytes.
|
||||
*/
|
||||
_sha256: function(message) {
|
||||
_sha256(message) {
|
||||
let hasher = Cc["@mozilla.org/security/hash;1"]
|
||||
.createInstance(Ci.nsICryptoHash);
|
||||
hasher.init(hasher.SHA256);
|
||||
|
|
@ -350,14 +350,14 @@ this.BrowserIDManager.prototype = {
|
|||
*
|
||||
* Return string: hex(first16Bytes(sha256(kBbytes)))
|
||||
*/
|
||||
_computeXClientState: function(kBbytes) {
|
||||
_computeXClientState(kBbytes) {
|
||||
return CommonUtils.bytesAsHex(this._sha256(kBbytes).slice(0, 16), false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Provide override point for testing token expiration.
|
||||
*/
|
||||
_now: function() {
|
||||
_now() {
|
||||
return this._fxaService.now()
|
||||
},
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ this.BrowserIDManager.prototype = {
|
|||
return this._fxaService.localtimeOffsetMsec;
|
||||
},
|
||||
|
||||
usernameFromAccount: function(val) {
|
||||
usernameFromAccount(val) {
|
||||
// we don't differentiate between "username" and "account"
|
||||
return val;
|
||||
},
|
||||
|
|
@ -407,8 +407,7 @@ this.BrowserIDManager.prototype = {
|
|||
// field directly and instead call a isSyncKeyValid() function
|
||||
// that we can override.
|
||||
return "99999999999999999999999999";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
|
@ -424,7 +423,7 @@ this.BrowserIDManager.prototype = {
|
|||
/**
|
||||
* Resets/Drops all credentials we hold for the current user.
|
||||
*/
|
||||
resetCredentials: function() {
|
||||
resetCredentials() {
|
||||
this.resetSyncKey();
|
||||
this._token = null;
|
||||
this._hashedUID = null;
|
||||
|
|
@ -436,7 +435,7 @@ this.BrowserIDManager.prototype = {
|
|||
/**
|
||||
* Resets/Drops the sync key we hold for the current user.
|
||||
*/
|
||||
resetSyncKey: function() {
|
||||
resetSyncKey() {
|
||||
this._syncKey = null;
|
||||
this._syncKeyBundle = null;
|
||||
this._syncKeyUpdated = true;
|
||||
|
|
@ -449,14 +448,14 @@ this.BrowserIDManager.prototype = {
|
|||
* allows us to avoid a network request for when we actually need the
|
||||
* migration info.
|
||||
*/
|
||||
prefetchMigrationSentinel: function(service) {
|
||||
prefetchMigrationSentinel(service) {
|
||||
// nothing to do here until we decide to migrate away from FxA.
|
||||
},
|
||||
|
||||
/**
|
||||
* Return credentials hosts for this identity only.
|
||||
*/
|
||||
_getSyncCredentialsHosts: function() {
|
||||
_getSyncCredentialsHosts() {
|
||||
return Utils.getSyncCredentialsHostsFxA();
|
||||
},
|
||||
|
||||
|
|
@ -486,7 +485,7 @@ this.BrowserIDManager.prototype = {
|
|||
|
||||
// Do we currently have keys, or do we have enough that we should be able
|
||||
// to successfully fetch them?
|
||||
_canFetchKeys: function() {
|
||||
_canFetchKeys() {
|
||||
let userData = this._signedInUser;
|
||||
// a keyFetchToken means we can almost certainly grab them.
|
||||
// kA and kB means we already have them.
|
||||
|
|
@ -499,7 +498,7 @@ this.BrowserIDManager.prototype = {
|
|||
* Returns a promise that resolves with the current auth state after
|
||||
* attempting to unlock.
|
||||
*/
|
||||
unlockAndVerifyAuthState: function() {
|
||||
unlockAndVerifyAuthState() {
|
||||
if (this._canFetchKeys()) {
|
||||
log.debug("unlockAndVerifyAuthState already has (or can fetch) sync keys");
|
||||
return Promise.resolve(STATUS_OK);
|
||||
|
|
@ -534,7 +533,7 @@ this.BrowserIDManager.prototype = {
|
|||
* Do we have a non-null, not yet expired token for the user currently
|
||||
* signed in?
|
||||
*/
|
||||
hasValidToken: function() {
|
||||
hasValidToken() {
|
||||
// If pref is set to ignore cached authentication credentials for debugging,
|
||||
// then return false to force the fetching of a new token.
|
||||
let ignoreCachedAuthCredentials = false;
|
||||
|
|
@ -573,7 +572,7 @@ this.BrowserIDManager.prototype = {
|
|||
// Refresh the sync token for our user. Returns a promise that resolves
|
||||
// with a token (which may be null in one sad edge-case), or rejects with an
|
||||
// error.
|
||||
_fetchTokenForUser: function() {
|
||||
_fetchTokenForUser() {
|
||||
// tokenServerURI is mis-named - convention is uri means nsISomething...
|
||||
let tokenServerURI = this._tokenServerUrl;
|
||||
let log = this._log;
|
||||
|
|
@ -694,7 +693,7 @@ this.BrowserIDManager.prototype = {
|
|||
|
||||
// Returns a promise that is resolved when we have a valid token for the
|
||||
// current user stored in this._token. When resolved, this._token is valid.
|
||||
_ensureValidToken: function() {
|
||||
_ensureValidToken() {
|
||||
if (this.hasValidToken()) {
|
||||
this._log.debug("_ensureValidToken already has one");
|
||||
return Promise.resolve();
|
||||
|
|
@ -723,14 +722,14 @@ this.BrowserIDManager.prototype = {
|
|||
);
|
||||
},
|
||||
|
||||
getResourceAuthenticator: function () {
|
||||
getResourceAuthenticator() {
|
||||
return this._getAuthenticationHeader.bind(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Obtain a function to be used for adding auth to RESTRequest instances.
|
||||
*/
|
||||
getRESTRequestAuthenticator: function() {
|
||||
getRESTRequestAuthenticator() {
|
||||
return this._addAuthenticationHeader.bind(this);
|
||||
},
|
||||
|
||||
|
|
@ -738,7 +737,7 @@ this.BrowserIDManager.prototype = {
|
|||
* @return a Hawk HTTP Authorization Header, lightly wrapped, for the .uri
|
||||
* of a RESTRequest or AsyncResponse object.
|
||||
*/
|
||||
_getAuthenticationHeader: function(httpObject, method) {
|
||||
_getAuthenticationHeader(httpObject, method) {
|
||||
let cb = Async.makeSpinningCallback();
|
||||
this._ensureValidToken().then(cb, cb);
|
||||
// Note that in failure states we return null, causing the request to be
|
||||
|
|
@ -768,14 +767,14 @@ this.BrowserIDManager.prototype = {
|
|||
let options = {
|
||||
now: this._now(),
|
||||
localtimeOffsetMsec: this._localtimeOffsetMsec,
|
||||
credentials: credentials,
|
||||
credentials,
|
||||
};
|
||||
|
||||
let headerValue = CryptoUtils.computeHAWK(httpObject.uri, method, options);
|
||||
return {headers: {authorization: headerValue.field}};
|
||||
},
|
||||
|
||||
_addAuthenticationHeader: function(request, method) {
|
||||
_addAuthenticationHeader(request, method) {
|
||||
let header = this._getAuthenticationHeader(request, method);
|
||||
if (!header) {
|
||||
return null;
|
||||
|
|
@ -784,7 +783,7 @@ this.BrowserIDManager.prototype = {
|
|||
return request;
|
||||
},
|
||||
|
||||
createClusterManager: function(service) {
|
||||
createClusterManager(service) {
|
||||
return new BrowserIDClusterManager(service);
|
||||
},
|
||||
|
||||
|
|
@ -809,7 +808,7 @@ function BrowserIDClusterManager(service) {
|
|||
BrowserIDClusterManager.prototype = {
|
||||
__proto__: ClusterManager.prototype,
|
||||
|
||||
_findCluster: function() {
|
||||
_findCluster() {
|
||||
let endPointFromIdentityToken = function() {
|
||||
// The only reason (in theory ;) that we can end up with a null token
|
||||
// is when this.identity._canFetchKeys() returned false. In turn, this
|
||||
|
|
@ -880,7 +879,7 @@ BrowserIDClusterManager.prototype = {
|
|||
return cb.wait();
|
||||
},
|
||||
|
||||
getUserBaseURL: function() {
|
||||
getUserBaseURL() {
|
||||
// Legacy Sync and FxA Sync construct the userBaseURL differently. Legacy
|
||||
// Sync appends path components onto an empty path, and in FxA Sync the
|
||||
// token server constructs this for us in an opaque manner. Since the
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ Tracker.prototype = {
|
|||
},
|
||||
|
||||
// Should be called by service everytime a sync has been done for an engine
|
||||
resetScore: function () {
|
||||
resetScore() {
|
||||
this._score = 0;
|
||||
},
|
||||
|
||||
|
|
@ -123,12 +123,12 @@ Tracker.prototype = {
|
|||
// being processed, or that shouldn't be synced.
|
||||
// But note: not persisted to disk
|
||||
|
||||
ignoreID: function (id) {
|
||||
ignoreID(id) {
|
||||
this.unignoreID(id);
|
||||
this._ignored.push(id);
|
||||
},
|
||||
|
||||
unignoreID: function (id) {
|
||||
unignoreID(id) {
|
||||
let index = this._ignored.indexOf(id);
|
||||
if (index != -1)
|
||||
this._ignored.splice(index, 1);
|
||||
|
|
@ -140,7 +140,7 @@ Tracker.prototype = {
|
|||
this._saveChangedIDs();
|
||||
},
|
||||
|
||||
addChangedID: function (id, when) {
|
||||
addChangedID(id, when) {
|
||||
if (!id) {
|
||||
this._log.warn("Attempted to add undefined ID to tracker");
|
||||
return false;
|
||||
|
|
@ -163,7 +163,7 @@ Tracker.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
removeChangedID: function (...ids) {
|
||||
removeChangedID(...ids) {
|
||||
if (!ids.length || this.ignoreAll) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ Tracker.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
clearChangedIDs: function () {
|
||||
clearChangedIDs() {
|
||||
this._log.trace("Clearing changed ID list");
|
||||
this._storage.data = {};
|
||||
this._saveChangedIDs();
|
||||
|
|
@ -198,13 +198,13 @@ Tracker.prototype = {
|
|||
_isTracking: false,
|
||||
|
||||
// Override these in your subclasses.
|
||||
startTracking: function () {
|
||||
startTracking() {
|
||||
},
|
||||
|
||||
stopTracking: function () {
|
||||
stopTracking() {
|
||||
},
|
||||
|
||||
engineIsEnabled: function () {
|
||||
engineIsEnabled() {
|
||||
if (!this.engine) {
|
||||
// Can't tell -- we must be running in a test!
|
||||
return true;
|
||||
|
|
@ -212,7 +212,7 @@ Tracker.prototype = {
|
|||
return this.engine.enabled;
|
||||
},
|
||||
|
||||
onEngineEnabledChanged: function (engineEnabled) {
|
||||
onEngineEnabledChanged(engineEnabled) {
|
||||
if (engineEnabled == this._isTracking) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ Tracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "weave:engine:start-tracking":
|
||||
if (!this.engineIsEnabled()) {
|
||||
|
|
@ -250,7 +250,7 @@ Tracker.prototype = {
|
|||
if (data == PREFS_BRANCH + "engine." + this.engine.prefName) {
|
||||
this.onEngineEnabledChanged(this.engine.enabled);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -317,7 +317,7 @@ Store.prototype = {
|
|||
* @param records Array of records to apply
|
||||
* @return Array of record IDs which did not apply cleanly
|
||||
*/
|
||||
applyIncomingBatch: function (records) {
|
||||
applyIncomingBatch(records) {
|
||||
let failed = [];
|
||||
for (let record of records) {
|
||||
try {
|
||||
|
|
@ -336,7 +336,7 @@ Store.prototype = {
|
|||
this.engine._noteApplyFailure();
|
||||
failed.push(record.id);
|
||||
}
|
||||
};
|
||||
}
|
||||
return failed;
|
||||
},
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ Store.prototype = {
|
|||
* @param record
|
||||
* Record to apply
|
||||
*/
|
||||
applyIncoming: function (record) {
|
||||
applyIncoming(record) {
|
||||
if (record.deleted)
|
||||
this.remove(record);
|
||||
else if (!this.itemExists(record.id))
|
||||
|
|
@ -373,7 +373,7 @@ Store.prototype = {
|
|||
* @param record
|
||||
* The store record to create an item from
|
||||
*/
|
||||
create: function (record) {
|
||||
create(record) {
|
||||
throw "override create in a subclass";
|
||||
},
|
||||
|
||||
|
|
@ -386,7 +386,7 @@ Store.prototype = {
|
|||
* @param record
|
||||
* The store record to delete an item from
|
||||
*/
|
||||
remove: function (record) {
|
||||
remove(record) {
|
||||
throw "override remove in a subclass";
|
||||
},
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ Store.prototype = {
|
|||
* @param record
|
||||
* The record to use to update an item from
|
||||
*/
|
||||
update: function (record) {
|
||||
update(record) {
|
||||
throw "override update in a subclass";
|
||||
},
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ Store.prototype = {
|
|||
* string record ID
|
||||
* @return boolean indicating whether record exists locally
|
||||
*/
|
||||
itemExists: function (id) {
|
||||
itemExists(id) {
|
||||
throw "override itemExists in a subclass";
|
||||
},
|
||||
|
||||
|
|
@ -431,7 +431,7 @@ Store.prototype = {
|
|||
* constructor for the newly-created record.
|
||||
* @return record type for this engine
|
||||
*/
|
||||
createRecord: function (id, collection) {
|
||||
createRecord(id, collection) {
|
||||
throw "override createRecord in a subclass";
|
||||
},
|
||||
|
||||
|
|
@ -443,7 +443,7 @@ Store.prototype = {
|
|||
* @param newID
|
||||
* string new record ID
|
||||
*/
|
||||
changeItemID: function (oldID, newID) {
|
||||
changeItemID(oldID, newID) {
|
||||
throw "override changeItemID in a subclass";
|
||||
},
|
||||
|
||||
|
|
@ -453,7 +453,7 @@ Store.prototype = {
|
|||
* @return Object with ID strings as keys and values of true. The values
|
||||
* are ignored.
|
||||
*/
|
||||
getAllIDs: function () {
|
||||
getAllIDs() {
|
||||
throw "override getAllIDs in a subclass";
|
||||
},
|
||||
|
||||
|
|
@ -467,7 +467,7 @@ Store.prototype = {
|
|||
* can be thought of as clearing out all state and restoring the "new
|
||||
* browser" state.
|
||||
*/
|
||||
wipe: function () {
|
||||
wipe() {
|
||||
throw "override wipe in a subclass";
|
||||
}
|
||||
};
|
||||
|
|
@ -483,7 +483,7 @@ this.EngineManager = function EngineManager(service) {
|
|||
this._log.level = Log.Level[Svc.Prefs.get("log.logger.service.engines", "Debug")];
|
||||
}
|
||||
EngineManager.prototype = {
|
||||
get: function (name) {
|
||||
get(name) {
|
||||
// Return an array of engines if we have an array of names
|
||||
if (Array.isArray(name)) {
|
||||
let engines = [];
|
||||
|
|
@ -506,7 +506,7 @@ EngineManager.prototype = {
|
|||
return engine;
|
||||
},
|
||||
|
||||
getAll: function () {
|
||||
getAll() {
|
||||
let engines = [];
|
||||
for (let [, engine] of Object.entries(this._engines)) {
|
||||
engines.push(engine);
|
||||
|
|
@ -517,7 +517,7 @@ EngineManager.prototype = {
|
|||
/**
|
||||
* N.B., does not pay attention to the declined list.
|
||||
*/
|
||||
getEnabled: function () {
|
||||
getEnabled() {
|
||||
return this.getAll()
|
||||
.filter((engine) => engine.enabled)
|
||||
.sort((a, b) => a.syncPriority - b.syncPriority);
|
||||
|
|
@ -527,37 +527,37 @@ EngineManager.prototype = {
|
|||
return this.getEnabled().map(e => e.name);
|
||||
},
|
||||
|
||||
persistDeclined: function () {
|
||||
persistDeclined() {
|
||||
Svc.Prefs.set("declinedEngines", [...this._declined].join(","));
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array.
|
||||
*/
|
||||
getDeclined: function () {
|
||||
getDeclined() {
|
||||
return [...this._declined];
|
||||
},
|
||||
|
||||
setDeclined: function (engines) {
|
||||
setDeclined(engines) {
|
||||
this._declined = new Set(engines);
|
||||
this.persistDeclined();
|
||||
},
|
||||
|
||||
isDeclined: function (engineName) {
|
||||
isDeclined(engineName) {
|
||||
return this._declined.has(engineName);
|
||||
},
|
||||
|
||||
/**
|
||||
* Accepts a Set or an array.
|
||||
*/
|
||||
decline: function (engines) {
|
||||
decline(engines) {
|
||||
for (let e of engines) {
|
||||
this._declined.add(e);
|
||||
}
|
||||
this.persistDeclined();
|
||||
},
|
||||
|
||||
undecline: function (engines) {
|
||||
undecline(engines) {
|
||||
for (let e of engines) {
|
||||
this._declined.delete(e);
|
||||
}
|
||||
|
|
@ -569,7 +569,7 @@ EngineManager.prototype = {
|
|||
*
|
||||
* This is useful after initial customization during setup.
|
||||
*/
|
||||
declineDisabled: function () {
|
||||
declineDisabled() {
|
||||
for (let e of this.getAll()) {
|
||||
if (!e.enabled) {
|
||||
this._log.debug("Declining disabled engine " + e.name);
|
||||
|
|
@ -587,7 +587,7 @@ EngineManager.prototype = {
|
|||
* Engine object used to get an instance of the engine
|
||||
* @return The engine object if anything failed
|
||||
*/
|
||||
register: function (engineObject) {
|
||||
register(engineObject) {
|
||||
if (Array.isArray(engineObject)) {
|
||||
return engineObject.map(this.register, this);
|
||||
}
|
||||
|
|
@ -610,7 +610,7 @@ EngineManager.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
unregister: function (val) {
|
||||
unregister(val) {
|
||||
let name = val;
|
||||
if (val instanceof Engine) {
|
||||
name = val.name;
|
||||
|
|
@ -618,7 +618,7 @@ EngineManager.prototype = {
|
|||
delete this._engines[name];
|
||||
},
|
||||
|
||||
clear: function () {
|
||||
clear() {
|
||||
for (let name in this._engines) {
|
||||
delete this._engines[name];
|
||||
}
|
||||
|
|
@ -685,7 +685,7 @@ Engine.prototype = {
|
|||
return tracker;
|
||||
},
|
||||
|
||||
sync: function () {
|
||||
sync() {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -700,7 +700,7 @@ Engine.prototype = {
|
|||
/**
|
||||
* Get rid of any local meta-data.
|
||||
*/
|
||||
resetClient: function () {
|
||||
resetClient() {
|
||||
if (!this._resetClient) {
|
||||
throw "engine does not implement _resetClient method";
|
||||
}
|
||||
|
|
@ -708,7 +708,7 @@ Engine.prototype = {
|
|||
this._notify("reset-client", this.name, this._resetClient)();
|
||||
},
|
||||
|
||||
_wipeClient: function () {
|
||||
_wipeClient() {
|
||||
this.resetClient();
|
||||
this._log.debug("Deleting all local data");
|
||||
this._tracker.ignoreAll = true;
|
||||
|
|
@ -717,7 +717,7 @@ Engine.prototype = {
|
|||
this._tracker.clearChangedIDs();
|
||||
},
|
||||
|
||||
wipeClient: function () {
|
||||
wipeClient() {
|
||||
this._notify("wipe-client", this.name, this._wipeClient)();
|
||||
},
|
||||
|
||||
|
|
@ -726,7 +726,7 @@ Engine.prototype = {
|
|||
* must have a `validate(engine)` method that returns a promise to an object
|
||||
* with a getSummary method). Otherwise return null.
|
||||
*/
|
||||
getValidator: function () {
|
||||
getValidator() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
@ -810,7 +810,7 @@ SyncEngine.prototype = {
|
|||
// Store the value as a string to keep floating point precision
|
||||
Svc.Prefs.set(this.name + ".lastSync", value.toString());
|
||||
},
|
||||
resetLastSync: function () {
|
||||
resetLastSync() {
|
||||
this._log.debug("Resetting " + this.name + " last sync time");
|
||||
Svc.Prefs.reset(this.name + ".lastSync");
|
||||
Svc.Prefs.set(this.name + ".lastSync", "0");
|
||||
|
|
@ -836,7 +836,7 @@ SyncEngine.prototype = {
|
|||
}, 0, this, "_toFetchDelay");
|
||||
},
|
||||
|
||||
loadToFetch: function () {
|
||||
loadToFetch() {
|
||||
// Initialize to empty if there's no file.
|
||||
this._toFetch = [];
|
||||
Utils.jsonLoad("toFetch/" + this.name, this, function(toFetch) {
|
||||
|
|
@ -867,7 +867,7 @@ SyncEngine.prototype = {
|
|||
}, 0, this, "_previousFailedDelay");
|
||||
},
|
||||
|
||||
loadPreviousFailed: function () {
|
||||
loadPreviousFailed() {
|
||||
// Initialize to empty if there's no file
|
||||
this._previousFailed = [];
|
||||
Utils.jsonLoad("failed/" + this.name, this, function(previousFailed) {
|
||||
|
|
@ -892,12 +892,12 @@ SyncEngine.prototype = {
|
|||
* Returns a changeset for this sync. Engine implementations can override this
|
||||
* method to bypass the tracker for certain or all changed items.
|
||||
*/
|
||||
getChangedIDs: function () {
|
||||
getChangedIDs() {
|
||||
return this._tracker.changedIDs;
|
||||
},
|
||||
|
||||
// Create a new record using the store and add in crypto fields.
|
||||
_createRecord: function (id) {
|
||||
_createRecord(id) {
|
||||
let record = this._store.createRecord(id, this.name);
|
||||
record.id = id;
|
||||
record.collection = this.name;
|
||||
|
|
@ -905,7 +905,7 @@ SyncEngine.prototype = {
|
|||
},
|
||||
|
||||
// Any setup that needs to happen at the beginning of each sync.
|
||||
_syncStartup: function () {
|
||||
_syncStartup() {
|
||||
|
||||
// Determine if we need to wipe on outdated versions
|
||||
let metaGlobal = this.service.recordManager.get(this.metaURL);
|
||||
|
|
@ -942,7 +942,7 @@ SyncEngine.prototype = {
|
|||
this._log.debug("Engine syncIDs: " + [engineData.syncID, this.syncID]);
|
||||
this.syncID = engineData.syncID;
|
||||
this._resetClient();
|
||||
};
|
||||
}
|
||||
|
||||
// Delete any existing data and reupload on bad version or missing meta.
|
||||
// No crypto component here...? We could regenerate per-collection keys...
|
||||
|
|
@ -978,7 +978,7 @@ SyncEngine.prototype = {
|
|||
* A tiny abstraction to make it easier to test incoming record
|
||||
* application.
|
||||
*/
|
||||
itemSource: function () {
|
||||
itemSource() {
|
||||
return new Collection(this.engineURL, this._recordObj, this.service);
|
||||
},
|
||||
|
||||
|
|
@ -987,7 +987,7 @@ SyncEngine.prototype = {
|
|||
* In the most awful and untestable way possible.
|
||||
* This now accepts something that makes testing vaguely less impossible.
|
||||
*/
|
||||
_processIncoming: function (newitems) {
|
||||
_processIncoming(newitems) {
|
||||
this._log.trace("Downloading & applying server changes");
|
||||
|
||||
// Figure out how many total items to fetch this sync; do less on mobile.
|
||||
|
|
@ -1281,11 +1281,11 @@ SyncEngine.prototype = {
|
|||
return false;
|
||||
},
|
||||
|
||||
_noteApplyFailure: function () {
|
||||
_noteApplyFailure() {
|
||||
// here would be a good place to record telemetry...
|
||||
},
|
||||
|
||||
_noteApplyNewFailure: function () {
|
||||
_noteApplyNewFailure() {
|
||||
// here would be a good place to record telemetry...
|
||||
},
|
||||
|
||||
|
|
@ -1295,7 +1295,7 @@ SyncEngine.prototype = {
|
|||
*
|
||||
* @return GUID of the similar item; falsy otherwise
|
||||
*/
|
||||
_findDupe: function (item) {
|
||||
_findDupe(item) {
|
||||
// By default, assume there's no dupe items for the engine
|
||||
},
|
||||
|
||||
|
|
@ -1309,7 +1309,7 @@ SyncEngine.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
_deleteId: function (id) {
|
||||
_deleteId(id) {
|
||||
this._tracker.removeChangedID(id);
|
||||
this._noteDeletedId(id);
|
||||
},
|
||||
|
|
@ -1344,7 +1344,7 @@ SyncEngine.prototype = {
|
|||
* @return boolean
|
||||
* Truthy if incoming record should be applied. False if not.
|
||||
*/
|
||||
_reconcile: function (item) {
|
||||
_reconcile(item) {
|
||||
if (this._log.level <= Log.Level.Trace) {
|
||||
this._log.trace("Incoming: " + item);
|
||||
}
|
||||
|
|
@ -1512,7 +1512,7 @@ SyncEngine.prototype = {
|
|||
},
|
||||
|
||||
// Upload outgoing records.
|
||||
_uploadOutgoing: function () {
|
||||
_uploadOutgoing() {
|
||||
this._log.trace("Uploading local changes to server.");
|
||||
|
||||
let modifiedIDs = this._modified.ids();
|
||||
|
|
@ -1612,7 +1612,7 @@ SyncEngine.prototype = {
|
|||
|
||||
// Any cleanup necessary.
|
||||
// Save the current snapshot so as to calculate changes at next sync
|
||||
_syncFinish: function () {
|
||||
_syncFinish() {
|
||||
this._log.trace("Finishing up sync");
|
||||
this._tracker.resetScore();
|
||||
|
||||
|
|
@ -1639,7 +1639,7 @@ SyncEngine.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_syncCleanup: function () {
|
||||
_syncCleanup() {
|
||||
if (!this._modified) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1652,7 +1652,7 @@ SyncEngine.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_sync: function () {
|
||||
_sync() {
|
||||
try {
|
||||
this._syncStartup();
|
||||
Observers.notify("weave:engine:sync:status", "process-incoming");
|
||||
|
|
@ -1665,7 +1665,7 @@ SyncEngine.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
canDecrypt: function () {
|
||||
canDecrypt() {
|
||||
// Report failure even if there's nothing to decrypt
|
||||
let canDecrypt = false;
|
||||
|
||||
|
|
@ -1679,7 +1679,7 @@ SyncEngine.prototype = {
|
|||
test.recordHandler = function recordHandler(record) {
|
||||
record.decrypt(key);
|
||||
canDecrypt = true;
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
// Any failure fetching/decrypting will just result in false
|
||||
try {
|
||||
|
|
@ -1695,13 +1695,13 @@ SyncEngine.prototype = {
|
|||
return canDecrypt;
|
||||
},
|
||||
|
||||
_resetClient: function () {
|
||||
_resetClient() {
|
||||
this.resetLastSync();
|
||||
this.previousFailed = [];
|
||||
this.toFetch = [];
|
||||
},
|
||||
|
||||
wipeServer: function () {
|
||||
wipeServer() {
|
||||
let response = this.service.resource(this.engineURL).delete();
|
||||
if (response.status != 200 && response.status != 404) {
|
||||
throw response;
|
||||
|
|
@ -1709,7 +1709,7 @@ SyncEngine.prototype = {
|
|||
this._resetClient();
|
||||
},
|
||||
|
||||
removeClientData: function () {
|
||||
removeClientData() {
|
||||
// Implement this method in engines that store client specific data
|
||||
// on the server.
|
||||
},
|
||||
|
|
@ -1730,7 +1730,7 @@ SyncEngine.prototype = {
|
|||
*
|
||||
* All return values will be part of the kRecoveryStrategy enumeration.
|
||||
*/
|
||||
handleHMACMismatch: function (item, mayRetry) {
|
||||
handleHMACMismatch(item, mayRetry) {
|
||||
// By default we either try again, or bail out noisily.
|
||||
return (this.service.handleHMACEvent() && mayRetry) ?
|
||||
SyncEngine.kRecoveryStrategy.retry :
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ AddonsTracker.prototype = {
|
|||
this.score += SCORE_INCREMENT_XLARGE;
|
||||
},
|
||||
|
||||
startTracking: function() {
|
||||
startTracking() {
|
||||
if (this.engine.enabled) {
|
||||
this.reconciler.startListening();
|
||||
}
|
||||
|
|
@ -740,7 +740,7 @@ AddonsTracker.prototype = {
|
|||
this.reconciler.addChangeListener(this);
|
||||
},
|
||||
|
||||
stopTracking: function() {
|
||||
stopTracking() {
|
||||
this.reconciler.removeChangeListener(this);
|
||||
this.reconciler.stopListening();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ BookmarksEngine.prototype = {
|
|||
return false;
|
||||
},
|
||||
|
||||
_processIncoming: function (newitems) {
|
||||
_processIncoming(newitems) {
|
||||
try {
|
||||
SyncEngine.prototype._processIncoming.call(this, newitems);
|
||||
} finally {
|
||||
|
|
@ -785,7 +785,7 @@ BookmarksStore.prototype = {
|
|||
},
|
||||
|
||||
_stmts: {},
|
||||
_getStmt: function(query) {
|
||||
_getStmt(query) {
|
||||
if (query in this._stmts) {
|
||||
return this._stmts[query];
|
||||
}
|
||||
|
|
@ -880,14 +880,14 @@ BookmarksTracker.prototype = {
|
|||
// in Places.
|
||||
persistChangedIDs: false,
|
||||
|
||||
startTracking: function() {
|
||||
startTracking() {
|
||||
PlacesUtils.bookmarks.addObserver(this, true);
|
||||
Svc.Obs.add("bookmarks-restore-begin", this);
|
||||
Svc.Obs.add("bookmarks-restore-success", this);
|
||||
Svc.Obs.add("bookmarks-restore-failed", this);
|
||||
},
|
||||
|
||||
stopTracking: function() {
|
||||
stopTracking() {
|
||||
PlacesUtils.bookmarks.removeObserver(this);
|
||||
Svc.Obs.remove("bookmarks-restore-begin", this);
|
||||
Svc.Obs.remove("bookmarks-restore-success", this);
|
||||
|
|
@ -1018,7 +1018,7 @@ BookmarksTracker.prototype = {
|
|||
this._upScore();
|
||||
},
|
||||
|
||||
onItemRemoved: function (itemId, parentId, index, type, uri,
|
||||
onItemRemoved(itemId, parentId, index, type, uri,
|
||||
guid, parentGuid, source) {
|
||||
if (IGNORED_SOURCES.includes(source)) {
|
||||
return;
|
||||
|
|
@ -1112,16 +1112,16 @@ BookmarksTracker.prototype = {
|
|||
this._upScore();
|
||||
},
|
||||
|
||||
onBeginUpdateBatch: function () {
|
||||
onBeginUpdateBatch() {
|
||||
++this._batchDepth;
|
||||
},
|
||||
onEndUpdateBatch: function () {
|
||||
onEndUpdateBatch() {
|
||||
if (--this._batchDepth === 0 && this._batchSawScoreIncrement) {
|
||||
this.score += SCORE_INCREMENT_XLARGE;
|
||||
this._batchSawScoreIncrement = false;
|
||||
}
|
||||
},
|
||||
onItemVisited: function () {}
|
||||
onItemVisited() {}
|
||||
};
|
||||
|
||||
class BookmarksChangeset extends Changeset {
|
||||
|
|
|
|||
|
|
@ -490,8 +490,8 @@ ClientEngine.prototype = {
|
|||
}
|
||||
|
||||
let action = {
|
||||
command: command,
|
||||
args: args,
|
||||
command,
|
||||
args,
|
||||
flowID: flowID || Utils.makeGUID(), // used for telemetry.
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ ExtensionStorageEngine.prototype = {
|
|||
syncPriority: 10,
|
||||
allowSkippedRecord: false,
|
||||
|
||||
_sync: function () {
|
||||
_sync() {
|
||||
return Async.promiseSpinningly(ExtensionStorageSync.syncAll());
|
||||
},
|
||||
|
||||
|
|
@ -68,15 +68,15 @@ function ExtensionStorageTracker(name, engine) {
|
|||
ExtensionStorageTracker.prototype = {
|
||||
__proto__: Tracker.prototype,
|
||||
|
||||
startTracking: function () {
|
||||
startTracking() {
|
||||
Svc.Obs.add("ext.storage.sync-changed", this);
|
||||
},
|
||||
|
||||
stopTracking: function () {
|
||||
stopTracking() {
|
||||
Svc.Obs.remove("ext.storage.sync-changed", this);
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
Tracker.prototype.observe.call(this, subject, topic, data);
|
||||
|
||||
if (this.ignoreAll) {
|
||||
|
|
@ -94,15 +94,15 @@ ExtensionStorageTracker.prototype = {
|
|||
|
||||
// Override a bunch of methods which don't do anything for us.
|
||||
// This is a performance hack.
|
||||
ignoreID: function() {
|
||||
ignoreID() {
|
||||
},
|
||||
unignoreID: function() {
|
||||
unignoreID() {
|
||||
},
|
||||
addChangedID: function() {
|
||||
addChangedID() {
|
||||
},
|
||||
removeChangedID: function() {
|
||||
removeChangedID() {
|
||||
},
|
||||
clearChangedIDs: function() {
|
||||
clearChangedIDs() {
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ var FormWrapper = {
|
|||
_getEntryCols: ["fieldname", "value"],
|
||||
_guidCols: ["guid"],
|
||||
|
||||
_promiseSearch: function(terms, searchData) {
|
||||
_promiseSearch(terms, searchData) {
|
||||
return new Promise(resolve => {
|
||||
let results = [];
|
||||
let callbacks = {
|
||||
|
|
@ -53,17 +53,17 @@ var FormWrapper = {
|
|||
},
|
||||
|
||||
// Do a "sync" search by spinning the event loop until it completes.
|
||||
_searchSpinningly: function(terms, searchData) {
|
||||
_searchSpinningly(terms, searchData) {
|
||||
return Async.promiseSpinningly(this._promiseSearch(terms, searchData));
|
||||
},
|
||||
|
||||
_updateSpinningly: function(changes) {
|
||||
_updateSpinningly(changes) {
|
||||
if (!Svc.FormHistory.enabled) {
|
||||
return; // update isn't going to do anything.
|
||||
}
|
||||
let cb = Async.makeSpinningCallback();
|
||||
let callbacks = {
|
||||
handleCompletion: function(reason) {
|
||||
handleCompletion(reason) {
|
||||
cb();
|
||||
}
|
||||
};
|
||||
|
|
@ -71,27 +71,27 @@ var FormWrapper = {
|
|||
return cb.wait();
|
||||
},
|
||||
|
||||
getEntry: function (guid) {
|
||||
let results = this._searchSpinningly(this._getEntryCols, {guid: guid});
|
||||
getEntry(guid) {
|
||||
let results = this._searchSpinningly(this._getEntryCols, {guid});
|
||||
if (!results.length) {
|
||||
return null;
|
||||
}
|
||||
return {name: results[0].fieldname, value: results[0].value};
|
||||
},
|
||||
|
||||
getGUID: function (name, value) {
|
||||
getGUID(name, value) {
|
||||
// Query for the provided entry.
|
||||
let query = { fieldname: name, value: value };
|
||||
let query = { fieldname: name, value };
|
||||
let results = this._searchSpinningly(this._guidCols, query);
|
||||
return results.length ? results[0].guid : null;
|
||||
},
|
||||
|
||||
hasGUID: function (guid) {
|
||||
hasGUID(guid) {
|
||||
// We could probably use a count function here, but searchSpinningly exists...
|
||||
return this._searchSpinningly(this._guidCols, {guid: guid}).length != 0;
|
||||
return this._searchSpinningly(this._guidCols, {guid}).length != 0;
|
||||
},
|
||||
|
||||
replaceGUID: function (oldGUID, newGUID) {
|
||||
replaceGUID(oldGUID, newGUID) {
|
||||
let changes = {
|
||||
op: "update",
|
||||
guid: oldGUID,
|
||||
|
|
@ -129,7 +129,7 @@ function FormStore(name, engine) {
|
|||
FormStore.prototype = {
|
||||
__proto__: Store.prototype,
|
||||
|
||||
_processChange: function (change) {
|
||||
_processChange(change) {
|
||||
// If this._changes is defined, then we are applying a batch, so we
|
||||
// can defer it.
|
||||
if (this._changes) {
|
||||
|
|
@ -141,7 +141,7 @@ FormStore.prototype = {
|
|||
FormWrapper._updateSpinningly(change);
|
||||
},
|
||||
|
||||
applyIncomingBatch: function (records) {
|
||||
applyIncomingBatch(records) {
|
||||
// We collect all the changes to be made then apply them all at once.
|
||||
this._changes = [];
|
||||
let failures = Store.prototype.applyIncomingBatch.call(this, records);
|
||||
|
|
@ -152,7 +152,7 @@ FormStore.prototype = {
|
|||
return failures;
|
||||
},
|
||||
|
||||
getAllIDs: function () {
|
||||
getAllIDs() {
|
||||
let results = FormWrapper._searchSpinningly(["guid"], [])
|
||||
let guids = {};
|
||||
for (let result of results) {
|
||||
|
|
@ -161,15 +161,15 @@ FormStore.prototype = {
|
|||
return guids;
|
||||
},
|
||||
|
||||
changeItemID: function (oldID, newID) {
|
||||
changeItemID(oldID, newID) {
|
||||
FormWrapper.replaceGUID(oldID, newID);
|
||||
},
|
||||
|
||||
itemExists: function (id) {
|
||||
itemExists(id) {
|
||||
return FormWrapper.hasGUID(id);
|
||||
},
|
||||
|
||||
createRecord: function (id, collection) {
|
||||
createRecord(id, collection) {
|
||||
let record = new FormRec(collection, id);
|
||||
let entry = FormWrapper.getEntry(id);
|
||||
if (entry != null) {
|
||||
|
|
@ -181,7 +181,7 @@ FormStore.prototype = {
|
|||
return record;
|
||||
},
|
||||
|
||||
create: function (record) {
|
||||
create(record) {
|
||||
this._log.trace("Adding form record for " + record.name);
|
||||
let change = {
|
||||
op: "add",
|
||||
|
|
@ -191,7 +191,7 @@ FormStore.prototype = {
|
|||
this._processChange(change);
|
||||
},
|
||||
|
||||
remove: function (record) {
|
||||
remove(record) {
|
||||
this._log.trace("Removing form record: " + record.id);
|
||||
let change = {
|
||||
op: "remove",
|
||||
|
|
@ -200,11 +200,11 @@ FormStore.prototype = {
|
|||
this._processChange(change);
|
||||
},
|
||||
|
||||
update: function (record) {
|
||||
update(record) {
|
||||
this._log.trace("Ignoring form record update request!");
|
||||
},
|
||||
|
||||
wipe: function () {
|
||||
wipe() {
|
||||
let change = {
|
||||
op: "remove"
|
||||
};
|
||||
|
|
@ -222,15 +222,15 @@ FormTracker.prototype = {
|
|||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
startTracking: function() {
|
||||
startTracking() {
|
||||
Svc.Obs.add("satchel-storage-changed", this);
|
||||
},
|
||||
|
||||
stopTracking: function() {
|
||||
stopTracking() {
|
||||
Svc.Obs.remove("satchel-storage-changed", this);
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
Tracker.prototype.observe.call(this, subject, topic, data);
|
||||
if (this.ignoreAll) {
|
||||
return;
|
||||
|
|
@ -245,7 +245,7 @@ FormTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
trackEntry: function (guid) {
|
||||
trackEntry(guid) {
|
||||
this.addChangedID(guid);
|
||||
this.score += SCORE_INCREMENT_MEDIUM;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ HistoryEngine.prototype = {
|
|||
|
||||
syncPriority: 7,
|
||||
|
||||
_processIncoming: function (newitems) {
|
||||
_processIncoming(newitems) {
|
||||
// We want to notify history observers that a batch operation is underway
|
||||
// so they don't do lots of work for each incoming record.
|
||||
let observers = PlacesUtils.history.getObservers();
|
||||
|
|
@ -134,7 +134,7 @@ HistoryStore.prototype = {
|
|||
},
|
||||
|
||||
_stmts: {},
|
||||
_getStmt: function(query) {
|
||||
_getStmt(query) {
|
||||
if (query in this._stmts) {
|
||||
return this._stmts[query];
|
||||
}
|
||||
|
|
@ -431,12 +431,12 @@ function HistoryTracker(name, engine) {
|
|||
HistoryTracker.prototype = {
|
||||
__proto__: Tracker.prototype,
|
||||
|
||||
startTracking: function() {
|
||||
startTracking() {
|
||||
this._log.info("Adding Places observer.");
|
||||
PlacesUtils.history.addObserver(this, true);
|
||||
},
|
||||
|
||||
stopTracking: function() {
|
||||
stopTracking() {
|
||||
this._log.info("Removing Places observer.");
|
||||
PlacesUtils.history.removeObserver(this);
|
||||
},
|
||||
|
|
@ -446,7 +446,7 @@ HistoryTracker.prototype = {
|
|||
Ci.nsISupportsWeakReference
|
||||
]),
|
||||
|
||||
onDeleteAffectsGUID: function (uri, guid, reason, source, increment) {
|
||||
onDeleteAffectsGUID(uri, guid, reason, source, increment) {
|
||||
if (this.ignoreAll || reason == Ci.nsINavHistoryObserver.REASON_EXPIRED) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -456,15 +456,15 @@ HistoryTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
onDeleteVisits: function (uri, visitTime, guid, reason) {
|
||||
onDeleteVisits(uri, visitTime, guid, reason) {
|
||||
this.onDeleteAffectsGUID(uri, guid, reason, "onDeleteVisits", SCORE_INCREMENT_SMALL);
|
||||
},
|
||||
|
||||
onDeleteURI: function (uri, guid, reason) {
|
||||
onDeleteURI(uri, guid, reason) {
|
||||
this.onDeleteAffectsGUID(uri, guid, reason, "onDeleteURI", SCORE_INCREMENT_XLARGE);
|
||||
},
|
||||
|
||||
onVisit: function (uri, vid, time, session, referrer, trans, guid) {
|
||||
onVisit(uri, vid, time, session, referrer, trans, guid) {
|
||||
if (this.ignoreAll) {
|
||||
this._log.trace("ignoreAll: ignoring visit for " + guid);
|
||||
return;
|
||||
|
|
@ -476,7 +476,7 @@ HistoryTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
onClearHistory: function () {
|
||||
onClearHistory() {
|
||||
this._log.trace("onClearHistory");
|
||||
// Note that we're going to trigger a sync, but none of the cleared
|
||||
// pages are tracked, so the deletions will not be propagated.
|
||||
|
|
@ -484,9 +484,9 @@ HistoryTracker.prototype = {
|
|||
this.score += SCORE_INCREMENT_XLARGE;
|
||||
},
|
||||
|
||||
onBeginUpdateBatch: function () {},
|
||||
onEndUpdateBatch: function () {},
|
||||
onPageChanged: function () {},
|
||||
onTitleChanged: function () {},
|
||||
onBeforeDeleteURI: function () {},
|
||||
onBeginUpdateBatch() {},
|
||||
onEndUpdateBatch() {},
|
||||
onPageChanged() {},
|
||||
onTitleChanged() {},
|
||||
onBeforeDeleteURI() {},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ PasswordEngine.prototype = {
|
|||
|
||||
syncPriority: 2,
|
||||
|
||||
_syncFinish: function () {
|
||||
_syncFinish() {
|
||||
SyncEngine.prototype._syncFinish.call(this);
|
||||
|
||||
// Delete the Weave credentials from the server once.
|
||||
|
|
@ -78,7 +78,7 @@ PasswordEngine.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_findDupe: function (item) {
|
||||
_findDupe(item) {
|
||||
let login = this._store._nsLoginInfoFromRecord(item);
|
||||
if (!login) {
|
||||
return;
|
||||
|
|
@ -104,14 +104,14 @@ function PasswordStore(name, engine) {
|
|||
PasswordStore.prototype = {
|
||||
__proto__: Store.prototype,
|
||||
|
||||
_newPropertyBag: function () {
|
||||
_newPropertyBag() {
|
||||
return Cc["@mozilla.org/hash-property-bag;1"].createInstance(Ci.nsIWritablePropertyBag2);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return an instance of nsILoginInfo (and, implicitly, nsILoginMetaInfo).
|
||||
*/
|
||||
_nsLoginInfoFromRecord: function (record) {
|
||||
_nsLoginInfoFromRecord(record) {
|
||||
function nullUndefined(x) {
|
||||
return (x == undefined) ? null : x;
|
||||
}
|
||||
|
|
@ -144,7 +144,7 @@ PasswordStore.prototype = {
|
|||
return info;
|
||||
},
|
||||
|
||||
_getLoginFromGUID: function (id) {
|
||||
_getLoginFromGUID(id) {
|
||||
let prop = this._newPropertyBag();
|
||||
prop.setPropertyAsAUTF8String("guid", id);
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ PasswordStore.prototype = {
|
|||
return null;
|
||||
},
|
||||
|
||||
getAllIDs: function () {
|
||||
getAllIDs() {
|
||||
let items = {};
|
||||
let logins = Services.logins.getAllLogins({});
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ PasswordStore.prototype = {
|
|||
return items;
|
||||
},
|
||||
|
||||
changeItemID: function (oldID, newID) {
|
||||
changeItemID(oldID, newID) {
|
||||
this._log.trace("Changing item ID: " + oldID + " to " + newID);
|
||||
|
||||
let oldLogin = this._getLoginFromGUID(oldID);
|
||||
|
|
@ -196,11 +196,11 @@ PasswordStore.prototype = {
|
|||
Services.logins.modifyLogin(oldLogin, prop);
|
||||
},
|
||||
|
||||
itemExists: function (id) {
|
||||
itemExists(id) {
|
||||
return !!this._getLoginFromGUID(id);
|
||||
},
|
||||
|
||||
createRecord: function (id, collection) {
|
||||
createRecord(id, collection) {
|
||||
let record = new LoginRec(collection, id);
|
||||
let login = this._getLoginFromGUID(id);
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ PasswordStore.prototype = {
|
|||
return record;
|
||||
},
|
||||
|
||||
create: function (record) {
|
||||
create(record) {
|
||||
let login = this._nsLoginInfoFromRecord(record);
|
||||
if (!login) {
|
||||
return;
|
||||
|
|
@ -241,7 +241,7 @@ PasswordStore.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
remove: function (record) {
|
||||
remove(record) {
|
||||
this._log.trace("Removing login " + record.id);
|
||||
|
||||
let loginItem = this._getLoginFromGUID(record.id);
|
||||
|
|
@ -253,7 +253,7 @@ PasswordStore.prototype = {
|
|||
Services.logins.removeLogin(loginItem);
|
||||
},
|
||||
|
||||
update: function (record) {
|
||||
update(record) {
|
||||
let loginItem = this._getLoginFromGUID(record.id);
|
||||
if (!loginItem) {
|
||||
this._log.debug("Skipping update for unknown item: " + record.hostname);
|
||||
|
|
@ -273,7 +273,7 @@ PasswordStore.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
wipe: function () {
|
||||
wipe() {
|
||||
Services.logins.removeAllLogins();
|
||||
},
|
||||
};
|
||||
|
|
@ -286,15 +286,15 @@ function PasswordTracker(name, engine) {
|
|||
PasswordTracker.prototype = {
|
||||
__proto__: Tracker.prototype,
|
||||
|
||||
startTracking: function () {
|
||||
startTracking() {
|
||||
Svc.Obs.add("passwordmgr-storage-changed", this);
|
||||
},
|
||||
|
||||
stopTracking: function () {
|
||||
stopTracking() {
|
||||
Svc.Obs.remove("passwordmgr-storage-changed", this);
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
Tracker.prototype.observe.call(this, subject, topic, data);
|
||||
|
||||
if (this.ignoreAll) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ PrefsEngine.prototype = {
|
|||
syncPriority: 1,
|
||||
allowSkippedRecord: false,
|
||||
|
||||
getChangedIDs: function () {
|
||||
getChangedIDs() {
|
||||
// No need for a proper timestamp (no conflict resolution needed).
|
||||
let changedIDs = {};
|
||||
if (this._tracker.modified)
|
||||
|
|
@ -52,12 +52,12 @@ PrefsEngine.prototype = {
|
|||
return changedIDs;
|
||||
},
|
||||
|
||||
_wipeClient: function () {
|
||||
_wipeClient() {
|
||||
SyncEngine.prototype._wipeClient.call(this);
|
||||
this.justWiped = true;
|
||||
},
|
||||
|
||||
_reconcile: function (item) {
|
||||
_reconcile(item) {
|
||||
// Apply the incoming item if we don't care about the local data
|
||||
if (this.justWiped) {
|
||||
this.justWiped = false;
|
||||
|
|
@ -85,7 +85,7 @@ PrefStore.prototype = {
|
|||
return this.__prefs;
|
||||
},
|
||||
|
||||
_getSyncPrefs: function () {
|
||||
_getSyncPrefs() {
|
||||
let syncPrefs = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefService)
|
||||
.getBranch(PREF_SYNC_PREFS_PREFIX)
|
||||
|
|
@ -95,12 +95,12 @@ PrefStore.prototype = {
|
|||
return controlPrefs.concat(syncPrefs);
|
||||
},
|
||||
|
||||
_isSynced: function (pref) {
|
||||
_isSynced(pref) {
|
||||
return pref.startsWith(PREF_SYNC_PREFS_PREFIX) ||
|
||||
this._prefs.get(PREF_SYNC_PREFS_PREFIX + pref, false);
|
||||
},
|
||||
|
||||
_getAllPrefs: function () {
|
||||
_getAllPrefs() {
|
||||
let values = {};
|
||||
for (let pref of this._getSyncPrefs()) {
|
||||
if (this._isSynced(pref)) {
|
||||
|
|
@ -119,7 +119,7 @@ PrefStore.prototype = {
|
|||
LightweightThemeManager.currentTheme = themeObject;
|
||||
},
|
||||
|
||||
_setAllPrefs: function (values) {
|
||||
_setAllPrefs(values) {
|
||||
let selectedThemeIDPref = "lightweightThemes.selectedThemeID";
|
||||
let selectedThemeIDBefore = this._prefs.get(selectedThemeIDPref, null);
|
||||
let selectedThemeIDAfter = selectedThemeIDBefore;
|
||||
|
|
@ -161,22 +161,22 @@ PrefStore.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
getAllIDs: function () {
|
||||
getAllIDs() {
|
||||
/* We store all prefs in just one WBO, with just one GUID */
|
||||
let allprefs = {};
|
||||
allprefs[PREFS_GUID] = true;
|
||||
return allprefs;
|
||||
},
|
||||
|
||||
changeItemID: function (oldID, newID) {
|
||||
changeItemID(oldID, newID) {
|
||||
this._log.trace("PrefStore GUID is constant!");
|
||||
},
|
||||
|
||||
itemExists: function (id) {
|
||||
itemExists(id) {
|
||||
return (id === PREFS_GUID);
|
||||
},
|
||||
|
||||
createRecord: function (id, collection) {
|
||||
createRecord(id, collection) {
|
||||
let record = new PrefRec(collection, id);
|
||||
|
||||
if (id == PREFS_GUID) {
|
||||
|
|
@ -188,15 +188,15 @@ PrefStore.prototype = {
|
|||
return record;
|
||||
},
|
||||
|
||||
create: function (record) {
|
||||
create(record) {
|
||||
this._log.trace("Ignoring create request");
|
||||
},
|
||||
|
||||
remove: function (record) {
|
||||
remove(record) {
|
||||
this._log.trace("Ignoring remove request");
|
||||
},
|
||||
|
||||
update: function (record) {
|
||||
update(record) {
|
||||
// Silently ignore pref updates that are for other apps.
|
||||
if (record.id != PREFS_GUID)
|
||||
return;
|
||||
|
|
@ -205,7 +205,7 @@ PrefStore.prototype = {
|
|||
this._setAllPrefs(record.value);
|
||||
},
|
||||
|
||||
wipe: function () {
|
||||
wipe() {
|
||||
this._log.trace("Ignoring wipe request");
|
||||
}
|
||||
};
|
||||
|
|
@ -238,16 +238,16 @@ PrefTracker.prototype = {
|
|||
return this.__prefs;
|
||||
},
|
||||
|
||||
startTracking: function () {
|
||||
startTracking() {
|
||||
Services.prefs.addObserver("", this, false);
|
||||
},
|
||||
|
||||
stopTracking: function () {
|
||||
stopTracking() {
|
||||
this.__prefs = null;
|
||||
Services.prefs.removeObserver("", this);
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
Tracker.prototype.observe.call(this, subject, topic, data);
|
||||
|
||||
switch (topic) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ TabEngine.prototype = {
|
|||
|
||||
syncPriority: 3,
|
||||
|
||||
getChangedIDs: function () {
|
||||
getChangedIDs() {
|
||||
// No need for a proper timestamp (no conflict resolution needed).
|
||||
let changedIDs = {};
|
||||
if (this._tracker.modified)
|
||||
|
|
@ -60,22 +60,22 @@ TabEngine.prototype = {
|
|||
},
|
||||
|
||||
// API for use by Sync UI code to give user choices of tabs to open.
|
||||
getAllClients: function () {
|
||||
getAllClients() {
|
||||
return this._store._remoteClients;
|
||||
},
|
||||
|
||||
getClientById: function (id) {
|
||||
getClientById(id) {
|
||||
return this._store._remoteClients[id];
|
||||
},
|
||||
|
||||
_resetClient: function () {
|
||||
_resetClient() {
|
||||
SyncEngine.prototype._resetClient.call(this);
|
||||
this._store.wipe();
|
||||
this._tracker.modified = true;
|
||||
this.hasSyncedThisSession = false;
|
||||
},
|
||||
|
||||
removeClientData: function () {
|
||||
removeClientData() {
|
||||
let url = this.engineURL + "/" + this.service.clientsEngine.localID;
|
||||
this.service.resource(url).delete();
|
||||
},
|
||||
|
|
@ -83,7 +83,7 @@ TabEngine.prototype = {
|
|||
/**
|
||||
* Return a Set of open URLs.
|
||||
*/
|
||||
getOpenURLs: function () {
|
||||
getOpenURLs() {
|
||||
let urls = new Set();
|
||||
for (let entry of this._store.getAllTabs()) {
|
||||
urls.add(entry.urlHistory[0]);
|
||||
|
|
@ -91,7 +91,7 @@ TabEngine.prototype = {
|
|||
return urls;
|
||||
},
|
||||
|
||||
_reconcile: function (item) {
|
||||
_reconcile(item) {
|
||||
// Skip our own record.
|
||||
// TabStore.itemExists tests only against our local client ID.
|
||||
if (this._store.itemExists(item.id)) {
|
||||
|
|
@ -115,24 +115,24 @@ function TabStore(name, engine) {
|
|||
TabStore.prototype = {
|
||||
__proto__: Store.prototype,
|
||||
|
||||
itemExists: function (id) {
|
||||
itemExists(id) {
|
||||
return id == this.engine.service.clientsEngine.localID;
|
||||
},
|
||||
|
||||
getWindowEnumerator: function () {
|
||||
getWindowEnumerator() {
|
||||
return Services.wm.getEnumerator("navigator:browser");
|
||||
},
|
||||
|
||||
shouldSkipWindow: function (win) {
|
||||
shouldSkipWindow(win) {
|
||||
return win.closed ||
|
||||
PrivateBrowsingUtils.isWindowPrivate(win);
|
||||
},
|
||||
|
||||
getTabState: function (tab) {
|
||||
getTabState(tab) {
|
||||
return JSON.parse(Svc.Session.getTabState(tab));
|
||||
},
|
||||
|
||||
getAllTabs: function (filter) {
|
||||
getAllTabs(filter) {
|
||||
let filteredUrls = new RegExp(Svc.Prefs.get("engine.tabs.filteredUrls"), "i");
|
||||
|
||||
let allTabs = [];
|
||||
|
|
@ -200,7 +200,7 @@ TabStore.prototype = {
|
|||
return allTabs;
|
||||
},
|
||||
|
||||
createRecord: function (id, collection) {
|
||||
createRecord(id, collection) {
|
||||
let record = new TabSetRecord(collection, id);
|
||||
record.clientName = this.engine.service.clientsEngine.localName;
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ TabStore.prototype = {
|
|||
return record;
|
||||
},
|
||||
|
||||
getAllIDs: function () {
|
||||
getAllIDs() {
|
||||
// Don't report any tabs if all windows are in private browsing for
|
||||
// first syncs.
|
||||
let ids = {};
|
||||
|
|
@ -259,18 +259,18 @@ TabStore.prototype = {
|
|||
return ids;
|
||||
},
|
||||
|
||||
wipe: function () {
|
||||
wipe() {
|
||||
this._remoteClients = {};
|
||||
},
|
||||
|
||||
create: function (record) {
|
||||
create(record) {
|
||||
this._log.debug("Adding remote tabs from " + record.clientName);
|
||||
this._remoteClients[record.id] = Object.assign({}, record.cleartext, {
|
||||
lastModified: record.modified
|
||||
});
|
||||
},
|
||||
|
||||
update: function (record) {
|
||||
update(record) {
|
||||
this._log.trace("Ignoring tab updates as local ones win");
|
||||
},
|
||||
};
|
||||
|
|
@ -290,13 +290,13 @@ TabTracker.prototype = {
|
|||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
|
||||
clearChangedIDs: function () {
|
||||
clearChangedIDs() {
|
||||
this.modified = false;
|
||||
},
|
||||
|
||||
_topics: ["pageshow", "TabOpen", "TabClose", "TabSelect"],
|
||||
|
||||
_registerListenersForWindow: function (window) {
|
||||
_registerListenersForWindow(window) {
|
||||
this._log.trace("Registering tab listeners in window");
|
||||
for (let topic of this._topics) {
|
||||
window.addEventListener(topic, this.onTab, false);
|
||||
|
|
@ -308,11 +308,11 @@ TabTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_unregisterListeners: function (event) {
|
||||
_unregisterListeners(event) {
|
||||
this._unregisterListenersForWindow(event.target);
|
||||
},
|
||||
|
||||
_unregisterListenersForWindow: function (window) {
|
||||
_unregisterListenersForWindow(window) {
|
||||
this._log.trace("Removing tab listeners in window");
|
||||
window.removeEventListener("unload", this._unregisterListeners, false);
|
||||
for (let topic of this._topics) {
|
||||
|
|
@ -323,7 +323,7 @@ TabTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
startTracking: function () {
|
||||
startTracking() {
|
||||
Svc.Obs.add("domwindowopened", this);
|
||||
let wins = Services.wm.getEnumerator("navigator:browser");
|
||||
while (wins.hasMoreElements()) {
|
||||
|
|
@ -331,7 +331,7 @@ TabTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
stopTracking: function () {
|
||||
stopTracking() {
|
||||
Svc.Obs.remove("domwindowopened", this);
|
||||
let wins = Services.wm.getEnumerator("navigator:browser");
|
||||
while (wins.hasMoreElements()) {
|
||||
|
|
@ -339,7 +339,7 @@ TabTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
Tracker.prototype.observe.call(this, subject, topic, data);
|
||||
|
||||
switch (topic) {
|
||||
|
|
@ -356,7 +356,7 @@ TabTracker.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
onTab: function (event) {
|
||||
onTab(event) {
|
||||
if (event.originalTarget.linkedBrowser) {
|
||||
let browser = event.originalTarget.linkedBrowser;
|
||||
if (PrivateBrowsingUtils.isBrowserPrivate(browser) &&
|
||||
|
|
@ -378,7 +378,7 @@ TabTracker.prototype = {
|
|||
},
|
||||
|
||||
// web progress listeners.
|
||||
onLocationChange: function (webProgress, request, location, flags) {
|
||||
onLocationChange(webProgress, request, location, flags) {
|
||||
// We only care about top-level location changes which are not in the same
|
||||
// document.
|
||||
if (webProgress.isTopLevel &&
|
||||
|
|
|
|||
|
|
@ -87,18 +87,18 @@ IdentityManager.prototype = {
|
|||
/**
|
||||
* Initialize the identity provider.
|
||||
*/
|
||||
initialize: function() {
|
||||
initialize() {
|
||||
// Nothing to do for this identity provider.
|
||||
},
|
||||
|
||||
finalize: function() {
|
||||
finalize() {
|
||||
// Nothing to do for this identity provider.
|
||||
},
|
||||
|
||||
/**
|
||||
* Called whenever Service.logout() is called.
|
||||
*/
|
||||
logout: function() {
|
||||
logout() {
|
||||
// nothing to do for this identity provider.
|
||||
},
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ IdentityManager.prototype = {
|
|||
* Ensure the user is logged in. Returns a promise that resolves when
|
||||
* the user is logged in, or is rejected if the login attempt has failed.
|
||||
*/
|
||||
ensureLoggedIn: function() {
|
||||
ensureLoggedIn() {
|
||||
// nothing to do for this identity provider
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
|
@ -169,7 +169,7 @@ IdentityManager.prototype = {
|
|||
/**
|
||||
* Resets/Drops all credentials we hold for the current user.
|
||||
*/
|
||||
resetCredentials: function() {
|
||||
resetCredentials() {
|
||||
this.basicPassword = null;
|
||||
this.resetSyncKey();
|
||||
},
|
||||
|
|
@ -177,7 +177,7 @@ IdentityManager.prototype = {
|
|||
/**
|
||||
* Resets/Drops the sync key we hold for the current user.
|
||||
*/
|
||||
resetSyncKey: function() {
|
||||
resetSyncKey() {
|
||||
this.syncKey = null;
|
||||
// syncKeyBundle cleared as a result of setting syncKey.
|
||||
},
|
||||
|
|
@ -372,7 +372,7 @@ IdentityManager.prototype = {
|
|||
* Returns a promise that resolves with the current auth state after
|
||||
* attempting to unlock.
|
||||
*/
|
||||
unlockAndVerifyAuthState: function() {
|
||||
unlockAndVerifyAuthState() {
|
||||
// Try to fetch the passphrase - this will prompt for MP unlock as a
|
||||
// side-effect...
|
||||
try {
|
||||
|
|
@ -441,7 +441,7 @@ IdentityManager.prototype = {
|
|||
* allows us to avoid a network request for when we actually need the
|
||||
* migration info.
|
||||
*/
|
||||
prefetchMigrationSentinel: function(service) {
|
||||
prefetchMigrationSentinel(service) {
|
||||
// Try and fetch the migration sentinel - it will end up in the recordManager
|
||||
// cache.
|
||||
try {
|
||||
|
|
@ -495,7 +495,7 @@ IdentityManager.prototype = {
|
|||
/**
|
||||
* Return credentials hosts for this identity only.
|
||||
*/
|
||||
_getSyncCredentialsHosts: function() {
|
||||
_getSyncCredentialsHosts() {
|
||||
return Utils.getSyncCredentialsHostsLegacy();
|
||||
},
|
||||
|
||||
|
|
@ -584,12 +584,12 @@ IdentityManager.prototype = {
|
|||
request.setHeader("authorization", "Basic " + btoa(up));
|
||||
},
|
||||
|
||||
createClusterManager: function(service) {
|
||||
createClusterManager(service) {
|
||||
Cu.import("resource://services-sync/stages/cluster.js");
|
||||
return new ClusterManager(service);
|
||||
},
|
||||
|
||||
offerSyncOptions: function () {
|
||||
offerSyncOptions() {
|
||||
// Do nothing for Sync 1.1.
|
||||
return {accepted: true};
|
||||
},
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ JPAKEClient.prototype = {
|
|||
}
|
||||
this._outgoing = {type: this._my_signerid + "3",
|
||||
version: KEYEXCHANGE_VERSION,
|
||||
payload: {ciphertext: ciphertext, IV: iv}};
|
||||
payload: {ciphertext, IV: iv}};
|
||||
this._log.trace("Generated message " + this._outgoing.type);
|
||||
callback();
|
||||
},
|
||||
|
|
@ -619,7 +619,7 @@ JPAKEClient.prototype = {
|
|||
}
|
||||
this._outgoing = {type: this._my_signerid + "3",
|
||||
version: KEYEXCHANGE_VERSION,
|
||||
payload: {ciphertext: ciphertext, IV: iv, hmac: hmac}};
|
||||
payload: {ciphertext, IV: iv, hmac}};
|
||||
this._log.trace("Generated message " + this._outgoing.type);
|
||||
callback();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -843,7 +843,7 @@ ErrorHandler.prototype = {
|
|||
return Svc.Prefs.set("errorhandler.alert.earliestNext", msec / 1000);
|
||||
},
|
||||
|
||||
clearServerAlerts: function () {
|
||||
clearServerAlerts() {
|
||||
// If we have any outstanding alerts, apparently they're no longer relevant.
|
||||
Svc.Prefs.resetBranch("errorhandler.alert");
|
||||
},
|
||||
|
|
@ -857,7 +857,7 @@ ErrorHandler.prototype = {
|
|||
* "message": // Logged in Sync logs.
|
||||
* }
|
||||
*/
|
||||
handleServerAlert: function (xwa) {
|
||||
handleServerAlert(xwa) {
|
||||
if (!xwa.code) {
|
||||
this._log.warn("Got structured X-Weave-Alert, but no alert code.");
|
||||
return;
|
||||
|
|
@ -895,7 +895,7 @@ ErrorHandler.prototype = {
|
|||
*
|
||||
* This method also looks for "side-channel" warnings.
|
||||
*/
|
||||
checkServerError: function (resp) {
|
||||
checkServerError(resp) {
|
||||
switch (resp.status) {
|
||||
case 200:
|
||||
case 404:
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ WBORecord.prototype = {
|
|||
|
||||
// Take a base URI string, with trailing slash, and return the URI of this
|
||||
// WBO based on collection and ID.
|
||||
uri: function(base) {
|
||||
uri(base) {
|
||||
if (this.collection && this.id) {
|
||||
let url = Utils.makeURI(base + this.collection + "/" + this.id);
|
||||
url.QueryInterface(Ci.nsIURL);
|
||||
|
|
@ -330,7 +330,7 @@ CollectionKeyManager.prototype = {
|
|||
let last;
|
||||
changed = changed.filter(x => (x != last) && (last = x));
|
||||
return {same: changed.length == 0,
|
||||
changed: changed};
|
||||
changed};
|
||||
},
|
||||
|
||||
get isClear() {
|
||||
|
|
@ -344,7 +344,7 @@ CollectionKeyManager.prototype = {
|
|||
this._default = null;
|
||||
},
|
||||
|
||||
keyForCollection: function(collection) {
|
||||
keyForCollection(collection) {
|
||||
if (collection && this._collections[collection])
|
||||
return this._collections[collection];
|
||||
|
||||
|
|
@ -356,7 +356,7 @@ CollectionKeyManager.prototype = {
|
|||
* over it and generate random keys for each collection.
|
||||
* Create a WBO for the given data.
|
||||
*/
|
||||
_makeWBO: function(collections, defaultBundle) {
|
||||
_makeWBO(collections, defaultBundle) {
|
||||
let wbo = new CryptoWrapper(CRYPTO_COLLECTION, KEYS_WBO);
|
||||
let c = {};
|
||||
for (let k in collections) {
|
||||
|
|
@ -374,14 +374,14 @@ CollectionKeyManager.prototype = {
|
|||
/**
|
||||
* Create a WBO for the current keys.
|
||||
*/
|
||||
asWBO: function(collection, id) {
|
||||
asWBO(collection, id) {
|
||||
return this._makeWBO(this._collections, this._default);
|
||||
},
|
||||
|
||||
/**
|
||||
* Compute a new default key, and new keys for any specified collections.
|
||||
*/
|
||||
newKeys: function(collections) {
|
||||
newKeys(collections) {
|
||||
let newDefaultKeyBundle = this.newDefaultKeyBundle();
|
||||
|
||||
let newColls = {};
|
||||
|
|
@ -399,7 +399,7 @@ CollectionKeyManager.prototype = {
|
|||
* Generates new keys, but does not replace our local copy. Use this to
|
||||
* verify an upload before storing.
|
||||
*/
|
||||
generateNewKeysWBO: function(collections) {
|
||||
generateNewKeysWBO(collections) {
|
||||
let newDefaultKey, newColls;
|
||||
[newDefaultKey, newColls] = this.newKeys(collections);
|
||||
|
||||
|
|
@ -459,7 +459,7 @@ CollectionKeyManager.prototype = {
|
|||
|
||||
// Take the fetched info/collections WBO, checking the change
|
||||
// time of the crypto collection.
|
||||
updateNeeded: function(info_collections) {
|
||||
updateNeeded(info_collections) {
|
||||
|
||||
this._log.info("Testing for updateNeeded. Last modified: " + this.lastModified);
|
||||
|
||||
|
|
|
|||
|
|
@ -464,8 +464,7 @@ ChannelListener.prototype = {
|
|||
// Save the latest server timestamp when possible.
|
||||
try {
|
||||
AsyncResource.serverTime = channel.getResponseHeader("X-Weave-Timestamp") - 0;
|
||||
}
|
||||
catch(ex) {}
|
||||
} catch (ex) {}
|
||||
|
||||
this._log.trace("onStartRequest: " + channel.requestMethod + " " +
|
||||
channel.URI.spec);
|
||||
|
|
@ -598,11 +597,11 @@ function ChannelNotificationListener(headersToCopy) {
|
|||
ChannelNotificationListener.prototype = {
|
||||
_logName: "Sync.Resource",
|
||||
|
||||
getInterface: function(aIID) {
|
||||
getInterface(aIID) {
|
||||
return this.QueryInterface(aIID);
|
||||
},
|
||||
|
||||
QueryInterface: function(aIID) {
|
||||
QueryInterface(aIID) {
|
||||
if (aIID.equals(Ci.nsIBadCertListener2) ||
|
||||
aIID.equals(Ci.nsIInterfaceRequestor) ||
|
||||
aIID.equals(Ci.nsISupports) ||
|
||||
|
|
|
|||
|
|
@ -303,8 +303,7 @@ Sync11Service.prototype = {
|
|||
if (keysChanged.length) {
|
||||
// Collection keys only. Reset individual engines.
|
||||
this.resetClient(keysChanged);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Default key changed: wipe it all.
|
||||
this.resetClient();
|
||||
}
|
||||
|
|
@ -543,7 +542,7 @@ Sync11Service.prototype = {
|
|||
* Perform the info fetch as part of a login or key fetch, or
|
||||
* inside engine sync.
|
||||
*/
|
||||
_fetchInfo: function (url) {
|
||||
_fetchInfo(url) {
|
||||
let infoURL = url || this.infoURL;
|
||||
|
||||
this._log.trace("In _fetchInfo: " + infoURL);
|
||||
|
|
@ -619,22 +618,19 @@ Sync11Service.prototype = {
|
|||
if (cryptoResp.success) {
|
||||
let keysChanged = this.handleFetchedKeys(syncKeyBundle, cryptoKeys);
|
||||
return true;
|
||||
}
|
||||
else if (cryptoResp.status == 404) {
|
||||
} else if (cryptoResp.status == 404) {
|
||||
// On failure, ask to generate new keys and upload them.
|
||||
// Fall through to the behavior below.
|
||||
this._log.warn("Got 404 for crypto/keys, but 'crypto' in info/collections. Regenerating.");
|
||||
cryptoKeys = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Some other problem.
|
||||
this.status.login = LOGIN_FAILED_SERVER_ERROR;
|
||||
this.errorHandler.checkServerError(cryptoResp);
|
||||
this._log.warn("Got status " + cryptoResp.status + " fetching crypto keys.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
} catch (ex) {
|
||||
this._log.warn("Got exception \"" + ex + "\" fetching cryptoKeys.");
|
||||
// TODO: Um, what exceptions might we get here? Should we re-throw any?
|
||||
|
||||
|
|
@ -642,16 +638,14 @@ Sync11Service.prototype = {
|
|||
if (Utils.isHMACMismatch(ex)) {
|
||||
this.status.login = LOGIN_FAILED_INVALID_PASSPHRASE;
|
||||
this.status.sync = CREDENTIALS_CHANGED;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// In the absence of further disambiguation or more precise
|
||||
// failure constants, just report failure.
|
||||
this.status.login = LOGIN_FAILED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._log.info("... 'crypto' is not a reported collection. Generating new keys.");
|
||||
}
|
||||
|
||||
|
|
@ -668,8 +662,7 @@ Sync11Service.prototype = {
|
|||
|
||||
// Last-ditch case.
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// No update needed: we're good!
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1202,13 +1195,11 @@ Sync11Service.prototype = {
|
|||
this._log.info("Wiped server; incompatible metadata: " + remoteVersion);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (remoteVersion > STORAGE_VERSION) {
|
||||
} else if (remoteVersion > STORAGE_VERSION) {
|
||||
this.status.sync = VERSION_OUT_OF_DATE;
|
||||
this._log.warn("Upgrade required to access newer storage version.");
|
||||
return false;
|
||||
}
|
||||
else if (meta.payload.syncID != this.syncID) {
|
||||
} else if (meta.payload.syncID != this.syncID) {
|
||||
|
||||
this._log.info("Sync IDs differ. Local is " + this.syncID + ", remote is " + meta.payload.syncID);
|
||||
this.resetClient();
|
||||
|
|
@ -1234,8 +1225,7 @@ Sync11Service.prototype = {
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!this.upgradeSyncKey(meta.payload.syncID)) {
|
||||
this._log.warn("Failed to upgrade sync key. Failing remote setup.");
|
||||
return false;
|
||||
|
|
@ -1303,8 +1293,7 @@ Sync11Service.prototype = {
|
|||
this._log.debug("Not syncing: login returned false.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this._log.trace("In sync: no need to login.");
|
||||
}
|
||||
return this._lockedSync(engineNamesToSync);
|
||||
|
|
@ -1366,7 +1355,7 @@ Sync11Service.prototype = {
|
|||
/**
|
||||
* Upload meta/global, throwing the response on failure.
|
||||
*/
|
||||
uploadMetaGlobal: function (meta) {
|
||||
uploadMetaGlobal(meta) {
|
||||
this._log.debug("Uploading meta/global: " + JSON.stringify(meta));
|
||||
|
||||
// It would be good to set the X-If-Unmodified-Since header to `timestamp`
|
||||
|
|
@ -1388,7 +1377,7 @@ Sync11Service.prototype = {
|
|||
*
|
||||
* Returns a promise that resolves with the sentinel, or null.
|
||||
*/
|
||||
getFxAMigrationSentinel: function() {
|
||||
getFxAMigrationSentinel() {
|
||||
if (this._shouldLogin()) {
|
||||
this._log.debug("In getFxAMigrationSentinel: should login.");
|
||||
if (!this.login()) {
|
||||
|
|
@ -1434,7 +1423,7 @@ Sync11Service.prototype = {
|
|||
* Returns a promise that resolves with a boolean which indicates if the
|
||||
* sentinel was successfully written.
|
||||
*/
|
||||
setFxAMigrationSentinel: function(sentinel) {
|
||||
setFxAMigrationSentinel(sentinel) {
|
||||
if (this._shouldLogin()) {
|
||||
this._log.debug("In setFxAMigrationSentinel: should login.");
|
||||
if (!this.login()) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ this.DeclinedEngines = function (service) {
|
|||
this.service = service;
|
||||
}
|
||||
this.DeclinedEngines.prototype = {
|
||||
updateDeclined: function (meta, engineManager=this.service.engineManager) {
|
||||
updateDeclined(meta, engineManager = this.service.engineManager) {
|
||||
let enabled = new Set(engineManager.getEnabled().map(e => e.name));
|
||||
let known = new Set(engineManager.getAll().map(e => e.name));
|
||||
let remoteDeclined = new Set(meta.payload.declined || []);
|
||||
|
|
@ -62,9 +62,9 @@ this.DeclinedEngines.prototype = {
|
|||
if (undecided.size) {
|
||||
let subject = {
|
||||
declined: newDeclined,
|
||||
enabled: enabled,
|
||||
known: known,
|
||||
undecided: undecided,
|
||||
enabled,
|
||||
known,
|
||||
undecided,
|
||||
};
|
||||
CommonUtils.nextTick(() => {
|
||||
Observers.notify("weave:engines:notdeclined", subject);
|
||||
|
|
|
|||
|
|
@ -131,8 +131,7 @@ EngineSynchronizer.prototype = {
|
|||
this.onComplete(new Error("Remote setup failed after processing commands."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
// Always immediately attempt to push back the local client (now
|
||||
// without commands).
|
||||
// Note that we don't abort here; if there's a 401 because we've
|
||||
|
|
@ -319,8 +318,7 @@ EngineSynchronizer.prototype = {
|
|||
_syncEngine: function _syncEngine(engine) {
|
||||
try {
|
||||
engine.sync();
|
||||
}
|
||||
catch(e) {
|
||||
} catch (e) {
|
||||
if (e.status == 401) {
|
||||
// Maybe a 401, cluster update perhaps needed?
|
||||
// We rely on ErrorHandler observing the sync failure notification to
|
||||
|
|
@ -341,7 +339,7 @@ EngineSynchronizer.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
_updateEnabledFromMeta: function (meta, numClients, engineManager=this.service.engineManager) {
|
||||
_updateEnabledFromMeta(meta, numClients, engineManager = this.service.engineManager) {
|
||||
this._log.info("Updating enabled engines: " +
|
||||
numClients + " clients.");
|
||||
|
||||
|
|
@ -445,7 +443,7 @@ EngineSynchronizer.prototype = {
|
|||
this.service._ignorePrefObserver = false;
|
||||
},
|
||||
|
||||
_updateEnabledEngines: function () {
|
||||
_updateEnabledEngines() {
|
||||
let meta = this.service.recordManager.get(this.service.metaURL);
|
||||
let numClients = this.service.scheduler.numClients;
|
||||
let engineManager = this.service.engineManager;
|
||||
|
|
|
|||
|
|
@ -598,12 +598,10 @@ class SyncTelemetryImpl {
|
|||
if (extra) {
|
||||
event.push(extra);
|
||||
}
|
||||
} else {
|
||||
if (extra) {
|
||||
} else if (extra) {
|
||||
event.push(null); // a null for the empty value.
|
||||
event.push(extra);
|
||||
}
|
||||
}
|
||||
this.events.push(event);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,13 +135,13 @@ UserAPI10Client.prototype = {
|
|||
let body = request.response.body;
|
||||
if (body == "0") {
|
||||
cb(null, false);
|
||||
return;
|
||||
|
||||
} else if (body == "1") {
|
||||
cb(null, true);
|
||||
return;
|
||||
|
||||
} else {
|
||||
cb(new Error("Unknown response from server: " + body), null);
|
||||
return;
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ UserAPI10Client.prototype = {
|
|||
}
|
||||
|
||||
cb(error, null);
|
||||
return;
|
||||
|
||||
},
|
||||
|
||||
_onChangePassword: function _onChangePassword(cb, request, error) {
|
||||
|
|
@ -218,7 +218,7 @@ UserAPI10Client.prototype = {
|
|||
error.body = response.body;
|
||||
|
||||
cb(error, null);
|
||||
return;
|
||||
|
||||
},
|
||||
};
|
||||
Object.freeze(UserAPI10Client.prototype);
|
||||
|
|
|
|||
|
|
@ -93,8 +93,7 @@ this.Utils = {
|
|||
return function WrappedCatch() {
|
||||
try {
|
||||
return func.call(thisArg);
|
||||
}
|
||||
catch(ex) {
|
||||
} catch (ex) {
|
||||
thisArg._log.debug("Exception calling " + (func.name || "anonymous function"), ex);
|
||||
if (exceptionCallback) {
|
||||
return exceptionCallback.call(thisArg, ex);
|
||||
|
|
@ -119,8 +118,7 @@ this.Utils = {
|
|||
|
||||
try {
|
||||
return func.call(thisArg);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
thisArg.unlock();
|
||||
}
|
||||
};
|
||||
|
|
@ -166,8 +164,7 @@ this.Utils = {
|
|||
let ret = func.call(thisArg);
|
||||
notify("finish", ret);
|
||||
return ret;
|
||||
}
|
||||
catch(ex) {
|
||||
} catch (ex) {
|
||||
notify("error", ex);
|
||||
throw ex;
|
||||
}
|
||||
|
|
@ -364,12 +361,10 @@ this.Utils = {
|
|||
if (e instanceof OS.File.Error && e.becauseNoSuchFile) {
|
||||
// Ignore non-existent files, but explicitly return null.
|
||||
json = null;
|
||||
} else {
|
||||
if (that._log) {
|
||||
} else if (that._log) {
|
||||
that._log.debug("Failed to load json", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback.call(that, json);
|
||||
|
|
@ -502,7 +497,7 @@ this.Utils = {
|
|||
* take user input for account/username, cleaning up appropriately.
|
||||
*/
|
||||
|
||||
isPassphrase: function(s) {
|
||||
isPassphrase(s) {
|
||||
if (s) {
|
||||
return /^[abcdefghijkmnpqrstuvwxyz23456789]{26}$/.test(Utils.normalizePassphrase(s));
|
||||
}
|
||||
|
|
@ -654,7 +649,7 @@ this.Utils = {
|
|||
* In general, these hosts will not have their passwords synced, will be
|
||||
* reset when we drop sync credentials, etc.
|
||||
*/
|
||||
getSyncCredentialsHosts: function() {
|
||||
getSyncCredentialsHosts() {
|
||||
let result = new Set(this.getSyncCredentialsHostsLegacy());
|
||||
for (let host of this.getSyncCredentialsHostsFxA()) {
|
||||
result.add(host);
|
||||
|
|
@ -665,7 +660,7 @@ this.Utils = {
|
|||
/*
|
||||
* Get the "legacy" identity hosts.
|
||||
*/
|
||||
getSyncCredentialsHostsLegacy: function() {
|
||||
getSyncCredentialsHostsLegacy() {
|
||||
// the legacy sync host
|
||||
return new Set([PWDMGR_HOST]);
|
||||
},
|
||||
|
|
@ -673,7 +668,7 @@ this.Utils = {
|
|||
/*
|
||||
* Get the FxA identity hosts.
|
||||
*/
|
||||
getSyncCredentialsHostsFxA: function() {
|
||||
getSyncCredentialsHostsFxA() {
|
||||
let result = new Set();
|
||||
// the FxA host
|
||||
result.add(FxAccountsCommon.FXA_PWDMGR_HOST);
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ function FakeLoginManager(fakeLogins) {
|
|||
// Use a fake nsILoginManager object.
|
||||
delete Services.logins;
|
||||
Services.logins = {
|
||||
removeAllLogins: function() { self.fakeLogins = []; },
|
||||
getAllLogins: function() { return self.fakeLogins; },
|
||||
addLogin: function(login) {
|
||||
removeAllLogins() { self.fakeLogins = []; },
|
||||
getAllLogins() { return self.fakeLogins; },
|
||||
addLogin(login) {
|
||||
getTestLogger().info("nsILoginManager.addLogin() called " +
|
||||
"with hostname '" + login.hostname + "'.");
|
||||
self.fakeLogins.push(login);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ XPCOMUtils.defineLazyGetter(this, 'SyncPingValidator', function() {
|
|||
});
|
||||
|
||||
var provider = {
|
||||
getFile: function(prop, persistent) {
|
||||
getFile(prop, persistent) {
|
||||
persistent.value = true;
|
||||
switch (prop) {
|
||||
case "ExtPrefDL":
|
||||
|
|
@ -157,7 +157,7 @@ function installAddon(name) {
|
|||
*/
|
||||
function uninstallAddon(addon) {
|
||||
let cb = Async.makeSyncCallback();
|
||||
let listener = {onUninstalled: function(uninstalled) {
|
||||
let listener = {onUninstalled(uninstalled) {
|
||||
if (uninstalled.id == addon.id) {
|
||||
AddonManager.removeAddonListener(listener);
|
||||
cb(uninstalled);
|
||||
|
|
@ -204,7 +204,7 @@ function mockGetWindowEnumerator(url, numWindows, numTabs, indexes, moreURLs) {
|
|||
closed: false,
|
||||
mockIsPrivate: false,
|
||||
gBrowser: {
|
||||
tabs: tabs,
|
||||
tabs,
|
||||
},
|
||||
};
|
||||
elements.push(win);
|
||||
|
|
@ -239,10 +239,10 @@ function mockGetWindowEnumerator(url, numWindows, numTabs, indexes, moreURLs) {
|
|||
});
|
||||
|
||||
return {
|
||||
hasMoreElements: function () {
|
||||
hasMoreElements() {
|
||||
return elements.length;
|
||||
},
|
||||
getNext: function () {
|
||||
getNext() {
|
||||
return elements.shift();
|
||||
},
|
||||
};
|
||||
|
|
@ -450,7 +450,7 @@ function promiseOneObserver(topic, callback) {
|
|||
return new Promise((resolve, reject) => {
|
||||
let observer = function(subject, data) {
|
||||
Svc.Obs.remove(topic, observer);
|
||||
resolve({ subject: subject, data: data });
|
||||
resolve({ subject, data });
|
||||
}
|
||||
Svc.Obs.add(topic, observer)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -72,17 +72,17 @@ ServerWBO.prototype = {
|
|||
return JSON.parse(this.payload);
|
||||
},
|
||||
|
||||
get: function() {
|
||||
get() {
|
||||
return JSON.stringify(this, ["id", "modified", "payload"]);
|
||||
},
|
||||
|
||||
put: function(input) {
|
||||
put(input) {
|
||||
input = JSON.parse(input);
|
||||
this.payload = input.payload;
|
||||
this.modified = new_timestamp();
|
||||
},
|
||||
|
||||
delete: function() {
|
||||
delete() {
|
||||
delete this.payload;
|
||||
delete this.modified;
|
||||
},
|
||||
|
|
@ -90,7 +90,7 @@ ServerWBO.prototype = {
|
|||
// This handler sets `newModified` on the response body if the collection
|
||||
// timestamp has changed. This allows wrapper handlers to extract information
|
||||
// that otherwise would exist only in the body stream.
|
||||
handler: function() {
|
||||
handler() {
|
||||
let self = this;
|
||||
|
||||
return function(request, response) {
|
||||
|
|
@ -216,7 +216,7 @@ ServerCollection.prototype = {
|
|||
*
|
||||
* @return an array of the payloads of each stored WBO.
|
||||
*/
|
||||
payloads: function () {
|
||||
payloads() {
|
||||
return this.wbos().map(function(wbo) {
|
||||
return JSON.parse(JSON.parse(wbo.payload).ciphertext);
|
||||
});
|
||||
|
|
@ -267,13 +267,13 @@ ServerCollection.prototype = {
|
|||
delete this._wbos[id];
|
||||
},
|
||||
|
||||
_inResultSet: function(wbo, options) {
|
||||
_inResultSet(wbo, options) {
|
||||
return wbo.payload
|
||||
&& (!options.ids || (options.ids.indexOf(wbo.id) != -1))
|
||||
&& (!options.newer || (wbo.modified > options.newer));
|
||||
},
|
||||
|
||||
count: function(options) {
|
||||
count(options) {
|
||||
options = options || {};
|
||||
let c = 0;
|
||||
for (let [id, wbo] of Object.entries(this._wbos)) {
|
||||
|
|
@ -284,7 +284,7 @@ ServerCollection.prototype = {
|
|||
return c;
|
||||
},
|
||||
|
||||
get: function(options) {
|
||||
get(options) {
|
||||
let result;
|
||||
if (options.full) {
|
||||
let data = [];
|
||||
|
|
@ -330,7 +330,7 @@ ServerCollection.prototype = {
|
|||
return result;
|
||||
},
|
||||
|
||||
post: function(input) {
|
||||
post(input) {
|
||||
input = JSON.parse(input);
|
||||
let success = [];
|
||||
let failed = {};
|
||||
|
|
@ -355,11 +355,11 @@ ServerCollection.prototype = {
|
|||
}
|
||||
}
|
||||
return {modified: new_timestamp(),
|
||||
success: success,
|
||||
failed: failed};
|
||||
success,
|
||||
failed};
|
||||
},
|
||||
|
||||
delete: function(options) {
|
||||
delete(options) {
|
||||
let deleted = [];
|
||||
for (let [id, wbo] of Object.entries(this._wbos)) {
|
||||
if (this._inResultSet(wbo, options)) {
|
||||
|
|
@ -373,7 +373,7 @@ ServerCollection.prototype = {
|
|||
|
||||
// This handler sets `newModified` on the response body if the collection
|
||||
// timestamp has changed.
|
||||
handler: function() {
|
||||
handler() {
|
||||
let self = this;
|
||||
|
||||
return function(request, response) {
|
||||
|
|
@ -655,7 +655,7 @@ SyncServer.prototype = {
|
|||
throw new Error("User already exists.");
|
||||
}
|
||||
this.users[username] = {
|
||||
password: password,
|
||||
password,
|
||||
collections: {}
|
||||
};
|
||||
return this.user(username);
|
||||
|
|
@ -768,11 +768,11 @@ SyncServer.prototype = {
|
|||
}
|
||||
let deleteCollections = this.deleteCollections.bind(this, username);
|
||||
return {
|
||||
collection: collection,
|
||||
createCollection: createCollection,
|
||||
createContents: createContents,
|
||||
deleteCollections: deleteCollections,
|
||||
modified: modified
|
||||
collection,
|
||||
createCollection,
|
||||
createContents,
|
||||
deleteCollections,
|
||||
modified
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ add_test(function test_ignore_untrusted_source_uris() {
|
|||
|
||||
for (let s of bad) {
|
||||
let sourceURI = ioService.newURI(s);
|
||||
let addon = {sourceURI: sourceURI, name: "bad", id: "bad"};
|
||||
let addon = {sourceURI, name: "bad", id: "bad"};
|
||||
|
||||
let canInstall = AddonUtils.canInstallAddon(addon);
|
||||
do_check_false(canInstall, "Correctly rejected a bad URL");
|
||||
|
|
@ -89,7 +89,7 @@ add_test(function test_ignore_untrusted_source_uris() {
|
|||
|
||||
for (let s of good) {
|
||||
let sourceURI = ioService.newURI(s);
|
||||
let addon = {sourceURI: sourceURI, name: "good", id: "good"};
|
||||
let addon = {sourceURI, name: "good", id: "good"};
|
||||
|
||||
let canInstall = AddonUtils.canInstallAddon(addon);
|
||||
do_check_true(canInstall, "Correctly accepted a good URL");
|
||||
|
|
@ -120,7 +120,7 @@ add_test(function test_source_uri_rewrite() {
|
|||
do_check_eq(SERVER_ADDRESS + "/require.xpi?src=sync",
|
||||
install.sourceURI.spec);
|
||||
|
||||
cb(null, {id: addon.id, addon: addon, install: install});
|
||||
cb(null, {id: addon.id, addon, install});
|
||||
}, false);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ add_task(async function test_disabled_install_semantics() {
|
|||
let now = Date.now() / 1000;
|
||||
|
||||
let record = encryptPayload({
|
||||
id: id,
|
||||
id,
|
||||
applicationID: Services.appinfo.ID,
|
||||
addonID: ADDON_ID,
|
||||
enabled: false,
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ var reconciler = engine._reconciler;
|
|||
*/
|
||||
function createRecordForThisApp(id, addonId, enabled, deleted) {
|
||||
return {
|
||||
id: id,
|
||||
id,
|
||||
addonID: addonId,
|
||||
enabled: enabled,
|
||||
enabled,
|
||||
deleted: !!deleted,
|
||||
applicationID: Services.appinfo.ID,
|
||||
source: "amo"
|
||||
|
|
|
|||
|
|
@ -125,14 +125,14 @@ add_test(function test_track_user_disable() {
|
|||
let cb = Async.makeSyncCallback();
|
||||
|
||||
let listener = {
|
||||
onDisabled: function(disabled) {
|
||||
onDisabled(disabled) {
|
||||
_("onDisabled");
|
||||
if (disabled.id == addon.id) {
|
||||
AddonManager.removeAddonListener(listener);
|
||||
cb();
|
||||
}
|
||||
},
|
||||
onDisabling: function(disabling) {
|
||||
onDisabling(disabling) {
|
||||
_("onDisabling add-on");
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@ function run_test() {
|
|||
_("Try calling the sync that should throw right away");
|
||||
engine._sync();
|
||||
do_throw("Should have failed sync!");
|
||||
}
|
||||
catch(ex) {
|
||||
} catch (ex) {
|
||||
_("Making sure what we threw ended up as the exception:", ex);
|
||||
do_check_eq(ex, "FAIL!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -727,7 +727,7 @@ add_task(async function test_misreconciled_root() {
|
|||
getBatched() {
|
||||
return this.get();
|
||||
},
|
||||
get: function () {
|
||||
get() {
|
||||
this.recordHandler(encrypted);
|
||||
return {success: true}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ add_task(async function test_batch_tracking() {
|
|||
await startTracking();
|
||||
|
||||
PlacesUtils.bookmarks.runInBatchMode({
|
||||
runBatched: function() {
|
||||
runBatched() {
|
||||
let folder = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.bookmarksMenuFolder,
|
||||
"Test Folder", PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
|
|
@ -240,10 +240,10 @@ add_task(async function test_nested_batch_tracking() {
|
|||
await startTracking();
|
||||
|
||||
PlacesUtils.bookmarks.runInBatchMode({
|
||||
runBatched: function() {
|
||||
runBatched() {
|
||||
|
||||
PlacesUtils.bookmarks.runInBatchMode({
|
||||
runBatched: function() {
|
||||
runBatched() {
|
||||
let folder = PlacesUtils.bookmarks.createFolder(
|
||||
PlacesUtils.bookmarks.bookmarksMenuFolder,
|
||||
"Test Folder", PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
|
|
@ -276,7 +276,7 @@ add_task(async function test_tracker_sql_batching() {
|
|||
await startTracking();
|
||||
|
||||
PlacesUtils.bookmarks.runInBatchMode({
|
||||
runBatched: function() {
|
||||
runBatched() {
|
||||
for (let i = 0; i < numItems; i++) {
|
||||
let syncBmkID = PlacesUtils.bookmarks.insertBookmark(
|
||||
PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ function MockFxAccounts() {
|
|||
let fxa = new FxAccounts({
|
||||
_now_is: Date.now(),
|
||||
|
||||
now: function () {
|
||||
now() {
|
||||
return this._now_is;
|
||||
},
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ function run_test() {
|
|||
Log.repository.getLogger("Sync.Identity").level = Log.Level.Trace;
|
||||
Log.repository.getLogger("Sync.BrowserIDManager").level = Log.Level.Trace;
|
||||
run_next_test();
|
||||
};
|
||||
}
|
||||
|
||||
add_test(function test_initial_state() {
|
||||
_("Verify initial state");
|
||||
|
|
@ -705,7 +705,7 @@ add_task(async function test_getKeysMissing() {
|
|||
|
||||
// Mock a fxAccounts object that returns no keys
|
||||
let fxa = new FxAccounts({
|
||||
fetchAndUnwrapKeys: function () {
|
||||
fetchAndUnwrapKeys() {
|
||||
return Promise.resolve({});
|
||||
},
|
||||
fxAccountsClient: new MockFxAccountsClient(),
|
||||
|
|
@ -757,7 +757,7 @@ add_task(async function test_signedInUserMissing() {
|
|||
configureFxAccountIdentity(browseridManager, identityConfig);
|
||||
|
||||
let fxa = new FxAccounts({
|
||||
fetchAndUnwrapKeys: function () {
|
||||
fetchAndUnwrapKeys() {
|
||||
return Promise.resolve({});
|
||||
},
|
||||
fxAccountsClient: new MockFxAccountsClient(),
|
||||
|
|
@ -795,14 +795,14 @@ async function initializeIdentityWithHAWKResponseFactory(config, cbGetResponse)
|
|||
this._uri = uri;
|
||||
this._credentials = credentials;
|
||||
this._extra = extra;
|
||||
};
|
||||
}
|
||||
MockRESTRequest.prototype = {
|
||||
setHeader: function() {},
|
||||
post: function(data, callback) {
|
||||
setHeader() {},
|
||||
post(data, callback) {
|
||||
this.response = cbGetResponse("post", data, this._uri, this._credentials, this._extra);
|
||||
callback.call(this);
|
||||
},
|
||||
get: function(callback) {
|
||||
get(callback) {
|
||||
// Skip /status requests (browserid_identity checks if the account still
|
||||
// exists after an auth error)
|
||||
if (this._uri.startsWith("http://mockedserver:9999/account/status")) {
|
||||
|
|
@ -868,11 +868,11 @@ function mockTokenServer(func) {
|
|||
requestLog.addAppender(new Log.DumpAppender());
|
||||
requestLog.level = Log.Level.Trace;
|
||||
}
|
||||
function MockRESTRequest(url) {};
|
||||
function MockRESTRequest(url) {}
|
||||
MockRESTRequest.prototype = {
|
||||
_log: requestLog,
|
||||
setHeader: function() {},
|
||||
get: function(callback) {
|
||||
setHeader() {},
|
||||
get(callback) {
|
||||
this.response = func();
|
||||
callback.call(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,10 +61,10 @@ add_task(async function test_bad_hmac() {
|
|||
let deletedItems = [];
|
||||
let callback = {
|
||||
__proto__: SyncServerCallback,
|
||||
onItemDeleted: function (username, coll, wboID) {
|
||||
onItemDeleted(username, coll, wboID) {
|
||||
deletedItems.push(coll + "/" + wboID);
|
||||
},
|
||||
onCollectionDeleted: function (username, coll) {
|
||||
onCollectionDeleted(username, coll) {
|
||||
deletedCollections.push(coll);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ add_task(async function test_locally_changed_keys() {
|
|||
|
||||
let w = new CryptoWrapper("history", "id");
|
||||
w.cleartext = {
|
||||
id: id,
|
||||
id,
|
||||
histUri: "http://foo/bar?" + id,
|
||||
title: id,
|
||||
sortindex: i,
|
||||
|
|
@ -160,7 +160,7 @@ add_task(async function test_locally_changed_keys() {
|
|||
|
||||
let w = new CryptoWrapper("history", "id");
|
||||
w.cleartext = {
|
||||
id: id,
|
||||
id,
|
||||
histUri: "http://foo/bar?" + id,
|
||||
title: id,
|
||||
sortindex: i,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ function SteamStore(engine) {
|
|||
SteamStore.prototype = {
|
||||
__proto__: Store.prototype,
|
||||
|
||||
wipe: function() {
|
||||
wipe() {
|
||||
this.wasWiped = true;
|
||||
}
|
||||
};
|
||||
|
|
@ -36,11 +36,11 @@ SteamEngine.prototype = {
|
|||
_storeObj: SteamStore,
|
||||
_trackerObj: SteamTracker,
|
||||
|
||||
_resetClient: function () {
|
||||
_resetClient() {
|
||||
this.wasReset = true;
|
||||
},
|
||||
|
||||
_sync: function () {
|
||||
_sync() {
|
||||
this.wasSynced = true;
|
||||
}
|
||||
};
|
||||
|
|
@ -48,12 +48,12 @@ SteamEngine.prototype = {
|
|||
var engineObserver = {
|
||||
topics: [],
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
observe(subject, topic, data) {
|
||||
do_check_eq(data, "steam");
|
||||
this.topics.push(topic);
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
reset() {
|
||||
this.topics = [];
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ add_task(async function test_processIncoming_abort() {
|
|||
|
||||
let collection = new ServerCollection();
|
||||
let id = Utils.makeGUID();
|
||||
let payload = encryptPayload({id: id, denomination: "Record No. " + id});
|
||||
let payload = encryptPayload({id, denomination: "Record No. " + id});
|
||||
collection.insert(id, payload);
|
||||
|
||||
let server = sync_httpd_setup({
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ function sync_httpd_setup() {
|
|||
let keysWBO = new ServerWBO("keys");
|
||||
let globalWBO = new ServerWBO("global", {storageVersion: STORAGE_VERSION,
|
||||
syncID: Utils.makeGUID(),
|
||||
engines: engines});
|
||||
engines});
|
||||
|
||||
let handlers = {
|
||||
"/1.1/johndoe/info/collections": collectionsHelper.handler,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue