Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marionette-client

Package Overview
Dependencies
Maintainers
5
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marionette-client - npm Package Compare versions

Comparing version 0.15.1 to 0.15.2

119

lib/marionette/client.js

@@ -489,3 +489,3 @@ (function(module, ns) {

value = self._transformResultValue(data[responseKey]);
} catch(e) {
} catch (e) {
console.log('Error: unable to transform marionette response', data);

@@ -614,2 +614,4 @@ }

var sync = !callback;
// must handle default callback case for sync code

@@ -624,32 +626,63 @@ callback = callback || this.defaultCallback;

// remember this runs on the host
function sleep(interval) {
setTimeout(marionetteScriptFinished, interval);
}
return (sync ? this.waitForSync : this.waitForAsync).call(
this, test, callback, interval, timeout);
},
var runtest = function runtest() {
if (Date.now() >= timeout) {
return callback(new Error('waitFor timed out'));
/**
* Poll some boolean function until it returns true synchronously.
*
* @param {Function} test some function that returns a boolean.
* @param {Function} callback function to call once our test passes or
* we time out.
* @param {number} interval how often to poll in ms.
* @param {number} timeout time at which we fail in ms.
*/
waitForSync: function(test, callback, interval, timeout) {
while (Date.now() < timeout) {
if (test()) {
return callback(null);
}
// mocha style "done" argument
test(function(err, result) {
if (err || result)
return callback(err, result);
this.executeAsyncScript(function(waitMillis) {
setTimeout(marionetteScriptFinished, waitMillis);
}, [interval]);
}
// test has failed retry
this.executeAsyncScript(sleep, [interval], runtest);
}.bind(this));
}.bind(this);
callback(new Error('timeout exceeded'));
},
// length indicates arity we use mocha style "done" so if an argument
// is not passed this test is sync and we fire done with the result
// of the given "test" function rather then passing a "done" argument.
if (!test.length) {
var originalTest = test;
test = function(done) {
done(null, originalTest());
};
/**
* Poll some boolean function until it returns true asynchronously.
*
* @param {Function} test some function that returns a boolean.
* @param {Function} callback function to call once our test passes or
* we time out.
* @param {number} interval how often to poll in ms.
* @param {number} timeout time at which we fail in ms.
*/
waitForAsync: function(test, callback, interval, timeout) {
if (Date.now() >= timeout) {
return callback(new Error('timeout exceeded'));
}
runtest();
var result, err;
try {
result = test();
} catch (e) {
err = e;
}
if (result || err) {
return callback(err || null);
}
var next = this.waitForAsync.bind(
this,
test,
callback,
interval,
timeout
);
setTimeout(next, interval);
},

@@ -746,2 +779,14 @@

/**
* Returns the type of current window.
*
* @method getWindowType
* @param {Function} [callback] executes with window type.
* @return {Object} self.
*/
getWindowType: function getWindowType(callback) {
var cmd = { type: 'getWindowType' };
return this._sendCommand(cmd, 'value', callback);
},
/**
* Imports a script into the marionette

@@ -853,2 +898,14 @@ * context for the duration of the session.

/**
* Returns the title of current window.
*
* @method title
* @param {Function} [callback] optional receives title.
* @return {Object} self.
*/
title: function title(callback) {
var cmd = { type: 'getTitle' };
return this._sendCommand(cmd, 'value', callback);
},
/**
* Gets url location for device.

@@ -956,2 +1013,14 @@ *

/**
* Returns a string representation of the DOM in current page.
*
* @method pageSource
* @param {Function} [callback] optional receives the page source.
* @return {Object} self.
*/
pageSource: function pageSource(callback) {
var cmd = { type: 'getPageSource' };
return this._sendCommand(cmd, 'value', callback);
},
/**
* Creates a base64-encoded screenshot of the element, or the current frame

@@ -958,0 +1027,0 @@ * if no element is specified.

{
"name": "marionette-client",
"version": "0.15.1",
"version": "0.15.2",
"main": "lib/marionette/index",

@@ -5,0 +5,0 @@ "description": "Marionette Javascript Client",

@@ -46,2 +46,3 @@ # Marionette JS Client

- [marionette-apps](https://github.com/mozilla-b2g/marionette-apps)
- [marionette-helper](https://github.com/mozilla-b2g/marionette-helper)
- [marionette-js-logger](https://github.com/mozilla-b2g/marionette-js-logger)

@@ -56,2 +57,4 @@

The published document: http://mozilla-b2g.github.io/marionette-js-client/api-docs/
### Reviewers

@@ -58,0 +61,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc