X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dd5efa11702934a9e00ae05b76f3f0279e1c36df..4e543a284e2b03b916c28ac7f92b956154b81b3a:/apps/workbench/test/integration_helper.rb diff --git a/apps/workbench/test/integration_helper.rb b/apps/workbench/test/integration_helper.rb index 1af7245a4e..85c929fdba 100644 --- a/apps/workbench/test/integration_helper.rb +++ b/apps/workbench/test/integration_helper.rb @@ -223,6 +223,17 @@ class ActionDispatch::IntegrationTest screenshot end if Capybara.current_driver == :selenium + # Clearing localStorage crashes on a page where JS isn't + # executed. We also need to make sure we're clearing + # localStorage for the test server's origin, even if we finished + # the test on a different origin. + host = Capybara.current_session.server.host + port = Capybara.current_session.server.port + base = "http://#{host}:#{port}" + if page.evaluate_script("window.document.contentType") != "text/html" || + !page.evaluate_script("window.location.toString()").start_with?(base) + visit "#{base}/404" + end page.execute_script("window.localStorage.clear()") else page.driver.restart if defined?(page.driver.restart)