Update sync client for JS changes.

This commit is contained in:
wolfbeast 2018-10-06 07:09:02 +02:00 committed by Roy Tam
commit ee948be1cf
54 changed files with 256 additions and 228 deletions

View file

@ -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 {

View file

@ -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};

View file

@ -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);

View file

@ -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");

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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;

View file

@ -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 == '.') {

View file

@ -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();

View file

@ -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;
}