diff core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php	Thu Jul 05 14:24:15 2018 +0000
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\FunctionalJavascriptTests;
+
+use Behat\Mink\Driver\Selenium2Driver;
+
+/**
+ * Provides a driver for Selenium testing.
+ */
+class DrupalSelenium2Driver extends Selenium2Driver {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setCookie($name, $value = NULL) {
+    if ($value === NULL) {
+      $this->getWebDriverSession()->deleteCookie($name);
+      return;
+    }
+
+    $cookieArray = [
+      'name' => $name,
+      'value' => urlencode($value),
+      'secure' => FALSE,
+      // Unlike \Behat\Mink\Driver\Selenium2Driver::setCookie we set a domain
+      // and an expire date, as otherwise cookies leak from one test site into
+      // another.
+      'domain' => parse_url($this->getWebDriverSession()->url(), PHP_URL_HOST),
+      'expires' => time() + 80000,
+    ];
+
+    $this->getWebDriverSession()->setCookie($cookieArray);
+  }
+
+}