Support for enabling/disabling localStorage #310

wants to merge 2 commits into


None yet

8 participants


Using set_attribute("LocalStorageEnabled", true). An integration test has been added to spec/integration/session_spec.rb.

Some code/inspiration was taken from a pull request by niklasb: #171

spraints commented Apr 2, 2012

I'm curious... Does localStorage actually store things with this patch? I made a similar change, and the localStorage API was available but not actually functioning.


It has been working for the project I'm using it for, although obviously all of the data disappears along with the webkit session, i.e., at the end of a test.

spraints commented Apr 2, 2012


I had mis-read the spec the first time... I thought 'count' was a part of the localStorage API, but I see now that it isn't and that the test demonstrates that localStorage is working. I'm not sure what I did wrong in my attempt to get localStorage to work.

jferris commented Apr 4, 2012

Thanks for the pull request.

I think it would be better to just have local storage enabled all the time. Is there a reason to ever disable it?

Also, we've been using the integration directory to run the specs from capybara itself. A better place for a test like this would be driver_spec.rb.


No, I don't see any good reason why it should be possible to disable it.

I'll take some time to retool the localStorage support so that it's always enabled and move the test to a better spot.

Will this be merged anytime soon?


jferris commented Apr 20, 2012

@chrisfarber Are you still planning to change this so that localStorage is always enabled?

dopin commented Apr 23, 2012

I need the localStorage support ASAP!!


This should do the trick. Sorry for the delay.

dopin commented Apr 24, 2012

Thank you @chrisfarber

Awesome, thanks very much!

gerad commented May 1, 2012

+1 localStorage would be useful for me too... is there a reason that this pull request isn't being merged into master?

jferris commented May 1, 2012

@gerad we're crunched for time. I'm hoping to take a look at pull requests soon.

gerad commented May 1, 2012

@jferris cool, thanks for the update!


@chrisfarber merged this into master

Is it possible to add in the functionality to disable localStorage. As I am trying to write a cucumber test for cases where users have disabled cookies. In most newer browsers when someone disables cookies it also disables local storage.

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