sessionStorage and localStorage are not cleared on reset #301

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

Comments

Projects
None yet
5 participants

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 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!

Contributor

levicole commented Apr 23, 2013

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 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

Owner

jferris commented Apr 24, 2013

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

Contributor

levicole commented Apr 26, 2013

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

Owner

jferris commented Apr 26, 2013

This is fixed on master. Thanks, @levicole.

@jferris jferris closed this Apr 26, 2013

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