diff options
Diffstat (limited to 'services/sync/tps/extensions')
18 files changed, 80 insertions, 67 deletions
diff --git a/services/sync/tps/extensions/mozmill/resource/driver/controller.js b/services/sync/tps/extensions/mozmill/resource/driver/controller.js index d5948598e..1a4e6f3b6 100644 --- a/services/sync/tps/extensions/mozmill/resource/driver/controller.js +++ b/services/sync/tps/extensions/mozmill/resource/driver/controller.js @@ -5,9 +5,9 @@ var EXPORTED_SYMBOLS = ["MozMillController", "globalEventRegistry", "sleep", "windowMap"]; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; var EventUtils = {}; Cu.import('resource://mozmill/stdlib/EventUtils.js', EventUtils); @@ -44,7 +44,11 @@ waitForEvents.prototype = { node.firedEvents = {}; this.registry = {}; - for each (var e in events) { + if (!events) { + return; + } + for (var key in events) { + var e = events[key]; var listener = function (event) { this.firedEvents[event.type] = true; } @@ -973,7 +977,10 @@ function browserAdditions (controller) { return windows.map.hasPageLoaded(utils.getWindowId(win)); }, "Timeout", timeout, aInterval); } - catch (ex if ex instanceof errors.TimeoutError) { + catch (ex) { + if (!(ex instanceof errors.TimeoutError)) { + throw ex; + } timed_out = true; } finally { diff --git a/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js b/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js index f08cf42f3..4bf35a384 100644 --- a/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js +++ b/services/sync/tps/extensions/mozmill/resource/driver/elementslib.js @@ -6,9 +6,9 @@ var EXPORTED_SYMBOLS = ["ID", "Link", "XPath", "Selector", "Name", "Anon", "Anon "Lookup", "_byID", "_byName", "_byAttrib", "_byAnonAttrib", ]; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); @@ -304,7 +304,7 @@ var _returnResult = function (results) { var _forChildren = function (element, name, value) { var results = []; - var nodes = [e for each (e in element.childNodes) if (e)] + var nodes = Array.from(element.childNodes).filter(e => e); for (var i in nodes) { var n = nodes[i]; @@ -318,7 +318,7 @@ var _forChildren = function (element, name, value) { var _forAnonChildren = function (_document, element, name, value) { var results = []; - var nodes = [e for each (e in _document.getAnoymousNodes(element)) if (e)]; + var nodes = Array.from(_document.getAnoymousNodes(element)).filter(e => e); for (var i in nodes ) { var n = nodes[i]; @@ -381,7 +381,7 @@ var _byAnonAttrib = function (_document, parent, attributes) { } } - var nodes = [n for each (n in _document.getAnonymousNodes(parent)) if (n.getAttribute)]; + var nodes = Array.from(_document.getAnonymousNodes(parent)).filter(n => n.getAttribute); function resultsForNodes (nodes) { for (var i in nodes) { @@ -404,7 +404,7 @@ var _byAnonAttrib = function (_document, parent, attributes) { resultsForNodes(nodes); if (results.length == 0) { - resultsForNodes([n for each (n in parent.childNodes) if (n != undefined && n.getAttribute)]) + resultsForNodes(Array.from(parent.childNodes).filter(n => n != undefined && n.getAttribute)); } return _returnResult(results) @@ -440,7 +440,7 @@ function Lookup(_document, expression) { throw new Error('Lookup constructor did not recieve enough arguments.'); } - var expSplit = [e for each (e in smartSplit(expression) ) if (e != '')]; + var expSplit = smartSplit(expression).filter(e => e != ''); expSplit.unshift(_document); var nCases = {'id':_byID, 'name':_byName, 'attrib':_byAttrib, 'index':_byIndex}; diff --git a/services/sync/tps/extensions/mozmill/resource/driver/mozelement.js b/services/sync/tps/extensions/mozmill/resource/driver/mozelement.js index 0af204794..ae55cb0ce 100644 --- a/services/sync/tps/extensions/mozmill/resource/driver/mozelement.js +++ b/services/sync/tps/extensions/mozmill/resource/driver/mozelement.js @@ -9,9 +9,9 @@ var EXPORTED_SYMBOLS = ["Elem", "Selector", "ID", "Link", "XPath", "Name", "Look const NAMESPACE_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; var EventUtils = {}; Cu.import('resource://mozmill/stdlib/EventUtils.js', EventUtils); diff --git a/services/sync/tps/extensions/mozmill/resource/driver/mozmill.js b/services/sync/tps/extensions/mozmill/resource/driver/mozmill.js index 283c9bfb4..1e422591f 100644 --- a/services/sync/tps/extensions/mozmill/resource/driver/mozmill.js +++ b/services/sync/tps/extensions/mozmill/resource/driver/mozmill.js @@ -13,9 +13,9 @@ var EXPORTED_SYMBOLS = ["controller", "utils", "elementslib", "os", "firePythonCallback", "getAddons" ]; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; Cu.import("resource://gre/modules/AddonManager.jsm"); diff --git a/services/sync/tps/extensions/mozmill/resource/modules/assertions.js b/services/sync/tps/extensions/mozmill/resource/modules/assertions.js index b49502057..c76f95747 100644 --- a/services/sync/tps/extensions/mozmill/resource/modules/assertions.js +++ b/services/sync/tps/extensions/mozmill/resource/modules/assertions.js @@ -4,7 +4,7 @@ var EXPORTED_SYMBOLS = ['Assert', 'Expect']; -const Cu = Components.utils; +var Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); @@ -658,7 +658,10 @@ Expect.prototype.waitFor = function Expect_waitFor(aCallback, aMessage, aTimeout try { Assert.prototype.waitFor.apply(this, arguments); } - catch (ex if ex instanceof errors.AssertionError) { + catch (ex) { + if (!(ex instanceof errors.AssertionError)) { + throw ex; + } message = ex.message; condition = false; } diff --git a/services/sync/tps/extensions/mozmill/resource/modules/frame.js b/services/sync/tps/extensions/mozmill/resource/modules/frame.js index 799e81d55..dae8276b6 100644 --- a/services/sync/tps/extensions/mozmill/resource/modules/frame.js +++ b/services/sync/tps/extensions/mozmill/resource/modules/frame.js @@ -5,9 +5,9 @@ var EXPORTED_SYMBOLS = ['Collector','Runner','events', 'runTestFile', 'log', 'timers', 'persisted', 'shutdownApplication']; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; const TIMEOUT_SHUTDOWN_HTTPD = 15000; @@ -256,7 +256,7 @@ events.pass = function (obj) { events.currentTest.__passes__.push(obj); } - for each (var timer in timers) { + for (var timer of timers) { timer.actions.push( {"currentTest": events.currentModule.__file__ + "::" + events.currentTest.__name__, "obj": obj, @@ -286,7 +286,7 @@ events.fail = function (obj) { events.currentTest.__fails__.push(obj); } - for each (var time in timers) { + for (var time of timers) { timer.actions.push( {"currentTest": events.currentModule.__file__ + "::" + events.currentTest.__name__, "obj": obj, @@ -325,7 +325,7 @@ events.fireEvent = function (name, obj) { } } - for each(var listener in this.globalListeners) { + for (var listener of this.globalListeners) { listener(name, obj); } } diff --git a/services/sync/tps/extensions/mozmill/resource/modules/windows.js b/services/sync/tps/extensions/mozmill/resource/modules/windows.js index fe9cfaa01..1c75a2d3d 100644 --- a/services/sync/tps/extensions/mozmill/resource/modules/windows.js +++ b/services/sync/tps/extensions/mozmill/resource/modules/windows.js @@ -4,9 +4,9 @@ var EXPORTED_SYMBOLS = ["init", "map"]; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; // imports var utils = {}; Cu.import('resource://mozmill/stdlib/utils.js', utils); diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/EventUtils.js b/services/sync/tps/extensions/mozmill/resource/stdlib/EventUtils.js index a821ab2e0..7f08469f0 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/EventUtils.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/EventUtils.js @@ -8,8 +8,8 @@ var EXPORTED_SYMBOLS = ["disableNonTestMouseEvents","sendMouseEvent", "sendChar" "synthesizeText", "synthesizeComposition", "synthesizeQuerySelectedText"]; -const Ci = Components.interfaces; -const Cc = Components.classes; +var Ci = Components.interfaces; +var Cc = Components.classes; var window = Cc["@mozilla.org/appshell/appShellService;1"] .getService(Ci.nsIAppShellService).hiddenDOMWindow; diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/os.js b/services/sync/tps/extensions/mozmill/resource/stdlib/os.js index fcda30572..ce88bea8a 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/os.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/os.js @@ -4,9 +4,9 @@ var EXPORTED_SYMBOLS = ['listDirectory', 'getFileForPath', 'abspath', 'getPlatform']; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); @@ -37,7 +37,7 @@ function abspath(rel, file) { file = file.parent; } - for each(var p in relSplit) { + for (var p of relSplit) { if (p == '..') { file = file.parent; } else if (p == '.') { diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js b/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js index 794c3e2c2..bfa7ef5a9 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/securable-module.js @@ -168,8 +168,7 @@ if (rootPaths) { if (rootPaths.constructor.name != "Array") rootPaths = [rootPaths]; - var fses = [new exports.LocalFileSystem(path) - for each (path in rootPaths)]; + var fses = rootPaths.map(path => new exports.LocalFileSystem(path)); options.fs = new exports.CompositeFileSystem(fses); } else options.fs = new exports.LocalFileSystem(); diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js b/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js index 3dcca76e0..f27bbaaf7 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/utils.js @@ -10,9 +10,9 @@ var EXPORTED_SYMBOLS = ["applicationName", "assert", "Copy", "getBrowserObject", "unwrapNode", "waitFor" ]; -const Cc = Components.classes; -const Ci = Components.interfaces; -const Cu = Components.utils; +var Cc = Components.classes; +var Ci = Components.interfaces; +var Cu = Components.utils; Cu.import("resource://gre/modules/NetUtil.jsm"); @@ -83,7 +83,7 @@ function getWindows(type) { } function getMethodInWindows(methodName) { - for each (var w in getWindows()) { + for (var w of getWindows()) { if (w[methodName] != undefined) { return w[methodName]; } @@ -93,7 +93,7 @@ function getMethodInWindows(methodName) { } function getWindowByTitle(title) { - for each (var w in getWindows()) { + for (var w of getWindows()) { if (w.document.title && w.document.title == title) { return w; } diff --git a/services/sync/tps/extensions/tps/resource/modules/addons.jsm b/services/sync/tps/extensions/tps/resource/modules/addons.jsm index 5c308b5c2..8dae75ede 100644 --- a/services/sync/tps/extensions/tps/resource/modules/addons.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/addons.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -let EXPORTED_SYMBOLS = ["Addon", "STATE_ENABLED", "STATE_DISABLED"]; +var EXPORTED_SYMBOLS = ["Addon", "STATE_ENABLED", "STATE_DISABLED"]; const {classes: Cc, interfaces: Ci, utils: Cu} = Components; diff --git a/services/sync/tps/extensions/tps/resource/modules/history.jsm b/services/sync/tps/extensions/tps/resource/modules/history.jsm index ab0514bcc..3e750a5f0 100644 --- a/services/sync/tps/extensions/tps/resource/modules/history.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/history.jsm @@ -33,7 +33,7 @@ var DumpHistory = function TPS_History__DumpHistory() { let node = root.getChild(i); let uri = node.uri; let curvisits = HistoryEntry._getVisits(uri); - for each (var visit in curvisits) { + for (var visit of curvisits) { Logger.logInfo("URI: " + uri + ", type=" + visit.type + ", date=" + visit.date, true); } } @@ -110,7 +110,7 @@ var HistoryEntry = { uri: uri, visits: [] }; - for each (visit in item.visits) { + for (let visit of item.visits) { place.visits.push({ visitDate: usSinceEpoch + (visit.date * 60 * 60 * 1000 * 1000), transitionType: visit.type @@ -150,8 +150,8 @@ var HistoryEntry = { "History entry in test file must have both 'visits' " + "and 'uri' properties"); let curvisits = this._getVisits(item.uri); - for each (visit in curvisits) { - for each (itemvisit in item.visits) { + for (let visit of curvisits) { + for (let itemvisit of item.visits) { let expectedDate = itemvisit.date * 60 * 60 * 1000 * 1000 + usSinceEpoch; if (visit.type == itemvisit.type && visit.date == expectedDate) { @@ -161,7 +161,7 @@ var HistoryEntry = { } let all_items_found = true; - for each (itemvisit in item.visits) { + for (let itemvisit of item.visits) { all_items_found = all_items_found && "found" in itemvisit; Logger.logInfo("History entry for " + item.uri + ", type:" + itemvisit.type + ", date:" + itemvisit.date + diff --git a/services/sync/tps/extensions/tps/resource/modules/passwords.jsm b/services/sync/tps/extensions/tps/resource/modules/passwords.jsm index f7221224a..a84800bab 100644 --- a/services/sync/tps/extensions/tps/resource/modules/passwords.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/passwords.jsm @@ -14,7 +14,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://tps/logger.jsm"); -let nsLoginInfo = new Components.Constructor( +var nsLoginInfo = new Components.Constructor( "@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init"); diff --git a/services/sync/tps/extensions/tps/resource/modules/prefs.jsm b/services/sync/tps/extensions/tps/resource/modules/prefs.jsm index 18a6e32ee..286c5a6b5 100644 --- a/services/sync/tps/extensions/tps/resource/modules/prefs.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/prefs.jsm @@ -13,7 +13,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; const WEAVE_PREF_PREFIX = "services.sync.prefs.sync."; -let prefs = Cc["@mozilla.org/preferences-service;1"] +var prefs = Cc["@mozilla.org/preferences-service;1"] .getService(Ci.nsIPrefBranch); Cu.import("resource://tps/logger.jsm"); diff --git a/services/sync/tps/extensions/tps/resource/modules/tabs.jsm b/services/sync/tps/extensions/tps/resource/modules/tabs.jsm index a2ce1afc1..af983573f 100644 --- a/services/sync/tps/extensions/tps/resource/modules/tabs.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/tabs.jsm @@ -13,7 +13,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://services-sync/main.js"); -let BrowserTabs = { +var BrowserTabs = { /** * Add * @@ -49,8 +49,12 @@ let BrowserTabs = { Find: function(uri, title, profile) { // Find the uri in Weave's list of tabs for the given profile. let engine = Weave.Service.engineManager.get("tabs"); - for (let [guid, client] in Iterator(engine.getAllClients())) { - for each (tab in client.tabs) { + for (let [guid, client] of Object.entries(engine.getAllClients())) { + if (!client.tabs) { + continue; + } + for (let key in client.tabs) { + let tab = client.tabs[key]; let weaveTabUrl = tab.urlHistory[0]; if (uri == weaveTabUrl && profile == client.clientName) if (title == undefined || title == tab.title) diff --git a/services/sync/tps/extensions/tps/resource/modules/windows.jsm b/services/sync/tps/extensions/tps/resource/modules/windows.jsm index 62cc80d2c..d892aea56 100644 --- a/services/sync/tps/extensions/tps/resource/modules/windows.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/windows.jsm @@ -14,7 +14,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://services-sync/main.js"); -let BrowserWindows = { +var BrowserWindows = { /** * Add * diff --git a/services/sync/tps/extensions/tps/resource/tps.jsm b/services/sync/tps/extensions/tps/resource/tps.jsm index d3a8b0b7d..db191def7 100644 --- a/services/sync/tps/extensions/tps/resource/tps.jsm +++ b/services/sync/tps/extensions/tps/resource/tps.jsm @@ -7,11 +7,11 @@ * listed symbols will exposed on import, and only when and where imported. */ -let EXPORTED_SYMBOLS = ["ACTIONS", "TPS"]; +var EXPORTED_SYMBOLS = ["ACTIONS", "TPS"]; const {classes: Cc, interfaces: Ci, utils: Cu} = Components; -let module = this; +var module = this; // Global modules Cu.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -89,7 +89,7 @@ const OBSERVER_TOPICS = ["fxaccounts:onlogin", "weave:service:sync:start" ]; -let TPS = { +var TPS = { _currentAction: -1, _currentPhase: -1, _enabledEngines: null, @@ -285,7 +285,7 @@ let TPS = { HandleTabs: function (tabs, action) { this._tabsAdded = tabs.length; this._tabsFinished = 0; - for each (let tab in tabs) { + for (let tab of tabs) { Logger.logInfo("executing action " + action.toUpperCase() + " on tab " + JSON.stringify(tab)); switch(action) { @@ -330,7 +330,7 @@ let TPS = { }, HandlePrefs: function (prefs, action) { - for each (pref in prefs) { + for (let pref of prefs) { Logger.logInfo("executing action " + action.toUpperCase() + " on pref " + JSON.stringify(pref)); let preference = new Preference(pref); @@ -349,7 +349,7 @@ let TPS = { }, HandleForms: function (data, action) { - for each (datum in data) { + for (let datum of data) { Logger.logInfo("executing action " + action.toUpperCase() + " on form entry " + JSON.stringify(datum)); let formdata = new FormData(datum, this._usSinceEpoch); @@ -377,7 +377,7 @@ let TPS = { HandleHistory: function (entries, action) { try { - for each (entry in entries) { + for (let entry of entries) { Logger.logInfo("executing action " + action.toUpperCase() + " on history entry " + JSON.stringify(entry)); switch(action) { @@ -410,7 +410,7 @@ let TPS = { HandlePasswords: function (passwords, action) { try { - for each (password in passwords) { + for (let password of passwords) { let password_id = -1; Logger.logInfo("executing action " + action.toUpperCase() + " on password " + JSON.stringify(password)); @@ -450,7 +450,7 @@ let TPS = { }, HandleAddons: function (addons, action, state) { - for each (let entry in addons) { + for (let entry of addons) { Logger.logInfo("executing action " + action.toUpperCase() + " on addon " + JSON.stringify(entry)); let addon = new Addon(this, entry); @@ -483,7 +483,7 @@ let TPS = { let items = []; for (folder in bookmarks) { let last_item_pos = -1; - for each (bookmark in bookmarks[folder]) { + for (let bookmark of bookmarks[folder]) { Logger.clearPotentialError(); let placesItem; bookmark['location'] = folder; @@ -525,7 +525,7 @@ let TPS = { } if (action == ACTION_DELETE || action == ACTION_MODIFY) { - for each (item in items) { + for (let item of items) { Logger.logInfo("executing action " + action.toUpperCase() + " on bookmark " + JSON.stringify(item)); switch(action) { @@ -689,7 +689,7 @@ let TPS = { // care about. if (settings.ignoreUnusedEngines && Array.isArray(this._enabledEngines)) { let names = {}; - for each (let name in this._enabledEngines) { + for (let name of this._enabledEngines) { names[name] = true; } |