Comparing version 1.4.1 to 1.5.0
@@ -22,2 +22,3 @@ /** | ||
var args = arguments; | ||
return new this.constructor(this, function (setContext) { | ||
@@ -344,2 +345,7 @@ var parentContext = this._context; | ||
function fixStack(error) { | ||
error.stack = error.stack + util.trimStack(trace.stack); | ||
throw error; | ||
} | ||
if (parent && parent.session) { | ||
@@ -366,5 +372,5 @@ this._parent = parent; | ||
Error.captureStackTrace(this, Command); | ||
var trace = {}; | ||
Error.captureStackTrace(trace, Command); | ||
/* jshint maxlen:130 */ | ||
this._promise = (parent ? parent.promise : Promise.resolve(undefined)).then(function (returnValue) { | ||
@@ -377,11 +383,13 @@ self._context = parent ? parent.context : TOP_CONTEXT; | ||
}).then( | ||
initialiser && initialiser.bind(this, setContext), | ||
errback && errback.bind(this, setContext) | ||
).catch(function (error) { | ||
// The first line of a stack trace from V8 is the string representation of the object holding the stack | ||
// trace; in this case, the Command object holds the stack trace, and has no string representation, so we | ||
// remove it from the output | ||
error.stack = error.stack + self.stack.replace(/^[^\n]+/, ''); | ||
throw error; | ||
}); | ||
initialiser && function (returnValue) { | ||
return Promise.resolve(returnValue) | ||
.then(initialiser.bind(self, setContext)) | ||
.catch(fixStack); | ||
}, | ||
errback && function (error) { | ||
return Promise.reject(error) | ||
.catch(errback.bind(self, setContext)) | ||
.catch(fixStack); | ||
} | ||
); | ||
} | ||
@@ -388,0 +396,0 @@ |
Contribution guidelines | ||
======================= | ||
## Hi! | ||
## Hi! Welcome! | ||
* The issues tab is for **bugs and feature enhancement requests only**, not questions. If you aren’t sure if your | ||
problem is a bug (or you know that it isn’t), please ask in one of the | ||
[support forums](https://github.com/theintern/intern/wiki/Support) instead. Any help questions posted to the bug | ||
tracker will normally be closed without a good answer in order to keep the bug tracker focused only on the development | ||
process. Sorry for any inconvenience! | ||
* If you can, find the right issue tracker for your problem: | ||
* [Dig Dug](https://github.com/theintern/digdug/issues) should be used for issues regarding downloading or starting | ||
service tunnels, or interacting with a service provider’s REST API | ||
* [Leadfoot](https://github.com/theintern/leadfoot/issues) should be used for issues with any of the functional | ||
testing APIs, including issues with cross-browser inconsistencies or unsupported Selenium environments | ||
* [Intern](https://github.com/theintern/intern/issues) for all other issues | ||
Thanks for taking a look at our contribution guidelines. This is a small open-source project and we’re always looking | ||
to get more people actively involved in its development and direction—even if you can’t send code! | ||
## Want to submit a new feature or bug fix? | ||
## How to get help | ||
* Thank you for your contribution! | ||
* If you want to help, but aren’t sure where to start, come [talk to us on IRC](irc://irc.freenode.net/intern) or ask | ||
how to start on a ticket that interests you | ||
* You should also talk to us if you are working on a big thing so we can coordinate before you spend a lot of time on it | ||
:) | ||
* Please make sure you sign a [Dojo Foundation CLA](http://dojofoundation.org/about/claForm) or we cannot accept your | ||
code | ||
* Code should conform to our [code style guidelines](https://github.com/sitepen/.jshintrc) | ||
* If possible and appropriate, updated tests should be a part of your pull request | ||
In order to keep the GitHub issue tracker focused on development tasks, our team prefers that **questions be asked on | ||
Stack Overflow or IRC instead of GitHub**. The [Getting help](https://theintern.github.io/intern/#getting-help) section | ||
of the user guide goes into detail about where and how to ask questions to get the best response! | ||
## Committers! | ||
If you’re in a hurry, here are some direct links: | ||
* [Post a question to Stack Overflow](http://stackoverflow.com/questions/ask?tags=intern) | ||
* [Join #intern on Freenode](https://webchat.freenode.net/?channels=intern) | ||
## Reporting bugs & feature requests | ||
For bugs, please [open a ticket](https://github.com/theintern/leadfoot/issues/new?body=Description:%0A%0ASteps+to+reproduce:%0A%0A1.%20%E2%80%A6%0A2.%20%E2%80%A6%0A3.%20%E2%80%A6%0A%0AExpected%20result:%0AActual%20result:%0A%0AIntern%20version:%0A%0AAny%20additional%20information:), | ||
providing a description of the problem, reproduction steps, expected result, and actual result. It’s very hard for us | ||
to solve your problem without all of this information. | ||
For feature requests, just open a ticket describing what you’d like to see and we’ll try to figure out how it can | ||
happen! We (and all the other Intern users) would really appreciate it if you could also pitch in to actually implement | ||
the feature (maybe with some help from us?). | ||
It’s not that important, but if you can, try to post to the correct issue tracker for your problem: | ||
* [Dig Dug](https://github.com/theintern/digdug/issues) should be used for issues regarding downloading or starting | ||
service tunnels, or interacting with a service provider’s REST API | ||
* [Leadfoot](https://github.com/theintern/leadfoot/issues) should be used for issues with any of the functional | ||
testing APIs, including issues with cross-browser inconsistencies or unsupported Selenium environments | ||
* [Intern](https://github.com/theintern/intern/issues) for all other issues | ||
## Getting involved | ||
Because Intern is a small project, *any* contribution you can make is much more impactful and much more appreciated | ||
than anything you could offer to big OSS projects that are already well-funded by big corporations like Google or | ||
Facebook. | ||
If you want to get involved with the sexy, sexy world of testing software, but aren’t sure where to start, come | ||
[talk to us on IRC](irc://irc.freenode.net/intern) or look through the list of | ||
[help-wanted tickets](https://github.com/theintern/leadfoot/labels/help-wanted) for something that piques your interest. | ||
The development team is always happy to provide guidance to new contributors! | ||
If you’re not a coder (or you just don’t want to write code), we can still really use your help in other areas, like | ||
improving [documentation](https://github.com/theintern/leadfoot/tree/gh-pages), or performing marketing and outreach, or | ||
helping other users on Stack Overflow or IRC, so get in touch if you’d be willing to help in any way! | ||
## Submitting pull requests | ||
Like most open source projects, we require everyone to sign a | ||
[contributor license agreement](http://dojofoundation.org/about/claForm) before we can accept any non-trivial | ||
pull requests. This project belongs to the same foundation as other great OSS projects like Dojo, Grunt, lodash, and | ||
RequireJS, so one e-signature makes you eligible to contribute to all of these projects! | ||
Code should conform to our [code style guidelines](https://github.com/sitepen/.jshintrc). If possible and | ||
appropriate, updated tests should also be a part of your pull request. (If you’re having trouble writing tests, we can | ||
help you with them!) | ||
## Advanced instructions for committers! | ||
* Please make sure to provide rigorous code review on new contributions | ||
* When in doubt, ask for a second review; don’t commit code that smells wrong just because it exists | ||
* Squash all pull requests into a single commit by using `git rebase -i` after a merge. Don’t use the shiny green | ||
button! | ||
* Squash pull requests into a single commit using `git rebase -i` after a merge. Don’t use the shiny green button! | ||
No merge commits allowed! | ||
* Put `[ci skip]` at the end of commit messages for commits that do not modify any code (readme changes, etc.) | ||
* (Intern only) After committing to master, always checkout `geezer` and `git merge master` if the code applies to both | ||
branches |
@@ -7,5 +7,7 @@ /* global window:false */ | ||
var fs = require('fs'); | ||
var strategies = require('./lib/strategies'); | ||
var waitForDeleted = require('./lib/waitForDeleted'); | ||
var util = require('./lib/util'); | ||
/** | ||
@@ -177,4 +179,9 @@ * Delegates the HTTP request for a method to the underlying {@link module:leadfoot/Session} object. | ||
* Types into the element. This method works the same as the {@link module:leadfoot/Session#pressKeys} method | ||
* except that any modifier keys are automatically released at the end of the command. | ||
* except that any modifier keys are automatically released at the end of the command. This method should be used | ||
* instead of {@link module:leadfoot/Session#pressKeys} to type filenames into file upload fields. | ||
* | ||
* Since 1.5, if the WebDriver server supports remote file uploads, and you type a path to a file on your local | ||
* computer, that file will be transparently uploaded to the remote server and the remote filename will be typed | ||
* instead. If you do not want to upload local files, use {@link module:leadfoot/Session#pressKeys} instead. | ||
* | ||
* @param {string|string[]} value | ||
@@ -190,2 +197,10 @@ * The text to type in the remote environment. See {@link module:leadfoot/Session#pressKeys} for more information. | ||
if (this.session.capabilities.remoteFiles) { | ||
var filename = value.join(''); | ||
if (fs.existsSync(filename)) { | ||
return this.session._uploadFile(filename).then(this.type.bind(this)); | ||
} | ||
} | ||
return this._post('value', { | ||
@@ -192,0 +207,0 @@ value: value |
@@ -58,1 +58,9 @@ /** | ||
}; | ||
/** | ||
* Removes the first line of a stack trace, which in V8 is the string representation of the object holding the stack | ||
* trace (which is garbage for captured stack traces). | ||
*/ | ||
exports.trimStack = function (stack) { | ||
return stack.replace(/^[^\n]+/, ''); | ||
}; |
{ | ||
"name": "leadfoot", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "Leadfoot. A JavaScript client library that brings cross-platform consistency to the Selenium WebDriver API.", | ||
@@ -13,2 +13,3 @@ "repository": { | ||
"dependencies": { | ||
"adm-zip": "^0.4.3", | ||
"dojo": "2.0.0-alpha.5" | ||
@@ -15,0 +16,0 @@ }, |
@@ -19,8 +19,8 @@ # “Leadfoot drives browsers insanely fast” | ||
* InternetExplorerDriver 2.41.0 | ||
* FirefoxDriver 2.41.0 | ||
* ChromeDriver 2.9 | ||
* SafariDriver 2.41.0 | ||
* Selendroid 0.9.0 | ||
* ios-driver 0.6.6 | ||
* InternetExplorerDriver 2.41.0+ | ||
* FirefoxDriver 2.41.0+ | ||
* ChromeDriver 2.9+ | ||
* SafariDriver 2.41.0+ | ||
* Selendroid 0.9.0+ | ||
* ios-driver 0.6.6+ | ||
@@ -34,3 +34,3 @@ Leadfoot is tested against IE8+ and all other modern browsers. | ||
with all of the tools you need to write robust unit and functional tests. Follow the instructions on | ||
[writing functional tests with Intern](https://github.com/theintern/intern/wiki/Writing-Tests-with-Intern#functional-testing) | ||
[writing functional tests with Intern](https://theintern.github.io/intern/#writing-functional-test) | ||
to learn how to use Leadfoot with Intern. | ||
@@ -44,7 +44,10 @@ | ||
## API documentation | ||
[View API documentation](https://theintern.github.io/leadfoot/) | ||
## License | ||
Leadfoot is available under the terms of the [New BSD License](LICENSE). All code is developed under the terms of the | ||
[Dojo Foundation CLA](http://dojofoundation.org/about/cla). | ||
Leadfoot is a Dojo Foundation project offered under the [New BSD](LICENSE) license. | ||
© 2014 SitePen, Inc. http://sitepen.com | ||
© [SitePen, Inc.](http://sitepen.com) and its [contributors](https://github.com/theintern/leadfoot/graphs/contributors) |
@@ -37,3 +37,3 @@ /* global document:false */ | ||
*/ | ||
return function (path, requestData, pathParts) { | ||
return function sendRequest(path, requestData, pathParts) { | ||
var url = this.url + path.replace(/\$(\d)/, function (_, index) { | ||
@@ -43,3 +43,3 @@ return encodeURIComponent(pathParts[index]); | ||
var kwArgs = { | ||
var kwArgs = lang.delegate(this.requestOptions, { | ||
followRedirects: false, | ||
@@ -54,3 +54,3 @@ handleAs: 'text', | ||
method: method | ||
}; | ||
}); | ||
@@ -72,3 +72,3 @@ if (requestData) { | ||
var trace = {}; | ||
Error.captureStackTrace(trace); | ||
Error.captureStackTrace(trace, sendRequest); | ||
@@ -203,3 +203,3 @@ return request(url, kwArgs).then(function handleResponse(response) { | ||
'] ' + error.message; | ||
error.stack = error.message + trace.stack.replace(/^[^\n]+/, ''); | ||
error.stack = error.message + util.trimStack(trace.stack); | ||
@@ -210,2 +210,5 @@ throw error; | ||
return data; | ||
}, function (error) { | ||
error.stack = error.message + util.trimStack(trace.stack); | ||
throw error; | ||
}); | ||
@@ -234,4 +237,6 @@ }; | ||
* be converted to a string. | ||
* @param {{ proxy: string }=} options | ||
* Additional request options to be used for requests to the server. | ||
*/ | ||
function Server(url) { | ||
function Server(url, options) { | ||
if (typeof url === 'object') { | ||
@@ -245,2 +250,3 @@ url = Object.create(url); | ||
this.url = urlUtil.format(url).replace(/\/*$/, '/'); | ||
this.requestOptions = options || {}; | ||
} | ||
@@ -794,3 +800,20 @@ | ||
function discoverServerFeatures() { | ||
var testedCapabilities = {}; | ||
/* jshint maxlen:300 */ | ||
testedCapabilities.remoteFiles = function () { | ||
return session._post('file', { | ||
file: 'UEsDBAoAAAAAAD0etkYAAAAAAAAAAAAAAAAIABwAdGVzdC50eHRVVAkAA2WnXlVlp15VdXgLAAEE8gMAAATyAwAAUEsBAh4DCgAAAAAAPR62RgAAAAAAAAAAAAAAAAgAGAAAAAAAAAAAAKSBAAAAAHRlc3QudHh0VVQFAANlp15VdXgLAAEE8gMAAATyAwAAUEsFBgAAAAABAAEATgAAAEIAAAAAAA==' | ||
}).then(function (filename) { | ||
return filename && filename.indexOf('test.txt') > -1; | ||
}).catch(unsupported); | ||
}; | ||
return Promise.all(testedCapabilities); | ||
} | ||
return session.get('about:blank') | ||
.then(discoverServerFeatures) | ||
.then(addCapabilities) | ||
.then(discoverFeatures) | ||
@@ -797,0 +820,0 @@ .then(addCapabilities) |
@@ -6,3 +6,5 @@ /*global document:false, window:false */ | ||
var AdmZip = require('adm-zip'); | ||
var Element = require('./Element'); | ||
var fs = require('fs'); | ||
var lang = require('dojo/lang'); | ||
@@ -1660,2 +1662,24 @@ var Promise = require('dojo/Promise'); | ||
return this._server.deleteSession(this._sessionId).then(noop); | ||
}, | ||
/** | ||
* Uploads a file to a remote Selenium server for use when testing file uploads. This API is not part of the | ||
* WebDriver specification and should not be used directly. To send a file to a server that supports file uploads, | ||
* use {@link module:leadfoot/Element#type} to type the name of the local file into a file input field and the file | ||
* will be transparently transmitted and used by the server. | ||
* | ||
* @private | ||
* @returns {Promise.<string>} | ||
*/ | ||
_uploadFile: function (filename) { | ||
var self = this; | ||
return new Promise(function (resolve) { | ||
var zip = new AdmZip(); | ||
zip.addLocalFile(filename); | ||
var data = zip.toBuffer().toString('base64'); | ||
zip = null; | ||
resolve(self._post('file', { file: data })); | ||
}); | ||
} | ||
@@ -1662,0 +1686,0 @@ }; |
@@ -199,2 +199,5 @@ /** | ||
* | ||
* @property {boolean} remoteFiles | ||
* Environments with this capability allow files to be uploaded from a remote client. | ||
* | ||
* @property {boolean} rotatable | ||
@@ -201,0 +204,0 @@ * Environments with this capability allow the rotation of the device to be set and retrieved using the WebDriver API. |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
202920
5212
51
2
2
+ Addedadm-zip@^0.4.3
+ Addedadm-zip@0.4.16(transitive)