rainux-selenium-webdriver 0.0.17

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 (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,208 @@
1
+ // Spoof the prompt service. Interesting thread on mozillazine:
2
+ // http://www.mail-archive.com/dev-tech-xpcom@lists.mozilla.org/msg00193.html
3
+
4
+ const CC = Components.classes;
5
+ const CI = Components.interfaces;
6
+
7
+ const CONSOLE = CC["@mozilla.org/consoleservice;1"].getService(CI["nsIConsoleService"]);
8
+
9
+ function dumpn(message) {
10
+ try {
11
+ CONSOLE.logStringMessage(message + "\n");
12
+ } catch (e) {
13
+ dump(message + "\n");
14
+ }
15
+ }
16
+
17
+ // Spoof implementation
18
+ function DrivenPromptService() {
19
+ // as defined in nsPromptService.h
20
+ var ORIGINAL_PARENT_SERVICE_ID = "{A2112D6A-0E28-421f-B46A-25C0B308CBD0}";
21
+
22
+ // Keep a reference to the original service
23
+ var originalService = Components.classesByID[ORIGINAL_PARENT_SERVICE_ID].getService();
24
+
25
+ this.originalPromptService_ =
26
+ originalService.QueryInterface(Components.interfaces.nsIPromptService);
27
+
28
+ dumpn("Spoofing prompt service");
29
+ }
30
+
31
+ // Constants from nsIPromtService.idl
32
+ DrivenPromptService.prototype = {
33
+ BUTTON_POS_0: 1,
34
+ BUTTON_POS_1: 256,
35
+ BUTTON_POS_2: 65536,
36
+
37
+ // Button Title Flags (used to set the labels of buttons in the prompt)
38
+ BUTTON_TITLE_OK: 1,
39
+ BUTTON_TITLE_CANCEL: 2,
40
+ BUTTON_TITLE_YES: 3,
41
+ BUTTON_TITLE_NO: 4,
42
+ BUTTON_TITLE_SAVE: 5,
43
+ BUTTON_TITLE_DONT_SAVE: 6,
44
+ BUTTON_TITLE_REVERT: 7,
45
+ BUTTON_TITLE_IS_STRING: 127,
46
+
47
+ // Button Default Flags (used to select which button is the default one)
48
+ BUTTON_POS_0_DEFAULT: 0,
49
+ BUTTON_POS_1_DEFAULT: 16777216,
50
+ BUTTON_POS_2_DEFAULT: 33554432,
51
+
52
+ // Causes the buttons to be initially disabled. They are enabled after a
53
+ // timeout expires. The implementation may interpret this loosely as the
54
+ // intent is to ensure that the user does not click through a security dialog
55
+ // too quickly. Strictly speaking, the implementation could choose to ignore
56
+ // this flag.
57
+ BUTTON_DELAY_ENABLE: 67108864,
58
+
59
+ // Selects the standard set of OK/Cancel buttons.
60
+ STD_OK_CANCEL_BUTTONS: (this.BUTTON_TITLE_OK * this.BUTTON_POS_0) + (this.BUTTON_TITLE_CANCEL
61
+ * this.BUTTON_POS_1),
62
+
63
+ // Selects the standard set of Yes/No buttons.
64
+ STD_YES_NO_BUTTONS: (this.BUTTON_TITLE_YES * this.BUTTON_POS_0) + (this.BUTTON_TITLE_NO
65
+ * this.BUTTON_POS_1)
66
+ };
67
+
68
+ DrivenPromptService.prototype.findAssociatedDriver_ = function(window) {
69
+ var ww = CC["@mozilla.org/embedcomp/window-watcher;1"].getService(CI["nsIWindowWatcher"]);
70
+
71
+ // There might be an easy answer.
72
+ var win = ww.getChromeForWindow(window);
73
+ if (win) {
74
+ return win;
75
+ }
76
+
77
+ // There isn't. Grab the top window's default view
78
+ var parent = window ? window : ww.activeWindow;
79
+ if (parent.wrappedJSObject)
80
+ parent = parent.wrappedJSObject;
81
+ var top = parent.top;
82
+
83
+ // Now iterate over all open browsers to find the one we belong to
84
+ var wm = CC["@mozilla.org/appshell/window-mediator;1"].getService(CI["nsIWindowMediator"]);
85
+ var allWindows = wm.getEnumerator("navigator:browser");
86
+ while (allWindows.hasMoreElements()) {
87
+ var chrome = allWindows.getNext().QueryInterface(CI.nsIDOMWindow);
88
+ if (chrome.content == window) {
89
+ return chrome.fxdriver;
90
+ }
91
+ }
92
+
93
+ // There's no meaningful way we can reach this.
94
+ return undefined;
95
+ };
96
+
97
+ DrivenPromptService.prototype.alert = function(aParent, aDialogTitle, aText) {
98
+ // Try to grab the top level window
99
+ var driver = this.findAssociatedDriver_(aParent);
100
+
101
+ if (driver && driver.response_) {
102
+ var res = driver.response_;
103
+ // TODO(simon): We can't rely on the normal JSON library here because it might not be available
104
+ // Come up with a cleaner way of doing this.
105
+ var json = "{ title: \"" + aDialogTitle + "\", text: \"" + aText + "\", __webdriverType: 'alert' }";
106
+
107
+ res.response = json;
108
+ res.send();
109
+ } else {
110
+ // TODO(simon): we should prevent the next command from blocking.
111
+ }
112
+
113
+ return this.originalPromptService_.alert(aParent, aDialogTitle, aText);
114
+ };
115
+
116
+ DrivenPromptService.prototype.alertCheck =
117
+ function(aParent, aDialogTitle, aText, aCheckMsg, aCheckState) {
118
+ return this.originalPromptService_.alertCheck(aParent, aDialogTitle, aText, aCheckMsg, aCheckState);
119
+ };
120
+
121
+ DrivenPromptService.prototype.confirm = function(aParent, aDialogTitle, aText) {
122
+ return this.originalPromptService_.confirm(aParent, aDialogTitle, aText);
123
+ };
124
+
125
+ DrivenPromptService.prototype.confirmCheck =
126
+ function(aParent, aDialogTitle, aText, aCheckMsg, aCheckState) {
127
+ return this.originalPromptService_.confirmCheck(aParent, aDialogTitle, aText, aCheckMsg, aCheckState);
128
+ };
129
+
130
+ DrivenPromptService.prototype.confirmEx =
131
+ function(aParent, aDialogTitle, aText, aButtonFlags, aButton0Title, aButton1Title, aButton2Title, aCheckMsg, aCheckState) {
132
+ return this.originalPromptService_.confirmEx(aParent, aDialogTitle, aText, aButtonFlags, aButton0Title, aButton1Title, aButton2Title, aCheckMsg, aCheckState);
133
+ };
134
+
135
+ DrivenPromptService.prototype.prompt =
136
+ function(aParent, aDialogTitle, aText, aValue, aCheckMsg, aCheckState) {
137
+ return this.originalPromptService_.prompt(aParent, aDialogTitle, aText, aValue, aCheckMsg, aCheckState);
138
+ };
139
+
140
+ DrivenPromptService.prototype.promptUsernameAndPassword =
141
+ function(aParent, aDialogTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState) {
142
+ return this.originalPromptService_.promptUsernameAndPassword(aParent, aDialogTitle, aText, aUsername, aPassword, aCheckMsg, aCheckState);
143
+ };
144
+
145
+ DrivenPromptService.prototype.promptPassword =
146
+ function(aParent, aDialogTitle, aText, aPassword, aCheckMsg, aCheckState) {
147
+ return this.originalPromptService_.promptPassword(aParent, aDialogTitle, aText, aPassword, aCheckMsg, aCheckState);
148
+ };
149
+
150
+ DrivenPromptService.prototype.select =
151
+ function(aParent, aDialogTitle, aText, aCount, aSelectList, aOutSelection) {
152
+ return this.originalPromptService_.select(aParent, aDialogTitle, aText, aCount, aSelectList, aOutSelection);
153
+ };
154
+
155
+ const PROMPT_CONTRACT_ID = "@mozilla.org/embedcomp/prompt-service;1";
156
+ const DRIVEN_PROMPT_SERVICE_CLASS_ID = Components.ID('{e26dbdcd-d3ba-4ded-88c3-6cb07ee3e9e0}');
157
+
158
+ var service = undefined;
159
+
160
+ var PromptServiceSpoofFactory = {
161
+ createInstance: function (aOuter, aIID) {
162
+ if (aOuter != null)
163
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
164
+ if (service == undefined) {
165
+ service = new DrivenPromptService();
166
+ }
167
+ return service;
168
+ }
169
+ };
170
+
171
+ function PromptServiceSpoofModule() {
172
+ this.firstTime_ = true;
173
+ }
174
+
175
+ PromptServiceSpoofModule.prototype.registerSelf = function(aCompMgr, aFileSpec, aLocation, aType) {
176
+ if (this.firstTime_) {
177
+ this.firstTime_ = false;
178
+ throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
179
+ }
180
+ aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
181
+ aCompMgr.registerFactoryLocation(
182
+ DRIVEN_PROMPT_SERVICE_CLASS_ID, "Driven prompt service", PROMPT_CONTRACT_ID, aFileSpec, aLocation, aType);
183
+ };
184
+
185
+ PromptServiceSpoofModule.prototype.unregisterSelf = function(aCompMgr, aLocation, aType) {
186
+ dumpn("Unregistering\n");
187
+ aCompMgr =
188
+ aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
189
+ aCompMgr.unregisterFactoryLocation(DRIVEN_PROMPT_SERVICE_CLASS_ID, aLocation);
190
+ };
191
+
192
+ PromptServiceSpoofModule.prototype.getClassObject = function(aCompMgr, aCID, aIID) {
193
+ if (!aIID.equals(Components.interfaces.nsIFactory))
194
+ throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
195
+
196
+ if (aCID.equals(DRIVEN_PROMPT_SERVICE_CLASS_ID))
197
+ return PromptServiceSpoofFactory;
198
+
199
+ throw Components.results.NS_ERROR_NO_INTERFACE;
200
+ };
201
+
202
+ PromptServiceSpoofModule.prototype.canUnload = function(aCompMgr) {
203
+ return true;
204
+ };
205
+
206
+ function NSGetModule(comMgr, fileSpec) {
207
+ return new PromptServiceSpoofModule();
208
+ }
@@ -0,0 +1,81 @@
1
+ /*
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
+ function Screenshooter() {
20
+ }
21
+
22
+
23
+ Screenshooter.grab = function(window) {
24
+ var document = window.document;
25
+ var documentElement = document.documentElement;
26
+ var canvas = document.getElementById('fxdriver-screenshot-canvas');
27
+ if (canvas == null) {
28
+ canvas = document.createElement('canvas');
29
+ canvas.id = 'fxdriver-screenshot-canvas';
30
+ canvas.style.display = 'none';
31
+ documentElement.appendChild(canvas);
32
+ }
33
+ var width =
34
+ Math.max(documentElement.scrollWidth, document.body.scrollWidth);
35
+ var height =
36
+ Math.max(documentElement.scrollHeight, document.body.scrollHeight);
37
+ canvas.width = width;
38
+ canvas.height = height;
39
+ var context = canvas.getContext('2d');
40
+ context.drawWindow(window, 0, 0, width, height, 'rgb(255,255,255)');
41
+ return canvas;
42
+ };
43
+
44
+
45
+ Screenshooter.toBase64 = function(canvas) {
46
+ var dataUrl = canvas.toDataURL('image/png');
47
+ var index = dataUrl.indexOf('base64,');
48
+ if (index == -1) {
49
+ // No base64 data marker.
50
+ throw new Error("Invalid base64 data: " + dataUrl);
51
+ }
52
+ return dataUrl.substring(index + 'base64,'.length);
53
+ };
54
+
55
+
56
+ Screenshooter.save = function(canvas, filepath) {
57
+ var cc = Components.classes;
58
+ var ci = Components.interfaces;
59
+ var dataUrl = canvas.toDataURL('image/png');
60
+ var ioService = cc['@mozilla.org/network/io-service;1'].
61
+ getService(ci.nsIIOService);
62
+ var dataUri = ioService.newURI(dataUrl, 'UTF-8', null);
63
+ var channel = ioService.newChannelFromURI(dataUri);
64
+ var file = cc['@mozilla.org/file/local;1'].createInstance(ci.nsILocalFile);
65
+ file.initWithPath(filepath);
66
+ var inputStream = channel.open();
67
+ var binaryInputStream = cc['@mozilla.org/binaryinputstream;1'].
68
+ createInstance(ci.nsIBinaryInputStream);
69
+ binaryInputStream.setInputStream(inputStream);
70
+ var fileOutputStream = cc['@mozilla.org/network/safe-file-output-stream;1'].
71
+ createInstance(ci.nsIFileOutputStream);
72
+ fileOutputStream.init(file, -1, -1, null);
73
+ var n = binaryInputStream.available();
74
+ var bytes = binaryInputStream.readBytes(n);
75
+ fileOutputStream.write(bytes, n);
76
+ if (fileOutputStream instanceof ci.nsISafeOutputStream) {
77
+ fileOutputStream.finish();
78
+ } else {
79
+ fileOutputStream.close();
80
+ }
81
+ };
@@ -0,0 +1,185 @@
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 Defines a class that reads commands from a socket and
21
+ * dispatches them to the nsICommandProcessor. When the response is ready, it is
22
+ * serialized and sent back to the client through the socket.
23
+ */
24
+
25
+
26
+ /**
27
+ * Communicates with a client by reading and writing from a socket.
28
+ * @param {nsISocketTransport} transport The connected socket transport.
29
+ * @constructor
30
+ * @extends {nsIStreamListener}
31
+ */
32
+ function SocketListener(transport) {
33
+ this.outstream = transport.
34
+ openOutputStream(Components.interfaces.nsITransport.OPEN_BLOCKING, 0, 0);
35
+
36
+ this.stream = transport.openInputStream(0, 0, 0);
37
+ var cin = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
38
+ createInstance(Components.interfaces.nsIConverterInputStream);
39
+ cin.init(this.stream, SocketListener.CHARSET, 0, 0x0000);
40
+
41
+ this.inputStream = cin;
42
+
43
+ var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"].
44
+ createInstance(Components.interfaces.nsIInputStreamPump);
45
+ pump.init(this.stream, -1, -1, 0, 0, false);
46
+ pump.asyncRead(this, null);
47
+
48
+ this.linesLeft = "";
49
+ this.data = "";
50
+ this.command = "";
51
+ this.step = 0;
52
+ this.readLength = false;
53
+
54
+ /**
55
+ * A reference to the command processor service. We grab the reference here
56
+ * instead of on the prototype since the component may not be loaded yet.
57
+ * @type {nsICommandProcessor}
58
+ * @private
59
+ */
60
+ this.commandProcessor_ = Components.
61
+ classes['@googlecode.com/webdriver/command-processor;1'].
62
+ getService(Components.interfaces.nsICommandProcessor);
63
+
64
+ /**
65
+ * The converter used when writing data back to the socket.
66
+ * @type {nsIScriptableUnicodeConverter}
67
+ * @private
68
+ */
69
+ this.converter_ = Components.
70
+ classes['@mozilla.org/intl/scriptableunicodeconverter'].
71
+ createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
72
+
73
+ this.converter_.charset = SocketListener.CHARSET;
74
+ }
75
+
76
+
77
+ /**
78
+ * Charset used for socket I/O.
79
+ * @type {string}
80
+ */
81
+ SocketListener.CHARSET = 'UTF-8';
82
+
83
+
84
+ /**
85
+ * Signals the start of a request. Each request lasts for the life of the
86
+ * underlying socket connection and represents a session with a FirefoxDriver
87
+ * client.
88
+ * @see {nsIRequestObserver#onStartRequest}
89
+ */
90
+ SocketListener.prototype.onStartRequest = function(request, context) {
91
+ };
92
+
93
+
94
+ /**
95
+ * Signals the end of a request (e.g. the underlying socket connection was
96
+ * closed).
97
+ * @see {nsIRequestObserver#onStopRequest}
98
+ */
99
+ SocketListener.prototype.onStopRequest = function(request, context, status) {
100
+ };
101
+
102
+
103
+ /**
104
+ * Called whenever another chunk of data is ready to be read from the socket.
105
+ * @param {nsIRequest} request The data's origin.
106
+ * @param {nsISupports} context User defined context.
107
+ * @param {nsIInputStream} inputStream The input stream containing the data
108
+ * chunk.
109
+ * @param {number} offset The total number of bytes read by previous calls to
110
+ * {@code #onDataAvailable}.
111
+ * @param {number} count The number of bytes available in the stream.
112
+ * @see {nsIStreamListener#onDataAvailable}
113
+ */
114
+ SocketListener.prototype.onDataAvailable = function(request, context,
115
+ inputStream, offset,
116
+ count) {
117
+ var incoming = {};
118
+ var read = this.inputStream.readString(count, incoming);
119
+
120
+ var lines = incoming.value.split('\n');
121
+ for (var j = 0; j < lines.length; j++) {
122
+ if (0 == this.step) {
123
+ var head = lines[j].split(": ", 2);
124
+ if (head[0] == "Content-Length") {
125
+ this.linesLeft = Number(head[1]);
126
+ this.readLength = true;
127
+ } else if (lines[j].length == 0 && this.readLength) {
128
+ this.step++;
129
+ }
130
+ } else {
131
+ this.data += lines[j];
132
+ this.linesLeft -= read;
133
+
134
+ if (this.linesLeft <= 0) {
135
+ this.executeCommand_();
136
+ j++; // Consume the empty line
137
+ }
138
+ }
139
+ }
140
+
141
+ if (this.linesLeft <= 0 && this.data) {
142
+ this.executeCommand_();
143
+ }
144
+ };
145
+
146
+
147
+ /**
148
+ * Parses the command data read from the socket into a JSON object and
149
+ * dispatches it to the command processesor.
150
+ * @private
151
+ */
152
+ SocketListener.prototype.executeCommand_ = function() {
153
+ var self = this;
154
+ var command = this.data;
155
+ var callback = function(response) {
156
+ //Utils.dumpn('writing to socket:\n' + response);
157
+ var data = self.converter_.convertToByteArray(response, {});
158
+ var header = "Length: " + data.length + "\n\n";
159
+ self.outstream.write(header, header.length);
160
+ self.outstream.flush();
161
+
162
+ var stream = self.converter_.convertToInputStream(response);
163
+ self.outstream.writeFrom(stream, data.length);
164
+ self.outstream.flush();
165
+ stream.close();
166
+ };
167
+
168
+ // Clear data for the next read.
169
+ this.data = '';
170
+ this.linesLeft = 0;
171
+ this.step = 0;
172
+ this.readLength = 0;
173
+
174
+ try {
175
+ this.commandProcessor_.execute(command, callback);
176
+ } catch (e) {
177
+ Utils.dump(e);
178
+ Utils.dumpn(command);
179
+
180
+ // Something has gone seriously wrong. Quit the browser.
181
+ this.commandProcessor_.execute(
182
+ JSON.stringify({'commandName': 'quit'}),
183
+ function() {});
184
+ }
185
+ };