marionette-client
Advanced tools
Comparing version 1.9.4 to 1.9.5
@@ -21,2 +21,28 @@ /* global Marionette */ | ||
/** | ||
* Click an element. | ||
* | ||
* @param {Marionette.Element} element The element to click. | ||
* @param {Number} button The button that's clicked (defaults to 0, which is | ||
* the 'left' or primary mouse button). | ||
* @param {Number} count The number of times the element is clicked. | ||
* @return {Object} self. | ||
*/ | ||
click: function click(element, button, count) { | ||
button = button || | ||
this.actionChain.push(['click', element.id, button, count]); | ||
return this; | ||
}, | ||
/** | ||
* Context click an element as to show it's context menu. | ||
* | ||
* @param {Marionette.Element} element The element to context click. | ||
* @return {Object} self. | ||
*/ | ||
contextClick: function contextClick(element) { | ||
this.actionChain.push(['click', element.id, 2, 1]); | ||
return this; | ||
}, | ||
/** | ||
* Send a 'touchstart' event to this element. If no coordinates are given, | ||
@@ -23,0 +49,0 @@ * it will be targeted at the center of the element. |
@@ -9,7 +9,7 @@ /* global Marionette */ | ||
var DEFAULT_SCRIPT_TIMEOUT = 20000; | ||
var DEFAULT_SEARCH_TIMEOUT = 20000; | ||
var DEFAULT_SCRIPT_TIMEOUT = 60000; | ||
var DEFAULT_SEARCH_TIMEOUT = 60000; | ||
var DEFAULT_WAIT_FOR_INTERVAL = 100; | ||
var DEFAULT_WAIT_FOR_TIMEOUT = 20000; | ||
var DEFAULT_WAIT_FOR_TIMEOUT = 60000; | ||
@@ -147,3 +147,3 @@ var SCOPE_TO_METHOD = Object.freeze({ | ||
/** | ||
* Object of hoooks. | ||
* Object of hooks. | ||
* | ||
@@ -495,2 +495,9 @@ * { | ||
driverSent = this.driver.send(data, cb); | ||
if (driverSent instanceof Promise){ | ||
driverSent.then( | ||
function onFulfill(res){ | ||
cb(res); | ||
} | ||
); | ||
} | ||
} catch (e) { | ||
@@ -555,2 +562,3 @@ // !!! HACK HACK HACK !!! | ||
_sendCommand: function(body, cb, key) { | ||
assert(!!this.driver, body.name + ' called on client w/o driver!'); | ||
try { | ||
@@ -1273,7 +1281,7 @@ return this.send(body, function(data) { | ||
executeJsScript: function executeJsScript(script, args, timeout, callback) { | ||
if (typeof(timeout) === 'function') { | ||
if (typeof timeout === 'function') { | ||
callback = timeout; | ||
timeout = null; | ||
} | ||
if (typeof(args) === 'function') { | ||
if (typeof args === 'function') { | ||
callback = args; | ||
@@ -1285,2 +1293,4 @@ args = null; | ||
// the simpletest sandbox exposes | ||
// necessary assertion functions in the global scope | ||
return this._executeScript({ | ||
@@ -1291,3 +1301,4 @@ name: 'executeJSScript', | ||
timeout: timeout, | ||
args: args | ||
args: args, | ||
sandbox: 'simpletest', | ||
} | ||
@@ -1332,20 +1343,29 @@ }, callback || this.defaultCallback); | ||
* @chainable | ||
* @param {String} script to run. | ||
* @param {Array} [args] optional args for script. | ||
* @param {Function} callback will receive result of the return \ | ||
* call in the script if there is one. | ||
* @param {String} optional sandbox is a tag referring to the sandbox you | ||
* wish to use; if you specify a new tag, a new sandbox | ||
* will be created. If you use the special tag 'system', | ||
* the sandbox will be created using the system principal | ||
* which has elevated privileges. | ||
* @return {Object} self. | ||
* @param {string} script | ||
* The script to evaluate. | ||
* @param {Array.<?>} args | ||
* Optional args for script that will be available as | ||
* {@code arguments} in the scope the script runs in. | ||
* @param {function} callback | ||
* The callback will receive result of the return call in the | ||
* script if there is one. | ||
* @param {string} sandbox | ||
* Name of the sandbox to evaluate the script in. If undefined, | ||
* the default sandbox will be used. If you specify "system", | ||
* the sandbox will have the system principal which gives | ||
* elevated privileges. | ||
* | ||
* @return {Marionette} | ||
* Reference to self. | ||
*/ | ||
executeScript: function executeScript(script, args, callback, sandbox) { | ||
if (typeof(args) === 'function') { | ||
if (typeof args === 'function') { | ||
callback = args; | ||
args = null; | ||
} | ||
if (typeof(sandbox) === 'undefined') | ||
if (typeof sandbox === 'undefined') { | ||
sandbox = 'default'; | ||
} | ||
return this._executeScript({ | ||
@@ -1356,3 +1376,3 @@ name: 'executeScript', | ||
args: args, | ||
sandbox: sandbox | ||
sandbox: sandbox, | ||
} | ||
@@ -1383,13 +1403,29 @@ }, callback || this.defaultCallback); | ||
* @chainable | ||
* @param {String} script script to run. | ||
* @param {Array} [args] optional args for script. | ||
* @param {Function} callback will receive result of the return \ | ||
* call in the script if there is one. | ||
* @return {Object} self. | ||
* | ||
* @param {string} script | ||
* The script to evaluate. | ||
* @param {Array.<?>} args | ||
* Optional args for script that will be available as | ||
* {@code arguments} in the scope the script runs in. | ||
* @param {function} callback | ||
* The callback will receive result of the return call in the | ||
* script if there is one. | ||
* @param {string} sandbox | ||
* Name of the sandbox to evaluate the script in. If undefined, | ||
* the default sandbox will be used. If you specify "system", | ||
* the sandbox will have the system principal which gives | ||
* elevated privileges. | ||
* | ||
* @return {Marionette} | ||
* Reference to self. | ||
*/ | ||
executeAsyncScript: function executeAsyncScript(script, args, callback) { | ||
if (typeof(args) === 'function') { | ||
executeAsyncScript: function(script, args, callback, sandbox) { | ||
if (typeof args === 'function') { | ||
callback = args; | ||
args = null; | ||
} | ||
if (typeof sandbox === 'undefined') { | ||
sandbox = 'default'; | ||
} | ||
return this._executeScript({ | ||
@@ -1399,3 +1435,4 @@ name: 'executeAsyncScript', | ||
script: script, | ||
args: args | ||
args: args, | ||
sandbox: sandbox, | ||
} | ||
@@ -1402,0 +1439,0 @@ }, callback || this.defaultCallback); |
@@ -151,3 +151,3 @@ /* global Marionette */ | ||
*/ | ||
connect: function connect(callback) { | ||
connect: function connect(callback, callbackpromises) { | ||
this.ready = true; | ||
@@ -158,6 +158,5 @@ this._responseQueue.push(function(data) { | ||
this.applicationType = data.applicationType; | ||
callback(); | ||
}.bind(this)); | ||
this._connect(); | ||
this._connect(callbackpromises); | ||
}, | ||
@@ -218,2 +217,7 @@ | ||
var cb = this._responseQueue.shift(); | ||
if (this.callbackpromises){ | ||
this.callbackpromises(); | ||
} | ||
cb(resp); | ||
@@ -220,0 +224,0 @@ |
@@ -12,2 +12,3 @@ /* global Marionette */ | ||
module.exports.TcpSync = require('./tcp-sync'); | ||
module.exports.Promises = require('./promises'); | ||
} else { | ||
@@ -14,0 +15,0 @@ if (typeof(window.TCPSocket) !== 'undefined') { |
@@ -69,3 +69,3 @@ 'use strict'; | ||
*/ | ||
Tcp.prototype._connect = function connect() { | ||
Tcp.prototype._connect = function connect(callbackpromises) { | ||
var options = { | ||
@@ -76,5 +76,7 @@ port: this.port, | ||
}; | ||
retrySocket.waitForSocket(options, function(err, socket) { | ||
debug('got socket starting command stream'); | ||
if (callbackpromises){ | ||
this.callbackpromises = callbackpromises; | ||
} | ||
this.socket = socket; | ||
@@ -81,0 +83,0 @@ this.client = new CommandStream(this.socket); |
@@ -1,1 +0,1 @@ | ||
{"name":"marionette-client","version":"1.9.4","author":"The Gaia Team <dev-gaia@lists.mozilla.org>","description":"Marionette Javascript Client","main":"lib/marionette/index","dependencies":{"debug":"~0.6","json-wire-protocol":"1.0.0","socket-retry-connect":"0.0.1","sockit-to-me":"1.0.2"},"devDependencies":{"yuidocjs":"~0.3","node-static":"~0.6","chai":"~1.7.2"}} | ||
{"name":"marionette-client","version":"1.9.5","author":"The Gaia Team <dev-gaia@lists.mozilla.org>","description":"Marionette Javascript Client","main":"lib/marionette/index","dependencies":{"debug":"~0.6","json-wire-protocol":"1.0.0","socket-retry-connect":"0.0.1","sockit-to-me":"1.0.2","promise":"7.0.4","find-port":"1.0.1"},"devDependencies":{"yuidocjs":"~0.3","node-static":"~0.6","chai":"~1.7.2"}} |
@@ -1097,11 +1097,27 @@ /* global DeviceInteraction, MockDriver, assert, exampleCmds, helper, setup */ | ||
suite('.executeScript', function() { | ||
setup(function() { | ||
test('should call _executeScript', function() { | ||
subject.executeScript(script, commandCallback); | ||
assert.deepEqual(calledWith, [ | ||
{ | ||
name: 'executeScript', | ||
parameters: { | ||
script: script, | ||
args: null, | ||
sandbox: 'default', | ||
} | ||
}, | ||
commandCallback | ||
]); | ||
}); | ||
test('should call _executeScript', function() { | ||
test('should call _executeScript with arguments', function() { | ||
subject.executeScript(script, ['foo'], commandCallback); | ||
assert.deepEqual(calledWith, [ | ||
{ | ||
name: 'executeScript', | ||
parameters: { script: script, args: null, sandbox: 'default' } | ||
parameters: { | ||
script: script, | ||
args: ['foo'], | ||
sandbox: 'default', | ||
} | ||
}, | ||
@@ -1111,2 +1127,17 @@ commandCallback | ||
}); | ||
test('should call _executeScript with custom sandbox', function() { | ||
subject.executeScript(script, null, commandCallback, 'foo'); | ||
assert.deepEqual(calledWith, [ | ||
{ | ||
name: 'executeScript', | ||
parameters: { | ||
script: script, | ||
args: null, | ||
sandbox: 'foo', | ||
} | ||
}, | ||
commandCallback | ||
]); | ||
}); | ||
}); | ||
@@ -1122,3 +1153,8 @@ | ||
name: 'executeJSScript', | ||
parameters: {script: script, timeout: true, args: null} | ||
parameters: { | ||
script: script, | ||
timeout: true, | ||
args: null, | ||
sandbox: 'simpletest', | ||
} | ||
}, commandCallback]); | ||
@@ -1129,11 +1165,27 @@ }); | ||
suite('.executeAsyncScript', function() { | ||
setup(function() { | ||
test('should call _executeScript', function() { | ||
subject.executeAsyncScript(script, commandCallback); | ||
assert.deepEqual(calledWith, [ | ||
{ | ||
name: 'executeAsyncScript', | ||
parameters: { | ||
script: script, | ||
args: null, | ||
sandbox: 'default', | ||
} | ||
}, | ||
commandCallback | ||
]); | ||
}); | ||
test('should call _executeScript', function() { | ||
test('should call _executeScript with arguments', function() { | ||
subject.executeAsyncScript(script, ['foo'], commandCallback); | ||
assert.deepEqual(calledWith, [ | ||
{ | ||
name: 'executeAsyncScript', | ||
parameters: {script: script, args: null} | ||
parameters: { | ||
script: script, | ||
args: ['foo'], | ||
sandbox: 'default', | ||
} | ||
}, | ||
@@ -1143,2 +1195,17 @@ commandCallback | ||
}); | ||
test('should call _executeScript with custom sandbox', function() { | ||
subject.executeAsyncScript(script, null, commandCallback, 'foo'); | ||
assert.deepEqual(calledWith, [ | ||
{ | ||
name: 'executeAsyncScript', | ||
parameters: { | ||
script: script, | ||
args: null, | ||
sandbox: 'foo', | ||
} | ||
}, | ||
commandCallback | ||
]); | ||
}); | ||
}); | ||
@@ -1145,0 +1212,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
338035
79
8113
6
6
+ Addedfind-port@1.0.1
+ Addedpromise@7.0.4
+ Addedasap@2.0.6(transitive)
+ Addedasync@0.2.10(transitive)
+ Addedfind-port@1.0.1(transitive)
+ Addedpromise@7.0.4(transitive)