Skip to content

Commit

Permalink
Use data urls to reset page instead of empty file
Browse files Browse the repository at this point in the history
closes #1035
closes #1214
closes #1203
closes #1198

Since it does not work with remote drivers, and somehow screws up on Windows.
  • Loading branch information
Jonas Nicklas and Kim Burgestrand committed Dec 20, 2013
1 parent a199af7 commit 2ce9672
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
2 changes: 0 additions & 2 deletions lib/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class UnselectNotAllowed < CapybaraError; end
class NotSupportedByDriverError < CapybaraError; end
class InfiniteRedirectError < CapybaraError; end

EMPTY_HTML_FILE_PATH = File.expand_path('./capybara/empty.html', File.dirname(__FILE__))

class << self
attr_accessor :asset_host, :app_host, :run_server, :default_host, :always_include_port
attr_accessor :server_port, :exact, :match, :exact_options, :visible_text_only
Expand Down
4 changes: 0 additions & 4 deletions lib/capybara/empty.html

This file was deleted.

5 changes: 2 additions & 3 deletions lib/capybara/selenium/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
:browser => :firefox
}
SPECIAL_OPTIONS = [:browser]
EMPTY_HTML = "data:text/html,<html></html>"

attr_reader :app, :options

Expand Down Expand Up @@ -97,9 +98,7 @@ def reset!
# to about:blank, so we rescue this error and do nothing
# instead.
end
uri = URI(Capybara::EMPTY_HTML_FILE_PATH)
uri.scheme = "file"
@browser.navigate.to(uri.to_s)
@browser.navigate.to(EMPTY_HTML)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/capybara/spec/session/reset_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
->(v) { v == nil },
->(v) { v == '' },
->(v) { v == 'about:blank' },
->(v) { v.end_with? Capybara::EMPTY_HTML_FILE_PATH } # allow file:// protocol
->(v) { v.start_with? "data:text/html" }
].any? { |p| p.(@session.current_url) }.should be_true
[
->(v) { v == '' },
->(v) { v == nil },
->(v) { v == Capybara::EMPTY_HTML_FILE_PATH }
->(v) { v.start_with? "data:text/html" }
].any? { |p| p.(@session.current_path) }.should be_true
@session.current_host.should be_nil
end
Expand Down

0 comments on commit 2ce9672

Please sign in to comment.