rainux-selenium-webdriver 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/COPYING +204 -0
  2. data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
  3. data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
  4. data/chrome/src/extension/background.html +9 -0
  5. data/chrome/src/extension/background.js +995 -0
  6. data/chrome/src/extension/content_script.js +1321 -0
  7. data/chrome/src/extension/icons/busy.png +0 -0
  8. data/chrome/src/extension/icons/free.png +0 -0
  9. data/chrome/src/extension/manifest-nonwin.json +19 -0
  10. data/chrome/src/extension/manifest-win.json +20 -0
  11. data/chrome/src/extension/utils.js +231 -0
  12. data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +8 -0
  13. data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +358 -0
  14. data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +124 -0
  15. data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +135 -0
  16. data/common/src/js/abstractcommandprocessor.js +134 -0
  17. data/common/src/js/asserts.js +296 -0
  18. data/common/src/js/by.js +149 -0
  19. data/common/src/js/command.js +304 -0
  20. data/common/src/js/context.js +58 -0
  21. data/common/src/js/core/Blank.html +7 -0
  22. data/common/src/js/core/InjectedRemoteRunner.html +8 -0
  23. data/common/src/js/core/RemoteRunner.html +101 -0
  24. data/common/src/js/core/SeleniumLog.html +109 -0
  25. data/common/src/js/core/TestPrompt.html +145 -0
  26. data/common/src/js/core/TestRunner-splash.html +55 -0
  27. data/common/src/js/core/TestRunner.html +165 -0
  28. data/common/src/js/core/icons/all.png +0 -0
  29. data/common/src/js/core/icons/continue.png +0 -0
  30. data/common/src/js/core/icons/continue_disabled.png +0 -0
  31. data/common/src/js/core/icons/pause.png +0 -0
  32. data/common/src/js/core/icons/pause_disabled.png +0 -0
  33. data/common/src/js/core/icons/selected.png +0 -0
  34. data/common/src/js/core/icons/step.png +0 -0
  35. data/common/src/js/core/icons/step_disabled.png +0 -0
  36. data/common/src/js/core/lib/cssQuery/cssQuery-p.js +6 -0
  37. data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +142 -0
  38. data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +150 -0
  39. data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +53 -0
  40. data/common/src/js/core/lib/cssQuery/src/cssQuery.js +356 -0
  41. data/common/src/js/core/lib/prototype.js +2006 -0
  42. data/common/src/js/core/lib/scriptaculous/builder.js +101 -0
  43. data/common/src/js/core/lib/scriptaculous/controls.js +815 -0
  44. data/common/src/js/core/lib/scriptaculous/dragdrop.js +915 -0
  45. data/common/src/js/core/lib/scriptaculous/effects.js +958 -0
  46. data/common/src/js/core/lib/scriptaculous/scriptaculous.js +47 -0
  47. data/common/src/js/core/lib/scriptaculous/slider.js +283 -0
  48. data/common/src/js/core/lib/scriptaculous/unittest.js +383 -0
  49. data/common/src/js/core/lib/snapsie.js +91 -0
  50. data/common/src/js/core/scripts/find_matching_child.js +69 -0
  51. data/common/src/js/core/scripts/htmlutils.js +8716 -0
  52. data/common/src/js/core/scripts/injection.html +72 -0
  53. data/common/src/js/core/scripts/selenium-api.js +3291 -0
  54. data/common/src/js/core/scripts/selenium-browserbot.js +2457 -0
  55. data/common/src/js/core/scripts/selenium-browserdetect.js +153 -0
  56. data/common/src/js/core/scripts/selenium-commandhandlers.js +379 -0
  57. data/common/src/js/core/scripts/selenium-executionloop.js +175 -0
  58. data/common/src/js/core/scripts/selenium-logging.js +148 -0
  59. data/common/src/js/core/scripts/selenium-remoterunner.js +695 -0
  60. data/common/src/js/core/scripts/selenium-testrunner.js +1362 -0
  61. data/common/src/js/core/scripts/selenium-version.js +5 -0
  62. data/common/src/js/core/scripts/ui-doc.html +808 -0
  63. data/common/src/js/core/scripts/ui-element.js +1644 -0
  64. data/common/src/js/core/scripts/ui-map-sample.js +979 -0
  65. data/common/src/js/core/scripts/user-extensions.js +3 -0
  66. data/common/src/js/core/scripts/user-extensions.js.sample +75 -0
  67. data/common/src/js/core/scripts/xmlextras.js +153 -0
  68. data/common/src/js/core/selenium-logo.png +0 -0
  69. data/common/src/js/core/selenium-test.css +43 -0
  70. data/common/src/js/core/selenium.css +316 -0
  71. data/common/src/js/core/xpath/dom.js +566 -0
  72. data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +2816 -0
  73. data/common/src/js/core/xpath/util.js +549 -0
  74. data/common/src/js/core/xpath/xmltoken.js +149 -0
  75. data/common/src/js/core/xpath/xpath.js +2481 -0
  76. data/common/src/js/extension/README +2 -0
  77. data/common/src/js/extension/dommessenger.js +152 -0
  78. data/common/src/js/factory.js +55 -0
  79. data/common/src/js/future.js +141 -0
  80. data/common/src/js/jsunit.js +40 -0
  81. data/common/src/js/jsunit/app/css/jsUnitStyle.css +50 -0
  82. data/common/src/js/jsunit/app/css/readme +10 -0
  83. data/common/src/js/jsunit/app/emptyPage.html +11 -0
  84. data/common/src/js/jsunit/app/jsUnitCore.js +534 -0
  85. data/common/src/js/jsunit/app/jsUnitMockTimeout.js +81 -0
  86. data/common/src/js/jsunit/app/jsUnitTestManager.js +705 -0
  87. data/common/src/js/jsunit/app/jsUnitTestSuite.js +44 -0
  88. data/common/src/js/jsunit/app/jsUnitTracer.js +102 -0
  89. data/common/src/js/jsunit/app/jsUnitVersionCheck.js +59 -0
  90. data/common/src/js/jsunit/app/main-counts-errors.html +12 -0
  91. data/common/src/js/jsunit/app/main-counts-failures.html +13 -0
  92. data/common/src/js/jsunit/app/main-counts-runs.html +13 -0
  93. data/common/src/js/jsunit/app/main-counts.html +21 -0
  94. data/common/src/js/jsunit/app/main-data.html +178 -0
  95. data/common/src/js/jsunit/app/main-errors.html +23 -0
  96. data/common/src/js/jsunit/app/main-frame.html +19 -0
  97. data/common/src/js/jsunit/app/main-loader.html +45 -0
  98. data/common/src/js/jsunit/app/main-progress.html +25 -0
  99. data/common/src/js/jsunit/app/main-results.html +67 -0
  100. data/common/src/js/jsunit/app/main-status.html +13 -0
  101. data/common/src/js/jsunit/app/testContainer.html +16 -0
  102. data/common/src/js/jsunit/app/testContainerController.html +77 -0
  103. data/common/src/js/jsunit/app/xbDebug.js +306 -0
  104. data/common/src/js/jsunit/changelog.txt +60 -0
  105. data/common/src/js/jsunit/css/jsUnitStyle.css +83 -0
  106. data/common/src/js/jsunit/images/green.gif +0 -0
  107. data/common/src/js/jsunit/images/logo_jsunit.gif +0 -0
  108. data/common/src/js/jsunit/images/powerby-transparent.gif +0 -0
  109. data/common/src/js/jsunit/images/red.gif +0 -0
  110. data/common/src/js/jsunit/licenses/JDOM_license.txt +56 -0
  111. data/common/src/js/jsunit/licenses/Jetty_license.html +213 -0
  112. data/common/src/js/jsunit/licenses/MPL-1.1.txt +470 -0
  113. data/common/src/js/jsunit/licenses/gpl-2.txt +340 -0
  114. data/common/src/js/jsunit/licenses/index.html +141 -0
  115. data/common/src/js/jsunit/licenses/lgpl-2.1.txt +504 -0
  116. data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +35 -0
  117. data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +35 -0
  118. data/common/src/js/jsunit/readme.txt +19 -0
  119. data/common/src/js/jsunit/testRunner.html +167 -0
  120. data/common/src/js/jsunit/version.txt +1 -0
  121. data/common/src/js/key.js +117 -0
  122. data/common/src/js/localcommandprocessor.js +185 -0
  123. data/common/src/js/testcase.js +217 -0
  124. data/common/src/js/timing.js +89 -0
  125. data/common/src/js/webdriver.js +890 -0
  126. data/common/src/js/webelement.js +485 -0
  127. data/common/src/rb/README +30 -0
  128. data/common/src/rb/lib/selenium-webdriver.rb +1 -0
  129. data/common/src/rb/lib/selenium/webdriver.rb +67 -0
  130. data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +91 -0
  131. data/common/src/rb/lib/selenium/webdriver/child_process.rb +180 -0
  132. data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +41 -0
  133. data/common/src/rb/lib/selenium/webdriver/driver.rb +252 -0
  134. data/common/src/rb/lib/selenium/webdriver/driver_extensions/takes_screenshot.rb +24 -0
  135. data/common/src/rb/lib/selenium/webdriver/element.rb +262 -0
  136. data/common/src/rb/lib/selenium/webdriver/error.rb +67 -0
  137. data/common/src/rb/lib/selenium/webdriver/find.rb +89 -0
  138. data/common/src/rb/lib/selenium/webdriver/keys.rb +84 -0
  139. data/common/src/rb/lib/selenium/webdriver/navigation.rb +27 -0
  140. data/common/src/rb/lib/selenium/webdriver/options.rb +50 -0
  141. data/common/src/rb/lib/selenium/webdriver/platform.rb +86 -0
  142. data/common/src/rb/lib/selenium/webdriver/target_locator.rb +70 -0
  143. data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
  144. data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
  145. data/firefox/prebuilt/linux/Release/x_ignore_nofocus.so +0 -0
  146. data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
  147. data/firefox/prebuilt/linux64/Release/x_ignore_nofocus.so +0 -0
  148. data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
  149. data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
  150. data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
  151. data/firefox/src/extension/chrome.manifest +3 -0
  152. data/firefox/src/extension/components/badCertListener.js +294 -0
  153. data/firefox/src/extension/components/context.js +37 -0
  154. data/firefox/src/extension/components/driver-component.js +127 -0
  155. data/firefox/src/extension/components/firefoxDriver.js +810 -0
  156. data/firefox/src/extension/components/json2.js +273 -0
  157. data/firefox/src/extension/components/keytest.html +554 -0
  158. data/firefox/src/extension/components/nsCommandProcessor.js +643 -0
  159. data/firefox/src/extension/components/promptService.js +208 -0
  160. data/firefox/src/extension/components/screenshooter.js +81 -0
  161. data/firefox/src/extension/components/socketListener.js +185 -0
  162. data/firefox/src/extension/components/utils.js +1263 -0
  163. data/firefox/src/extension/components/webLoadingListener.js +57 -0
  164. data/firefox/src/extension/components/webdriverserver.js +106 -0
  165. data/firefox/src/extension/components/wrappedElement.js +683 -0
  166. data/firefox/src/extension/content/fxdriver.xul +30 -0
  167. data/firefox/src/extension/content/server.js +95 -0
  168. data/firefox/src/extension/idl/nsICommandProcessor.idl +38 -0
  169. data/firefox/src/extension/idl/nsIResponseHandler.idl +34 -0
  170. data/firefox/src/extension/install.rdf +29 -0
  171. data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +31 -0
  172. data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +107 -0
  173. data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +484 -0
  174. data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +90 -0
  175. data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +155 -0
  176. data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +233 -0
  177. data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +59 -0
  178. data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +23 -0
  179. data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
  180. data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
  181. data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +14 -0
  182. data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +565 -0
  183. data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +99 -0
  184. data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +147 -0
  185. data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +16 -0
  186. data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +408 -0
  187. data/remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb +105 -0
  188. data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +53 -0
  189. data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +71 -0
  190. data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +49 -0
  191. data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +32 -0
  192. metadata +303 -0
