Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

sessionStorage and localStorage are not cleared on reset #301

Closed
til opened this Issue · 6 comments

5 participants

@til

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

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

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

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

@jferris
Owner

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

@levicole

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

@jferris
Owner

This is fixed on master. Thanks, @levicole.

@jferris jferris closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.