selenium-webdriver 0.0.24 → 0.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. data/{common/src/rb/CHANGES → CHANGES} +13 -0
  2. data/{common/src/rb/README → README} +1 -1
  3. data/{common/src/rb/lib → lib}/selenium-webdriver.rb +0 -0
  4. data/{common/src/rb/lib → lib}/selenium/webdriver.rb +2 -1
  5. data/{common/src/rb/lib → lib}/selenium/webdriver/bridge_helper.rb +0 -0
  6. data/{common/src/rb/lib → lib}/selenium/webdriver/child_process.rb +0 -0
  7. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome.rb +0 -0
  8. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/bridge.rb +2 -2
  9. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/command_executor.rb +0 -0
  10. data/lib/selenium/webdriver/chrome/extension.zip +0 -0
  11. data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/launcher.rb +26 -20
  12. data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/dir.rb +0 -0
  13. data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/string.rb +0 -0
  14. data/{common/src/rb/lib → lib}/selenium/webdriver/driver.rb +0 -0
  15. data/{common/src/rb/lib → lib}/selenium/webdriver/driver_extensions/takes_screenshot.rb +0 -0
  16. data/{common/src/rb/lib → lib}/selenium/webdriver/element.rb +0 -0
  17. data/{common/src/rb/lib → lib}/selenium/webdriver/error.rb +0 -0
  18. data/{common/src/rb/lib → lib}/selenium/webdriver/file_reaper.rb +2 -1
  19. data/{common/src/rb/lib → lib}/selenium/webdriver/find.rb +0 -0
  20. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox.rb +2 -1
  21. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/binary.rb +32 -6
  22. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/bridge.rb +0 -0
  23. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  24. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/launcher.rb +0 -0
  25. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  26. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  27. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profile.rb +37 -72
  28. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profiles_ini.rb +0 -0
  29. data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/util.rb +0 -0
  30. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie.rb +2 -2
  31. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/bridge.rb +7 -2
  32. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/lib.rb +0 -0
  33. data/{jobbie/prebuilt/Win32/Release → lib/selenium/webdriver/ie/native/win32}/InternetExplorerDriver.dll +0 -0
  34. data/lib/selenium/webdriver/ie/native/x64/InternetExplorerDriver.dll +0 -0
  35. data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/util.rb +0 -0
  36. data/{common/src/rb/lib → lib}/selenium/webdriver/keys.rb +0 -0
  37. data/{common/src/rb/lib → lib}/selenium/webdriver/navigation.rb +0 -0
  38. data/{common/src/rb/lib → lib}/selenium/webdriver/options.rb +0 -0
  39. data/{common/src/rb/lib → lib}/selenium/webdriver/platform.rb +5 -1
  40. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote.rb +0 -0
  41. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/bridge.rb +0 -0
  42. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/capabilities.rb +0 -0
  43. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/commands.rb +0 -0
  44. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/common.rb +0 -0
  45. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/curb.rb +0 -0
  46. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/default.rb +5 -1
  47. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/response.rb +0 -0
  48. data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/server_error.rb +0 -0
  49. data/{common/src/rb/lib → lib}/selenium/webdriver/target_locator.rb +0 -0
  50. data/{common/src/rb/lib → lib}/selenium/webdriver/timeouts.rb +0 -0
  51. data/lib/selenium/webdriver/zip_helper.rb +30 -0
  52. metadata +73 -214
  53. data/COPYING +0 -204
  54. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  55. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  56. data/chrome/src/extension/background.html +0 -9
  57. data/chrome/src/extension/background.js +0 -1029
  58. data/chrome/src/extension/content_script.js +0 -1488
  59. data/chrome/src/extension/icons/busy.png +0 -0
  60. data/chrome/src/extension/icons/free.png +0 -0
  61. data/chrome/src/extension/manifest-nonwin.json +0 -19
  62. data/chrome/src/extension/manifest-win.json +0 -20
  63. data/chrome/src/extension/utils.js +0 -231
  64. data/common/src/js/abstractcommandprocessor.js +0 -132
  65. data/common/src/js/asserts.js +0 -296
  66. data/common/src/js/by.js +0 -149
  67. data/common/src/js/command.js +0 -380
  68. data/common/src/js/core/Blank.html +0 -7
  69. data/common/src/js/core/InjectedRemoteRunner.html +0 -8
  70. data/common/src/js/core/RemoteRunner.html +0 -101
  71. data/common/src/js/core/SeleniumLog.html +0 -109
  72. data/common/src/js/core/TestPrompt.html +0 -145
  73. data/common/src/js/core/TestRunner-splash.html +0 -55
  74. data/common/src/js/core/TestRunner.html +0 -165
  75. data/common/src/js/core/icons/all.png +0 -0
  76. data/common/src/js/core/icons/continue.png +0 -0
  77. data/common/src/js/core/icons/continue_disabled.png +0 -0
  78. data/common/src/js/core/icons/pause.png +0 -0
  79. data/common/src/js/core/icons/pause_disabled.png +0 -0
  80. data/common/src/js/core/icons/selected.png +0 -0
  81. data/common/src/js/core/icons/step.png +0 -0
  82. data/common/src/js/core/icons/step_disabled.png +0 -0
  83. data/common/src/js/core/lib/cssQuery/cssQuery-p.js +0 -6
  84. data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +0 -142
  85. data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +0 -150
  86. data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +0 -53
  87. data/common/src/js/core/lib/cssQuery/src/cssQuery.js +0 -356
  88. data/common/src/js/core/lib/prototype.js +0 -2006
  89. data/common/src/js/core/lib/scriptaculous/builder.js +0 -101
  90. data/common/src/js/core/lib/scriptaculous/controls.js +0 -815
  91. data/common/src/js/core/lib/scriptaculous/dragdrop.js +0 -915
  92. data/common/src/js/core/lib/scriptaculous/effects.js +0 -958
  93. data/common/src/js/core/lib/scriptaculous/scriptaculous.js +0 -47
  94. data/common/src/js/core/lib/scriptaculous/slider.js +0 -283
  95. data/common/src/js/core/lib/scriptaculous/unittest.js +0 -383
  96. data/common/src/js/core/lib/snapsie.js +0 -91
  97. data/common/src/js/core/scripts/find_matching_child.js +0 -69
  98. data/common/src/js/core/scripts/htmlutils.js +0 -8716
  99. data/common/src/js/core/scripts/injection.html +0 -72
  100. data/common/src/js/core/scripts/selenium-api.js +0 -3291
  101. data/common/src/js/core/scripts/selenium-browserbot.js +0 -2457
  102. data/common/src/js/core/scripts/selenium-browserdetect.js +0 -153
  103. data/common/src/js/core/scripts/selenium-commandhandlers.js +0 -379
  104. data/common/src/js/core/scripts/selenium-executionloop.js +0 -175
  105. data/common/src/js/core/scripts/selenium-logging.js +0 -148
  106. data/common/src/js/core/scripts/selenium-remoterunner.js +0 -695
  107. data/common/src/js/core/scripts/selenium-testrunner.js +0 -1362
  108. data/common/src/js/core/scripts/selenium-version.js +0 -5
  109. data/common/src/js/core/scripts/ui-doc.html +0 -808
  110. data/common/src/js/core/scripts/ui-element.js +0 -1644
  111. data/common/src/js/core/scripts/ui-map-sample.js +0 -979
  112. data/common/src/js/core/scripts/user-extensions.js +0 -3
  113. data/common/src/js/core/scripts/user-extensions.js.sample +0 -75
  114. data/common/src/js/core/scripts/xmlextras.js +0 -153
  115. data/common/src/js/core/selenium-logo.png +0 -0
  116. data/common/src/js/core/selenium-test.css +0 -43
  117. data/common/src/js/core/selenium.css +0 -316
  118. data/common/src/js/core/xpath/dom.js +0 -566
  119. data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +0 -2816
  120. data/common/src/js/core/xpath/util.js +0 -549
  121. data/common/src/js/core/xpath/xmltoken.js +0 -149
  122. data/common/src/js/core/xpath/xpath.js +0 -2481
  123. data/common/src/js/extension/README +0 -2
  124. data/common/src/js/extension/dommessenger.js +0 -152
  125. data/common/src/js/factory.js +0 -55
  126. data/common/src/js/future.js +0 -141
  127. data/common/src/js/jsunit.js +0 -40
  128. data/common/src/js/jsunit/app/css/jsUnitStyle.css +0 -50
  129. data/common/src/js/jsunit/app/css/readme +0 -10
  130. data/common/src/js/jsunit/app/emptyPage.html +0 -11
  131. data/common/src/js/jsunit/app/jsUnitCore.js +0 -534
  132. data/common/src/js/jsunit/app/jsUnitMockTimeout.js +0 -81
  133. data/common/src/js/jsunit/app/jsUnitTestManager.js +0 -705
  134. data/common/src/js/jsunit/app/jsUnitTestSuite.js +0 -44
  135. data/common/src/js/jsunit/app/jsUnitTracer.js +0 -102
  136. data/common/src/js/jsunit/app/jsUnitVersionCheck.js +0 -59
  137. data/common/src/js/jsunit/app/main-counts-errors.html +0 -12
  138. data/common/src/js/jsunit/app/main-counts-failures.html +0 -13
  139. data/common/src/js/jsunit/app/main-counts-runs.html +0 -13
  140. data/common/src/js/jsunit/app/main-counts.html +0 -21
  141. data/common/src/js/jsunit/app/main-data.html +0 -178
  142. data/common/src/js/jsunit/app/main-errors.html +0 -23
  143. data/common/src/js/jsunit/app/main-frame.html +0 -19
  144. data/common/src/js/jsunit/app/main-loader.html +0 -45
  145. data/common/src/js/jsunit/app/main-progress.html +0 -25
  146. data/common/src/js/jsunit/app/main-results.html +0 -67
  147. data/common/src/js/jsunit/app/main-status.html +0 -13
  148. data/common/src/js/jsunit/app/testContainer.html +0 -16
  149. data/common/src/js/jsunit/app/testContainerController.html +0 -77
  150. data/common/src/js/jsunit/app/xbDebug.js +0 -306
  151. data/common/src/js/jsunit/changelog.txt +0 -60
  152. data/common/src/js/jsunit/css/jsUnitStyle.css +0 -83
  153. data/common/src/js/jsunit/images/green.gif +0 -0
  154. data/common/src/js/jsunit/images/logo_jsunit.gif +0 -0
  155. data/common/src/js/jsunit/images/powerby-transparent.gif +0 -0
  156. data/common/src/js/jsunit/images/red.gif +0 -0
  157. data/common/src/js/jsunit/licenses/JDOM_license.txt +0 -56
  158. data/common/src/js/jsunit/licenses/Jetty_license.html +0 -213
  159. data/common/src/js/jsunit/licenses/MPL-1.1.txt +0 -470
  160. data/common/src/js/jsunit/licenses/gpl-2.txt +0 -340
  161. data/common/src/js/jsunit/licenses/index.html +0 -141
  162. data/common/src/js/jsunit/licenses/lgpl-2.1.txt +0 -504
  163. data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +0 -35
  164. data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +0 -35
  165. data/common/src/js/jsunit/readme.txt +0 -19
  166. data/common/src/js/jsunit/testRunner.html +0 -167
  167. data/common/src/js/jsunit/version.txt +0 -1
  168. data/common/src/js/key.js +0 -117
  169. data/common/src/js/localcommandprocessor.js +0 -171
  170. data/common/src/js/testcase.js +0 -219
  171. data/common/src/js/timing.js +0 -89
  172. data/common/src/js/webdriver.js +0 -860
  173. data/common/src/js/webelement.js +0 -483
  174. data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
  175. data/firefox/prebuilt/amd64/libnoblur64.so +0 -0
  176. data/firefox/prebuilt/i386/libnoblur.so +0 -0
  177. data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
  178. data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
  179. data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
  180. data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
  181. data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
  182. data/firefox/src/extension/chrome.manifest +0 -3
  183. data/firefox/src/extension/components/badCertListener.js +0 -295
  184. data/firefox/src/extension/components/dispatcher.js +0 -495
  185. data/firefox/src/extension/components/driver-component.js +0 -130
  186. data/firefox/src/extension/components/errorcode.js +0 -70
  187. data/firefox/src/extension/components/firefoxDriver.js +0 -831
  188. data/firefox/src/extension/components/json2.js +0 -273
  189. data/firefox/src/extension/components/keytest.html +0 -554
  190. data/firefox/src/extension/components/nsCommandProcessor.js +0 -684
  191. data/firefox/src/extension/components/promptService.js +0 -208
  192. data/firefox/src/extension/components/request.js +0 -219
  193. data/firefox/src/extension/components/response.js +0 -276
  194. data/firefox/src/extension/components/screenshooter.js +0 -81
  195. data/firefox/src/extension/components/session.js +0 -314
  196. data/firefox/src/extension/components/sessionstore.js +0 -226
  197. data/firefox/src/extension/components/socketListener.js +0 -435
  198. data/firefox/src/extension/components/utils.js +0 -1335
  199. data/firefox/src/extension/components/webLoadingListener.js +0 -57
  200. data/firefox/src/extension/components/webdriverserver.js +0 -110
  201. data/firefox/src/extension/components/wrappedElement.js +0 -706
  202. data/firefox/src/extension/content/fxdriver.xul +0 -30
  203. data/firefox/src/extension/content/server.js +0 -95
  204. data/firefox/src/extension/idl/nsICommandProcessor.idl +0 -38
  205. data/firefox/src/extension/idl/nsIResponseHandler.idl +0 -34
  206. data/firefox/src/extension/install.rdf +0 -29
  207. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
