[ChromeDriver] Update Selenium code to latest version

Update to revision: 3f8670ddf1fd033c00732ae64ace2254f8cf4f41
Change-Id: I97c2ec64d6dc8436bde0fa642ce84244ffd07c01
diff --git a/README.chromium b/README.chromium
index 58ca3a8..f1fb9ba 100644
--- a/README.chromium
+++ b/README.chromium
@@ -2,7 +2,7 @@
 Short Name: WebDriver
 URL: https://github.com/SeleniumHQ/selenium
 Version: 3.14
-Revision: 253fc6b579f23c799b618cfc778ddf1eed4f0d90
+Revision: 3f8670ddf1fd033c00732ae64ace2254f8cf4f41
 License: Apache 2.0,
 License File: https://github.com/SeleniumHQ/selenium/blob/master/LICENSE
 Security Critical: no
diff --git a/Rakefile b/Rakefile
index 2c5f64b..151089d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -31,10 +31,8 @@
 # The original build rules
 require 'rake-tasks/task-gen'
 require 'rake-tasks/checks'
-require 'rake-tasks/dotnet'
 require 'rake-tasks/c'
 require 'rake-tasks/selenium'
-require 'rake-tasks/se-ide'
 require 'rake-tasks/ie_code_generator'
 require 'rake-tasks/ci'
 require 'rake-tasks/copyright'
@@ -46,15 +44,13 @@
 verbose($DEBUG)
 
 def release_version
-  "3.14"
+  "3.141"
 end
 
 def version
-  "#{release_version}.0"
+  "#{release_version}.5"
 end
 
-ide_version = "2.9.1"
-
 # The build system used by webdriver is layered on top of rake, and we call it
 # "crazy fun" for no readily apparent reason.
 
@@ -90,14 +86,20 @@
 # need to fall back to prebuilt binaries. The prebuilt binaries are stored in
 # a directory structure identical to that used in the "build" folder, but
 # rooted at one of the following locations:
-["cpp/prebuilt", "ide/main/prebuilt", "javascript/firefox-driver/prebuilt"].each do |pre|
+["cpp/prebuilt", "javascript/firefox-driver/prebuilt"].each do |pre|
   crazy_fun.prebuilt_roots << pre
 end
 
 # Finally, find every file named "build.desc" in the project, and generate
 # rake tasks from them. These tasks are normal rake tasks, and can be invoked
 # from rake.
-crazy_fun.create_tasks(Dir["**/build.desc"])
+crazy_fun.create_tasks(Dir["common/**/build.desc"])
+crazy_fun.create_tasks(Dir["cpp/**/build.desc"])
+crazy_fun.create_tasks(Dir["javascript/**/build.desc"])
+crazy_fun.create_tasks(Dir["py/**/build.desc"])
+crazy_fun.create_tasks(Dir["rake-tasks/**/build.desc"])
+crazy_fun.create_tasks(Dir["rb/**/build.desc"])
+crazy_fun.create_tasks(Dir["third_party/**/build.desc"])
 
 # Buck integration. Loaded after CrazyFun has initialized all the tasks it'll handle.
 # This is because the buck integration creates a rule for "//.*"
@@ -168,11 +170,6 @@
 desc 'Build the standalone server'
 task 'selenium-server-standalone' => '//java/server/src/org/openqa/grid/selenium:selenium'
 
