2.5.0-development: missing `window.localStorage` #14740

Open
shinnn opened this Issue Jan 10, 2017 · 2 comments

Projects

None yet

3 participants

@shinnn
shinnn commented Jan 10, 2017

1. Which version of PhantomJS are you using? Tip: run phantomjs --version.

2.5.0-development

2. What steps will reproduce the problem?

i. Create a JavaScript file check-local-storage.js, such as:

'use strict';

var page = require('webpage').create();

page.open('http://example.com', function() {
  var ls = page.evaluate(function() {
    return String(window.localStorage);
  });

  console.log(ls);

  phantom.exit();
});

ii. Run the script with PhantomJS v2.5.0-development.

$ phantomjs --version
> 2.5.0-development

$ phantomjs check-local-storage.js
> null

As you can see, in 2.5.0-development window.localStorage is not a valid object and we can't use its methods – clear, getItem, setItem etc.

3. Which operating system are you using?

$ sw_vers

ProductName:	Mac OS X
ProductVersion:	10.12.2
BuildVersion:	16C67

4. Did you use binary PhantomJS or did you compile it from source?

The binary downloaded from https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.5.0-beta-macos.zip.

5. Please provide any additional information below.

With the latest stable version v2.1.1 installed via Homebrew, the code above prints the expected behavior. So, this bug was certainly introduced in v2.5.0-development.

$ phantomjs --version
> 2.1.1

$ phantomjs check-local-storage.js
> [object Storage]
@Vitallium
Collaborator
Vitallium commented Jan 10, 2017 edited

Since 2.5 (or this commit fc57497) localStorage disabled by default. This change was introduced to make PhantomJS portable as much as possible. To enable localStorage you have to set its quota >= 0, e.g.:

phantomjs --local-storage-quota=5000

We also have plans on moving configuration options to a default configuration file, so you will need to specify default options once.

@Vitallium Vitallium added the Invalid label Jan 17, 2017
@GopianiS

How will I be able to enable the localStorage via OpenQA.Selenium.PhantomJS?
I'm using the 2.5.0-development version for Selenium C# testing and the testing web application is causing issues as localStorage is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment