selenium-webdriver 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  2. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  3. data/chrome/src/extension/background.js +64 -48
  4. data/chrome/src/extension/content_script.js +253 -132
  5. data/chrome/src/extension/manifest-nonwin.json +1 -1
  6. data/chrome/src/extension/manifest-win.json +1 -1
  7. data/chrome/src/extension/utils.js +8 -8
  8. data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +9 -0
  9. data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +38 -280
  10. data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +119 -117
  11. data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +36 -26
  12. data/common/src/js/abstractcommandprocessor.js +9 -11
  13. data/common/src/js/command.js +159 -83
  14. data/common/src/js/core/RemoteRunner.html +2 -2
  15. data/common/src/js/core/TestRunner-splash.html +3 -3
  16. data/common/src/js/core/TestRunner.html +5 -17
  17. data/common/src/js/core/scripts/htmlutils.js +4208 -2506
  18. data/common/src/js/core/scripts/selenium-api.js +2 -2
  19. data/common/src/js/core/scripts/selenium-browserbot.js +66 -58
  20. data/common/src/js/core/scripts/selenium-version.js +1 -1
  21. data/common/src/js/localcommandprocessor.js +5 -19
  22. data/common/src/js/testcase.js +2 -0
  23. data/common/src/js/webdriver.js +63 -93
  24. data/common/src/js/webelement.js +40 -42
  25. data/common/src/rb/lib/selenium/webdriver.rb +23 -14
  26. data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +8 -35
  27. data/common/src/rb/lib/selenium/webdriver/child_process.rb +2 -0
  28. data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +1 -0
  29. data/common/src/rb/lib/selenium/webdriver/core_ext/string.rb +5 -0
  30. data/common/src/rb/lib/selenium/webdriver/driver.rb +20 -15
  31. data/common/src/rb/lib/selenium/webdriver/driver_extensions/takes_screenshot.rb +7 -2
  32. data/common/src/rb/lib/selenium/webdriver/element.rb +11 -2
  33. data/common/src/rb/lib/selenium/webdriver/error.rb +9 -5
  34. data/common/src/rb/lib/selenium/webdriver/keys.rb +1 -2
  35. data/common/src/rb/lib/selenium/webdriver/navigation.rb +16 -0
  36. data/common/src/rb/lib/selenium/webdriver/options.rb +32 -0
  37. data/common/src/rb/lib/selenium/webdriver/platform.rb +17 -1
  38. data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
  39. data/firefox/src/extension/components/dispatcher.js +492 -0
  40. data/firefox/src/extension/components/driver-component.js +4 -1
  41. data/firefox/src/extension/components/errorcode.js +70 -0
  42. data/firefox/src/extension/components/firefoxDriver.js +173 -154
  43. data/firefox/src/extension/components/nsCommandProcessor.js +171 -132
  44. data/firefox/src/extension/components/promptService.js +5 -5
  45. data/firefox/src/extension/components/request.js +219 -0
  46. data/firefox/src/extension/components/response.js +276 -0
  47. data/firefox/src/extension/components/session.js +281 -0
  48. data/firefox/src/extension/components/sessionstore.js +226 -0
  49. data/firefox/src/extension/components/socketListener.js +350 -100
  50. data/firefox/src/extension/components/utils.js +166 -98
  51. data/firefox/src/extension/components/webdriverserver.js +9 -5
  52. data/firefox/src/extension/components/wrappedElement.js +189 -166
  53. data/firefox/src/extension/install.rdf +1 -1
  54. data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +2 -0
  55. data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +39 -33
  56. data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +7 -421
  57. data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +7 -64
  58. data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +2 -3
  59. data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +54 -10
  60. data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +2 -0
  61. data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +6 -0
  62. data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
  63. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
  64. data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +2 -0
  65. data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +38 -13
  66. data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +9 -2
  67. data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +5 -0
  68. data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +2 -0
  69. data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +42 -38
  70. data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +56 -47
  71. data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +26 -26
  72. data/remote/client/src/rb/lib/selenium/webdriver/remote/patron_http_client.rb +58 -0
  73. data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +10 -12
  74. data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +2 -17
  75. metadata +44 -23
  76. data/common/src/js/context.js +0 -58
  77. data/firefox/src/extension/components/context.js +0 -37