-task :ide => [ "//ide:selenium-ide-multi" ]
-task :ide_proxy_setup => [ "//javascript/selenium-atoms", "se_ide:setup_proxy" ]
-task :ide_proxy_remove => [ "se_ide:remove_proxy" ]
-task :ide_bamboo => ["se_ide:assemble_ide_in_bamboo"]
-
 task :test_javascript => [
   'calcdeps',
   '//javascript/atoms:atoms-chrome:run',
@@ -288,14 +285,7 @@
 
 task :test_py => [ :py_prep_for_install_release, "//py:marionette_test:run" ]
 
-task :test_dotnet => [
-  "//dotnet/test:firefox:run"
-]
-
 task :test => [ :test_javascript, :test_java, :test_rb ]
-if (msbuild_installed?)
-  task :test => [ :test_dotnet ]
-end
 if (python?)
   task :test => [ :test_py ]
 end
@@ -310,8 +300,6 @@
   rm_rf 'dist/'
 end
 
-task :dotnet => [ "//dotnet", "//dotnet:support", "//dotnet:core", "//dotnet:webdriverbackedselenium" ]
-
 # Generate a C++ Header file for mapping between magic numbers and #defines
 # in the C++ code.
 ie_generate_type_mapping(:name => "ie_result_type_cpp",
@@ -527,11 +515,6 @@
 desc 'Build the selenium client jars'
 task 'selenium-java' => '//java/client/src/org/openqa/selenium:selenium'
 
-desc 'Build and package Selenium IDE'
-task :release_ide  => [:ide] do
-  cp 'build/ide/selenium-ide.xpi', "build/ide/selenium-ide-#{ide_version}.xpi"
-end
-
 namespace :node do
   task :atoms => [
     "//javascript/atoms/fragments:is-displayed",
diff --git a/buildAutomation.sh b/buildAutomation.sh
index a1af11f..99cfb5c 100755
--- a/buildAutomation.sh
+++ b/buildAutomation.sh
@@ -47,4 +47,5 @@
         cp -f third_party/java/assertj/assertj-core-3.11.1.jar $1/jar
         cp -f third_party/java/gson/gson-2.8.4.jar $1/jar
         cp -f third_party/java/littleshoot/littleproxy-1.1.3-SNAPSHOT.jar $1/jar
+        cp -f buck-out/gen/third_party/java/selenium/__htmlunit-driver__/htmlunit-driver-2.32.1.jar $1/jar
 fi
diff --git a/common/src/web/button.png b/common/src/web/button.png
new file mode 100644
index 0000000..81a06ee
--- /dev/null
+++ b/common/src/web/button.png
Binary files differ
diff --git a/common/src/web/formPage.html b/common/src/web/formPage.html
index 45ae2b7..b4f41dc 100644
--- a/common/src/web/formPage.html
+++ b/common/src/web/formPage.html
@@ -19,7 +19,7 @@
 </form>
 
 <form method="get" action="resultPage.html" name="image">
-    <input type="image" id="imageButton" alt="click me!" src="images/button.gif"/>
+    <input type="image" id="imageButton" alt="click me!" src="button.png"/>
 </form>
 
 <form method="get" action="resultPage.html" name="optional" style="display: block">
diff --git a/common/src/web/selectableItems.html b/common/src/web/selectableItems.html
index 190b2ad..a891544 100644
--- a/common/src/web/selectableItems.html
+++ b/common/src/web/selectableItems.html
@@ -3,7 +3,7 @@
 <head>
 	<meta charset="UTF-8" />
 	<title>jQuery UI Selectable - Default functionality</title>
-        <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.1.custom.css" rel="stylesheet" />
+        <link type="text/css" href="css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />
         <script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
         <script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script>
 	
diff --git a/jar/annotations.jar b/jar/annotations.jar
index 026b710..c1f0385 100644
--- a/jar/annotations.jar
+++ b/jar/annotations.jar
Binary files differ
diff --git a/jar/drivers.jar b/jar/drivers.jar
index b17e8a3..249d6bf 100644
--- a/jar/drivers.jar
+++ b/jar/drivers.jar
Binary files differ
diff --git a/jar/environment.jar b/jar/environment.jar
index 4bd2783..9372c9d 100644
--- a/jar/environment.jar
+++ b/jar/environment.jar
Binary files differ
diff --git a/jar/helpers-selenium.jar b/jar/helpers-selenium.jar
index c4747d8..e00ca4e 100644
--- a/jar/helpers-selenium.jar
+++ b/jar/helpers-selenium.jar
Binary files differ
diff --git a/jar/htmlunit-driver-2.32.1.jar b/jar/htmlunit-driver-2.32.1.jar
new file mode 100644
index 0000000..97887d4
--- /dev/null
+++ b/jar/htmlunit-driver-2.32.1.jar
Binary files differ
diff --git a/jar/selenium.jar b/jar/selenium.jar
index a9ca062..620c109 100644
--- a/jar/selenium.jar
+++ b/jar/selenium.jar
Binary files differ
diff --git a/jar/test-base.jar b/jar/test-base.jar
index 58b7946..ed0ccb8 100644
--- a/jar/test-base.jar
+++ b/jar/test-base.jar
Binary files differ
diff --git a/jar/tests-selenium.jar b/jar/tests-selenium.jar
index dec8e19..6ad1395 100644
--- a/jar/tests-selenium.jar
+++ b/jar/tests-selenium.jar
Binary files differ
diff --git a/jar/tests-support.jar b/jar/tests-support.jar
index 558554e..895f2ef 100644
--- a/jar/tests-support.jar
+++ b/jar/tests-support.jar
Binary files differ
diff --git a/seleniumHQ.patch b/seleniumHQ.patch
index 935fc9e..8766621 100644
--- a/seleniumHQ.patch
+++ b/seleniumHQ.patch
@@ -1,5 +1,5 @@
 diff --git a/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java b/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java
-index ac7da88826..7b251ed038 100644
+index b4a5ebde80..1a0f1869d3 100644
 --- a/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java
 +++ b/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java
 @@ -77,6 +77,9 @@
@@ -97,10 +97,10 @@
 +  }
  }
 diff --git a/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java b/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java
-index 1748a38e33..78b170a4a2 100644
+index 0067bee3ed..074b33e3bf 100644
 --- a/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java
 +++ b/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java
-@@ -111,10 +111,6 @@ public JettyAppServer(String hostName, int httpPort, int httpsPort) {
+@@ -112,10 +112,6 @@ public JettyAppServer(String hostName, int httpPort, int httpsPort) {
  
      ServletContextHandler defaultContext = addResourceHandler(
          DEFAULT_CONTEXT_PATH, locate("common/src/web"));
@@ -112,18 +112,18 @@
      TemporaryFilesystem tempFs = TemporaryFilesystem.getDefaultTmpFS();
      tempPageDir = tempFs.createTempDir("pages", "test");
 diff --git a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
-index 887c4370d9..72d044a423 100644
+index c3f5e39c38..e54136b838 100644
 --- a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
 +++ b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
-@@ -33,6 +33,7 @@
- import org.junit.runners.model.Statement;
+@@ -31,6 +31,7 @@
+ import org.openqa.selenium.Capabilities;
  import org.openqa.selenium.Pages;
  import org.openqa.selenium.WebDriver;
 +import org.openqa.selenium.WebDriverException;
  import org.openqa.selenium.environment.GlobalTestEnvironment;
  import org.openqa.selenium.environment.InProcessTestEnvironment;
  import org.openqa.selenium.environment.TestEnvironment;
-@@ -197,10 +198,25 @@ private boolean notImplemented(Stream<NotYetImplemented> nyi) {
+@@ -163,10 +164,25 @@ private boolean notImplemented(Stream<NotYetImplemented> nyi) {
        return nyi.anyMatch(driver -> matches(browser, new Driver[]{driver.value()}));
      }
  
@@ -151,9 +151,43 @@
          return new Statement() {
            @Override
            public void evaluate() throws Throwable {
-@@ -238,6 +254,29 @@ private void createDriver() {
+@@ -207,10 +223,32 @@ public void createNewDriver(Capabilities capabilities) {
  
-   public static WebDriver actuallyCreateDriver() {
+   private static WebDriver actuallyCreateDriver() {
+     WebDriver driver = storedDriver.get();
++    // If the driver is left in a bad state, create a new one.
++    // This happens on Android after any test that creates its own driver.
++    // Since only one instance of Chrome can run on Android at a time, the
++    // stored driver's browser is destroyed.
++    try
++    {
++      if (driver != null)
++      {
++        driver.getCurrentUrl();
++      }
++    }
++    catch (WebDriverException e)
++    {
++      try
++      {
++        driver.quit();
++      }
++      catch (RuntimeException ignored)
++      {
++        System.exit(1);
++      }
++      driver = null;
++    }
+ 
+     if (driver == null ||
+         (driver instanceof RemoteWebDriver && ((RemoteWebDriver)driver).getSessionId() == null)) {
+-      StaticResources.ensureAvailable();
+       driver = new WebDriverBuilder().get();
+       storedDriver.set(driver);
+     }
+@@ -219,6 +257,29 @@ private static WebDriver actuallyCreateDriver() {
+ 
+   private static WebDriver actuallyCreateDriver(Capabilities capabilities) {
      WebDriver driver = storedDriver.get();
 +    // If the driver is left in a bad state, create a new one.
 +    // This happens on Android after any test that creates its own driver.
@@ -182,13 +216,13 @@
      if (driver == null ||
          (driver instanceof RemoteWebDriver && ((RemoteWebDriver)driver).getSessionId() == null)) {
 diff --git a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java
-index fe29d52fbf..4aae189ef6 100644
+index 24febe5e42..d0bcbdde20 100644
 --- a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java
 +++ b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java
-@@ -65,13 +65,11 @@ public TestChromeDriver(Capabilities capabilities) {
+@@ -61,13 +61,11 @@ public TestChromeDriver(Capabilities capabilities) {
    private static URL getServiceUrl() {
      try {
-       if (service == null && !SauceDriver.shouldUseSauce()) {
+       if (service == null) {
 -        Path logFile = Files.createTempFile("chromedriver", ".log");
          service = new ChromeDriverService.Builder()
              .withVerbose(true)
@@ -200,7 +234,7 @@
          // Fugly.
          Runtime.getRuntime().addShutdownHook(new Thread(() -> service.stop()));
        }
-@@ -84,15 +82,40 @@ private static URL getServiceUrl() {
+@@ -80,15 +78,39 @@ private static URL getServiceUrl() {
    private static Capabilities chromeWithCustomCapabilities(Capabilities originalCapabilities) {
      ChromeOptions options = new ChromeOptions();
      options.addArguments("disable-extensions", "disable-infobars", "disable-breakpad");
@@ -218,7 +252,6 @@
 +    }
 +
      String chromePath = System.getProperty("webdriver.chrome.binary");
-+
      if (chromePath != null) {
        options.setBinary(new File(chromePath));
      }
@@ -246,10 +279,10 @@
        options.merge(originalCapabilities);
      }
 diff --git a/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java b/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java
-index 5d72393134..f6d7cae958 100644
+index 72b97bdee4..e08b5c9e64 100644
 --- a/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java
 +++ b/java/client/test/org/openqa/selenium/testing/drivers/TestIgnorance.java
-@@ -87,25 +87,47 @@ public TestIgnorance(Browser browser) {
+@@ -82,20 +82,44 @@ public TestIgnorance(Browser browser) {
    }
  
    public boolean isIgnored(Description method) {
@@ -279,30 +312,24 @@
 +      }
      }
  
--    ignored |= isIgnoredBecauseOfNativeEvents(method.getTestClass().getAnnotation(NativeEventsRequired.class));
--    ignored |= isIgnoredBecauseOfNativeEvents(method.getAnnotation(NativeEventsRequired.class));
+-    ignored |= isIgnoredDueToEnvironmentVariables(method);
 +    for (int i = 0; i < positivePatterns.length; i++) {
 +      if (name.matches(positivePatterns[i])) {
- 
--    ignored |= isIgnoredDueToEnvironmentVariables(method);
++
 +        boolean ignored = ignoreComparator.shouldIgnore(method.getTestClass().getAnnotation(IgnoreList.class)) ||
 +                          ignoreComparator.shouldIgnore(method.getTestClass().getAnnotation(Ignore.class)) ||
 +                          ignoreComparator.shouldIgnore(method.getAnnotation(IgnoreList.class)) ||
 +                          ignoreComparator.shouldIgnore(method.getAnnotation(Ignore.class));
  
--    ignored |= isIgnoredDueToBeingOnSauce(method);
+-    return ignored;
 +        ignored |= isIgnoredBecauseOfJUnit4Ignore(method.getTestClass().getAnnotation(org.junit.Ignore.class));
 +        ignored |= isIgnoredBecauseOfJUnit4Ignore(method.getAnnotation(org.junit.Ignore.class));
- 
--    return ignored;
++
 +        if (Boolean.getBoolean("ignored_only")) {
 +          ignored = !ignored;
 +        }
 +
-+        ignored |= isIgnoredBecauseOfNativeEvents(method.getTestClass().getAnnotation(NativeEventsRequired.class));
-+        ignored |= isIgnoredBecauseOfNativeEvents(method.getAnnotation(NativeEventsRequired.class));
 +        ignored |= isIgnoredDueToEnvironmentVariables(method);
-+        ignored |= isIgnoredDueToBeingOnSauce(method);
 +
 +        return ignored;
 +      }
@@ -312,14 +339,15 @@
  
    private boolean isIgnoredBecauseOfJUnit4Ignore(org.junit.Ignore annotation) {
 diff --git a/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java b/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java
-index ff719fd99d..b7a341f4f7 100644
+index ab6ea68623..319fb964cd 100644
 --- a/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java
 +++ b/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java
-@@ -45,7 +45,12 @@
- 
+@@ -47,8 +47,12 @@
+   private static LinkedList<Runnable> shutdownActions = new LinkedList<>();
    private static Set<WebDriver> managedDrivers = new HashSet<>();
    static {
--    Runtime.getRuntime().addShutdownHook(new Thread(() -> managedDrivers.forEach(WebDriver::quit)));
+-    shutdownActions.add(() -> managedDrivers.forEach(WebDriver::quit));
+-    Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdownActions.forEach(Runnable::run)));
 +    Runtime.getRuntime().addShutdownHook(new Thread( () -> {
 +      try {
 +        managedDrivers.forEach(WebDriver::quit);
@@ -328,4 +356,4 @@
 +    }));
    }
  
-   private static Map<Browser, Supplier<Capabilities>> capabilitySuppliers =
+   static void addShutdownAction(Runnable action) {