Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

sessionStorage and localStorage are not cleared on reset #301

Closed
til opened this issue Mar 22, 2012 · 6 comments
Closed

sessionStorage and localStorage are not cleared on reset #301

til opened this issue Mar 22, 2012 · 6 comments

Comments

@til
Copy link

til commented Mar 22, 2012

sessionStorage and localStorage are not cleared on reset, but I think they should, in the same way that cookies are being reset.

For example here the second scenario fails when running both specs together:

feature "reset sessionStorage", :js do

  scenario "first" do
    visit "/"
    page.execute_script "sessionStorage.setItem('test', 'foo')"
  end

  scenario "second" do
    visit "/"
    page.evaluate_script("sessionStorage.getItem('test')").should == ""
  end

end
@TALlama
Copy link

TALlama commented Jun 15, 2012

I got this working locally with the following snippet tossed into support:

AfterStep('@javascript') do
  next if @local_storage_has_been_cleared
  next unless current_url =~ /localhost/ || current_url =~ /127.0.0.1/
  next unless page.present?

  @local_storage_has_been_cleared = true
  page.execute_script('if (localStorage && localStorage.clear) localStorage.clear()')
end

You'll have to adjust the current_url check as appropriate for your setup.

Hope this helps somebody!

@levicole
Copy link
Contributor

I'm running into this issue as well. Is this just not considered a bug? I will gladly take a stab at submitting a patch if I can.

@gvt
Copy link

gvt commented Apr 23, 2013

+1 for this issue. Is this the expected behavior and calling code should deal with it? Or is it a bug

@jferris
Copy link
Contributor

jferris commented Apr 24, 2013

@levicole yeah, I'd say this is a bug. A tested patch would be most welcome.

@levicole
Copy link
Contributor

@jferris I've pushed a pull request for resetting localStorage in #515

@jferris
Copy link
Contributor

jferris commented Apr 26, 2013

This is fixed on master. Thanks, @levicole.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants