Răsfoiți Sursa

Merge pull request #33 from gempesaw/insecure_add_cookie

Making sure that secure cookie is created only when secure option is 1 & insecure when it is 0.
Aditya Ivaturi 13 ani în urmă
părinte
comite
59d2f4f60f
2 a modificat fișierele cu 3 adăugiri și 3 ștergeri
  1. 1 1
      lib/Selenium/Remote/Driver.pm
  2. 2 2
      t/01-driver.t

+ 1 - 1
lib/Selenium/Remote/Driver.pm

@@ -1349,7 +1349,7 @@ sub add_cookie {
     my $res        = { 'command' => 'addCookie' };
     my $json_false = JSON::false;
     my $json_true  = JSON::true;
-    $secure = ( defined $secure ) ? $json_true : $json_false;
+    $secure = ( defined $secure && $secure ) ? $json_true : $json_false;
 
     my $params = {
         'cookie' => {

+ 2 - 2
t/01-driver.t

@@ -11,7 +11,7 @@ BEGIN {
       BAIL_OUT ("Couldn't load Driver");
       exit;
    }
-   
+
    if (defined $ENV{'WD_MOCKING_RECORD'} && ($ENV{'WD_MOCKING_RECORD'}==1))
    {
       use t::lib::MockSeleniumWebDriver;
@@ -119,6 +119,7 @@ COOKIES: {
             pass('Adding cookie foo...');
             $ret = $driver->get_all_cookies();
             is(@{$ret}, 1, 'foo cookie added.');
+            is($ret->[0]{'secure'}, "false", 'foo cookie insecure.');
             $ret = $driver->delete_cookie_named('foo');
             pass('Deleting cookie foo...');
             $ret = $driver->get_all_cookies();
@@ -245,4 +246,3 @@ elsif ($record)
 }
 
 done_testing;
-