Subject: | patch to method add_cookie |
hi.
I found a problem with the method add_cookies.
Attach the script that reproduces the problem and its patch.
Thanks,
Tomohiro Hosaka
### script ###
#!/usr/local/bin/perl
use rlib;
use Modern::Perl;
use Firefox::Marionette;
use YAML::Syck;
{
my $ff = Firefox::Marionette->new;
$ff->go("https://www.google.com"); # All cookies have a "expiry".
# fine
$ff->add_cookie($_) for $ff->cookies;
}
{
my $ff = Firefox::Marionette->new;
$ff->go("https://www.amazon.com"); # There are cookies that do not have a "expiry".
# Exception occured. invalid argument: Cookie expiry must be a positive integer
$ff->add_cookie($_) for $ff->cookies;
}
__END__
# say Dump [$ff->cookies];
# ---
# - !!perl/hash:Firefox::Marionette::Cookie
# domain: .amazon.com
# http_only: 0
# name: skin
# path: /
# secure: 0
# value: noskin
# - !!perl/hash:Firefox::Marionette::Cookie
# domain: .amazon.com
# expiry: '2082787201'
# http_only: 0
# name: session-id
# path: /
# secure: 0
# value: 142-5535180-0213954
# ... snip ...
### patch ###
diff --git a/lib/Firefox/Marionette.pm b/lib/Firefox/Marionette.pm
index c3dc918..051fd47 100755
--- a/lib/Firefox/Marionette.pm
+++ b/lib/Firefox/Marionette.pm
@@ -2611,7 +2611,7 @@ sub add_cookie {
domain => $domain,
path => $cookie->path(),
value => $cookie->value(),
- expiry => $cookie->expiry(),
+ ( $cookie->expiry() ? ( expiry => $cookie->expiry() ) : () ),
name => $cookie->name()
}
}