зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1660881 - [marionette] Use defineLazyGetter to define global objects. r=marionette-reviewers,maja_zf
Differential Revision: https://phabricator.services.mozilla.com/D89398
This commit is contained in:
Родитель
89d8db7e53
Коммит
9aae0f1df6
|
@ -27,15 +27,19 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
|
||||
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
|
||||
|
||||
// Enable testing this module, as Services.appinfo.* is not available
|
||||
// in xpcshell tests.
|
||||
const appinfo = { name: "<missing>", version: "<missing>" };
|
||||
try {
|
||||
appinfo.name = Services.appinfo.name.toLowerCase();
|
||||
} catch (e) {}
|
||||
try {
|
||||
appinfo.version = Services.appinfo.version;
|
||||
} catch (e) {}
|
||||
XPCOMUtils.defineLazyGetter(this, "appinfo", () => {
|
||||
// Enable testing this module, as Services.appinfo.* is not available
|
||||
// in xpcshell tests.
|
||||
const appinfo = { name: "<missing>", version: "<missing>" };
|
||||
try {
|
||||
appinfo.name = Services.appinfo.name.toLowerCase();
|
||||
} catch (e) {}
|
||||
try {
|
||||
appinfo.version = Services.appinfo.version;
|
||||
} catch (e) {}
|
||||
|
||||
return appinfo;
|
||||
});
|
||||
|
||||
/** Representation of WebDriver session timeouts. */
|
||||
class Timeouts {
|
||||
|
|
|
@ -20,7 +20,9 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
/** Provides functionality for creating and sending DOM events. */
|
||||
this.event = {};
|
||||
|
||||
const dblclickTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
XPCOMUtils.defineLazyGetter(this, "dblclickTimer", () => {
|
||||
return Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
});
|
||||
|
||||
// Max interval between two clicks that should result in a dblclick (in ms)
|
||||
const DBLCLICK_INTERVAL = 640;
|
||||
|
|
|
@ -14,6 +14,15 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
StreamUtils: "chrome://marionette/content/stream-utils.js",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "unicodeConverter", () => {
|
||||
const unicodeConverter = Cc[
|
||||
"@mozilla.org/intl/scriptableunicodeconverter"
|
||||
].createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||
unicodeConverter.charset = "UTF-8";
|
||||
|
||||
return unicodeConverter;
|
||||
});
|
||||
|
||||
/**
|
||||
* Packets contain read / write functionality for the different packet types
|
||||
* supported by the debugging protocol, so that a transport can focus on
|
||||
|
@ -34,11 +43,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
* Called to clean up at the end of use
|
||||
*/
|
||||
|
||||
const unicodeConverter = Cc[
|
||||
"@mozilla.org/intl/scriptableunicodeconverter"
|
||||
].createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||
unicodeConverter.charset = "UTF-8";
|
||||
|
||||
const defer = function() {
|
||||
let deferred = {
|
||||
promise: new Promise((resolve, reject) => {
|
||||
|
|
|
@ -26,15 +26,14 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
WebElement: "chrome://marionette/content/element.js",
|
||||
});
|
||||
|
||||
const CC = Components.Constructor;
|
||||
|
||||
const ServerSocket = CC(
|
||||
"@mozilla.org/network/server-socket;1",
|
||||
"nsIServerSocket",
|
||||
"initSpecialConnection"
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
|
||||
XPCOMUtils.defineLazyGetter(this, "ServerSocket", () => {
|
||||
return Components.Constructor(
|
||||
"@mozilla.org/network/server-socket;1",
|
||||
"nsIServerSocket",
|
||||
"initSpecialConnection"
|
||||
);
|
||||
});
|
||||
|
||||
const { KeepWhenOffline, LoopbackOnly } = Ci.nsIServerSocket;
|
||||
|
||||
|
|
|
@ -22,12 +22,13 @@ XPCOMUtils.defineLazyServiceGetter(
|
|||
"nsIIOUtil"
|
||||
);
|
||||
|
||||
const CC = Components.Constructor;
|
||||
const ScriptableInputStream = CC(
|
||||
"@mozilla.org/scriptableinputstream;1",
|
||||
"nsIScriptableInputStream",
|
||||
"init"
|
||||
);
|
||||
XPCOMUtils.defineLazyGetter(this, "ScriptableInputStream", () => {
|
||||
return Components.Constructor(
|
||||
"@mozilla.org/scriptableinputstream;1",
|
||||
"nsIScriptableInputStream",
|
||||
"init"
|
||||
);
|
||||
});
|
||||
|
||||
const BUFFER_SIZE = 0x8000;
|
||||
|
||||
|
|
|
@ -20,7 +20,17 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
StreamUtils: "chrome://marionette/content/stream-utils.js",
|
||||
});
|
||||
|
||||
const CC = Components.Constructor;
|
||||
XPCOMUtils.defineLazyGetter(this, "Pipe", () => {
|
||||
return Components.Constructor("@mozilla.org/pipe;1", "nsIPipe", "init");
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "ScriptableInputStream", () => {
|
||||
return Components.Constructor(
|
||||
"@mozilla.org/scriptableinputstream;1",
|
||||
"nsIScriptableInputStream",
|
||||
"init"
|
||||
);
|
||||
});
|
||||
|
||||
const flags = { wantVerbose: false, wantLogging: false };
|
||||
|
||||
|
@ -30,14 +40,6 @@ const dumpv = flags.wantVerbose
|
|||
}
|
||||
: function() {};
|
||||
|
||||
const Pipe = CC("@mozilla.org/pipe;1", "nsIPipe", "init");
|
||||
|
||||
const ScriptableInputStream = CC(
|
||||
"@mozilla.org/scriptableinputstream;1",
|
||||
"nsIScriptableInputStream",
|
||||
"init"
|
||||
);
|
||||
|
||||
const PACKET_HEADER_MAX = 200;
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче