marionette-client
Advanced tools
Comparing version 0.11.0 to 0.12.0-alpha
@@ -95,3 +95,10 @@ (function(module, ns) { | ||
* | ||
* // alternatively there is a lazy api which test runners can use. | ||
* | ||
* var client = new Client(null, { lazy: true }); | ||
* | ||
* // accepts same arguments as normal constructor calls. | ||
* client.resetWithDriver(driver, {}); | ||
* | ||
* | ||
* @class Marionette.Client | ||
@@ -103,38 +110,7 @@ * @constructor | ||
function Client(driver, options) { | ||
if (typeof(options) === 'undefined') { | ||
options = {}; | ||
} | ||
this.driver = driver; | ||
this.defaultCallback = options.defaultCallback || false; | ||
// when the driver is lazily added skip | ||
if (!driver && options && options.lazy) | ||
return; | ||
// pick up some options from the driver | ||
if (driver.defaultCallback && !this.defaultCallback) { | ||
this.defaultCallback = driver.defaultCallback; | ||
} | ||
if (driver.isSync) { | ||
this.isSync = driver.isSync; | ||
} | ||
if (!this.defaultCallback) { | ||
this.defaultCallback = driver.defaultCallback ? | ||
driver.defaultCallback : | ||
function() {}; | ||
} | ||
// create hooks | ||
this._hooks = {}; | ||
// create the initial state for this client | ||
this._state = { | ||
context: 'content', | ||
scriptTimeout: 5000, | ||
searchTimeout: 250 | ||
}; | ||
// give the root client a scope. | ||
this._scope = {}; | ||
for (var key in this._state) { | ||
this._scope[key] = this._state[key]; | ||
} | ||
this.resetWithDriver(driver, options); | ||
} | ||
@@ -262,2 +238,49 @@ | ||
/** | ||
* Resets the internal state of the client. | ||
* | ||
* This is only safe to do when the client has no session. | ||
* | ||
* @param {Marionette.Drivers.Abstract} driver fully initialized driver. | ||
* @param {Object} options options for driver. | ||
*/ | ||
resetWithDriver: function(driver, options) { | ||
if (typeof(options) === 'undefined') { | ||
options = {}; | ||
} | ||
this.driver = driver; | ||
this.defaultCallback = options.defaultCallback || false; | ||
// pick up some options from the driver | ||
if (driver.defaultCallback && !this.defaultCallback) { | ||
this.defaultCallback = driver.defaultCallback; | ||
} | ||
if (driver.isSync) { | ||
this.isSync = driver.isSync; | ||
} | ||
if (!this.defaultCallback) { | ||
this.defaultCallback = driver.defaultCallback ? | ||
driver.defaultCallback : | ||
function() {}; | ||
} | ||
// create hooks | ||
this._hooks = {}; | ||
// create the initial state for this client | ||
this._state = { | ||
context: 'content', | ||
scriptTimeout: 5000, | ||
searchTimeout: 250 | ||
}; | ||
// give the root client a scope. | ||
this._scope = {}; | ||
for (var key in this._state) { | ||
this._scope[key] = this._state[key]; | ||
} | ||
}, | ||
/** | ||
* Adds a plugin to the client instance. | ||
@@ -676,2 +699,6 @@ * | ||
this._sendCommand(cmd, 'ok', function(err, value) { | ||
// clear state of the past session | ||
this.session = null; | ||
this.actor = null; | ||
this.driver.close(); | ||
@@ -678,0 +705,0 @@ this._handleCallback(callback, err, value); |
{ | ||
"name": "marionette-client", | ||
"version": "0.11.0", | ||
"version": "0.12.0-alpha", | ||
"main": "lib/marionette/index", | ||
@@ -5,0 +5,0 @@ "description": "Marionette Javascript Client", |
Sorry, the diff of this file is too big to display
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
2
171210
5626