@@ -0,0 +1,2 @@
1
+ This directory contains Javascript files that are used in both the Chrome and
2
+ Firefox extensions.
@@ -0,0 +1,152 @@
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 Messenger service used to communicate with the current web
21
+ * page through custom DOM events.
22
+ *
23
+ * <p>The DomMessenger will listen for {@code webdriverCommand} events on the
24
+ * document. The event target should be a node whose {@code command} attribute
25
+ * is a JSON string with the command to execute.
26
+ *
27
+ * <p>Once the command has been executed, the response will be stored as a JSON
28
+ * string in the {@code response} attribute of the node that dispatched the
29
+ * original {@code webdriverCommand} event. The DomMessenger will then dispatch
30
+ * a {@code webdriverResponse} event on that node to notify the page that a
31
+ * response is ready.
32
+ *
33
+ * @author jmleyba@gmail.com (Jason Leyba)
34
+ */
35
+
36
+
37
+ /**
38
+ * The DomMessenger is used to communicate with the current webpage through
39
+ * custom events fired on the DOM.
40
+ *
41
+ * @param { {execute: function(string, function(string))} } commandProcessor The
42
+ * object to send commands to for execution. The object should have a single
43
+ * method, {@code execute}, that takes two arguments: the command to execute
44
+ * as a JSON string, and a callback for the command response (specified as a
45
+ * JSON string).
46
+ * @constructor
47
+ */
48
+ var DomMessenger = function(commandProcessor) {
49
+
50
+ /**
51
+ * The object to use as a command processor.
52
+ * @type { {execute: function(string, function(string))} }
53
+ * @private
54
+ */
55
+ this.commandProcessor_ = commandProcessor;
56
+
57
+ var self = this; // TODO(jmleyba): bind
58
+
59
+ /**
60
+ * EventListener for {@code COMMAND_EVENT}s.
61
+ * @type {function(Event)}
62
+ * @private
63
+ */
64
+ this.commandEventListener_ = function(e) {
65
+ self.onCommand(e);
66
+ };
67
+ };
68
+
69
+
70
+ /**
71
+ * Attributes used to pass information between the extension and the current
72
+ * web page.
73
+ * @enum {string}
74
+ */
75
+ DomMessenger.Attribute = {
76
+ COMMAND: 'command',
77
+ RESPONSE: 'response'
78
+ };
79
+
80
+
81
+ /**
82
+ * Custom event types used to signal a new message either to or from the current
83
+ * web page.
84
+ * @enum {string}
85
+ */
86
+ DomMessenger.EventType = {
87
+ COMMAND: 'webdriverCommand',
88
+ RESPONSE: 'webdriverResponse'
89
+ };
90
+
91
+
92
+ /**
93
+ * Called when a page loads to
94
+ * Called when a page loads so an element can be injected for communicating with
95
+ * the web page.
96
+ */
97
+ DomMessenger.prototype.onPageLoad = function(e) {
98
+ // Annotate the documentElement to signal to the client that webdriver is
99
+ // installed.
100
+ var doc = e.originalTarget || e.target;
101
+ doc.documentElement.setAttribute('webdriver', true);
102
+ doc.addEventListener(
103
+ DomMessenger.EventType.COMMAND, this.commandEventListener_, true);
104
+ };
105
+
106
+
107
+ /**
108
+ * Called when a page unloads; removes the command event listener.
109
+ * @param {Event} e The unload event, whose target is the document that was
110
+ * unloaded.
111
+ */
112
+ DomMessenger.prototype.onPageUnload = function(e) {
113
+ var doc = e.originalTarget || e.target;
114
+ doc.removeEventListener(
115
+ DomMessenger.EventType.COMMAND, this.commandEventListener_, true);
116
+ };
117
+
118
+
119
+ /**
120
+ * Handles {@code COMMAND_EVENT}s. The command should be stored as a JSON string
121
+ * in the {@code COMMAND_ATTRIBUTE}.
122
+ * @param {Event} e The command event.
123
+ */
124
+ DomMessenger.prototype.onCommand = function(e) {
125
+ var client = e.target;
126
+ var command = client.getAttribute(DomMessenger.Attribute.COMMAND);
127
+
128
+ if (!command) {
129
+ throw Error('No command specified');
130
+ }
131
+
132
+ var self = this; // TODO(jmleyba): bind
133
+ this.commandProcessor_.execute(command, function(response) {
134
+ self.dispatchResponse(client, response);
135
+ });
136
+ };
137
+
138
+
139
+ /**
140
+ * Dispatches a {@code RESPONSE_EVENT} to notify the appropriate page that a
141
+ * command it gave completed execution.
142
+ * @param {Node} client The DOM node that issued the command this response is
143
+ * for.
144
+ * @param {string} response Response to a command as a JSON string.
145
+ */
146
+ DomMessenger.prototype.dispatchResponse = function(client, response) {
147
+ client.setAttribute(DomMessenger.Attribute.RESPONSE, response);
148
+ var evt = client.ownerDocument.createEvent('Event');
149
+ evt.initEvent(DomMessenger.EventType.RESPONSE,
150
+ /*canBubble=*/true, /*cancellable=*/true);
151
+ client.dispatchEvent(evt);
152
+ };
@@ -0,0 +1,55 @@
1
+ /** @license
2
+ Copyright 2007-2009 WebDriver committers
3
+ Copyright 2007-2009 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
+ * @fileoverview Provides factory methods for creating new instances of
20
+ * {@code webdriver.WebDriver}.
21
+ * @author jmleyba@gmail.com (Jason Leyba)
22
+ */
23
+
24
+ goog.provide('webdriver.factory');
25
+
26
+ goog.require('goog.userAgent');
27
+ goog.require('webdriver.LocalCommandProcessor');
28
+ goog.require('webdriver.WebDriver');
29
+
30
+
31
+ /**
32
+ * Creates a new {@code webdriver.WebDriver} instance that uses an
33
+ * {@code webdriver.AbstractCommandProcessor}. This driver will only be able to
34
+ * perform the most basic of commands: sleeping and calling user defined
35
+ * functions.
36
+ * @return {webdriver.WebDriver} A new WebDriver instance.
37
+ */
38
+ webdriver.factory.createAbstractDriver = function() {
39
+ return new webdriver.WebDriver(new webdriver.AbstractCommandProcessor());
40
+ };
41
+
42
+
43
+ /**
44
+ * Creates a new {@code webdriver.WebDriver} instance that uses a
45
+ * CommandProcessor directly accessible to the current JavaScript engine.
46
+ * Currently, only Firefox is supported, but IE and Google Chrome support is
47
+ * planned.
48
+ * TODO(jmleyba): Add support for Internet Explorer and Goolge Chrome.
49
+ * @return {webdriver.WebDriver} A new WebDriver instance.
50
+ * @throws If called from a JavaScript engine that does not have support for a
51
+ * local CommandProcessor.
52
+ */
53
+ webdriver.factory.createLocalWebDriver = function() {
54
+ return new webdriver.WebDriver(new webdriver.LocalCommandProcessor());
55
+ };
@@ -0,0 +1,141 @@
1
+ /** @license
2
+ Copyright 2007-2009 WebDriver committers
3
+ Copyright 2007-2009 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
+ * @fileoverview Defines a class for representing the result of an asynchronous
20
+ * {@code webdriver.Command}.
21
+ * @author jmleyba@gmail.com (Jason Leyba)
22
+ */
23
+
24
+ goog.provide('webdriver.Future');
25
+
26
+ goog.require('goog.Disposable');
27
+ goog.require('goog.array');
28
+
29
+
30
+ /**
31
+ * Represents the result of an asynchronous {@code webdriver.Command}. Methods
32
+ * are provided to check if the result has been set and to retrieve the result.
33
+ * @param {webdriver.WebDriver} driver The WebDriver instance that will
34
+ * eventually set this instance's value.
35
+ * @constructor
36
+ * @extends {goog.Disposable}
37
+ */
38
+ webdriver.Future = function(driver) {
39
+ goog.Disposable.call(this);
40
+
41
+ /**
42
+ * The WebDriver that will eventaully set this instance's value.
43
+ * @type {webdriver.WebDriver}
44
+ * @private
45
+ */
46
+ this.driver_ = driver;
47
+
48
+ /**
49
+ * The value of this Future.
50
+ * @type {*}
51
+ * @private
52
+ */
53
+ this.value_ = webdriver.Future.NOT_SET_;
54
+
55
+ /**
56
+ * Futures whose values are linked to this one. When this future's value is
57
+ * set, all of the linked futures will also be updated.
58
+ * @type {Array.<webdriver.Future>}
59
+ * @private
60
+ */
61
+ this.linkedFutures_ = [];
62
+ };
63
+ goog.inherits(webdriver.Future, goog.Disposable);
64
+
65
+
66
+ /**
67
+ * A special place-holder value used to represent that the result for a future
68
+ * has not been computed yet.
69
+ * @type {Object}
70
+ * @private
71
+ */
72
+ webdriver.Future.NOT_SET_ = {};
73
+
74
+
75
+ /** @override */
76
+ webdriver.Future.prototype.disposeInternal = function() {
77
+ delete this.driver_;
78
+ delete this.value_;
79
+ delete this.linkedFutures_;
80
+ webdriver.Future.superClass_.disposeInternal.call(this);
81
+ };
82
+
83
+
84
+ /**
85
+ * @return {*} The value of this Future.
86
+ * @throws If the value has not been set yet.
87
+ */
88
+ webdriver.Future.prototype.getValue = function() {
89
+ if (this.value_ === webdriver.Future.NOT_SET_) {
90
+ throw new Error('Value has not been set yet');
91
+ }
92
+ return this.value_;
93
+ };
94
+
95
+
96
+ /**
97
+ * @return {webdriver.WebDriver} The WebDriver that set/will set this Future's
98
+ * value.
99
+ */
100
+ webdriver.Future.prototype.getDriver = function() {
101
+ return this.driver_;
102
+ };
103
+
104
+
105
+ /**
106
+ * Sets the value of this Future and dispatches a
107
+ * {@code goog.events.EventType.CHANGE} event. If the given value is another
108
+ * future and its value has not been set, a callback will be registered to
109
+ * set this instance's value when the input future's value is set. Note that
110
+ * the value of a future may only be set once.
111
+ * @param {*} value The new value.
112
+ */
113
+ webdriver.Future.prototype.setValue = function(value) {
114
+ if (this.isSet()) {
115
+ return;
116
+ }
117
+ if (value instanceof webdriver.Future) {
118
+ if (value.isSet()) {
119
+ value = value.getValue();
120
+ this.value_ = value;
121
+ goog.array.forEach(this.linkedFutures_, function(future) {
122
+ future.setValue(value);
123
+ });
124
+ } else {
125
+ value.linkedFutures_.push(this);
126
+ }
127
+ } else {
128
+ this.value_ = value;
129
+ goog.array.forEach(this.linkedFutures_, function(future) {
130
+ future.setValue(value);
131
+ });
132
+ }
133
+ };
134
+
135
+
136
+ /**
137
+ * @return {boolean} Whether this future has had its value set.
138
+ */
139
+ webdriver.Future.prototype.isSet = function() {
140
+ return this.value_ !== webdriver.Future.NOT_SET_;
141
+ };
@@ -0,0 +1,40 @@
1
+ /** @license
2
+ Copyright 2007-2009 WebDriver committers
3
+ Copyright 2007-2009 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
+ * @fileoverview File to include for turnning any HTML page into a WebDriver
20
+ * JSUnit test suite by configuring an onload listener to the body that will
21
+ * instantiate and start the test runner.
22
+ */
23
+
24
+ goog.provide('webdriver.jsunit');
25
+
26
+ goog.require('goog.testing.jsunit');
27
+ goog.require('webdriver.TestCase');
28
+ goog.require('webdriver.asserts');
29
+ goog.require('webdriver.factory');
30
+
31
+
32
+ (function() {
33
+ window.onload = function() {
34
+ var test = new webdriver.TestCase(document.title,
35
+ webdriver.factory.createLocalWebDriver);
36
+ test.autoDiscoverTests();
37
+ G_testRunner.initialize(test);
38
+ G_testRunner.execute(test);
39
+ };
40
+ })();
@@ -0,0 +1,50 @@
1
+ body {
2
+ margin-top: 0;
3
+ margin-bottom: 0;
4
+ font-family: Verdana, Arial, Helvetica, sans-serif;
5
+ color: #000;
6
+ font-size: 0.8em;
7
+ background-color: #fff;
8
+ }
9
+
10
+ a:link, a:visited {
11
+ color: #00F;
12
+ }
13
+
14
+ a:hover {
15
+ color: #F00;
16
+ }
17
+
18
+ h1 {
19
+ font-size: 1.2em;
20
+ font-weight: bold;
21
+ color: #039;
22
+ font-family: Verdana, Arial, Helvetica, sans-serif;
23
+ }
24
+
25
+ h2 {
26
+ font-weight: bold;
27
+ color: #039;
28
+ font-family: Verdana, Arial, Helvetica, sans-serif;
29
+ }
30
+
31
+ h3 {
32
+ font-weight: bold;
33
+ color: #039;
34
+ text-decoration: underline;
35
+ font-family: Verdana, Arial, Helvetica, sans-serif;
36
+ }
37
+
38
+ h4 {
39
+ font-weight: bold;
40
+ color: #039;
41
+ font-family: Verdana, Arial, Helvetica, sans-serif;
42
+ }
43
+
44
+ .jsUnitTestResultSuccess {
45
+ color: #000;
46
+ }
47
+
48
+ .jsUnitTestResultNotSuccess {
49
+ color: #F00;
50
+ }
@@ -0,0 +1,10 @@
1
+ this file is required due to differences in behavior between Mozilla/Opera
2
+ and Internet Explorer.
3
+
4
+ main-data.html calls kickOffTests() which calls top.testManager.start()
5
+ in the top most frame. top.testManager.start() initializes the output
6
+ frames using document.write and HTML containing a relative <link> to the
7
+ jsUnitStyle.css file. In MSIE, the base href used to find the CSS file is
8
+ that of the top level frame however in Mozilla/Opera the base href is
9
+ that of main-data.html. This leads to not-found for the jsUnitStyle.css
10
+ in Mozilla/Opera. Creating app/css/jsUnitStyle.css works around this problem.