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:
parent
b5a8fca5db
commit
6e485ca45d
4 changed files with 34 additions and 0 deletions
|
@ -139,6 +139,12 @@ page.driver.block_unknown_urls
|
||||||
page.driver.allow_url 'example.com/*.js'
|
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
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
|
|
@ -277,6 +277,10 @@ module Capybara::Webkit
|
||||||
command("SetUnknownUrlMode", "block")
|
command("SetUnknownUrlMode", "block")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allow_unknown_urls
|
||||||
|
allow_url("*")
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def check
|
def check
|
||||||
|
|
|
@ -33,6 +33,10 @@ module Capybara::Webkit
|
||||||
browser.block_unknown_urls
|
browser.block_unknown_urls
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allow_unknown_urls
|
||||||
|
browser.allow_url("*")
|
||||||
|
end
|
||||||
|
|
||||||
def current_url
|
def current_url
|
||||||
browser.current_url
|
browser.current_url
|
||||||
end
|
end
|
||||||
|
|
|
@ -2685,6 +2685,26 @@ CACHE MANIFEST
|
||||||
end
|
end
|
||||||
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
|
it "can block unknown hosts" do
|
||||||
driver.block_unknown_urls
|
driver.block_unknown_urls
|
||||||
visit("/")
|
visit("/")
|
||||||
|
|
Loading…
Reference in a new issue