1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Add ability to allow all unknown hosts

Adds `page.driver.allow_unknown_hosts`.
This commit is contained in:
nritholtz 2015-04-09 16:11:55 -04:00 committed by Joe Ferris
parent b5a8fca5db
commit 6e485ca45d
4 changed files with 34 additions and 0 deletions

View file

@ -139,6 +139,12 @@ page.driver.block_unknown_urls
page.driver.allow_url 'example.com/*.js'
```
**allow_unknown_urls**: Allow requests to all URLs. This will silence unknown URL warnings, or permit requests to all URLs when `block_unknown_urls` is used. Allowed URLs are reset on `Driver#reset!`.
```ruby
page.driver.allow_unknown_urls
```
Contributing
------------

View file

@ -277,6 +277,10 @@ module Capybara::Webkit
command("SetUnknownUrlMode", "block")
end
def allow_unknown_urls
allow_url("*")
end
private
def check

View file

@ -33,6 +33,10 @@ module Capybara::Webkit
browser.block_unknown_urls
end
def allow_unknown_urls
browser.allow_url("*")
end
def current_url
browser.current_url
end

View file

@ -2685,6 +2685,26 @@ CACHE MANIFEST
end
end
it "can allow all hosts" do
driver.allow_unknown_urls
visit("/")
expect(stderr).not_to include("http://example.com/path")
expect(stderr).not_to include(driver.current_url)
driver.within_frame("frame") do
expect(driver.find("//body").first.text).not_to be_empty
end
end
it "resets allowed hosts on reset" do
driver.allow_unknown_urls
driver.reset!
visit("/")
expect(stderr).to include("http://example.com/path")
expect(stderr).not_to include(driver.current_url)
end
it "can block unknown hosts" do
driver.block_unknown_urls
visit("/")