@@ -0,0 +1,219 @@
1
+ /*
2
+ Copyright 2007-2010 WebDriver committers
3
+ Copyright 2007-2010 Google Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+
18
+ /**
19
+ * Encapsulates information describing an HTTP request.
20
+ * @param {Request.Method} method The HTTP method used to make the request.
21
+ * @param {nsIURL} requestUrl URL for the requested resource.
22
+ * @param {Object} headers Map of request headers;.
23
+ * @param {?string} body The request body, or null, if the request method does
24
+ * not permit a message body.
25
+ * @constructor
26
+ */
27
+ function Request(method, requestUrl, headers, body) {
28
+
29
+ /**
30
+ * A wrapped self-reference for XPConnect.
31
+ * @type {Request}
32
+ */
33
+ this.wrappedJSObject = this;
34
+
35
+ /**
36
+ * The HTTP method used to make the request.
37
+ * @type {Request.Method}
38
+ * @private
39
+ */
40
+ this.method_ = method;
41
+
42
+
43
+ /**
44
+ * URL for the requested resource.
45
+ * @type {?nsIURL}
46
+ * @private
47
+ */
48
+ this.requestUrl_ = requestUrl;
49
+
50
+ /**
51
+ * The request path, minus the segments mapped to the servlet.
52
+ * @type {?string}
53
+ * @private
54
+ */
55
+ this.pathInfo_ = this.requestUrl_.path;
56
+
57
+ /**
58
+ * Map of request headers. All header names are specified as lowercase
59
+ * strings.
60
+ * @type {Object}
61
+ * @private
62
+ */
63
+ this.headers_ = {};
64
+ for (var name in headers) {
65
+ this.headers_[name] = headers[name]
66
+ }
67
+
68
+ /**
69
+ * The request body, if there was one.
70
+ * @type {?string}
71
+ * @private
72
+ */
73
+ this.body_ = body;
74
+
75
+ /**
76
+ * Map of custom request attributes.
77
+ * @type {Object}
78
+ * @private
79
+ */
80
+ this.attributes_ = {};
81
+ }
82
+
83
+
84
+ /**
85
+ * The set of valid HTTP methods.
86
+ * @enum {string}
87
+ */
88
+ Request.Method = {
89
+ 'DELETE': 'DELETE',
90
+ 'GET': 'GET',
91
+ 'HEAD': 'HEAD',
92
+ 'OPTIONS': 'OPTIONS',
93
+ 'POST': 'POST',
94
+ 'PUT': 'PUT',
95
+ 'TRACE': 'TRACE'
96
+ };
97
+
98
+
99
+ /**
100
+ * Path to the servlet servicing this request.
101
+ * @type {string}
102
+ * @private
103
+ */
104
+ Request.prototype.servletPath_ = '/';
105
+
106
+
107
+ /** @return {Request.Method} The HTTP method used to make the request. */
108
+ Request.prototype.getMethod = function() {
109
+ return this.method_;
110
+ };
111
+
112
+
113
+ /** @return {?nsIURL} The full request URL. */
114
+ Request.prototype.getRequestUrl = function() {
115
+ return this.requestUrl_;
116
+ };
117
+
118
+
119
+ /**
120
+ * Retrieves the named header value.
121
+ * @param {string} name The name of the header to lookup.
122
+ * @return {string} The header value, if it was included in this request.
123
+ */
124
+ Request.prototype.getHeader = function(name) {
125
+ return this.headers_[name.toLowerCase()];
126
+ };
127
+
128
+
129
+ /**
130
+ * Sets the servlet path for this request; that is the path prefix that is
131
+ * mapped to the receiving servlet. The remainder of the path, excluding query
132
+ * and param data, is available via Request.getPathInfo().
133
+ * @param {string} servletPath The receiving servlet's path.
134
+ */
135
+ Request.prototype.setServletPath = function(servletPath) {
136
+ if (servletPath[0] != '/') {
137
+ servletPath = '/' + servletPath;
138
+ }
139
+ var length = servletPath.length;
140
+ if (length > 1 && servletPath[length - 1] == '/') {
141
+ servletPath = servletPath.substring(0, length - 1);
142
+ }
143
+
144
+ this.servletPath_ = servletPath;
145
+ this.pathInfo_ = this.requestUrl_.path;
146
+ if (this.servletPath_ != '/') {
147
+ this.pathInfo_ = this.pathInfo_.substring(this.servletPath_.length);
148
+ }
149
+
150
+ if (this.pathInfo_.length > 1 &&
151
+ this.pathInfo_.charAt(this.pathInfo_.length - 1) == '/') {
152
+ this.pathInfo_ = this.pathInfo_.substring(0, this.pathInfo_.length - 1);
153
+ }
154
+ };
155
+
156
+
157
+ /** @return {string} The servlet path for this request. */
158
+ Request.prototype.getServletPath = function() {
159
+ return this.servletPath_;
160
+ };
161
+
162
+
163
+ /** @return {string} The path info for this request. */
164
+ Request.prototype.getPathInfo = function() {
165
+ return this.pathInfo_;
166
+ };
167
+
168
+
169
+ /** @return {?string} The request body if there was one. */
170
+ Request.prototype.getBody = function() {
171
+ return this.body_;
172
+ };
173
+
174
+
175
+ /** @return {string} The value of the named attribute if it exists. */
176
+ Request.prototype.getAttribute = function(name) {
177
+ return this.attributes_[name];
178
+ };
179
+
180
+
181
+ /** @return {Array.<string>} A list of names for all set attributes. */
182
+ Request.prototype.getAttributeNames = function() {
183
+ var names = [];
184
+ for (var name in this.attributes_) {
185
+ names.push(name);
186
+ }
187
+ return names;
188
+ };
189
+
190
+
191
+ /**
192
+ * Sets an attribute on this request, replacing any previously set attribute
193
+ * value.
194
+ * @param {string} name The name of the attribute, or null to delete it.
195
+ * @param {*} value The attribute value.
196
+ */
197
+ Request.prototype.setAttribute = function(name, value) {
198
+ if (value === null || value === undefined) {
199
+ delete this.attributes_[name];
200
+ } else {
201
+ this.attributes_[name] = value;
202
+ }
203
+ };
204
+
205
+
206
+ /**
207
+ * @return {string} This request as a string for debugging.
208
+ */
209
+ Request.prototype.toDebugString = function() {
210
+ var message = this.method_ + ' ' + this.requestUrl_.path + ' HTTP/1.1\r\n';
211
+ for (var name in this.headers_) {
212
+ message += name + ':' + this.headers_[name] + '\r\n';
213
+ }
214
+ message += '\r\n';
215
+ if (this.body_) {
216
+ message += this.body_;
217
+ }
218
+ return message;
219
+ };
@@ -0,0 +1,276 @@
1
+ /*
2
+ Copyright 2007-2010 WebDriver committers
3
+ Copyright 2007-2010 Google Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+
18
+ /**
19
+ * Encapsulates the information for a HTTP response.
20
+ * @param {?Request} request The request this is a response to. May be null if
21
+ * this response is to a malformed request that could not be fully parsed.
22
+ * @param {nsIOutputStream} outputStream The stream to write responses to.
23
+ * @constructor
24
+ */
25
+ function Response(request, outputStream) {
26
+
27
+ /**
28
+ * The request this is a response to.
29
+ * @type {?Request}
30
+ * @private
31
+ */
32
+ this.request_ = request;
33
+
34
+ /**
35
+ * The stream to write responses to.
36
+ * @type {nsIOutputStream}
37
+ * @private
38
+ */
39
+ this.outputStream_ = outputStream;
40
+
41
+ /**
42
+ * The headers for this response.
43
+ * @type {Object}
44
+ * @private
45
+ */
46
+ this.headers_ = {};
47
+
48
+ /**
49
+ * This response's message body.
50
+ * @type {string}
51
+ * @private
52
+ */
53
+ this.body_ = '';
54
+ }
55
+
56
+
57
+ Response.CONTINUE = 100;
58
+ Response.OK = 200;
59
+ Response.NO_CONTENT = 204;
60
+ Response.SEE_OTHER = 303;
61
+ Response.BAD_REQUEST = 400;
62
+ Response.NOT_FOUND = 404;
63
+ Response.METHOD_NOT_ALLOWED = 405;
64
+ Response.LENGTH_REQUIRED = 411;
65
+ Response.INTERNAL_ERROR = 500;
66
+ Response.NOT_IMPLEMENTED = 501;
67
+ Response.HTTP_VERSION_NOT_SUPPORTED = 505;
68
+
69
+ Response.TEXT_PLAIN = 'text/plain';
70
+ Response.TEXT_HTML = 'text/html';
71
+ Response.APPLICATION_JSON = 'application/json';
72
+
73
+
74
+ /**
75
+ * Internal map of supported status messages.
76
+ * @enum {string}
77
+ */
78
+ Response.StatusMessage_ = {
79
+ 100: 'Continue',
80
+ 200: 'OK',
81
+ 204: 'No Content',
82
+ 303: 'See Other',
83
+ 400: 'Bad Request',
84
+ 404: 'Not Found',
85
+ 405: 'Method Not Allowed',
86
+ 411: 'Length Required',
87
+ 500: 'Internal Server Error',
88
+ 501: 'Not Implemented',
89
+ 505: 'HTTP Version Not Supported'
90
+ };
91
+
92
+
93
+ /**
94
+ * Constant for carriage return line feed.
95
+ * @type {string}
96
+ * @const
97
+ */
98
+ Response.CRLF = '\r\n';
99
+
100
+
101
+ /**
102
+ * Whether this response has been committed. Each response may only be
103
+ * committed once.
104
+ * @type {boolean}
105
+ * @private
106
+ */
107
+ Response.prototype.committed_ = false;
108
+
109
+
110
+ /**
111
+ * This response's HTTP stauts code.
112
+ * @type {number}
113
+ * @private
114
+ */
115
+ Response.prototype.status_ = Response.OK;
116
+
117
+
118
+ /** @return {number} The current HTTP response status code. */
119
+ Response.prototype.getStatus = function() {
120
+ return this.status_;
121
+ };
122
+
123
+
124
+ /**
125
+ * Set this response's HTTP status code.
126
+ */
127
+ Response.prototype.setStatus = function(status) {
128
+ this.status_ = status;
129
+ };
130
+
131
+
132
+ /**
133
+ * Sets the value of a header field.
134
+ * @param {string} name The name of the header.
135
+ * @param {?string} value The header value, or null to delete the field.
136
+ */
137
+ Response.prototype.setHeader = function(name, value) {
138
+ if (value == null) {
139
+ delete this.headers_[name];
140
+ } else {
141
+ this.headers_[name] = value;
142
+ }
143
+ };
144
+
145
+
146
+ /**
147
+ * Sets the value of this response's Content-Type header. Responses are always
148
+ * sent as UTF-8, so the content type value need not specify a charset.
149
+ * @param {string} The new content type.
150
+ */
151
+ Response.prototype.setContentType = function(type) {
152
+ this.setHeader('Content-Type', type + '; charset=UTF-8');
153
+ };
154
+
155
+
156
+ /**
157
+ * @param {string} name The name of the header to get.
158
+ * @return {string} The value of the named header if it has been specified.
159
+ */
160
+ Response.prototype.getHeader = function(name) {
161
+ return this.headers_[name];
162
+ };
163
+
164
+
165
+ /**
166
+ * Sets this response's message body, overwriting any previously saved content.
167
+ * The message body will be converted to UTF-8 before the response is committed.
168
+ * @param {string} body The new message body.
169
+ * @see Response.prototype.commit
170
+ */
171
+ Response.prototype.setBody = function(body) {
172
+ this.body_ = body.toString();
173
+ };
174
+
175
+
176
+ /** @return {string} The response message body. */
177
+ Response.prototype.getBody = function() {
178
+ return this.body_;
179
+ };
180
+
181
+
182
+ /**
183
+ * Convenience function for sending a 303 redirect.
184
+ * @param {string} location The location to redirect to.
185
+ */
186
+ Response.prototype.sendRedirect = function(location) {
187
+ this.setStatus(Response.SEE_OTHER);
188
+ this.setHeader('Location', location);
189
+ this.commit();
190
+ };
191
+
192
+
193
+ /**
194
+ * Convenience function for sending an error message.
195
+ * @param {number} code The HTTP status code to use. Must be either a 4xx or
196
+ * 5xx value.
197
+ * @param {string} opt_message An optional error message to include.
198
+ * @param {string} opt_contentType An optional content type to send with the
199
+ * error response.
200
+ */
201
+ Response.prototype.sendError = function(code, opt_message, opt_contentType) {
202
+ this.setStatus(code);
203
+ this.setBody(opt_message || '');
204
+ if (opt_contentType) {
205
+ this.setContentType(opt_contentType);
206
+ }
207
+ this.commit();
208
+ };
209
+
210
+
211
+ /**
212
+ * Commits this response. This function is a no-op if the response has already
213
+ * been committed.
214
+ */
215
+ Response.prototype.commit = function() {
216
+ if (this.committed_) {
217
+ var info = ['Response already committed'];
218
+ if (this.request_) {
219
+ info.push('request: ' + this.request_.getMethod() + ' ' +
220
+ this.request_.getRequestUrl().path);
221
+ info.push(' ' + this.request_.getBody())
222
+ }
223
+ info.push('response: ' + this.status_ + ' ' +
224
+ Response.StatusMessage_[this.status_]);
225
+ info.push(' ' + this.body_);
226
+ Components.utils.reportError(info.join('\n '));
227
+ return;
228
+ }
229
+
230
+ var statusCanHaveBody = (this.status_ < 100 || this.status_ > 199) &&
231
+ this.status_ != 204 && this.status_ != 304;
232
+
233
+ var converter = Components.
234
+ classes['@mozilla.org/intl/scriptableunicodeconverter'].
235
+ createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
236
+ converter.charset = 'UTF-8';
237
+
238
+ var bytes = converter.convertToByteArray(this.body_, {});
239
+
240
+ var statusLine = 'HTTP/1.1 ' + this.status_ + ' ' +
241
+ Response.StatusMessage_[this.status_] + Response.CRLF;
242
+
243
+ this.setHeader('Date', new Date().toUTCString());
244
+ if (this.status_ < 100 || this.status_ > 199) {
245
+ this.setHeader('Connection', 'close');
246
+ }
247
+ if (statusCanHaveBody) {
248
+ this.setHeader('Content-Length', bytes.length);
249
+ }
250
+
251
+ var headers = '';
252
+ for (var name in this.headers_) {
253
+ headers += name + ': ' + this.headers_[name] + Response.CRLF;
254
+ }
255
+
256
+ // Send the status line and headers.
257
+ var toSend = statusLine + headers + Response.CRLF;
258
+ this.outputStream_.write(toSend, toSend.length);
259
+
260
+ // If necessary, send the body.
261
+ if (statusCanHaveBody &&
262
+ ((this.status_ > 399 && this.status_ < 600) ||
263
+ (this.request_.getMethod() != Request.Method.HEAD))) {
264
+ var byteStream = converter.convertToInputStream(this.body_);
265
+ this.outputStream_.writeFrom(byteStream, bytes.length);
266
+ }
267
+
268
+ // Finish things up: flush and close the stream; don't close the stream if
269
+ // this is a 1xx response as there should be a final response sent (in another
270
+ // instance using the same stream).
271
+ this.outputStream_.flush();
272
+ if (this.status_ < 100 || this.status_ > 199) {
273
+ this.outputStream_.close();
274
+ }
275
+ this.committed_ = true;
276
+ };