@@ -1,684 +0,0 @@
1
- /*
2
- Copyright 2007-2009 WebDriver committers
3
- Copyright 2007-2009 Google Inc.
4
- Portions copyright 2007 ThoughtWorks, Inc
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License");
7
- you may not use this file except in compliance with the License.
8
- You may obtain a copy of the License at
9
-
10
- http://www.apache.org/licenses/LICENSE-2.0
11
-
12
- Unless required by applicable law or agreed to in writing, software
13
- distributed under the License is distributed on an "AS IS" BASIS,
14
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific language governing permissions and
16
- limitations under the License.
17
- */
18
-
19
- /**
20
- * @fileOverview Contains a Javascript implementation for
21
- * nsICommandProcessor.idl. The implemented XPCOM component is exposed to
22
- * the content page as a global property so that it can be used from
23
- * unpriviledged code.
24
- */
25
-
26
-
27
- /**
28
- * When this component is loaded, load the necessary subscripts.
29
- */
30
- (function() {
31
- var scripts = [
32
- 'errorcode.js',
33
- 'utils.js'
34
- ];
35
-
36
- // Firefox 3.5+ has native JSON support; prefer that over our script from
37
- // www.json.org, which may be slower.
38
- var appInfo = Components.classes['@mozilla.org/xre/app-info;1'].
39
- getService(Components.interfaces.nsIXULAppInfo);
40
- var versionChecker = Components.classes['@mozilla.org/xpcom/version-comparator;1'].
41
- getService(Components.interfaces.nsIVersionComparator);
42
- if (versionChecker.compare(appInfo.version, '3.5') < 0) {
43
- scripts.push('json2.js');
44
- }
45
-
46
- var fileProtocolHandler = Components.
47
- classes['@mozilla.org/network/protocol;1?name=file'].
48
- createInstance(Components.interfaces.nsIFileProtocolHandler);
49
- var loader = Components.classes['@mozilla.org/moz/jssubscript-loader;1'].
50
- createInstance(Components.interfaces.mozIJSSubScriptLoader);
51
-
52
- for (var script in scripts) {
53
- var file = __LOCATION__.parent.clone();
54
- file.append(scripts[script]);
55
-
56
- var fileName = fileProtocolHandler.getURLSpecFromFile(file);
57
- loader.loadSubScript(fileName);
58
- }
59
- })();
60
-
61
-
62
- /**
63
- * Encapsulates the result of a command to the {@code nsCommandProcessor}.
64
- * @param {Object} command JSON object describing the command to execute.
65
- * @param {nsIResponseHandler} responseHandler The handler to send the response
66
- * to.
67
- * @constructor
68
- */
69
- var Response = function(command, responseHandler) {
70
- this.statusBarLabel_ = null;
71
- this.responseHandler_ = responseHandler;
72
- this.json_ = {
73
- name: command ? command.name : 'Unknown command',
74
- sessionId: command['sessionId'],
75
- status: ErrorCode.SUCCESS,
76
- value: ''
77
- };
78
- if (this.json_['sessionId'] && this.json_['sessionId']['value']) {
79
- this.json_['sessionId'] = this.json_['sessionId']['value'];
80
- }
81
- this.session = null;
82
- };
83
-
84
- Response.prototype = {
85
-
86
- /**
87
- * Updates the extension status label to indicate we are about to execute a
88
- * command.
89
- * @param {window} win The content window that the command will be executed on.
90
- */
91
- startCommand: function(win) {
92
- this.statusBarLabel_ = win.document.getElementById("fxdriver-label");
93
- if (this.statusBarLabel_) {
94
- this.statusBarLabel_.style.color = "red";
95
- }
96
- },
97
-
98
- /**
99
- * Sends the encapsulated response to the registered callback.
100
- */
101
- send: function() {
102
- if (this.responseSent_) {
103
- // We shouldn't ever send the same response twice.
104
- return;
105
- }
106
- // Indicate that we are no longer executing a command.
107
- if (this.statusBarLabel_) {
108
- this.statusBarLabel_.style.color = 'black';
109
- }
110
-
111
- this.responseHandler_.handleResponse(JSON.stringify(this.json_));
112
-
113
- // Neuter ourselves
114
- this.responseSent_ = true;
115
- },
116
-
117
- /**
118
- * Sends a WebDriver error response.
119
- * @param {WebDriverError} e The error to send.
120
- */
121
- sendError: function(e) {
122
- // if (e instanceof WebDriverError) won't work here since
123
- // WebDriverError is defined in the utils.js subscript which is
124
- // loaded independently in this component and in the main driver
125
- // component.
126
- this.status = e.isWebDriverError ? e.code : ErrorCode.UNHANDLED_ERROR;
127
- this.value = ErrorCode.toJSON(e);
128
- this.send();
129
- },
130
-
131
- set name(name) { this.json_.name = name; },
132
- get name() { return this.json_.name; },
133
- set status(newStatus) { this.json_.status = newStatus; },
134
- get status() { return this.json_.status; },
135
- set value(val) { this.json_.value = val; },
136
- get value() { return this.json_.value; }
137
- };
138
-
139
-
140
- /**
141
- * Handles executing a command from the {@code CommandProcessor} once the window
142
- * has fully loaded.
143
- * @param {FirefoxDriver} driver The FirefoxDriver instance to execute the
144
- * command with.
145
- * @param {Object} command JSON object describing the command to execute.
146
- * @param {Response} response The response object to send the command response
147
- * in.
148
- * @param {Number} opt_sleepDelay The amount of time to wait before attempting
149
- * the command again if the window is not ready.
150
- * @constructor
151
- */
152
- var DelayedCommand = function(driver, command, response, opt_sleepDelay) {
153
- this.driver_ = driver;
154
- this.command_ = command;
155
- this.response_ = response;
156
- this.onBlank_ = false;
157
- this.sleepDelay_ = opt_sleepDelay || DelayedCommand.DEFAULT_SLEEP_DELAY;
158
-
159
- var activeWindow = response.session.getWindow();
160
- try {
161
- var webNav = activeWindow.
162
- QueryInterface(Components.interfaces.nsIInterfaceRequestor).
163
- getInterface(Components.interfaces.nsIWebNavigation);
164
- this.loadGroup_ = webNav.
165
- QueryInterface(Components.interfaces.nsIInterfaceRequestor).
166
- getInterface(Components.interfaces.nsILoadGroup);
167
- } catch (ex) {
168
- // Well this sucks. This can happen if the DOM gets trashed or if the window
169
- // is unexpectedly closed. We need to report this error to the user so they
170
- // can let us (webdriver-eng) know that the FirefoxDriver is busted.
171
- response.sendError(ex);
172
- // Re-throw the error so the command will be aborted.
173
- throw ex;
174
- }
175
- };
176
-
177
-
178
- /**
179
- * Default amount of time, in milliseconds, to wait before (re)attempting a
180
- * {@code DelayedCommand}.
181
- * @type {Number}
182
- */
183
- DelayedCommand.DEFAULT_SLEEP_DELAY = 100;
184
-
185
-
186
- /**
187
- * Executes the command after the specified delay.
188
- * @param {Number} ms The delay in milliseconds.
189
- */
190
- DelayedCommand.prototype.execute = function(ms) {
191
- var self = this;
192
- this.driver_.window.setTimeout(function() {
193
- self.executeInternal_();
194
- }, ms);
195
- };
196
-
197
-
198
- /**
199
- * @return {boolean} Whether this instance should delay execution of its
200
- * command for a pending request in the current window's nsILoadGroup.
201
- */
202
- DelayedCommand.prototype.shouldDelayExecutionForPendingRequest_ = function() {
203
- try {
204
- if (this.loadGroup_.isPending()) {
205
- var hasOnLoadBlocker = false;
206
- var numPending = 0;
207
- var requests = this.loadGroup_.requests;
208
- while (requests.hasMoreElements()) {
209
- var request =
210
- requests.getNext().QueryInterface(Components.interfaces.nsIRequest);
211
- if (request.isPending()) {
212
- numPending += 1;
213
- hasOnLoadBlocker = hasOnLoadBlocker ||
214
- (request.name == 'about:document-onload-blocker');
215
-
216
- if (numPending > 1) {
217
- // More than one pending request, need to wait.
218
- return true;
219
- }
220
- }
221
- }
222
-
223
- if (numPending && !hasOnLoadBlocker) {
224
- Utils.dumpn('Ignoring pending about:document-onload-blocker request');
225
- // If we only have one pending request and it is not a
226
- // document-onload-blocker, we need to wait. We do not wait for
227
- // document-onload-blocker requests since these are created when
228
- // one of document.[open|write|writeln] is called. If document.close is
229
- // never called, the document-onload-blocker request will not be
230
- // completed.
231
- return true;
232
- }
233
- }
234
- } catch(e) {
235
- Utils.dumpn('Problem while checking if we should delay execution: ' + e);
236
- return true;
237
- }
238
-
239
- return false;
240
- };
241
-
242
-
243
- /**
244
- * Attempts to execute the command. If the window is not ready for the command
245
- * to execute, will set a timeout to try again.
246
- * @private
247
- */
248
- DelayedCommand.prototype.executeInternal_ = function() {
249
- if (this.shouldDelayExecutionForPendingRequest_()) {
250
- return this.execute(this.sleepDelay_);
251
- }
252
-
253
- // Ugh! New windows open on "about:blank" before going to their
254
- // destination URL. This check attempts to tell the difference between a
255
- // newly opened window and someone actually wanting to do something on
256
- // about:blank.
257
- if (this.driver_.window.location == 'about:blank' && !this.onBlank_) {
258
- this.onBlank_ = true;
259
- return this.execute(this.sleepDelay_);
260
- } else {
261
- try {
262
- this.response_.name = this.command_.name;
263
- // TODO(simon): This is rampantly ugly, but allows an alert to kill the command
264
- // TODO(simon): This is never cleared, but _should_ be okay, because send wipes itself
265
- this.driver_.response_ = this.response_;
266
-
267
- this.driver_[this.command_.name](
268
- this.response_, this.command_.parameters);
269
- } catch (e) {
270
- if (!e.isWebDriverError) {
271
- Utils.dumpn(
272
- 'Exception caught by driver: ' + this.command_.name +
273
- '(' + this.command_.parameters + ')\n' + e);
274
- }
275
- this.response_.sendError(e);
276
- }
277
- }
278
- };
279
-
280
-
281
- /**
282
- * Class for dispatching WebDriver requests. Handles window locating commands
283
- * (e.g. switching, searching, etc.), all other commands are executed with the
284
- * {@code FirefoxDriver} through reflection. Note this is a singleton class.
285
- * @constructor
286
- */
287
- var nsCommandProcessor = function() {
288
- this.wrappedJSObject = this;
289
- this.wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].
290
- getService(Components.interfaces.nsIWindowMediator);
291
- };
292
-
293
- /**
294
- * Flags for the {@code nsIClassInfo} interface.
295
- * @type {Number}
296
- */
297
- nsCommandProcessor.prototype.flags =
298
- Components.interfaces.nsIClassInfo.DOM_OBJECT;
299
-
300
- /**
301
- * Implementaiton language detail for the {@code nsIClassInfo} interface.
302
- * @type {String}
303
- */
304
- nsCommandProcessor.prototype.implementationLanguage =
305
- Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT;
306
-
307
-
308
- /**
309
- * Logs a message to the Console Service and then throws an error.
310
- * @param {String} message The message to log.
311
- * @throws {Components.results.NS_ERROR_FAILURE}
312
- */
313
- nsCommandProcessor.logError = function(message) {
314
- // TODO(jleyba): This should log an error and not a generic message.
315
- Utils.dumpn(message);
316
- throw Components.results.NS_ERROR_FAILURE;
317
- };
318
-
319
-
320
- /**
321
- * Processes a command request for the {@code FirefoxDriver}.
322
- * @param {string} jsonCommandString The command to execute, specified in a
323
- * JSON string.
324
- * @param {nsIResponseHandler} responseHandler The callback to send the response
325
- * to.
326
- */
327
- nsCommandProcessor.prototype.execute = function(jsonCommandString,
328
- responseHandler) {
329
- var command, response;
330
- try {
331
- command = JSON.parse(jsonCommandString);
332
- } catch (ex) {
333
- response = JSON.stringify({
334
- 'status': ErrorCode.UNHANDLED_ERROR,
335
- 'value': 'Error parsing command: "' + jsonCommandString + '"'
336
- });
337
- responseHandler.handleResponse(response);
338
- return;
339
- }
340
-
341
- response = new Response(command, responseHandler);
342
-
343
- // These commands do not require a session.
344
- if (command.name == 'newSession' ||
345
- command.name == 'quit' ||
346
- command.name == 'getWindowHandles') {
347
- try {
348
- this[command.name](response, command.parameters);
349
- } catch (ex) {
350
- response.sendError(ex);
351
- }
352
- return;
353
- }
354
-
355
- var sessionId = command.sessionId;
356
- if (!sessionId) {
357
- response.sendError(new WebDriverError(ErrorCode.UNHANDLED_ERROR,
358
- 'No session ID specified'));
359
- return;
360
- }
361
-
362
- sessionId = sessionId.value;
363
- try {
364
- response.session = Components.
365
- classes['@googlecode.com/webdriver/wdsessionstoreservice;1'].
366
- getService(Components.interfaces.nsISupports).
367
- wrappedJSObject.
368
- getSession(sessionId).
369
- wrappedJSObject;
370
- } catch (ex) {
371
- response.sendError(new WebDriverError(ErrorCode.UNHANDLED_ERROR,
372
- 'Session not found: ' + sessionId));
373
- return;
374
- }
375
-
376
- if (command.name == 'deleteSession' ||
377
- command.name == 'getSessionCapabilities' ||
378
- command.name == 'switchToWindow') {
379
- return this[command.name](response, command.parameters);
380
- }
381
-
382
- var sessionWindow = response.session.getChromeWindow();
383
- var driver = sessionWindow.fxdriver; // TODO(jmleyba): We only need to store an ID on the window!
384
- if (!driver) {
385
- response.sendError(new WebDriverError(ErrorCode.UNHANDLED_ERROR,
386
- 'Session has no driver: ' + response.session.getId()));
387
- return;
388
- }
389
-
390
- if (typeof driver[command.name] != 'function') {
391
- response.sendError(new WebDriverError(ErrorCode.UNKNOWN_COMMAND,
392
- 'Unrecognised command: ' + command.name));
393
- return;
394
- }
395
-
396
- response.startCommand(sessionWindow);
397
- new DelayedCommand(driver, command, response).execute(0);
398
- };
399
-
400
-
401
- /**
402
- * Changes the context of the caller to the specified window.
403
- * @param {Response} response The response object to send the command response
404
- * in.
405
- * @param {{name: string}} parameters The command parameters.
406
- * @param {number} opt_searchAttempt Which attempt this is at finding the
407
- * window to switch to.
408
- */
409
- nsCommandProcessor.prototype.switchToWindow = function(response, parameters,
410
- opt_searchAttempt) {
411
- var lookFor = parameters.name;
412
- var matches = function(win, lookFor) {
413
- return !win.closed &&
414
- (win.content && win.content.name == lookFor) ||
415
- (win.top && win.top.fxdriver && win.top.fxdriver.id == lookFor);
416
- };
417
-
418
- var windowFound = this.searchWindows_('navigator:browser', function(win) {
419
- if (matches(win, lookFor)) {
420
- // Create a switch indicator file so the native events library
421
- // will know a window switch is in progress and will indeed
422
- // switch focus.
423
- createSwitchFile("switch:" + win.fxdriver.id);
424
-
425
- win.focus();
426
- if (win.top.fxdriver) {
427
- response.session.setChromeWindow(win.top);
428
- response.value = response.session.getId();
429
- response.send();
430
- } else {
431
- response.sendError(new WebDriverError(ErrorCode.UNHANDLED_ERROR,
432
- 'No driver found attached to top window!'));
433
- }
434
- // Found the desired window, stop the search.
435
- return true;
436
- }
437
- });
438
-
439
- // It is possible that the window won't be found on the first attempt. This is
440
- // typically true for anchors with a target attribute set. This search could
441
- // execute before the target window has finished loaded, meaning the content
442
- // window won't have a name or FirefoxDriver instance yet (see matches above).
443
- // If we don't find the window, set a timeout and try again.
444
- if (!windowFound) {
445
- // TODO(jmleyba): We should be sniffing the current windows to detect if
446
- // one is still loading vs. a brute force "try again"
447
- var searchAttempt = opt_searchAttempt || 0;
448
- if (searchAttempt > 3) {
449
- response.sendError(new WebDriverError(ErrorCode.NO_SUCH_WINDOW,
450
- 'Unable to locate window "' + lookFor + '"'));
451
- } else {
452
- var self = this;
453
- this.wm.getMostRecentWindow('navigator:browser').
454
- setTimeout(function() {
455
- self.switchToWindow(response, parameters, (searchAttempt + 1));
456
- }, 500);
457
- }
458
- }
459
- };
460
-
461
-
462
- /**
463
- * Retrieves a list of all known FirefoxDriver windows.
464
- * @param {Response} response The response object to send the command response
465
- * in.
466
- */
467
- nsCommandProcessor.prototype.getWindowHandles = function(response) {
468
- var res = [];
469
- this.searchWindows_('navigator:browser', function(win) {
470
- if (win.top && win.top.fxdriver) {
471
- res.push(win.top.fxdriver.id);
472
- } else if (win.content) {
473
- res.push(win.content.name);
474
- }
475
- });
476
- response.value = res;
477
- response.send();
478
- };
479
-
480
-
481
- /**
482
- * Searches over a selection of windows, calling a visitor function on each
483
- * window found in the search.
484
- * @param {?string} search_criteria The category of windows to search or
485
- * {@code null} to search all windows.
486
- * @param {function} visitor_fn A visitor function to call with each window. The
487
- * function may return true to indicate that the window search should abort
488
- * early.
489
- * @return {boolean} Whether the visitor function short circuited the search.
490
- */
491
- nsCommandProcessor.prototype.searchWindows_ = function(search_criteria,
492
- visitor_fn) {
493
- var allWindows = this.wm.getEnumerator(search_criteria);
494
- while (allWindows.hasMoreElements()) {
495
- var win = allWindows.getNext();
496
- if (visitor_fn(win)) {
497
- return true;
498
- }
499
- }
500
- return false;
501
- };
502
-
503
-
504
- /**
505
- * Locates the most recently used FirefoxDriver window.
506
- * @param {Response} response The object to send the command response in.
507
- */
508
- nsCommandProcessor.prototype.newSession = function(response) {
509
- var win = this.wm.getMostRecentWindow("navigator:browser");
510
- var driver = win.fxdriver;
511
- if (!driver) {
512
- response.sendError(new WebDriverError(ErrorCode.UNHANDLED_ERROR,
513
- 'No drivers associated with the window'));
514
- } else {
515
- var sessionStore = Components.
516
- classes['@googlecode.com/webdriver/wdsessionstoreservice;1'].
517
- getService(Components.interfaces.nsISupports);
518
-
519
- var session = sessionStore.wrappedJSObject.createSession();
520
- session = session.wrappedJSObject; // XPConnect...
521
- session.setChromeWindow(win);
522
-
523
- response.session = session;
524
- response.value = session.getId();
525
- }
526
- response.send();
527
- };
528
-
529
-
530
- /**
531
- * Describes a session.
532
- * @param {Response} response The object to send the command response in.
533
- */
534
- nsCommandProcessor.prototype.getSessionCapabilities = function(response) {
535
- var appInfo = Components.classes['@mozilla.org/xre/app-info;1'].
536
- getService(Components.interfaces.nsIXULAppInfo);
537
- var xulRuntime = Components.classes['@mozilla.org/xre/app-info;1'].
538
- getService(Components.interfaces.nsIXULRuntime);
539
- response.value = {
540
- 'browserName': 'firefox',
541
- 'version': appInfo.version,
542
- 'javascriptEnabled': true,
543
- 'platform': xulRuntime.OS, // same as Platform.valueOf("name");
544
- 'cssSelectorsEnabled': true,
545
- 'takesScreenshot': true
546
- };
547
- response.send();
548
- };
549
-
550
-
551
- /**
552
- * Deletes the session associated with the current request.
553
- * @param {Response} response The object to send the command response in.
554
- */
555
- nsCommandProcessor.prototype.deleteSession = function(response) {
556
- var sessionStore = Components.
557
- classes['@googlecode.com/webdriver/wdsessionstoreservice;1'].
558
- getService(Components.interfaces.nsISupports);
559
- sessionStore.wrappedJSObject.deleteSession(response.session.getId());
560
- response.send();
561
- };
562
-
563
-
564
- /**
565
- * Forcefully shuts down the Firefox application.
566
- * @param {Response} response The object to send the command response in.
567
- */
568
- nsCommandProcessor.prototype.quit = function(response) {
569
- // Go ahead and respond to the command request to acknowledge that we are
570
- // shutting down. We do this because once we force a quit, there's no way
571
- // to respond. Clients will just have to trust that this shutdown didn't
572
- // fail. Or they could monitor the PID. Either way, not much we can do about
573
- // it in here.
574
- response.send();
575
-
576
- // Use an nsITimer to give the response time to go out.
577
- var event = {
578
- notify: function(timer) {
579
- // Create a switch file so the native events library will
580
- // let all events through in case of a close.
581
- createSwitchFile("close:<ALL>");
582
- Components.classes['@mozilla.org/toolkit/app-startup;1'].
583
- getService(Components.interfaces.nsIAppStartup).
584
- quit(Components.interfaces.nsIAppStartup.eForceQuit);
585
- }
586
- };
587
-
588
- var timer = Components.classes['@mozilla.org/timer;1'].
589
- createInstance(Components.interfaces.nsITimer);
590
- timer.initWithCallback(event, 500, // milliseconds
591
- Components.interfaces.nsITimer.TYPE_ONE_SHOT);
592
- };
593
-
594
-
595
- nsCommandProcessor.prototype.getInterfaces = function(count) {
596
- var ifaces = [
597
- Components.interfaces.nsICommandProcessor,
598
- Components.interfaces.nsISupports
599
- ];
600
- count.value = ifaces.length;
601
- return ifaces;
602
- };
603
-
604
-
605
- nsCommandProcessor.prototype.QueryInterface = function (aIID) {
606
- if (!aIID.equals(Components.interfaces.nsICommandProcessor) &&
607
- !aIID.equals(Components.interfaces.nsISupports)) {
608
- throw Components.results.NS_ERROR_NO_INTERFACE;
609
- }
610
- return this;
611
- };
612
-
613
-
614
- nsCommandProcessor.CLASS_ID =
615
- Components.ID('{692e5117-a4a2-4b00-99f7-0685285b4db5}');
616
- nsCommandProcessor.CLASS_NAME = 'Firefox WebDriver CommandProcessor';
617
- nsCommandProcessor.CONTRACT_ID =
618
- '@googlecode.com/webdriver/command-processor;1';
619
-
620
-
621
- /**
622
- * Factory object for obtaining a reference to the singleton instance of
623
- * {@code CommandProcessor}.
624
- */
625
- nsCommandProcessor.Factory = {
626
- instance_ : null,
627
-
628
- createInstance: function(aOuter, aIID) {
629
- if (aOuter != null) {
630
- throw Components.results.NS_ERROR_NO_AGGREGATION;
631
- }
632
- if (!this.instance_) {
633
- this.instance_ = new nsCommandProcessor();
634
- }
635
- return this.instance_.QueryInterface(aIID);
636
- }
637
- };
638
-
639
-
640
- /**
641
- * Module definition for registering this XPCOM component.
642
- */
643
- nsCommandProcessor.Module = {
644
- firstTime_: true,
645
-
646
- registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) {
647
- if (this.firstTime_) {
648
- this.firstTime_ = false;
649
- throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
650
- }
651
- aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar).
652
- registerFactoryLocation(
653
- nsCommandProcessor.CLASS_ID,
654
- nsCommandProcessor.CLASS_NAME,
655
- nsCommandProcessor.CONTRACT_ID,
656
- aFileSpec, aLocation, aType);
657
- },
658
-
659
- unregisterSelf: function(aCompMgr, aLocation) {
660
- aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar).
661
- unregisterFactoryLocation(nsCommandProcessor.CLASS_ID, aLocation);
662
- },
663
-
664
- getClassObject: function(aCompMgr, aCID, aIID) {
665
- if (!aIID.equals(Components.interfaces.nsIFactory)) {
666
- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
667
- } else if (!aCID.equals(nsCommandProcessor.CLASS_ID)) {
668
- throw Components.results.NS_ERROR_NO_INTERFACE;
669
- }
670
- return nsCommandProcessor.Factory;
671
- },
672
-
673
- canUnload: function() {
674
- return true;
675
- }
676
- };
677
-
678
-
679
- /**
680
- * Module initialization.
681
- */
682
- function NSGetModule() {
683
- return nsCommandProcessor.Module;
684
- }