selenium-webdriver 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- data/{common/src/rb/CHANGES → CHANGES} +13 -0
- data/{common/src/rb/README → README} +1 -1
- data/{common/src/rb/lib → lib}/selenium-webdriver.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver.rb +2 -1
- data/{common/src/rb/lib → lib}/selenium/webdriver/bridge_helper.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/child_process.rb +0 -0
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome.rb +0 -0
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/bridge.rb +2 -2
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/command_executor.rb +0 -0
- data/lib/selenium/webdriver/chrome/extension.zip +0 -0
- data/{chrome/src/rb/lib → lib}/selenium/webdriver/chrome/launcher.rb +26 -20
- data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/dir.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/core_ext/string.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/driver.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/driver_extensions/takes_screenshot.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/element.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/error.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/file_reaper.rb +2 -1
- data/{common/src/rb/lib → lib}/selenium/webdriver/find.rb +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox.rb +2 -1
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/binary.rb +32 -6
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/bridge.rb +0 -0
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/launcher.rb +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profile.rb +37 -72
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/profiles_ini.rb +0 -0
- data/{firefox/src/rb/lib → lib}/selenium/webdriver/firefox/util.rb +0 -0
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie.rb +2 -2
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/bridge.rb +7 -2
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/lib.rb +0 -0
- data/{jobbie/prebuilt/Win32/Release → lib/selenium/webdriver/ie/native/win32}/InternetExplorerDriver.dll +0 -0
- data/lib/selenium/webdriver/ie/native/x64/InternetExplorerDriver.dll +0 -0
- data/{jobbie/src/rb/lib → lib}/selenium/webdriver/ie/util.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/keys.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/navigation.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/options.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/platform.rb +5 -1
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/bridge.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/capabilities.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/commands.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/common.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/curb.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/http/default.rb +5 -1
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/response.rb +0 -0
- data/{remote/client/src/rb/lib → lib}/selenium/webdriver/remote/server_error.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/target_locator.rb +0 -0
- data/{common/src/rb/lib → lib}/selenium/webdriver/timeouts.rb +0 -0
- data/lib/selenium/webdriver/zip_helper.rb +30 -0
- metadata +73 -214
- data/COPYING +0 -204
- data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
- data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
- data/chrome/src/extension/background.html +0 -9
- data/chrome/src/extension/background.js +0 -1029
- data/chrome/src/extension/content_script.js +0 -1488
- data/chrome/src/extension/icons/busy.png +0 -0
- data/chrome/src/extension/icons/free.png +0 -0
- data/chrome/src/extension/manifest-nonwin.json +0 -19
- data/chrome/src/extension/manifest-win.json +0 -20
- data/chrome/src/extension/utils.js +0 -231
- data/common/src/js/abstractcommandprocessor.js +0 -132
- data/common/src/js/asserts.js +0 -296
- data/common/src/js/by.js +0 -149
- data/common/src/js/command.js +0 -380
- data/common/src/js/core/Blank.html +0 -7
- data/common/src/js/core/InjectedRemoteRunner.html +0 -8
- data/common/src/js/core/RemoteRunner.html +0 -101
- data/common/src/js/core/SeleniumLog.html +0 -109
- data/common/src/js/core/TestPrompt.html +0 -145
- data/common/src/js/core/TestRunner-splash.html +0 -55
- data/common/src/js/core/TestRunner.html +0 -165
- data/common/src/js/core/icons/all.png +0 -0
- data/common/src/js/core/icons/continue.png +0 -0
- data/common/src/js/core/icons/continue_disabled.png +0 -0
- data/common/src/js/core/icons/pause.png +0 -0
- data/common/src/js/core/icons/pause_disabled.png +0 -0
- data/common/src/js/core/icons/selected.png +0 -0
- data/common/src/js/core/icons/step.png +0 -0
- data/common/src/js/core/icons/step_disabled.png +0 -0
- data/common/src/js/core/lib/cssQuery/cssQuery-p.js +0 -6
- data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +0 -142
- data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +0 -150
- data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +0 -53
- data/common/src/js/core/lib/cssQuery/src/cssQuery.js +0 -356
- data/common/src/js/core/lib/prototype.js +0 -2006
- data/common/src/js/core/lib/scriptaculous/builder.js +0 -101
- data/common/src/js/core/lib/scriptaculous/controls.js +0 -815
- data/common/src/js/core/lib/scriptaculous/dragdrop.js +0 -915
- data/common/src/js/core/lib/scriptaculous/effects.js +0 -958
- data/common/src/js/core/lib/scriptaculous/scriptaculous.js +0 -47
- data/common/src/js/core/lib/scriptaculous/slider.js +0 -283
- data/common/src/js/core/lib/scriptaculous/unittest.js +0 -383
- data/common/src/js/core/lib/snapsie.js +0 -91
- data/common/src/js/core/scripts/find_matching_child.js +0 -69
- data/common/src/js/core/scripts/htmlutils.js +0 -8716
- data/common/src/js/core/scripts/injection.html +0 -72
- data/common/src/js/core/scripts/selenium-api.js +0 -3291
- data/common/src/js/core/scripts/selenium-browserbot.js +0 -2457
- data/common/src/js/core/scripts/selenium-browserdetect.js +0 -153
- data/common/src/js/core/scripts/selenium-commandhandlers.js +0 -379
- data/common/src/js/core/scripts/selenium-executionloop.js +0 -175
- data/common/src/js/core/scripts/selenium-logging.js +0 -148
- data/common/src/js/core/scripts/selenium-remoterunner.js +0 -695
- data/common/src/js/core/scripts/selenium-testrunner.js +0 -1362
- data/common/src/js/core/scripts/selenium-version.js +0 -5
- data/common/src/js/core/scripts/ui-doc.html +0 -808
- data/common/src/js/core/scripts/ui-element.js +0 -1644
- data/common/src/js/core/scripts/ui-map-sample.js +0 -979
- data/common/src/js/core/scripts/user-extensions.js +0 -3
- data/common/src/js/core/scripts/user-extensions.js.sample +0 -75
- data/common/src/js/core/scripts/xmlextras.js +0 -153
- data/common/src/js/core/selenium-logo.png +0 -0
- data/common/src/js/core/selenium-test.css +0 -43
- data/common/src/js/core/selenium.css +0 -316
- data/common/src/js/core/xpath/dom.js +0 -566
- data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +0 -2816
- data/common/src/js/core/xpath/util.js +0 -549
- data/common/src/js/core/xpath/xmltoken.js +0 -149
- data/common/src/js/core/xpath/xpath.js +0 -2481
- data/common/src/js/extension/README +0 -2
- data/common/src/js/extension/dommessenger.js +0 -152
- data/common/src/js/factory.js +0 -55
- data/common/src/js/future.js +0 -141
- data/common/src/js/jsunit.js +0 -40
- data/common/src/js/jsunit/app/css/jsUnitStyle.css +0 -50
- data/common/src/js/jsunit/app/css/readme +0 -10
- data/common/src/js/jsunit/app/emptyPage.html +0 -11
- data/common/src/js/jsunit/app/jsUnitCore.js +0 -534
- data/common/src/js/jsunit/app/jsUnitMockTimeout.js +0 -81
- data/common/src/js/jsunit/app/jsUnitTestManager.js +0 -705
- data/common/src/js/jsunit/app/jsUnitTestSuite.js +0 -44
- data/common/src/js/jsunit/app/jsUnitTracer.js +0 -102
- data/common/src/js/jsunit/app/jsUnitVersionCheck.js +0 -59
- data/common/src/js/jsunit/app/main-counts-errors.html +0 -12
- data/common/src/js/jsunit/app/main-counts-failures.html +0 -13
- data/common/src/js/jsunit/app/main-counts-runs.html +0 -13
- data/common/src/js/jsunit/app/main-counts.html +0 -21
- data/common/src/js/jsunit/app/main-data.html +0 -178
- data/common/src/js/jsunit/app/main-errors.html +0 -23
- data/common/src/js/jsunit/app/main-frame.html +0 -19
- data/common/src/js/jsunit/app/main-loader.html +0 -45
- data/common/src/js/jsunit/app/main-progress.html +0 -25
- data/common/src/js/jsunit/app/main-results.html +0 -67
- data/common/src/js/jsunit/app/main-status.html +0 -13
- data/common/src/js/jsunit/app/testContainer.html +0 -16
- data/common/src/js/jsunit/app/testContainerController.html +0 -77
- data/common/src/js/jsunit/app/xbDebug.js +0 -306
- data/common/src/js/jsunit/changelog.txt +0 -60
- data/common/src/js/jsunit/css/jsUnitStyle.css +0 -83
- data/common/src/js/jsunit/images/green.gif +0 -0
- data/common/src/js/jsunit/images/logo_jsunit.gif +0 -0
- data/common/src/js/jsunit/images/powerby-transparent.gif +0 -0
- data/common/src/js/jsunit/images/red.gif +0 -0
- data/common/src/js/jsunit/licenses/JDOM_license.txt +0 -56
- data/common/src/js/jsunit/licenses/Jetty_license.html +0 -213
- data/common/src/js/jsunit/licenses/MPL-1.1.txt +0 -470
- data/common/src/js/jsunit/licenses/gpl-2.txt +0 -340
- data/common/src/js/jsunit/licenses/index.html +0 -141
- data/common/src/js/jsunit/licenses/lgpl-2.1.txt +0 -504
- data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +0 -35
- data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +0 -35
- data/common/src/js/jsunit/readme.txt +0 -19
- data/common/src/js/jsunit/testRunner.html +0 -167
- data/common/src/js/jsunit/version.txt +0 -1
- data/common/src/js/key.js +0 -117
- data/common/src/js/localcommandprocessor.js +0 -171
- data/common/src/js/testcase.js +0 -219
- data/common/src/js/timing.js +0 -89
- data/common/src/js/webdriver.js +0 -860
- data/common/src/js/webelement.js +0 -483
- data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
- data/firefox/prebuilt/amd64/libnoblur64.so +0 -0
- data/firefox/prebuilt/i386/libnoblur.so +0 -0
- data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
- data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
- data/firefox/prebuilt/nsICommandProcessor.xpt +0 -0
- data/firefox/prebuilt/nsINativeEvents.xpt +0 -0
- data/firefox/prebuilt/nsIResponseHandler.xpt +0 -0
- data/firefox/src/extension/chrome.manifest +0 -3
- data/firefox/src/extension/components/badCertListener.js +0 -295
- data/firefox/src/extension/components/dispatcher.js +0 -495
- data/firefox/src/extension/components/driver-component.js +0 -130
- data/firefox/src/extension/components/errorcode.js +0 -70
- data/firefox/src/extension/components/firefoxDriver.js +0 -831
- data/firefox/src/extension/components/json2.js +0 -273
- data/firefox/src/extension/components/keytest.html +0 -554
- data/firefox/src/extension/components/nsCommandProcessor.js +0 -684
- data/firefox/src/extension/components/promptService.js +0 -208
- data/firefox/src/extension/components/request.js +0 -219
- data/firefox/src/extension/components/response.js +0 -276
- data/firefox/src/extension/components/screenshooter.js +0 -81
- data/firefox/src/extension/components/session.js +0 -314
- data/firefox/src/extension/components/sessionstore.js +0 -226
- data/firefox/src/extension/components/socketListener.js +0 -435
- data/firefox/src/extension/components/utils.js +0 -1335
- data/firefox/src/extension/components/webLoadingListener.js +0 -57
- data/firefox/src/extension/components/webdriverserver.js +0 -110
- data/firefox/src/extension/components/wrappedElement.js +0 -706
- data/firefox/src/extension/content/fxdriver.xul +0 -30
- data/firefox/src/extension/content/server.js +0 -95
- data/firefox/src/extension/idl/nsICommandProcessor.idl +0 -38
- data/firefox/src/extension/idl/nsIResponseHandler.idl +0 -34
- data/firefox/src/extension/install.rdf +0 -29
- data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
data/COPYING
DELETED
@@ -1,204 +0,0 @@
|
|
1
|
-
|
2
|
-
Apache License
|
3
|
-
Version 2.0, January 2004
|
4
|
-
http://www.apache.org/licenses/
|
5
|
-
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
-
|
8
|
-
1. Definitions.
|
9
|
-
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
-
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
-
the copyright owner that is granting the License.
|
15
|
-
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
-
other entities that control, are controlled by, or are under common
|
18
|
-
control with that entity. For the purposes of this definition,
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
20
|
-
direction or management of such entity, whether by contract or
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
-
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
-
exercising permissions granted by this License.
|
26
|
-
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
28
|
-
including but not limited to software source code, documentation
|
29
|
-
source, and configuration files.
|
30
|
-
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
32
|
-
transformation or translation of a Source form, including but
|
33
|
-
not limited to compiled object code, generated documentation,
|
34
|
-
and conversions to other media types.
|
35
|
-
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
37
|
-
Object form, made available under the License, as indicated by a
|
38
|
-
copyright notice that is included in or attached to the work
|
39
|
-
(an example is provided in the Appendix below).
|
40
|
-
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
-
the Work and Derivative Works thereof.
|
48
|
-
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
50
|
-
the original version of the Work and any modifications or additions
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
-
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
65
|
-
subsequently incorporated within the Work.
|
66
|
-
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
73
|
-
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
-
where such license applies only to those patent claims licensable
|
80
|
-
by such Contributor that are necessarily infringed by their
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
83
|
-
institute patent litigation against any entity (including a
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
86
|
-
or contributory patent infringement, then any patent licenses
|
87
|
-
granted to You under this License for that Work shall terminate
|
88
|
-
as of the date such litigation is filed.
|
89
|
-
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
92
|
-
modifications, and in Source or Object form, provided that You
|
93
|
-
meet the following conditions:
|
94
|
-
|
95
|
-
(a) You must give any other recipients of the Work or
|
96
|
-
Derivative Works a copy of this License; and
|
97
|
-
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
99
|
-
stating that You changed the files; and
|
100
|
-
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
103
|
-
attribution notices from the Source form of the Work,
|
104
|
-
excluding those notices that do not pertain to any part of
|
105
|
-
the Derivative Works; and
|
106
|
-
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
109
|
-
include a readable copy of the attribution notices contained
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
112
|
-
of the following places: within a NOTICE text file distributed
|
113
|
-
as part of the Derivative Works; within the Source form or
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
115
|
-
within a display generated by the Derivative Works, if and
|
116
|
-
wherever such third-party notices normally appear. The contents
|
117
|
-
of the NOTICE file are for informational purposes only and
|
118
|
-
do not modify the License. You may add Your own attribution
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
121
|
-
that such additional attribution notices cannot be construed
|
122
|
-
as modifying the License.
|
123
|
-
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
125
|
-
may provide additional or different license terms and conditions
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
129
|
-
the conditions stated in this License.
|
130
|
-
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
134
|
-
this License, without any additional terms or conditions.
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
-
the terms of any separate license agreement you may have executed
|
137
|
-
with Licensor regarding such Contributions.
|
138
|
-
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
141
|
-
except as required for reasonable and customary use in describing the
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
-
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
153
|
-
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
159
|
-
incidental, or consequential damages of any character arising as a
|
160
|
-
result of this License or out of the use or inability to use the
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
163
|
-
other commercial damages or losses), even if such Contributor
|
164
|
-
has been advised of the possibility of such damages.
|
165
|
-
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
-
or other liability obligations and/or rights consistent with this
|
170
|
-
License. However, in accepting such obligations, You may act only
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
175
|
-
of your accepting any such warranty or additional liability.
|
176
|
-
|
177
|
-
END OF TERMS AND CONDITIONS
|
178
|
-
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
180
|
-
|
181
|
-
To apply the Apache License to your work, attach the following
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
-
replaced with your own identifying information. (Don't include
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
185
|
-
comment syntax for the file format. We also recommend that a
|
186
|
-
file or class name and description of purpose be included on the
|
187
|
-
same "printed page" as the copyright notice for easier
|
188
|
-
identification within third-party archives.
|
189
|
-
|
190
|
-
Copyright 2007-2009 Google Inc.
|
191
|
-
Copyright 2007-2009 WebDriver committers
|
192
|
-
|
193
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
194
|
-
you may not use this file except in compliance with the License.
|
195
|
-
You may obtain a copy of the License at
|
196
|
-
|
197
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
198
|
-
|
199
|
-
Unless required by applicable law or agreed to in writing, software
|
200
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
201
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
202
|
-
See the License for the specific language governing permissions and
|
203
|
-
limitations under the License.
|
204
|
-
|
Binary file
|
Binary file
|
@@ -1,1029 +0,0 @@
|
|
1
|
-
/** @namespace */
|
2
|
-
ChromeDriver = {};
|
3
|
-
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Array of all information about currently loaded tabs (where a WebDriver
|
7
|
-
* window is probably a tab)
|
8
|
-
* Entries of form:
|
9
|
-
* {Int tabId, String windowName, Port mainPort, Boolean isFrameset, FrameData[] frames}
|
10
|
-
* FrameData ::= {[Int frameId], String frameName, Port framePort, FrameData[]}
|
11
|
-
* frameId can be undefined, if it has not yet been looked up, but should be
|
12
|
-
* added once it is known
|
13
|
-
* @type {Array.<Object>} TODO(jmleyba): Type info
|
14
|
-
*/
|
15
|
-
ChromeDriver.tabs = [];
|
16
|
-
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Port to the currently active frame (or tab, if the current page is not a
|
20
|
-
* frameset).
|
21
|
-
* @type {?Port}
|
22
|
-
*/
|
23
|
-
ChromeDriver.activePort = null;
|
24
|
-
|
25
|
-
|
26
|
-
/**
|
27
|
-
* ID of the currently active tab.
|
28
|
-
* @type {?string}
|
29
|
-
*/
|
30
|
-
ChromeDriver.activeTabId = null;
|
31
|
-
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Whether we should switch to the next tab which opens. Should be set if the
|
35
|
-
* last active tab was closed.
|
36
|
-
* @type {boolean}
|
37
|
-
*/
|
38
|
-
ChromeDriver.doFocusOnNextOpenedTab = true;
|
39
|
-
|
40
|
-
|
41
|
-
/**
|
42
|
-
* Place to temporarily store the URL currently being loaded, so that we can
|
43
|
-
* retry if needed, because opening a URL is an async callback.
|
44
|
-
* @type {?string}
|
45
|
-
*/
|
46
|
-
ChromeDriver.urlBeingLoaded = null;
|
47
|
-
|
48
|
-
|
49
|
-
/**
|
50
|
-
* URL we believe we're currently on.
|
51
|
-
* @type {?string}
|
52
|
-
*/
|
53
|
-
ChromeDriver.currentUrl = null;
|
54
|
-
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Whether we are loading a new URL that difers from the current URL only in
|
58
|
-
* fragment.
|
59
|
-
* @type {boolean}
|
60
|
-
*/
|
61
|
-
ChromeDriver.isGettingUrlButOnlyChangingByFragment = false;
|
62
|
-
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Whether we are currently executing a {@code ChromeDriver#close()}, and
|
66
|
-
* accordingly should send a success response when the tab closes.
|
67
|
-
* @type {boolean}
|
68
|
-
*/
|
69
|
-
ChromeDriver.isClosingTab = false;
|
70
|
-
|
71
|
-
|
72
|
-
/**
|
73
|
-
* Whether we have sent a response to the {currently, most recently loading
|
74
|
-
* page.
|
75
|
-
* @type {boolean}
|
76
|
-
*/
|
77
|
-
ChromeDriver.hasSentResponseToThisPageLoading = false;
|
78
|
-
|
79
|
-
|
80
|
-
/**
|
81
|
-
* Whether we believe a page is open to which we have no content script.
|
82
|
-
* @type {boolean}
|
83
|
-
*/
|
84
|
-
ChromeDriver.hasNoConnectionToPage = true;
|
85
|
-
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Stores the remaining frames to traverse when switching frames.
|
89
|
-
* @type {Array.<string>}
|
90
|
-
*/
|
91
|
-
ChromeDriver.restOfCurrentFramePath = [];
|
92
|
-
|
93
|
-
|
94
|
-
/**
|
95
|
-
* Port to the frameset or main content page we currently have loaded, so that
|
96
|
-
* we can probe it for information about its frames.
|
97
|
-
* @type {?Port}
|
98
|
-
*/
|
99
|
-
ChromeDriver.portToUseForFrameLookups = null;
|
100
|
-
|
101
|
-
|
102
|
-
/**
|
103
|
-
* The last request we sent that has not been answered, so that if we change
|
104
|
-
* page between sending a request and receiving a response, we can re-send it to
|
105
|
-
* the newly loaded page.
|
106
|
-
* @type {*} TODO(jmleyba)
|
107
|
-
*/
|
108
|
-
ChromeDriver.lastRequestToBeSentWhichHasntBeenAnsweredYet = null;
|
109
|
-
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Whether the plugin has the OS-specific window handle for the active tab. This
|
113
|
-
* is called HWND rather than window handle to avoid confusion with the other
|
114
|
-
* use of window handle to mean 'name of window'.
|
115
|
-
* @type {boolean}
|
116
|
-
*/
|
117
|
-
ChromeDriver.hasHwnd = false;
|
118
|
-
|
119
|
-
|
120
|
-
/**
|
121
|
-
* THe last XMLHttpRequest we made (used for communication with test language
|
122
|
-
* bindings).
|
123
|
-
* @type {?XMLHttpRequest}
|
124
|
-
*/
|
125
|
-
ChromeDriver.xmlHttpRequest = null;
|
126
|
-
|
127
|
-
/**
|
128
|
-
* URL to ping for commands.
|
129
|
-
* @type {string}
|
130
|
-
*/
|
131
|
-
ChromeDriver.xmlHttpRequestUrl = null;
|
132
|
-
|
133
|
-
|
134
|
-
/**
|
135
|
-
* @type {number}
|
136
|
-
*/
|
137
|
-
ChromeDriver.requestSequenceNumber = 0;
|
138
|
-
|
139
|
-
|
140
|
-
/**
|
141
|
-
* @type {number}
|
142
|
-
*/
|
143
|
-
ChromeDriver.lastReceivedSequenceNumber = -2;
|
144
|
-
|
145
|
-
|
146
|
-
/**
|
147
|
-
* @type {number}
|
148
|
-
*/
|
149
|
-
ChromeDriver.getUrlRequestSequenceNumber = 0;
|
150
|
-
|
151
|
-
|
152
|
-
/**
|
153
|
-
* Prefix prepended to the hopefully unique javascript window name, in hopes of
|
154
|
-
* further removing conflict.
|
155
|
-
* @type {string}
|
156
|
-
*/
|
157
|
-
ChromeDriver.windowHandlePrefix = '__webdriver_chromedriver_windowhandle';
|
158
|
-
|
159
|
-
|
160
|
-
/**
|
161
|
-
* Whether we will not execute any commands because we are already executing
|
162
|
-
* one.
|
163
|
-
* @type {boolean}
|
164
|
-
*/
|
165
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
166
|
-
|
167
|
-
/**
|
168
|
-
* It's possible that the page has completed loading,
|
169
|
-
* but the content script has not yet fired.
|
170
|
-
* In this case, to not report that there is no page,
|
171
|
-
* when we are just too fast, we wait up to this amount of time.
|
172
|
-
* @type {number} unit: milliseconds
|
173
|
-
*/
|
174
|
-
ChromeDriver.timeoutUntilGiveUpOnContentScriptLoading = 5000;
|
175
|
-
|
176
|
-
/**
|
177
|
-
* How long we are currently waiting for the content script to load
|
178
|
-
* after loading the page
|
179
|
-
* @type {number} unit: milliseconds
|
180
|
-
*/
|
181
|
-
ChromeDriver.currentlyWaitingUntilGiveUpOnContentScriptLoading;
|
182
|
-
|
183
|
-
/**
|
184
|
-
* The amount of time, in milliseconds, to wait for an element to be located
|
185
|
-
* when performing a search.
|
186
|
-
* When searching for a single element, the driver will wait up to this amount
|
187
|
-
* of time for the element to be located before returning an error.
|
188
|
-
* When searching for multiple elements, the driver will wait up to this amount
|
189
|
-
* of time for at least one element to be located before returning an empty
|
190
|
-
* list.
|
191
|
-
* @type {number}
|
192
|
-
* @private
|
193
|
-
*/
|
194
|
-
ChromeDriver.implicitWait_ = 0;
|
195
|
-
|
196
|
-
//Set ChromeDriver.currentlyWaitingUntilGiveUpOnContentScriptLoading;
|
197
|
-
resetCurrentlyWaitingOnContentScriptTime();
|
198
|
-
|
199
|
-
/**
|
200
|
-
* How long we wait between poling whether we have a content script,
|
201
|
-
* when loading a new page, up until
|
202
|
-
* ChromeDriver.timeoutUntilGiveUpOnContentScriptLoading
|
203
|
-
* @type {number} unit: milliseconds
|
204
|
-
*/
|
205
|
-
ChromeDriver.waitForContentScriptIncrement = 100;
|
206
|
-
|
207
|
-
chrome.extension.onConnect.addListener(function(port) {
|
208
|
-
if (ChromeDriver.xmlHttpRequestUrl == null) {
|
209
|
-
//This is the first content script, so is from the URL we need to connect to
|
210
|
-
ChromeDriver.xmlHttpRequestUrl = port.tab.url;
|
211
|
-
//Tell the ChromeCommandExecutor that we are here
|
212
|
-
sendResponseByXHR("", false);
|
213
|
-
return;
|
214
|
-
} else if (port.tab.url.indexOf(ChromeDriver.xmlHttpRequestUrl) == 0) {
|
215
|
-
//We have reloaded the xmlHttpRequest page. Ignore the connection.
|
216
|
-
return;
|
217
|
-
}
|
218
|
-
|
219
|
-
console.log("Connected to " + port.name);
|
220
|
-
// Note: The frameset port *always* connects before any frame port. After
|
221
|
-
// that, the order is in page loading time
|
222
|
-
ChromeDriver.hasNoConnectionToPage = false;
|
223
|
-
var foundTab = false;
|
224
|
-
for (var tab in ChromeDriver.tabs) {
|
225
|
-
if (ChromeDriver.tabs[tab].tabId == port.tab.id) {
|
226
|
-
//We must be a new [i]frame in the page, because when a page closes, it is
|
227
|
-
// removed from ChromeDriver.tabs
|
228
|
-
//TODO(danielwh): Work out WHICH page it's a sub-frame of (I don't look
|
229
|
-
// forward to this)
|
230
|
-
ChromeDriver.tabs[tab].frames.push({
|
231
|
-
frameName: port.name,
|
232
|
-
framePort: port,
|
233
|
-
frames: []
|
234
|
-
});
|
235
|
-
//Loaded a frame. Pushed it to the array. We don't know which page it's
|
236
|
-
// a sub-frame of, in the case of nested frames, if they have the same
|
237
|
-
// names. It would be nice to think people didn't use frames, let alone
|
238
|
-
// several layers of nesting of frames with the same name, but if it turns
|
239
|
-
// out to be a problem... Well, we'll see.
|
240
|
-
foundTab = true;
|
241
|
-
break;
|
242
|
-
}
|
243
|
-
}
|
244
|
-
if (!foundTab) {
|
245
|
-
//New tab!
|
246
|
-
//We don't know if it's a frameset yet, so we leave that as undefined
|
247
|
-
ChromeDriver.tabs.push({
|
248
|
-
tabId: port.tab.id,
|
249
|
-
windowName: ChromeDriver.windowHandlePrefix + "_" + port.tab.id,
|
250
|
-
mainPort: port,
|
251
|
-
frames: []
|
252
|
-
});
|
253
|
-
}
|
254
|
-
|
255
|
-
if (ChromeDriver.doFocusOnNextOpenedTab) {
|
256
|
-
ChromeDriver.activePort = port;
|
257
|
-
setActiveTabDetails(port.tab);
|
258
|
-
//Re-parse the last request we sent if we didn't get a response,
|
259
|
-
//because we ain't seeing a response any time soon
|
260
|
-
|
261
|
-
if (ChromeDriver.lastRequestToBeSentWhichHasntBeenAnsweredYet != null) {
|
262
|
-
if (ChromeDriver.urlBeingLoaded != null) {
|
263
|
-
ChromeDriver.lastRequestToBeSentWhichHasntBeenAnsweredYet = null;
|
264
|
-
} else {
|
265
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
266
|
-
console.log("Re-trying request which was sent but not answered");
|
267
|
-
parseRequest(ChromeDriver.lastRequestToBeSentWhichHasntBeenAnsweredYet);
|
268
|
-
}
|
269
|
-
}
|
270
|
-
}
|
271
|
-
|
272
|
-
if (ChromeDriver.urlBeingLoaded != null) {
|
273
|
-
//This was the result of a getUrl. Need to issue a response
|
274
|
-
sendEmptyResponseWhenTabIsLoaded(port.tab);
|
275
|
-
}
|
276
|
-
port.onMessage.addListener(parsePortMessage);
|
277
|
-
port.onDisconnect.addListener(function disconnectPort(port) {
|
278
|
-
console.log("Disconnected from " + port.name);
|
279
|
-
var remainingTabs = [];
|
280
|
-
for (var tab in ChromeDriver.tabs) {
|
281
|
-
if (ChromeDriver.tabs[tab].tabId == port.tab.id) {
|
282
|
-
if (ChromeDriver.tabs[tab].mainPort == port) {
|
283
|
-
//This main tab is being closed.
|
284
|
-
//Don't include it in the new version of ChromeDriver.tabs.
|
285
|
-
//Any subframes will also disconnect,
|
286
|
-
//but their tabId won't be present in the array,
|
287
|
-
//so they will be ignored.
|
288
|
-
continue;
|
289
|
-
} else {
|
290
|
-
//This is a subFrame being ditched
|
291
|
-
var remainingFrames = [];
|
292
|
-
for (var frame in ChromeDriver.tabs[tab].frames) {
|
293
|
-
if (ChromeDriver.tabs[tab].frames[frame].framePort == port) {
|
294
|
-
continue;
|
295
|
-
}
|
296
|
-
remainingFrames.push(ChromeDriver.tabs[tab].frames[frame]);
|
297
|
-
}
|
298
|
-
ChromeDriver.tabs[tab].frames = remainingFrames;
|
299
|
-
}
|
300
|
-
}
|
301
|
-
remainingTabs.push(ChromeDriver.tabs[tab]);
|
302
|
-
}
|
303
|
-
ChromeDriver.tabs = remainingTabs;
|
304
|
-
if (ChromeDriver.tabs.length == 0 || ChromeDriver.activePort == null ||
|
305
|
-
ChromeDriver.activePort.tab.id == port.tab.id) {
|
306
|
-
//If it is the active tab, perhaps we have followed a link,
|
307
|
-
//so we should focus on it.
|
308
|
-
//We have nothing better to focus on, anyway.
|
309
|
-
resetActiveTabDetails();
|
310
|
-
}
|
311
|
-
if (ChromeDriver.isClosingTab) {
|
312
|
-
//We are actively closing the tab, and expect a response to this
|
313
|
-
sendResponseToParsedRequest({status: 0}, false)
|
314
|
-
ChromeDriver.isClosingTab = false;
|
315
|
-
if (ChromeDriver.tabs.length == 0) {
|
316
|
-
chrome.windows.getAll({}, function(windows) {
|
317
|
-
for (var window in windows) {
|
318
|
-
chrome.windows.remove(windows[window].id);
|
319
|
-
}
|
320
|
-
});
|
321
|
-
}
|
322
|
-
}
|
323
|
-
});
|
324
|
-
});
|
325
|
-
|
326
|
-
/**
|
327
|
-
* Sends the passed argument as the result of a command
|
328
|
-
* @param result object encapsulating result to send
|
329
|
-
* @param wait whether we expect this command to possibly make changes
|
330
|
-
* we need to wait for (e.g. adding elements, opening windows) - if so,
|
331
|
-
* we wait until we think these effects are done
|
332
|
-
*/
|
333
|
-
function sendResponseByXHR(result, wait) {
|
334
|
-
console.log("Sending result by XHR: " + JSON.stringify(result));
|
335
|
-
if (ChromeDriver.xmlHttpRequest != null) {
|
336
|
-
ChromeDriver.xmlHttpRequest.abort();
|
337
|
-
}
|
338
|
-
ChromeDriver.xmlHttpRequest = new XMLHttpRequest();
|
339
|
-
ChromeDriver.xmlHttpRequest.onreadystatechange =
|
340
|
-
handleXmlHttpRequestReadyStateChange;
|
341
|
-
ChromeDriver.xmlHttpRequest.open(
|
342
|
-
"POST", ChromeDriver.xmlHttpRequestUrl, true);
|
343
|
-
ChromeDriver.xmlHttpRequest.setRequestHeader(
|
344
|
-
"Content-type", "application/json");
|
345
|
-
//Default to waiting for page changes, just in case
|
346
|
-
//TODO(danielwh): Iterate over tabs checking their status
|
347
|
-
if (wait === undefined || wait == null || wait) {
|
348
|
-
setTimeout(sendResult, 600, [result]);
|
349
|
-
} else {
|
350
|
-
sendResult(result);
|
351
|
-
}
|
352
|
-
}
|
353
|
-
|
354
|
-
/**
|
355
|
-
* Actually sends the result by XHR
|
356
|
-
* Should only EVER be called by sendResponseByXHR,
|
357
|
-
* as it ignores things like setting up XHR and blocking,
|
358
|
-
* and just forces the sending over an assumed open XHR
|
359
|
-
* @param result String to send
|
360
|
-
*/
|
361
|
-
function sendResult(result) {
|
362
|
-
//TODO(danielwh): Iterate over tabs checking their status
|
363
|
-
ChromeDriver.xmlHttpRequest.send(result + "\nEOResponse\n");
|
364
|
-
console.log("Sent result by XHR: " + JSON.stringify(result));
|
365
|
-
}
|
366
|
-
|
367
|
-
/**
|
368
|
-
* Sends the response to a request, which has been parsed by parseRequest
|
369
|
-
* Should be used only from within parseRequest (or methods called from it),
|
370
|
-
* because it adheres to the blocking semantics of parseRequest
|
371
|
-
*/
|
372
|
-
function sendResponseToParsedRequest(toSend, wait) {
|
373
|
-
if (!ChromeDriver.isBlockedWaitingForResponse) {
|
374
|
-
console.log("Tried to send a response (" + toSend +
|
375
|
-
") when not waiting for one. Dropping response.");
|
376
|
-
return;
|
377
|
-
}
|
378
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
379
|
-
ChromeDriver.lastRequestToBeSentWhichHasntBeenAnsweredYet = null;
|
380
|
-
console.log("SENDING RESPOND TO PARSED REQUEST");
|
381
|
-
toSend['sessionId'] = 'static_session_id';
|
382
|
-
sendResponseByXHR(JSON.stringify(toSend), wait);
|
383
|
-
setExtensionBusyIndicator(false);
|
384
|
-
}
|
385
|
-
|
386
|
-
/**
|
387
|
-
* When we receive a request, dispatches parseRequest to execute it
|
388
|
-
*/
|
389
|
-
function handleXmlHttpRequestReadyStateChange() {
|
390
|
-
if (this.readyState == 4) {
|
391
|
-
if (this.status != 200) {
|
392
|
-
console.log("Request state was 4 but status: " + this.status +
|
393
|
-
". responseText: " + this.responseText);
|
394
|
-
} else {
|
395
|
-
console.log("GOT XHR RESPONSE: " + this.responseText);
|
396
|
-
var request = JSON.parse(this.responseText);
|
397
|
-
if (request.request == "quit") {
|
398
|
-
//We're only allowed to send a response if we're blocked waiting for one, so pretend
|
399
|
-
console.log("SENDING QUIT XHR");
|
400
|
-
sendResponseByXHR(JSON.stringify({status: 0}), false);
|
401
|
-
} else {
|
402
|
-
console.log("Got request to execute from XHR: " + this.responseText);
|
403
|
-
parseRequest(request);
|
404
|
-
}
|
405
|
-
}
|
406
|
-
}
|
407
|
-
}
|
408
|
-
|
409
|
-
/**
|
410
|
-
* Parses a request received from the ChromeCommandExecutor and either sends the
|
411
|
-
* response, or sends a message to the content script with a command to execute
|
412
|
-
* @param request object encapsulating the request (e.g.
|
413
|
-
* {request: url, url: "http://www.google.co.uk"})
|
414
|
-
*/
|
415
|
-
function parseRequest(request) {
|
416
|
-
if (ChromeDriver.isBlockedWaitingForResponse) {
|
417
|
-
console.log("Already sent a request which hasn't been replied to yet. " +
|
418
|
-
"Not parsing any more.");
|
419
|
-
return;
|
420
|
-
}
|
421
|
-
ChromeDriver.isBlockedWaitingForResponse = true;
|
422
|
-
setExtensionBusyIndicator(true);
|
423
|
-
|
424
|
-
switch (request.request) {
|
425
|
-
case "newSession":
|
426
|
-
sendResponseToParsedRequest({
|
427
|
-
status: 0,
|
428
|
-
value: {
|
429
|
-
'browserName': 'chrome',
|
430
|
-
'version': navigator.appVersion.replace(/.*Chrome\/(\d(\.\d+)*\b).*/, "$1"),
|
431
|
-
'platform': navigator.platform,
|
432
|
-
'javascriptEnabled': true,
|
433
|
-
}
|
434
|
-
});
|
435
|
-
break;
|
436
|
-
case "get":
|
437
|
-
getUrl(request.url);
|
438
|
-
break;
|
439
|
-
case "close":
|
440
|
-
//Doesn't re-focus the ChromeDriver.activePort on any tab.
|
441
|
-
chrome.tabs.remove(ChromeDriver.activeTabId);
|
442
|
-
ChromeDriver.isClosingTab = true;
|
443
|
-
break;
|
444
|
-
case "getCurrentWindowHandle":
|
445
|
-
if (ChromeDriver.activePort == null) {
|
446
|
-
// console.log("No active port right now.");
|
447
|
-
// Fine. Find the active tab.
|
448
|
-
// TODO(simon): This is lame and error prone
|
449
|
-
var len = ChromeDriver.tabs.length;
|
450
|
-
for (var i = 0; i < len; i++) {
|
451
|
-
if (ChromeDriver.tabs[i].selected) {
|
452
|
-
sendResponseToParsedRequest({status: 0, value: ChromeDriver.tabs[i].id}, false);
|
453
|
-
}
|
454
|
-
}
|
455
|
-
|
456
|
-
// Hohoho. The first argument to tabs.getSelected is optional, but must be set.
|
457
|
-
chrome.windows.getCurrent(function(win) {
|
458
|
-
chrome.tabs.getSelected(win.id, function(tab) {
|
459
|
-
var len = ChromeDriver.tabs.length;
|
460
|
-
for (var i = 0; i < len; i++) {
|
461
|
-
if (ChromeDriver.tabs[i].tabId == tab.id) {
|
462
|
-
sendResponseToParsedRequest({status: 0, value: ChromeDriver.tabs[i].tabId}, false);
|
463
|
-
return;
|
464
|
-
}
|
465
|
-
}
|
466
|
-
});
|
467
|
-
});
|
468
|
-
} else {
|
469
|
-
// Wow. I can't see this being error prone in the slightest
|
470
|
-
var handle = ChromeDriver.windowHandlePrefix + "_" + ChromeDriver.activePort.sender.tab.id;
|
471
|
-
sendResponseToParsedRequest({status: 0, value: handle}, false);
|
472
|
-
};
|
473
|
-
break;
|
474
|
-
case "getWindowHandles":
|
475
|
-
sendResponseToParsedRequest(getWindowHandles(), false);
|
476
|
-
break;
|
477
|
-
case "switchToFrame":
|
478
|
-
if (request.id === undefined || request.id === null) {
|
479
|
-
switchToDefaultContent();
|
480
|
-
} else {
|
481
|
-
switchToFrame(request.id);
|
482
|
-
}
|
483
|
-
break;
|
484
|
-
case "switchToFrameByIndex":
|
485
|
-
case "switchToFrameByName":
|
486
|
-
switchToFrame(request.id);
|
487
|
-
break;
|
488
|
-
case "switchToWindow":
|
489
|
-
ChromeDriver.hasHwnd = false;
|
490
|
-
if (request.name !== undefined) {
|
491
|
-
setActivePortByWindowName(request.name);
|
492
|
-
} else {
|
493
|
-
sendResponseToParsedRequest({
|
494
|
-
status: 23,
|
495
|
-
value: {
|
496
|
-
message: 'Window to switch to was not given'
|
497
|
-
}
|
498
|
-
}, false);
|
499
|
-
}
|
500
|
-
break;
|
501
|
-
case "screenshot":
|
502
|
-
getScreenshot();
|
503
|
-
break;
|
504
|
-
case "implicitlyWait":
|
505
|
-
ChromeDriver.implicitWait_ = request.ms || 0;
|
506
|
-
sendResponseToParsedRequest({status: 0});
|
507
|
-
break;
|
508
|
-
case "clickElement":
|
509
|
-
case "hoverOverElement":
|
510
|
-
// Falling through, as native events are handled the same
|
511
|
-
case "sendKeysToElement":
|
512
|
-
if (typeof(request.keys) == "object" && request.keys.length !== undefined) {
|
513
|
-
request.keys = request.keys.join("");
|
514
|
-
}
|
515
|
-
sendMessageOnActivePortAndAlsoKeepTrackOfIt(
|
516
|
-
wrapInjectEmbedIfNecessary(request));
|
517
|
-
break;
|
518
|
-
case "getCurrentUrl":
|
519
|
-
case "getTitle":
|
520
|
-
if (hasNoPage()) {
|
521
|
-
console.log("Not got a page, but asked for string, so sending empty string");
|
522
|
-
sendResponseToParsedRequest({status: 0, value: ''});
|
523
|
-
break;
|
524
|
-
}
|
525
|
-
// Falling through, as if we do have a page, we want to treat this like a
|
526
|
-
// normal request
|
527
|
-
case "findElement":
|
528
|
-
case "findChildElement":
|
529
|
-
if (hasNoPage()) {
|
530
|
-
console.log("Not got a page, but asked for element, so throwing NoSuchElementException");
|
531
|
-
sendResponseToParsedRequest({status: 7, value: {message: 'Was not on a page, so could not find elements'}});
|
532
|
-
break;
|
533
|
-
}
|
534
|
-
// Falling through, as if we do have a page, we want to treat this like a
|
535
|
-
// normal request
|
536
|
-
case "findElements":
|
537
|
-
case "findChildElements":
|
538
|
-
if (hasNoPage()) {
|
539
|
-
console.log("Not got a page, but asked for elements, so returning no elements");
|
540
|
-
sendResponseToParsedRequest({status: 0, value: []});
|
541
|
-
break;
|
542
|
-
}
|
543
|
-
// Falling through, as if we do have a page, we want to treat this like a
|
544
|
-
// normal request
|
545
|
-
case "deleteAllCookies":
|
546
|
-
case "deleteCookie":
|
547
|
-
if (hasNoPage()) {
|
548
|
-
console.log("Not got a page, but asked to delete cookies, so returning ok");
|
549
|
-
sendResponseToParsedRequest({status: 0});
|
550
|
-
break;
|
551
|
-
}
|
552
|
-
// Falling through, as if we do have a page, we want to treat this like a
|
553
|
-
// normal request
|
554
|
-
case "executeScript":
|
555
|
-
if (hasNoPage()) {
|
556
|
-
console.log("Not got a page, but asked to execute script, so sending error 17");
|
557
|
-
sendResponseToParsedRequest({status: 17, value: {message: 'Was not on a page, so could not execute javascript'}});
|
558
|
-
break;
|
559
|
-
}
|
560
|
-
// Falling through, as if we do have a page, we want to treat this like a
|
561
|
-
// normal request
|
562
|
-
default:
|
563
|
-
var sequenceNumber = ChromeDriver.requestSequenceNumber;
|
564
|
-
ChromeDriver.requestSequenceNumber++;
|
565
|
-
sendMessageOnActivePortAndAlsoKeepTrackOfIt({
|
566
|
-
request: request,
|
567
|
-
sequenceNumber: sequenceNumber,
|
568
|
-
implicitWait: ChromeDriver.implicitWait_
|
569
|
-
});
|
570
|
-
break;
|
571
|
-
}
|
572
|
-
}
|
573
|
-
|
574
|
-
function getScreenshot() {
|
575
|
-
chrome.tabs.captureVisibleTab(null, getScreenshotResult);
|
576
|
-
}
|
577
|
-
|
578
|
-
function getScreenshotResult(snapshotDataUrl) {
|
579
|
-
var index = snapshotDataUrl.indexOf('base64,');
|
580
|
-
if (index == -1) {
|
581
|
-
sendResponseToParsedRequest({status: 99}, false);
|
582
|
-
return;
|
583
|
-
}
|
584
|
-
var base64 = snapshotDataUrl.substring(index + 'base64,'.length);
|
585
|
-
sendResponseToParsedRequest({status: 0, value: base64}, false);
|
586
|
-
}
|
587
|
-
|
588
|
-
function sendMessageOnActivePortAndAlsoKeepTrackOfIt(message) {
|
589
|
-
ChromeDriver.lastRequestToBeSentWhichHasntBeenAnsweredYet = message.request;
|
590
|
-
try {
|
591
|
-
ChromeDriver.activePort.postMessage(message);
|
592
|
-
} catch (e) {
|
593
|
-
console.log("Tried to send request without an active port. " +
|
594
|
-
"Request will retry when connected, but will hang until then.");
|
595
|
-
}
|
596
|
-
}
|
597
|
-
|
598
|
-
/**
|
599
|
-
* Parse messages coming in on the port (responses from the content script).
|
600
|
-
* @param message JSON message of format:
|
601
|
-
* {response: "some command",
|
602
|
-
* value: {statusCode: STATUS_CODE
|
603
|
-
* [, optional params]}}
|
604
|
-
*/
|
605
|
-
function parsePortMessage(message) {
|
606
|
-
console.log(
|
607
|
-
"Received response from content script: " + JSON.stringify(message));
|
608
|
-
if (!message || !message.response || !message.response.value ||
|
609
|
-
message.response.value.statusCode === undefined ||
|
610
|
-
message.response.value.statusCode === null ||
|
611
|
-
message.sequenceNumber === undefined || message.sequenceNumber < ChromeDriver.lastReceivedSequenceNumber) {
|
612
|
-
// Should only ever happen if we sent a bad request,
|
613
|
-
// or the content script is broken
|
614
|
-
console.log("Got invalid response from the content script.");
|
615
|
-
return;
|
616
|
-
}
|
617
|
-
var toSend = {status: 12};
|
618
|
-
ChromeDriver.lastRequestToBeSentWhichHasntBeenAnsweredYet = null;
|
619
|
-
switch (message.response.value.statusCode) {
|
620
|
-
// Error codes are loosely based on native exception codes, see
|
621
|
-
// common/src/cpp/webdriver-interactions/errorcodes.h
|
622
|
-
case 0:
|
623
|
-
case 7: //org.openqa.selenium.NoSuchElementException
|
624
|
-
case 8: //org.openqa.selenium.NoSuchFrameException
|
625
|
-
case 9: //java.lang.UnsupportedOperationException [Unknown command]
|
626
|
-
case 10: //org.openqa.selenium.StaleElementReferenceException
|
627
|
-
case 11: //org.openqa.selenium.ElementNotVisibleException
|
628
|
-
case 12: //java.lang.UnsupportedOperationException [Invalid element state ]
|
629
|
-
case 13: //org.openqa.selenium.WebDriverException [Unhandled error]
|
630
|
-
case 17: //org.openqa.selenium.WebDriverException [Bad javascript]
|
631
|
-
case 19: //org.openqa.selenium.XPathLookupException
|
632
|
-
case 23: //org.openqa.selenium.NoSuchWindowException
|
633
|
-
case 24: //org.openqa.selenium.InvalidCookieDomainException
|
634
|
-
case 25: //org.openqa.selenium.UnableToSetCookieException
|
635
|
-
case 99: //org.openqa.selenium.WebDriverException [Native event]
|
636
|
-
toSend = {status: message.response.value.statusCode, value: null};
|
637
|
-
if (message.response.value !== undefined && message.response.value !== null &&
|
638
|
-
message.response.value.value !== undefined) {
|
639
|
-
toSend.value = message.response.value.value;
|
640
|
-
}
|
641
|
-
sendResponseToParsedRequest(toSend, message.response.wait);
|
642
|
-
break;
|
643
|
-
case "no-op":
|
644
|
-
//Some special operation which isn't sending HTTP
|
645
|
-
switch (message.response.response) {
|
646
|
-
case "clickElement":
|
647
|
-
try {
|
648
|
-
if (document.embeds[0].clickAt(message.response.value.x, message.response.value.y)) {
|
649
|
-
sendResponseToParsedRequest({status: 0}, true);
|
650
|
-
} else {
|
651
|
-
sendResponseToParsedRequest({status: 99}, true);
|
652
|
-
}
|
653
|
-
} catch(e) {
|
654
|
-
console.log("Error natively clicking. Trying non-native.");
|
655
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
656
|
-
parseRequest({
|
657
|
-
request: 'nonNativeClickElement',
|
658
|
-
id: message.response.value.id
|
659
|
-
});
|
660
|
-
}
|
661
|
-
break;
|
662
|
-
case "hoverElement":
|
663
|
-
try {
|
664
|
-
var points = message.response.value;
|
665
|
-
if (document.embeds[0].mouseMoveTo(15, points.oldX, points.oldY, points.newX, points.newY)) {
|
666
|
-
sendResponseToParsedRequest({status: 0}, true);
|
667
|
-
} else {
|
668
|
-
sendResponseToParsedRequest({status: 99}, true);
|
669
|
-
}
|
670
|
-
} catch(e) {
|
671
|
-
sendResponseToParsedRequest({status: 99}, true);
|
672
|
-
}
|
673
|
-
break;
|
674
|
-
case "sendKeysToElement":
|
675
|
-
try {
|
676
|
-
if (document.embeds[0].sendKeys(message.response.value.keys)) {
|
677
|
-
sendResponseToParsedRequest({status: 0}, true);
|
678
|
-
} else {
|
679
|
-
sendResponseToParsedRequest({status: 99}, true);
|
680
|
-
}
|
681
|
-
} catch(e) {
|
682
|
-
console.log("Error natively sending keys. Trying non-native.");
|
683
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
684
|
-
parseRequest({
|
685
|
-
request: 'sendElementNonNativeKeys',
|
686
|
-
id: message.response.value.id,
|
687
|
-
keys: message.response.value.keys
|
688
|
-
});
|
689
|
-
}
|
690
|
-
break;
|
691
|
-
case "sniffForMetaRedirects":
|
692
|
-
if (!message.response.value.value &&
|
693
|
-
!ChromeDriver.hasSentResponseToThisPageLoading) {
|
694
|
-
ChromeDriver.urlBeingLoaded = null;
|
695
|
-
ChromeDriver.hasSentResponseToThisPageLoading = true;
|
696
|
-
switchToDefaultContent();
|
697
|
-
}
|
698
|
-
break;
|
699
|
-
case "newTabInformation":
|
700
|
-
var response = message.response.value;
|
701
|
-
for (var tab in ChromeDriver.tabs) {
|
702
|
-
//RACE CONDITION!!!
|
703
|
-
//This call should happen before another content script
|
704
|
-
//connects and returns this value,
|
705
|
-
//but if it doesn't, we may get mismatched information
|
706
|
-
if (ChromeDriver.tabs[tab].isFrameset === undefined) {
|
707
|
-
ChromeDriver.tabs[tab].isFrameset = response.isFrameset;
|
708
|
-
return;
|
709
|
-
} else {
|
710
|
-
for (var frame in ChromeDriver.tabs[tab].frames) {
|
711
|
-
var theFrame = ChromeDriver.tabs[tab].frames[frame];
|
712
|
-
if (theFrame.isFrameset === undefined) {
|
713
|
-
theFrame.isFrameset = response.isFrameset;
|
714
|
-
return;
|
715
|
-
}
|
716
|
-
}
|
717
|
-
}
|
718
|
-
}
|
719
|
-
break;
|
720
|
-
case "getFrameNameFromIndex":
|
721
|
-
var newName = message.response.value.name;
|
722
|
-
if (ChromeDriver.restOfCurrentFramePath.length != 0) {
|
723
|
-
newName += "." + ChromeDriver.restOfCurrentFramePath.join(".");
|
724
|
-
}
|
725
|
-
switchToFrameByName(newName);
|
726
|
-
break;
|
727
|
-
}
|
728
|
-
break;
|
729
|
-
}
|
730
|
-
}
|
731
|
-
|
732
|
-
/**
|
733
|
-
* If the plugin doesn't currently have an HWND for this page,
|
734
|
-
* we need to get one by injecting an embed
|
735
|
-
*/
|
736
|
-
function wrapInjectEmbedIfNecessary(requestObject) {
|
737
|
-
if (ChromeDriver.hasHwnd) {
|
738
|
-
var sequenceNumber = ChromeDriver.requestSequenceNumber;
|
739
|
-
ChromeDriver.requestSequenceNumber++;
|
740
|
-
return {
|
741
|
-
sequenceNumber: sequenceNumber,
|
742
|
-
request: requestObject
|
743
|
-
};
|
744
|
-
} else {
|
745
|
-
var wrappedObject = {
|
746
|
-
sequenceNumber: ChromeDriver.requestSequenceNumber,
|
747
|
-
request: {
|
748
|
-
request: "injectEmbed",
|
749
|
-
followup: {
|
750
|
-
sequenceNumber: ChromeDriver.requestSequenceNumber + 1,
|
751
|
-
request: requestObject
|
752
|
-
}
|
753
|
-
}
|
754
|
-
};
|
755
|
-
ChromeDriver.requestSequenceNumber += 2;
|
756
|
-
return wrappedObject;
|
757
|
-
}
|
758
|
-
}
|
759
|
-
|
760
|
-
/**
|
761
|
-
* Gets all current window handles
|
762
|
-
* @return an array containing all of the current window handles
|
763
|
-
*/
|
764
|
-
function getWindowHandles() {
|
765
|
-
var windowHandles = [];
|
766
|
-
for (var tab in ChromeDriver.tabs) {
|
767
|
-
windowHandles.push(ChromeDriver.tabs[tab].windowName);
|
768
|
-
}
|
769
|
-
return {status: 0, value: windowHandles}
|
770
|
-
}
|
771
|
-
|
772
|
-
function resetActiveTabDetails() {
|
773
|
-
ChromeDriver.activePort = null;
|
774
|
-
ChromeDriver.hasHwnd = false;
|
775
|
-
ChromeDriver.activeTabId = null;
|
776
|
-
ChromeDriver.doFocusOnNextOpenedTab = true;
|
777
|
-
ChromeDriver.hasSentResponseToThisPageLoading = false;
|
778
|
-
ChromeDriver.portToUseForFrameLookups = null;
|
779
|
-
ChromeDriver.currentUrl = null;
|
780
|
-
resetCurrentlyWaitingOnContentScriptTime();
|
781
|
-
}
|
782
|
-
|
783
|
-
function setActiveTabDetails(tab) {
|
784
|
-
ChromeDriver.activeTabId = tab.id;
|
785
|
-
ChromeDriver.activeWindowId = tab.windowId;
|
786
|
-
ChromeDriver.doFocusOnNextOpenedTab = false;
|
787
|
-
ChromeDriver.currentUrl = tab.url;
|
788
|
-
resetCurrentlyWaitingOnContentScriptTime();
|
789
|
-
}
|
790
|
-
|
791
|
-
function switchToDefaultContent() {
|
792
|
-
ChromeDriver.hasHwnd = false;
|
793
|
-
for (var tab in ChromeDriver.tabs) {
|
794
|
-
if (ChromeDriver.tabs[tab].tabId == ChromeDriver.activeTabId) {
|
795
|
-
if (ChromeDriver.tabs[tab].isFrameset) {
|
796
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
797
|
-
parseRequest({request: 'switchToFrame', id: 0});
|
798
|
-
} else {
|
799
|
-
ChromeDriver.activePort = ChromeDriver.tabs[tab].mainPort;
|
800
|
-
sendResponseToParsedRequest({status: 0}, false);
|
801
|
-
}
|
802
|
-
return;
|
803
|
-
}
|
804
|
-
}
|
805
|
-
}
|
806
|
-
|
807
|
-
function switchToFrame(id) {
|
808
|
-
ChromeDriver.hasHwnd = false;
|
809
|
-
for (var tab in ChromeDriver.tabs) {
|
810
|
-
if (ChromeDriver.tabs[tab].tabId == ChromeDriver.activeTabId) {
|
811
|
-
ChromeDriver.portToUseForFrameLookups = ChromeDriver.tabs[tab].mainPort;
|
812
|
-
break;
|
813
|
-
}
|
814
|
-
}
|
815
|
-
if (typeof id == 'string') {
|
816
|
-
switchToFrameByName(id);
|
817
|
-
} else if (typeof id == 'number') {
|
818
|
-
getFrameNameFromIndex(id);
|
819
|
-
} else {
|
820
|
-
sendResponseToParsedRequest({
|
821
|
-
status: 9,
|
822
|
-
value: {
|
823
|
-
message: "Switching frames other than by name or id is unsupported"
|
824
|
-
}
|
825
|
-
});
|
826
|
-
}
|
827
|
-
}
|
828
|
-
|
829
|
-
function switchToFrameByName(name) {
|
830
|
-
var names = name.split(".");
|
831
|
-
|
832
|
-
for (var tab in ChromeDriver.tabs) {
|
833
|
-
if (ChromeDriver.tabs[tab].tabId == ChromeDriver.activeTabId) {
|
834
|
-
var frame;
|
835
|
-
for (frame in ChromeDriver.tabs[tab].frames) {
|
836
|
-
// Maybe name was a fully qualified name, which perhaps just happened to
|
837
|
-
// include .s
|
838
|
-
if (ChromeDriver.tabs[tab].frames[frame].frameName == name) {
|
839
|
-
ChromeDriver.activePort =
|
840
|
-
ChromeDriver.tabs[tab].frames[frame].framePort;
|
841
|
-
ChromeDriver.restOfCurrentFramePath = [];
|
842
|
-
sendResponseToParsedRequest({status: 0}, false);
|
843
|
-
return;
|
844
|
-
}
|
845
|
-
}
|
846
|
-
for (frame in ChromeDriver.tabs[tab].frames) {
|
847
|
-
// Maybe we're looking for a child, see if this is the parent of it
|
848
|
-
if (ChromeDriver.tabs[tab].frames[frame].frameName == names[0]) {
|
849
|
-
ChromeDriver.activePort =
|
850
|
-
ChromeDriver.tabs[tab].frames[frame].framePort;
|
851
|
-
ChromeDriver.portToUseForFrameLookups = ChromeDriver.activePort;
|
852
|
-
names.shift();
|
853
|
-
ChromeDriver.restOfCurrentFramePath = names;
|
854
|
-
if (names.length == 0) {
|
855
|
-
sendResponseToParsedRequest({status: 0}, false);
|
856
|
-
return;
|
857
|
-
} else {
|
858
|
-
switchToFrameByName(names.join("."));
|
859
|
-
return;
|
860
|
-
}
|
861
|
-
}
|
862
|
-
}
|
863
|
-
}
|
864
|
-
}
|
865
|
-
|
866
|
-
//Maybe the "name" was actually an index? Let's find out...
|
867
|
-
var index = null;
|
868
|
-
try {
|
869
|
-
index = parseInt(names[0]);
|
870
|
-
} catch (e) {
|
871
|
-
}
|
872
|
-
if (!isNaN(index)) {
|
873
|
-
names.shift();
|
874
|
-
ChromeDriver.restOfCurrentFramePath = names;
|
875
|
-
getFrameNameFromIndex(index);
|
876
|
-
return;
|
877
|
-
}
|
878
|
-
|
879
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
880
|
-
parseRequest({request: 'switchToNamedIFrameIfOneExists', name: name});
|
881
|
-
}
|
882
|
-
|
883
|
-
function getFrameNameFromIndex(index) {
|
884
|
-
var message = {
|
885
|
-
request: {
|
886
|
-
request: "getFrameNameFromIndex",
|
887
|
-
index: index
|
888
|
-
},
|
889
|
-
sequenceNumber: ChromeDriver.requestSequenceNumber
|
890
|
-
};
|
891
|
-
ChromeDriver.requestSequenceNumber++;
|
892
|
-
ChromeDriver.portToUseForFrameLookups.postMessage(message);
|
893
|
-
}
|
894
|
-
|
895
|
-
/**
|
896
|
-
* Closes the current tab if it exists, and opens a new one, in which it
|
897
|
-
* gets the URL passed
|
898
|
-
* @param url the URL to load
|
899
|
-
*/
|
900
|
-
function getUrl(url) {
|
901
|
-
ChromeDriver.urlBeingLoaded = url;
|
902
|
-
var tempActiveTagId = ChromeDriver.activeTabId;
|
903
|
-
if (url.indexOf("#") > -1 && ChromeDriver.currentUrl != null &&
|
904
|
-
ChromeDriver.currentUrl.split("#")[0] == url.split("#")[0]) {
|
905
|
-
ChromeDriver.isGettingUrlButOnlyChangingByFragment = true;
|
906
|
-
} else {
|
907
|
-
resetActiveTabDetails();
|
908
|
-
}
|
909
|
-
ChromeDriver.currentUrl = url;
|
910
|
-
if (tempActiveTagId == null) {
|
911
|
-
chrome.tabs.create({url: url, selected: true}, getUrlCallback);
|
912
|
-
} else {
|
913
|
-
ChromeDriver.activeTabId = tempActiveTagId;
|
914
|
-
if (ChromeDriver.isGettingUrlButOnlyChangingByFragment) {
|
915
|
-
chrome.tabs.update(ChromeDriver.activeTabId, {url: url, selected: true},
|
916
|
-
getUrlCallback);
|
917
|
-
} else {
|
918
|
-
// we need to create the new tab before deleting the old one
|
919
|
-
// in order to avoid hanging on OS X
|
920
|
-
var oldId = ChromeDriver.activeTabId;
|
921
|
-
resetActiveTabDetails();
|
922
|
-
chrome.tabs.create({url: url, selected: true}, getUrlCallback);
|
923
|
-
chrome.tabs.remove(oldId);
|
924
|
-
}
|
925
|
-
}
|
926
|
-
}
|
927
|
-
|
928
|
-
function getUrlCallback(tab) {
|
929
|
-
if (chrome.extension.lastError) {
|
930
|
-
// An error probably arose because Chrome didn't have a window yet
|
931
|
-
// (see crbug.com 19846)
|
932
|
-
// If we retry, we *should* be fine. Unless something really bad is
|
933
|
-
// happening, in which case we will probably hang indefinitely trying to
|
934
|
-
// reload the same URL
|
935
|
-
getUrl(ChromeDriver.urlBeingLoaded);
|
936
|
-
return;
|
937
|
-
}
|
938
|
-
if (tab == null) {
|
939
|
-
//chrome.tabs.update's callback doesn't pass a Tab argument,
|
940
|
-
//so we need to populate it ourselves
|
941
|
-
chrome.tabs.get(ChromeDriver.activeTabId, getUrlCallback);
|
942
|
-
return;
|
943
|
-
}
|
944
|
-
if (tab.status != "complete") {
|
945
|
-
// Use the helper calback so that we actually get updated version of the tab
|
946
|
-
// we're getting
|
947
|
-
setTimeout("getUrlCallbackById(" + tab.id + ")", 10);
|
948
|
-
} else {
|
949
|
-
ChromeDriver.getUrlRequestSequenceNumber++;
|
950
|
-
if (ChromeDriver.activePort == null) {
|
951
|
-
if (ChromeDriver.currentlyWaitingUntilGiveUpOnContentScriptLoading <= 0) {
|
952
|
-
ChromeDriver.hasNoConnectionToPage = true;
|
953
|
-
sendEmptyResponseWhenTabIsLoaded(tab);
|
954
|
-
} else {
|
955
|
-
ChromeDriver.currentlyWaitingUntilGiveUpOnContentScriptLoading -=
|
956
|
-
ChromeDriver.waitForContentScriptIncrement;
|
957
|
-
setTimeout("getUrlCallbackById(" + tab.id + ")", ChromeDriver.waitForContentScriptIncrement);
|
958
|
-
return;
|
959
|
-
}
|
960
|
-
}
|
961
|
-
setActiveTabDetails(tab);
|
962
|
-
}
|
963
|
-
if (ChromeDriver.isGettingUrlButOnlyChangingByFragment) {
|
964
|
-
ChromeDriver.urlBeingLoaded = null;
|
965
|
-
resetCurrentlyWaitingOnContentScriptTime();
|
966
|
-
sendResponseToParsedRequest({status: 0}, false);
|
967
|
-
ChromeDriver.isGettingUrlButOnlyChangingByFragment = false;
|
968
|
-
}
|
969
|
-
}
|
970
|
-
|
971
|
-
function getUrlCallbackById(tabId) {
|
972
|
-
chrome.tabs.get(tabId, getUrlCallback);
|
973
|
-
}
|
974
|
-
|
975
|
-
function sendEmptyResponseWhenTabIsLoaded(tab) {
|
976
|
-
if (tab.status == "complete") {
|
977
|
-
if (ChromeDriver.activePort) {
|
978
|
-
ChromeDriver.isBlockedWaitingForResponse = false;
|
979
|
-
parseRequest({request: 'sniffForMetaRedirects'});
|
980
|
-
} else {
|
981
|
-
if (!ChromeDriver.hasSentResponseToThisPageLoading) {
|
982
|
-
ChromeDriver.urlBeingLoaded = null;
|
983
|
-
sendResponseToParsedRequest({status: 0}, false);
|
984
|
-
}
|
985
|
-
}
|
986
|
-
} else {
|
987
|
-
chrome.tabs.get(tab.id, sendEmptyResponseWhenTabIsLoaded);
|
988
|
-
}
|
989
|
-
}
|
990
|
-
|
991
|
-
|
992
|
-
function setExtensionBusyIndicator(busy) {
|
993
|
-
if (busy) {
|
994
|
-
chrome.browserAction.setIcon({path: "icons/busy.png"})
|
995
|
-
} else {
|
996
|
-
chrome.browserAction.setIcon({path: "icons/free.png"})
|
997
|
-
}
|
998
|
-
}
|
999
|
-
|
1000
|
-
function setActivePortByWindowName(handle) {
|
1001
|
-
for (var tab in ChromeDriver.tabs) {
|
1002
|
-
if (ChromeDriver.tabs[tab].windowName == handle ||
|
1003
|
-
ChromeDriver.tabs[tab].mainPort.name == handle ||
|
1004
|
-
ChromeDriver.tabs[tab].tabId.toString() == handle) {
|
1005
|
-
ChromeDriver.activePort = ChromeDriver.tabs[tab].mainPort;
|
1006
|
-
chrome.tabs.get(ChromeDriver.tabs[tab].tabId, setActiveTabDetails);
|
1007
|
-
chrome.tabs.update(ChromeDriver.tabs[tab].tabId, {selected: true});
|
1008
|
-
sendResponseToParsedRequest({status: 0}, false);
|
1009
|
-
return;
|
1010
|
-
}
|
1011
|
-
}
|
1012
|
-
sendResponseToParsedRequest({status: 23, value: {message: 'Could not find window to switch to by handle: ' + handle}}, false);
|
1013
|
-
}
|
1014
|
-
|
1015
|
-
|
1016
|
-
/**
|
1017
|
-
* @return {boolean} Whether there is currently no active page.
|
1018
|
-
*/
|
1019
|
-
function hasNoPage() {
|
1020
|
-
return ChromeDriver.hasNoConnectionToPage ||
|
1021
|
-
ChromeDriver.activePort == null ||
|
1022
|
-
ChromeDriver.activeTabId == null;
|
1023
|
-
}
|
1024
|
-
|
1025
|
-
function resetCurrentlyWaitingOnContentScriptTime() {
|
1026
|
-
console.log('resetting current content script wait time');
|
1027
|
-
ChromeDriver.currentlyWaitingUntilGiveUpOnContentScriptLoading =
|
1028
|
-
ChromeDriver.timeoutUntilGiveUpOnContentScriptLoading;
|
1029
|
-
}
|