rainux-selenium-webdriver 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +204 -0
- data/chrome/prebuilt/Win32/Release/npchromedriver.dll +0 -0
- data/chrome/prebuilt/x64/Release/npchromedriver.dll +0 -0
- data/chrome/src/extension/background.html +9 -0
- data/chrome/src/extension/background.js +995 -0
- data/chrome/src/extension/content_script.js +1321 -0
- 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 +19 -0
- data/chrome/src/extension/manifest-win.json +20 -0
- data/chrome/src/extension/utils.js +231 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome.rb +8 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/bridge.rb +358 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/command_executor.rb +124 -0
- data/chrome/src/rb/lib/selenium/webdriver/chrome/launcher.rb +135 -0
- data/common/src/js/abstractcommandprocessor.js +134 -0
- data/common/src/js/asserts.js +296 -0
- data/common/src/js/by.js +149 -0
- data/common/src/js/command.js +304 -0
- data/common/src/js/context.js +58 -0
- data/common/src/js/core/Blank.html +7 -0
- data/common/src/js/core/InjectedRemoteRunner.html +8 -0
- data/common/src/js/core/RemoteRunner.html +101 -0
- data/common/src/js/core/SeleniumLog.html +109 -0
- data/common/src/js/core/TestPrompt.html +145 -0
- data/common/src/js/core/TestRunner-splash.html +55 -0
- data/common/src/js/core/TestRunner.html +165 -0
- 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 +6 -0
- data/common/src/js/core/lib/cssQuery/src/cssQuery-level2.js +142 -0
- data/common/src/js/core/lib/cssQuery/src/cssQuery-level3.js +150 -0
- data/common/src/js/core/lib/cssQuery/src/cssQuery-standard.js +53 -0
- data/common/src/js/core/lib/cssQuery/src/cssQuery.js +356 -0
- data/common/src/js/core/lib/prototype.js +2006 -0
- data/common/src/js/core/lib/scriptaculous/builder.js +101 -0
- data/common/src/js/core/lib/scriptaculous/controls.js +815 -0
- data/common/src/js/core/lib/scriptaculous/dragdrop.js +915 -0
- data/common/src/js/core/lib/scriptaculous/effects.js +958 -0
- data/common/src/js/core/lib/scriptaculous/scriptaculous.js +47 -0
- data/common/src/js/core/lib/scriptaculous/slider.js +283 -0
- data/common/src/js/core/lib/scriptaculous/unittest.js +383 -0
- data/common/src/js/core/lib/snapsie.js +91 -0
- data/common/src/js/core/scripts/find_matching_child.js +69 -0
- data/common/src/js/core/scripts/htmlutils.js +8716 -0
- data/common/src/js/core/scripts/injection.html +72 -0
- data/common/src/js/core/scripts/selenium-api.js +3291 -0
- data/common/src/js/core/scripts/selenium-browserbot.js +2457 -0
- data/common/src/js/core/scripts/selenium-browserdetect.js +153 -0
- data/common/src/js/core/scripts/selenium-commandhandlers.js +379 -0
- data/common/src/js/core/scripts/selenium-executionloop.js +175 -0
- data/common/src/js/core/scripts/selenium-logging.js +148 -0
- data/common/src/js/core/scripts/selenium-remoterunner.js +695 -0
- data/common/src/js/core/scripts/selenium-testrunner.js +1362 -0
- data/common/src/js/core/scripts/selenium-version.js +5 -0
- data/common/src/js/core/scripts/ui-doc.html +808 -0
- data/common/src/js/core/scripts/ui-element.js +1644 -0
- data/common/src/js/core/scripts/ui-map-sample.js +979 -0
- data/common/src/js/core/scripts/user-extensions.js +3 -0
- data/common/src/js/core/scripts/user-extensions.js.sample +75 -0
- data/common/src/js/core/scripts/xmlextras.js +153 -0
- data/common/src/js/core/selenium-logo.png +0 -0
- data/common/src/js/core/selenium-test.css +43 -0
- data/common/src/js/core/selenium.css +316 -0
- data/common/src/js/core/xpath/dom.js +566 -0
- data/common/src/js/core/xpath/javascript-xpath-0.1.11.js +2816 -0
- data/common/src/js/core/xpath/util.js +549 -0
- data/common/src/js/core/xpath/xmltoken.js +149 -0
- data/common/src/js/core/xpath/xpath.js +2481 -0
- data/common/src/js/extension/README +2 -0
- data/common/src/js/extension/dommessenger.js +152 -0
- data/common/src/js/factory.js +55 -0
- data/common/src/js/future.js +141 -0
- data/common/src/js/jsunit.js +40 -0
- data/common/src/js/jsunit/app/css/jsUnitStyle.css +50 -0
- data/common/src/js/jsunit/app/css/readme +10 -0
- data/common/src/js/jsunit/app/emptyPage.html +11 -0
- data/common/src/js/jsunit/app/jsUnitCore.js +534 -0
- data/common/src/js/jsunit/app/jsUnitMockTimeout.js +81 -0
- data/common/src/js/jsunit/app/jsUnitTestManager.js +705 -0
- data/common/src/js/jsunit/app/jsUnitTestSuite.js +44 -0
- data/common/src/js/jsunit/app/jsUnitTracer.js +102 -0
- data/common/src/js/jsunit/app/jsUnitVersionCheck.js +59 -0
- data/common/src/js/jsunit/app/main-counts-errors.html +12 -0
- data/common/src/js/jsunit/app/main-counts-failures.html +13 -0
- data/common/src/js/jsunit/app/main-counts-runs.html +13 -0
- data/common/src/js/jsunit/app/main-counts.html +21 -0
- data/common/src/js/jsunit/app/main-data.html +178 -0
- data/common/src/js/jsunit/app/main-errors.html +23 -0
- data/common/src/js/jsunit/app/main-frame.html +19 -0
- data/common/src/js/jsunit/app/main-loader.html +45 -0
- data/common/src/js/jsunit/app/main-progress.html +25 -0
- data/common/src/js/jsunit/app/main-results.html +67 -0
- data/common/src/js/jsunit/app/main-status.html +13 -0
- data/common/src/js/jsunit/app/testContainer.html +16 -0
- data/common/src/js/jsunit/app/testContainerController.html +77 -0
- data/common/src/js/jsunit/app/xbDebug.js +306 -0
- data/common/src/js/jsunit/changelog.txt +60 -0
- data/common/src/js/jsunit/css/jsUnitStyle.css +83 -0
- 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 +56 -0
- data/common/src/js/jsunit/licenses/Jetty_license.html +213 -0
- data/common/src/js/jsunit/licenses/MPL-1.1.txt +470 -0
- data/common/src/js/jsunit/licenses/gpl-2.txt +340 -0
- data/common/src/js/jsunit/licenses/index.html +141 -0
- data/common/src/js/jsunit/licenses/lgpl-2.1.txt +504 -0
- data/common/src/js/jsunit/licenses/mpl-tri-license-c.txt +35 -0
- data/common/src/js/jsunit/licenses/mpl-tri-license-html.txt +35 -0
- data/common/src/js/jsunit/readme.txt +19 -0
- data/common/src/js/jsunit/testRunner.html +167 -0
- data/common/src/js/jsunit/version.txt +1 -0
- data/common/src/js/key.js +117 -0
- data/common/src/js/localcommandprocessor.js +185 -0
- data/common/src/js/testcase.js +217 -0
- data/common/src/js/timing.js +89 -0
- data/common/src/js/webdriver.js +890 -0
- data/common/src/js/webelement.js +485 -0
- data/common/src/rb/README +30 -0
- data/common/src/rb/lib/selenium-webdriver.rb +1 -0
- data/common/src/rb/lib/selenium/webdriver.rb +67 -0
- data/common/src/rb/lib/selenium/webdriver/bridge_helper.rb +91 -0
- data/common/src/rb/lib/selenium/webdriver/child_process.rb +180 -0
- data/common/src/rb/lib/selenium/webdriver/core_ext/dir.rb +41 -0
- data/common/src/rb/lib/selenium/webdriver/driver.rb +252 -0
- data/common/src/rb/lib/selenium/webdriver/driver_extensions/takes_screenshot.rb +24 -0
- data/common/src/rb/lib/selenium/webdriver/element.rb +262 -0
- data/common/src/rb/lib/selenium/webdriver/error.rb +67 -0
- data/common/src/rb/lib/selenium/webdriver/find.rb +89 -0
- data/common/src/rb/lib/selenium/webdriver/keys.rb +84 -0
- data/common/src/rb/lib/selenium/webdriver/navigation.rb +27 -0
- data/common/src/rb/lib/selenium/webdriver/options.rb +50 -0
- data/common/src/rb/lib/selenium/webdriver/platform.rb +86 -0
- data/common/src/rb/lib/selenium/webdriver/target_locator.rb +70 -0
- data/firefox/prebuilt/Win32/Release/webdriver-firefox.dll +0 -0
- data/firefox/prebuilt/linux/Release/libwebdriver-firefox.so +0 -0
- data/firefox/prebuilt/linux/Release/x_ignore_nofocus.so +0 -0
- data/firefox/prebuilt/linux64/Release/libwebdriver-firefox.so +0 -0
- data/firefox/prebuilt/linux64/Release/x_ignore_nofocus.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 +3 -0
- data/firefox/src/extension/components/badCertListener.js +294 -0
- data/firefox/src/extension/components/context.js +37 -0
- data/firefox/src/extension/components/driver-component.js +127 -0
- data/firefox/src/extension/components/firefoxDriver.js +810 -0
- data/firefox/src/extension/components/json2.js +273 -0
- data/firefox/src/extension/components/keytest.html +554 -0
- data/firefox/src/extension/components/nsCommandProcessor.js +643 -0
- data/firefox/src/extension/components/promptService.js +208 -0
- data/firefox/src/extension/components/screenshooter.js +81 -0
- data/firefox/src/extension/components/socketListener.js +185 -0
- data/firefox/src/extension/components/utils.js +1263 -0
- data/firefox/src/extension/components/webLoadingListener.js +57 -0
- data/firefox/src/extension/components/webdriverserver.js +106 -0
- data/firefox/src/extension/components/wrappedElement.js +683 -0
- data/firefox/src/extension/content/fxdriver.xul +30 -0
- data/firefox/src/extension/content/server.js +95 -0
- data/firefox/src/extension/idl/nsICommandProcessor.idl +38 -0
- data/firefox/src/extension/idl/nsIResponseHandler.idl +34 -0
- data/firefox/src/extension/install.rdf +29 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox.rb +31 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/binary.rb +107 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/bridge.rb +484 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/extension_connection.rb +90 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/launcher.rb +155 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/profile.rb +233 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/profiles_ini.rb +59 -0
- data/firefox/src/rb/lib/selenium/webdriver/firefox/util.rb +23 -0
- data/jobbie/prebuilt/Win32/Release/InternetExplorerDriver.dll +0 -0
- data/jobbie/prebuilt/x64/Release/InternetExplorerDriver.dll +0 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie.rb +14 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/bridge.rb +565 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/lib.rb +99 -0
- data/jobbie/src/rb/lib/selenium/webdriver/ie/util.rb +147 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote.rb +16 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/bridge.rb +408 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/capabilities.rb +105 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/commands.rb +53 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/default_http_client.rb +71 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/response.rb +49 -0
- data/remote/client/src/rb/lib/selenium/webdriver/remote/server_error.rb +32 -0
- metadata +303 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
class Navigation
|
4
|
+
|
5
|
+
def initialize(driver)
|
6
|
+
@bridge = driver.bridge
|
7
|
+
end
|
8
|
+
|
9
|
+
def to(url)
|
10
|
+
@bridge.get url
|
11
|
+
end
|
12
|
+
|
13
|
+
def back
|
14
|
+
@bridge.goBack
|
15
|
+
end
|
16
|
+
|
17
|
+
def forward
|
18
|
+
@bridge.goForward
|
19
|
+
end
|
20
|
+
|
21
|
+
def refresh
|
22
|
+
@bridge.refresh
|
23
|
+
end
|
24
|
+
|
25
|
+
end # Navigation
|
26
|
+
end # WebDriver
|
27
|
+
end # Selenium
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
class Options
|
4
|
+
|
5
|
+
def initialize(driver)
|
6
|
+
@bridge = driver.bridge
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_cookie(opts = {})
|
10
|
+
raise ArgumentError, "name is required" unless opts[:name]
|
11
|
+
raise ArgumentError, "value is required" unless opts[:value]
|
12
|
+
|
13
|
+
opts[:path] ||= "/"
|
14
|
+
opts[:secure] ||= false
|
15
|
+
|
16
|
+
@bridge.addCookie opts
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete_cookie(name)
|
20
|
+
@bridge.deleteCookie name
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete_all_cookies
|
24
|
+
@bridge.deleteAllCookies
|
25
|
+
end
|
26
|
+
|
27
|
+
def all_cookies
|
28
|
+
@bridge.getAllCookies.map do |cookie|
|
29
|
+
{
|
30
|
+
:name => cookie["name"],
|
31
|
+
:value => cookie["value"],
|
32
|
+
:path => cookie["path"],
|
33
|
+
:domain => cookie["domain"],
|
34
|
+
:expires => cookie["expires"],
|
35
|
+
:secure => cookie["secure"]
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def speed
|
41
|
+
@bridge.getSpeed.downcase.to_sym
|
42
|
+
end
|
43
|
+
|
44
|
+
def speed=(speed)
|
45
|
+
@bridge.setSpeed(speed.to_s.upcase)
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Options
|
49
|
+
end # WebDriver
|
50
|
+
end # Selenium
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
|
3
|
+
module Selenium
|
4
|
+
module WebDriver
|
5
|
+
module Platform
|
6
|
+
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def home
|
10
|
+
# jruby has an issue with ENV['HOME'] on Windows
|
11
|
+
@home ||= Platform.jruby? ? java.lang.System.getProperty('user.home') : ENV['HOME']
|
12
|
+
end
|
13
|
+
|
14
|
+
def platform
|
15
|
+
@platform ||= begin
|
16
|
+
if defined? RUBY_ENGINE
|
17
|
+
RUBY_ENGINE.to_sym
|
18
|
+
else
|
19
|
+
:ruby
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def os
|
25
|
+
@os ||= begin
|
26
|
+
case Config::CONFIG['host_os']
|
27
|
+
when /mswin|msys|mingw32/
|
28
|
+
:windows
|
29
|
+
when /darwin|mac os/
|
30
|
+
:macosx
|
31
|
+
when /linux/
|
32
|
+
:linux
|
33
|
+
when /solaris|bsd/
|
34
|
+
:unix
|
35
|
+
else
|
36
|
+
# unlikely
|
37
|
+
raise Error::WebDriverError, "unknown os #{Config::CONFIG['host_os']}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def jruby?
|
43
|
+
platform == :jruby
|
44
|
+
end
|
45
|
+
|
46
|
+
def ironruby?
|
47
|
+
platform == :ironruby
|
48
|
+
end
|
49
|
+
|
50
|
+
def ruby187?
|
51
|
+
!!(RUBY_VERSION =~ /^1\.8\.7/)
|
52
|
+
end
|
53
|
+
|
54
|
+
def ruby19?
|
55
|
+
!!(RUBY_VERSION =~ /^1\.9/)
|
56
|
+
end
|
57
|
+
|
58
|
+
def win?
|
59
|
+
os == :windows
|
60
|
+
end
|
61
|
+
|
62
|
+
def mac?
|
63
|
+
os == :macosx
|
64
|
+
end
|
65
|
+
|
66
|
+
def wrap_in_quotes_if_necessary(str)
|
67
|
+
win? ? %{"#{str}"} : str
|
68
|
+
end
|
69
|
+
|
70
|
+
def make_writable(file)
|
71
|
+
File.chmod 0766, file
|
72
|
+
end
|
73
|
+
|
74
|
+
end # Platform
|
75
|
+
end # WebDriver
|
76
|
+
end # Selenium
|
77
|
+
|
78
|
+
if __FILE__ == $0
|
79
|
+
p :platform => Selenium::WebDriver::Platform.platform,
|
80
|
+
:os => Selenium::WebDriver::Platform.os,
|
81
|
+
:ruby187? => Selenium::WebDriver::Platform.ruby187?,
|
82
|
+
:ruby19? => Selenium::WebDriver::Platform.ruby19?,
|
83
|
+
:jruby? => Selenium::WebDriver::Platform.jruby?,
|
84
|
+
:win? => Selenium::WebDriver::Platform.win?,
|
85
|
+
:home => Selenium::WebDriver::Platform.home
|
86
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Selenium
|
2
|
+
module WebDriver
|
3
|
+
class TargetLocator
|
4
|
+
|
5
|
+
#
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
|
9
|
+
def initialize(driver)
|
10
|
+
@bridge = driver.bridge
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# switch to the frame with the given id
|
15
|
+
#
|
16
|
+
|
17
|
+
def frame(id)
|
18
|
+
@bridge.switchToFrame id
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# switch to the frame with the given id
|
23
|
+
#
|
24
|
+
# If given a block, this method will return to the original window after
|
25
|
+
# block execution.
|
26
|
+
#
|
27
|
+
# @param id
|
28
|
+
# A window handle
|
29
|
+
#
|
30
|
+
|
31
|
+
def window(id)
|
32
|
+
if block_given?
|
33
|
+
original = @bridge.getCurrentWindowHandle
|
34
|
+
@bridge.switchToWindow id
|
35
|
+
|
36
|
+
yield
|
37
|
+
|
38
|
+
current_handles = @bridge.getWindowHandles
|
39
|
+
|
40
|
+
if current_handles.size == 1
|
41
|
+
original = current_handles.shift
|
42
|
+
end
|
43
|
+
|
44
|
+
@bridge.switchToWindow original
|
45
|
+
else
|
46
|
+
@bridge.switchToWindow id
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# get the active element
|
52
|
+
#
|
53
|
+
# @return [WebDriver::Element]
|
54
|
+
#
|
55
|
+
|
56
|
+
def active_element
|
57
|
+
@bridge.switchToActiveElement
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# selects either the first frame on the page, or the main document when a page contains iframes.
|
62
|
+
#
|
63
|
+
|
64
|
+
def default_content
|
65
|
+
@bridge.switchToDefaultContent
|
66
|
+
end
|
67
|
+
|
68
|
+
end # TargetLocator
|
69
|
+
end # WebDriver
|
70
|
+
end # Selenium
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,294 @@
|
|
1
|
+
/*
|
2
|
+
Copyright 2007-2009 WebDriver committers
|
3
|
+
Copyright 2007-2009 Google Inc.
|
4
|
+
Portions copyright 2007 ThoughtWorks, Inc
|
5
|
+
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
you may not use this file except in compliance with the License.
|
8
|
+
You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
*/
|
18
|
+
|
19
|
+
/**
|
20
|
+
* @fileOverview Contains a Javascript implementation for
|
21
|
+
* a custom nsICertOverrideService. This class will forward requests to the
|
22
|
+
* original certificate override service - unless it was told to accept all
|
23
|
+
* of them.
|
24
|
+
*/
|
25
|
+
|
26
|
+
const CC = Components.classes;
|
27
|
+
const CI = Components.interfaces;
|
28
|
+
|
29
|
+
const CONSOLE = CC["@mozilla.org/consoleservice;1"].
|
30
|
+
getService(CI["nsIConsoleService"]);
|
31
|
+
|
32
|
+
function localdump(message) {
|
33
|
+
try {
|
34
|
+
CONSOLE.logStringMessage(message + "\n");
|
35
|
+
} catch (e) {
|
36
|
+
dump(message + "\n");
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
function getPreferenceFromProfile(prefName, prefDefaultValue) {
|
41
|
+
var prefs =
|
42
|
+
CC["@mozilla.org/preferences-service;1"].getService(CI["nsIPrefBranch"]);
|
43
|
+
|
44
|
+
if (!prefs.prefHasUserValue(prefName)) {
|
45
|
+
localdump(prefName + ' not set; defaulting to ' + prefDefaultValue);
|
46
|
+
return prefDefaultValue;
|
47
|
+
}
|
48
|
+
|
49
|
+
var prefValue = prefs.getBoolPref(prefName);
|
50
|
+
localdump("Found preference for " + prefName + ": " + prefValue);
|
51
|
+
|
52
|
+
return prefValue;
|
53
|
+
}
|
54
|
+
|
55
|
+
function shouldAcceptUntrustedCerts() {
|
56
|
+
return getPreferenceFromProfile("webdriver_accept_untrusted_certs", true);
|
57
|
+
}
|
58
|
+
|
59
|
+
function shouldAssumeUntrustedIssuer() {
|
60
|
+
return getPreferenceFromProfile("webdriver_assume_untrusted_issuer", true);
|
61
|
+
}
|
62
|
+
|
63
|
+
function WdCertOverrideService() {
|
64
|
+
// Defaults to true - accepting untrusted certificates.
|
65
|
+
// This puts the module into effect - setting it to false
|
66
|
+
// will delegate all calls to the original service.
|
67
|
+
this.acceptAll = shouldAcceptUntrustedCerts();
|
68
|
+
|
69
|
+
// If untrusted issuer is set to false by the user,
|
70
|
+
// the initial bitmask will not include ERROR_UNTRUSTED.
|
71
|
+
//
|
72
|
+
// See the javadoc for FirefoxProfile and documentation
|
73
|
+
// for fillNeededBits for further explanation.
|
74
|
+
var untrusted_issuer = shouldAssumeUntrustedIssuer();
|
75
|
+
if (untrusted_issuer) {
|
76
|
+
this.default_bits = this.ERROR_UNTRUSTED;
|
77
|
+
} else {
|
78
|
+
this.default_bits = 0;
|
79
|
+
}
|
80
|
+
|
81
|
+
localdump("Accept untrusted certificates: " + this.acceptAll);
|
82
|
+
|
83
|
+
// UUID of the original implementor of this service.
|
84
|
+
var ORIGINAL_OVERRIDE_SERVICE_ID = "{67ba681d-5485-4fff-952c-2ee337ffdcd6}";
|
85
|
+
|
86
|
+
// Keep a reference to the original bad certificate listener.
|
87
|
+
var originalService = Components.classesByID[ORIGINAL_OVERRIDE_SERVICE_ID].
|
88
|
+
getService();
|
89
|
+
|
90
|
+
this.origListener_ =
|
91
|
+
originalService.QueryInterface(
|
92
|
+
Components.interfaces.nsICertOverrideService);
|
93
|
+
};
|
94
|
+
|
95
|
+
// Constants needed since WdCertOverrideService implements
|
96
|
+
// nsICertOverrideService
|
97
|
+
WdCertOverrideService.prototype = {
|
98
|
+
ERROR_UNTRUSTED: 1,
|
99
|
+
ERROR_MISMATCH: 2,
|
100
|
+
ERROR_TIME: 4
|
101
|
+
};
|
102
|
+
|
103
|
+
// Returns the bit needed to mask if the certificate has expired, 0 otherwise.
|
104
|
+
WdCertOverrideService.prototype.certificateExpiredBit_ = function
|
105
|
+
(theCert, verification_result) {
|
106
|
+
if ((verification_result & theCert.CERT_EXPIRED) != 0) {
|
107
|
+
localdump("Certificate expired.");
|
108
|
+
return this.ERROR_TIME;
|
109
|
+
}
|
110
|
+
|
111
|
+
return 0;
|
112
|
+
}
|
113
|
+
|
114
|
+
// Returns the bit needed to mask untrusted issuers, 0 otherwise.
|
115
|
+
// Note that this bit is already set by default in default_bits
|
116
|
+
WdCertOverrideService.prototype.certificateIssuerUntrusted_ = function
|
117
|
+
(theCert, verification_result) {
|
118
|
+
if (((verification_result & theCert.ISSUER_UNKNOWN) != 0) ||
|
119
|
+
((verification_result & theCert.ISSUER_NOT_TRUSTED) != 0) ||
|
120
|
+
((verification_result & theCert.CERT_NOT_TRUSTED) != 0) ||
|
121
|
+
((verification_result & theCert.INVALID_CA) != 0)) {
|
122
|
+
localdump("Certificate issuer unknown.");
|
123
|
+
return this.ERROR_UNTRUSTED;
|
124
|
+
}
|
125
|
+
|
126
|
+
return 0;
|
127
|
+
}
|
128
|
+
|
129
|
+
// Returns the bit needed to mask mismatch between actual hostname
|
130
|
+
// and the hostname the certificate was issued for, 0 otherwise.
|
131
|
+
WdCertOverrideService.prototype.certificateHostnameMismatch_ = function
|
132
|
+
(theCert, aHost) {
|
133
|
+
if (theCert.commonName !== aHost) {
|
134
|
+
localdump("Host name mismatch: cert: " + theCert.commonName + " get: " + aHost);
|
135
|
+
return this.ERROR_MISMATCH;
|
136
|
+
}
|
137
|
+
|
138
|
+
return 0;
|
139
|
+
}
|
140
|
+
|
141
|
+
// Given a certificate and the host it was received for, fill in the bits
|
142
|
+
// needed to accept this certificate for this host, even though the
|
143
|
+
// certificate is invalid.
|
144
|
+
//
|
145
|
+
// Note that the bitmask has to be accurate: At the moment, Firefox expects
|
146
|
+
// the returned bitmask to match *exactly* to the errors the certificate
|
147
|
+
// caused. If extra bits will be set, the untrusted certificate screen
|
148
|
+
// will appear.
|
149
|
+
WdCertOverrideService.prototype.fillNeededBits = function(aCert, aHost) {
|
150
|
+
var verification_bits = aCert.verifyForUsage(aCert.CERT_USAGE_SSLClient);
|
151
|
+
var return_bits = this.default_bits;
|
152
|
+
|
153
|
+
localdump("Certificate verification results: " + verification_bits);
|
154
|
+
|
155
|
+
return_bits = return_bits | this.certificateExpiredBit_(
|
156
|
+
aCert, verification_bits);
|
157
|
+
return_bits = return_bits | this.certificateIssuerUntrusted_(
|
158
|
+
aCert, verification_bits);
|
159
|
+
return_bits = return_bits | this.certificateHostnameMismatch_(aCert, aHost);
|
160
|
+
localdump("return_bits now: " + return_bits);
|
161
|
+
return return_bits;
|
162
|
+
};
|
163
|
+
|
164
|
+
// Interface functions from now on.
|
165
|
+
WdCertOverrideService.prototype.hasMatchingOverride = function(
|
166
|
+
aHostName, aPort, aCert, aOverrideBits, aIsTemporary) {
|
167
|
+
var retval = false;
|
168
|
+
|
169
|
+
if (this.acceptAll === true) {
|
170
|
+
localdump("Allowing certificate from site: " + aHostName + ":" + aPort);
|
171
|
+
retval = true;
|
172
|
+
aIsTemporary.value = false;
|
173
|
+
|
174
|
+
aOverrideBits.value = this.fillNeededBits(aCert, aHostName);
|
175
|
+
localdump("Override Bits: " + aOverrideBits.value);
|
176
|
+
} else {
|
177
|
+
retval = this.origListener_.hasMatchingOverride(aHostName, aPort,
|
178
|
+
aCert, aOverrideBits, aIsTemporary);
|
179
|
+
}
|
180
|
+
|
181
|
+
return retval;
|
182
|
+
};
|
183
|
+
|
184
|
+
// Delegate the rest of the functions - they are not interesting as they are not
|
185
|
+
// called during validation of invalid certificate normally.
|
186
|
+
WdCertOverrideService.prototype.clearValidityOverride = function(aHostName,
|
187
|
+
aPort) {
|
188
|
+
this.origListener_.clearValidityOverride(aHostName, aPort);
|
189
|
+
};
|
190
|
+
|
191
|
+
WdCertOverrideService.prototype.getAllOverrideHostsWithPorts = function(
|
192
|
+
aCount, aHostsWithPortsArray) {
|
193
|
+
this.origListener_.getAllOverrideHostsWithPorts(aCert, aHostsWithPortsArray);
|
194
|
+
};
|
195
|
+
|
196
|
+
WdCertOverrideService.prototype.getValidityOverride = function(
|
197
|
+
aHostName, aPort, aHashAlg, aFingerprint, aOverrideBits, aIsTemporary) {
|
198
|
+
return this.origListener_.getValidityOverride(
|
199
|
+
aHostName, aPort, aHashAlg, aFingerprint, aOverrideBits, aIsTemporary);
|
200
|
+
};
|
201
|
+
|
202
|
+
WdCertOverrideService.prototype.isCertUsedForOverrides = function(
|
203
|
+
aCert, aCheckTemporaries, aCheckPermanents) {
|
204
|
+
return this.origListener_.isCertUsedForOverrides(
|
205
|
+
aCert, aCheckTemporaries, aCheckPermanents);
|
206
|
+
};
|
207
|
+
|
208
|
+
WdCertOverrideService.prototype.rememberValidityOverride = function(
|
209
|
+
aHostName, aPort, aCert, aOverrideBits, aTemporary) {
|
210
|
+
this.origListener_.rememberValidityOverride(
|
211
|
+
aHostName, aPort, aCert, aOverrideBits, aTemporary);
|
212
|
+
};
|
213
|
+
|
214
|
+
WdCertOverrideService.prototype.QueryInterface = function(aIID) {
|
215
|
+
if (aIID.equals(Components.interfaces.nsICertOverrideService) ||
|
216
|
+
aIID.equals(Components.interfaces.nsIInterfaceRequestor) ||
|
217
|
+
aIID.equals(Components.interfaces.nsISupports)) {
|
218
|
+
return this;
|
219
|
+
}
|
220
|
+
|
221
|
+
throw Components.results.NS_ERROR_NO_INTERFACE;
|
222
|
+
}
|
223
|
+
|
224
|
+
// Service contract ID which we override
|
225
|
+
const CERTOVERRIDE_CONTRACT_ID = "@mozilla.org/security/certoverride;1";
|
226
|
+
// UUID for this instance specifically.
|
227
|
+
const DUMMY_CERTOVERRIDE_SERVICE_CLASS_ID =
|
228
|
+
Components.ID('{c8fffaba-9b7a-41aa-872d-7e7366c16715}');
|
229
|
+
|
230
|
+
var service = undefined;
|
231
|
+
|
232
|
+
var WDCertOverrideFactory = {
|
233
|
+
createInstance: function (aOuter, aIID) {
|
234
|
+
if (aOuter != null)
|
235
|
+
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
236
|
+
if (service == undefined) {
|
237
|
+
service = new WdCertOverrideService();
|
238
|
+
}
|
239
|
+
return service;
|
240
|
+
}
|
241
|
+
};
|
242
|
+
|
243
|
+
function WDBadCertListenerModule() {
|
244
|
+
this.firstTime_ = true;
|
245
|
+
}
|
246
|
+
|
247
|
+
WDBadCertListenerModule.prototype.registerSelf = function(
|
248
|
+
aCompMgr, aFileSpec, aLocation, aType) {
|
249
|
+
|
250
|
+
if (this.firstTime_) {
|
251
|
+
this.firstTime_ = false;
|
252
|
+
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
253
|
+
}
|
254
|
+
|
255
|
+
localdump("Registering Override Certificate service.");
|
256
|
+
aCompMgr = aCompMgr.QueryInterface(
|
257
|
+
Components.interfaces.nsIComponentRegistrar);
|
258
|
+
aCompMgr.registerFactoryLocation(
|
259
|
+
DUMMY_CERTOVERRIDE_SERVICE_CLASS_ID, "WebDriver Override Cert Service",
|
260
|
+
CERTOVERRIDE_CONTRACT_ID, aFileSpec, aLocation, aType);
|
261
|
+
};
|
262
|
+
|
263
|
+
WDBadCertListenerModule.prototype.unregisterSelf = function(
|
264
|
+
aCompMgr, aLocation, aType) {
|
265
|
+
localdump("Un-registering Override Certificate service.");
|
266
|
+
aCompMgr =
|
267
|
+
aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
268
|
+
aCompMgr.unregisterFactoryLocation(DUMMY_CERTOVERRIDE_SERVICE_CLASS_ID, aLocation);
|
269
|
+
};
|
270
|
+
|
271
|
+
WDBadCertListenerModule.prototype.getClassObject = function(
|
272
|
+
aCompMgr, aCID, aIID) {
|
273
|
+
if (!aIID.equals(Components.interfaces.nsIFactory))
|
274
|
+
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
275
|
+
|
276
|
+
if (aCID.equals(DUMMY_CERTOVERRIDE_SERVICE_CLASS_ID))
|
277
|
+
return WDCertOverrideFactory;
|
278
|
+
|
279
|
+
throw Components.results.NS_ERROR_NO_INTERFACE;
|
280
|
+
};
|
281
|
+
|
282
|
+
WDBadCertListenerModule.prototype.canUnload = function(aCompMgr) {
|
283
|
+
return true;
|
284
|
+
};
|
285
|
+
|
286
|
+
function NSGetModule(comMgr, fileSpec) {
|
287
|
+
var appInfo = Components.classes['@mozilla.org/xre/app-info;1'].
|
288
|
+
getService(Components.interfaces.nsIXULAppInfo);
|
289
|
+
var versionChecker = Components.classes['@mozilla.org/xpcom/version-comparator;1'].
|
290
|
+
getService(Components.interfaces.nsIVersionComparator);
|
291
|
+
if (versionChecker.compare(appInfo.version, '3.0') >= 0) {
|
292
|
+
return new WDBadCertListenerModule();
|
293
|
+
}
|
294
|
+
}
|