Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions spec/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

it "supports :logger argument" do
browser = Ferrum::Browser.new(logger: logger)
browser.go_to(base_url("/ferrum/console_log"))
browser.go_to(base_url("/console_log"))
expect(logger.string).to include("Hello world")
ensure
browser&.quit
Expand All @@ -52,7 +52,7 @@
it "supports :ignore_default_browser_options argument" do
defaults = Ferrum::Browser::Options::Chrome.options.except("disable-web-security")
browser = Ferrum::Browser.new(ignore_default_browser_options: true, browser_options: defaults)
browser.go_to(base_url("/ferrum/console_log"))
browser.go_to(base_url("/console_log"))
ensure
browser&.quit
end
Expand All @@ -73,7 +73,7 @@
browser = Ferrum::Browser.new(base_url: base_url,
extensions: [File.expand_path("support/geolocation.js", __dir__)])

browser.go_to("/ferrum/requiring_custom_extension")
browser.go_to("/requiring_custom_extension")

expect(
browser.body
Expand All @@ -94,7 +94,7 @@
browser = Ferrum::Browser.new(base_url: base_url,
extensions: [{ source: "window.secret = 'top'" }])

browser.go_to("/ferrum/requiring_custom_extension")
browser.go_to("/requiring_custom_extension")

expect(browser.evaluate(%(window.secret))).to eq("top")
ensure
Expand Down Expand Up @@ -237,7 +237,7 @@
it "supports :pending_connection_errors argument" do
browser = Ferrum::Browser.new(base_url: base_url, pending_connection_errors: false, timeout: 0.5)

expect { browser.go_to("/ferrum/really_slow") }.not_to raise_error
expect { browser.go_to("/really_slow") }.not_to raise_error
ensure
browser&.quit
end
Expand Down Expand Up @@ -388,13 +388,13 @@
expect(browser.targets.size).to eq(1)

browser.execute <<-JS
window.open("/ferrum/simple", "popup1")
window.open("/simple", "popup1")
JS

sleep 0.1

browser.execute <<-JS
window.open("/ferrum/simple", "popup2")
window.open("/simple", "popup2")
JS

popup1, popup2 = browser.windows(:last, 2)
Expand All @@ -416,12 +416,12 @@
end

include_examples "resize viewport by fullscreen" do
let(:path) { "/ferrum/custom_html_size" }
let(:path) { "/custom_html_size" }
let(:viewport_size) { [1280, 1024] }
end

include_examples "resize viewport by fullscreen" do
let(:path) { "/ferrum/custom_html_size_100%" }
let(:path) { "/custom_html_size_100%" }
let(:viewport_size) { [1272, 1008] }
end

Expand All @@ -444,7 +444,7 @@
});
JS

browser.go_to("/ferrum/with_user_js")
browser.go_to("/with_user_js")
language = browser.at_xpath("//*[@id='browser-languages']/text()").text
expect(language).to eq("tlh")
ensure
Expand All @@ -457,15 +457,15 @@
browser.go_to

browser.execute <<~JS
window.open("/ferrum/simple", "popup")
window.open("/simple", "popup")
JS

sleep 0.1

expect(browser.targets.size).to eq(2)

browser.execute <<~JS
window.open("/ferrum/simple", "popup2")
window.open("/simple", "popup2")
JS

sleep 0.1
Expand Down Expand Up @@ -519,7 +519,7 @@
expect(browser.targets.size).to eq(0)

page = browser.create_page
page.go_to("/ferrum/simple")
page.go_to("/simple")

expect(browser.contexts.size).to eq(1)
expect(browser.targets.size).to eq(1)
Expand All @@ -530,7 +530,7 @@
expect(browser.targets.size).to eq(0)

browser.create_page do |page|
page.go_to("/ferrum/simple")
page.go_to("/simple")
end

sleep 1 # It may take longer to close the target
Expand All @@ -543,7 +543,7 @@
expect(browser.contexts.size).to eq(0)

page = browser.create_page(new_context: true)
page.go_to("/ferrum/simple")
page.go_to("/simple")

context = browser.contexts[page.context_id]
expect(browser.contexts.size).to eq(1)
Expand All @@ -560,7 +560,7 @@

page = browser.create_page(new_context: true)
context = browser.contexts[page.context_id]
page.go_to("/ferrum/simple")
page.go_to("/simple")
page.close

expect(browser.contexts.size).to eq(1)
Expand All @@ -574,7 +574,7 @@
expect(browser.contexts.size).to eq(0)

browser.create_page(new_context: true) do |page|
page.go_to("/ferrum/simple")
page.go_to("/simple")
end

expect(browser.contexts.size).to eq(0)
Expand Down
6 changes: 3 additions & 3 deletions spec/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
browser.go_to

browser.execute <<-JS
window.open("/ferrum/slow", "popup")
window.open("/slow", "popup")
JS

popup, = browser.windows(:last)
Expand All @@ -18,7 +18,7 @@
browser.go_to

browser.execute <<-JS
window.open("/ferrum/simple", "popup")
window.open("/simple", "popup")
JS

popup, = browser.windows(:last)
Expand All @@ -28,7 +28,7 @@
sleep 0.5 # https://github.com/ChromeDevTools/devtools-protocol/issues/145

browser.execute <<-JS
window.open("/ferrum/simple", "popup")
window.open("/simple", "popup")
JS

sleep 0.5 # https://github.com/ChromeDevTools/devtools-protocol/issues/145
Expand Down
14 changes: 7 additions & 7 deletions spec/cookies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@
browser.cookies.set(
name: "stealth",
value: "omg",
path: "/ferrum",
path: "/custom",
httponly: true,
samesite: "Strict"
)

browser.go_to("/get_cookie")
expect(browser.body).to_not include("omg")

browser.go_to("/ferrum/get_cookie")
browser.go_to("/custom/get_cookie")
expect(browser.body).to include("omg")

expect(browser.cookies["stealth"].path).to eq("/ferrum")
expect(browser.cookies["stealth"].path).to eq("/custom")
expect(browser.cookies["stealth"].httponly?).to be_truthy
expect(browser.cookies["stealth"].samesite).to eq("Strict")
end
Expand Down Expand Up @@ -213,10 +213,10 @@
browser.cookies.set(name: "stealth", value: "127.0.0.1")
browser.cookies.set(name: "stealth", value: "localhost", domain: "localhost")

browser.go_to("http://localhost:#{port}/ferrum/get_cookie")
browser.go_to("http://localhost:#{port}/get_cookie")
expect(browser.body).to include("localhost")

browser.go_to("http://127.0.0.1:#{port}/ferrum/get_cookie")
browser.go_to("http://127.0.0.1:#{port}/get_cookie")
expect(browser.body).to include("127.0.0.1")
end

Expand All @@ -225,10 +225,10 @@
browser.cookies.set(name: "stealth", value: "123456", domain: "localhost")

port = server.port
browser.go_to("http://localhost:#{port}/ferrum/get_cookie")
browser.go_to("http://localhost:#{port}/get_cookie")
expect(browser.body).to include("123456")

browser.go_to("http://127.0.0.1:#{port}/ferrum/get_cookie")
browser.go_to("http://127.0.0.1:#{port}/get_cookie")
expect(browser.body).not_to include("123456")
ensure
browser&.quit
Expand Down
10 changes: 5 additions & 5 deletions spec/dialog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Ferrum::Dialog do
describe "#accept" do
it "works with nested modals" do
browser.go_to("/ferrum/with_js")
browser.go_to("/with_js")
browser.on(:dialog) do |dialog, _index, _total|
if dialog.match?("Are you sure?")
dialog.accept
Expand All @@ -21,7 +21,7 @@
browser.go_to

browser.execute <<-JS
window.open("/ferrum/with_js", "popup")
window.open("/with_js", "popup")
JS

popup, = browser.windows(:last)
Expand All @@ -41,7 +41,7 @@
browser.go_to

browser.execute <<-JS
window.open("/ferrum/with_js", "popup")
window.open("/with_js", "popup")
JS

popup, = browser.windows(:last)
Expand All @@ -58,7 +58,7 @@

describe "#match?" do
it "matches on partial strings" do
browser.go_to("/ferrum/with_js")
browser.go_to("/with_js")
browser.on(:dialog) do |dialog, _index, _total|
if dialog.match?(Regexp.escape("[reg.exp] (chara©+er$)"))
dialog.accept
Expand All @@ -73,7 +73,7 @@
end

it "matches on regular expressions" do
browser.go_to("/ferrum/with_js")
browser.go_to("/with_js")
browser.on(:dialog) do |dialog, _index, _total|
if dialog.match?(/^.t.ext.*\[\w{3}\.\w{3}\]/i)
dialog.accept
Expand Down
18 changes: 9 additions & 9 deletions spec/frame/runtime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
end

it "propagates a Javascript error during page load to a ruby exception" do
expect { browser.go_to("/ferrum/js_error") }.to raise_error(Ferrum::JavaScriptError)
expect { browser.go_to("/js_error") }.to raise_error(Ferrum::JavaScriptError)
end

it "does not propagate a Javascript error to ruby if error raising disabled" do
browser = Ferrum::Browser.new(base_url: base_url, js_errors: false)
browser.go_to("/ferrum/js_error")
browser.go_to("/js_error")
browser.execute "setTimeout(function() { omg }, 0)"
sleep 0.1
expect(browser.body).to include("hello")
Expand All @@ -66,7 +66,7 @@
it "does not propagate a Javascript error to ruby if error raising disabled and client restarted" do
browser = Ferrum::Browser.new(base_url: base_url, js_errors: false)
browser.restart
browser.go_to("/ferrum/js_error")
browser.go_to("/js_error")
browser.execute "setTimeout(function() { omg }, 0)"
sleep 0.1
expect(browser.body).to include("hello")
Expand All @@ -78,19 +78,19 @@

describe "#evaluate" do
it "returns an element" do
browser.go_to("/ferrum/type")
browser.go_to("/type")
element = browser.evaluate(%(document.getElementById("empty_input")))
expect(element).to eq(browser.at_css("#empty_input"))
end

it "returns deeply nested node" do
browser.go_to("/ferrum/deeply_nested")
browser.go_to("/deeply_nested")
node = browser.evaluate(%(document.getElementById("text")))
expect(node.text).to eq("text")
end

it "returns structures with elements" do
browser.go_to("/ferrum/type")
browser.go_to("/type")
result = browser.evaluate <<~JS
{
a: document.getElementById("empty_input"),
Expand Down Expand Up @@ -176,7 +176,7 @@
end

it "evaluates a function on a node" do
browser.go_to("/ferrum/index")
browser.go_to("/index")
node = browser.at_xpath(".//a")

function = <<~JS
Expand Down Expand Up @@ -211,7 +211,7 @@
browser.evaluate("$('a').first().text()")
end.to raise_error(Ferrum::JavaScriptError)

browser.add_script_tag(url: "/ferrum/jquery.min.js")
browser.add_script_tag(url: "/jquery.min.js")

expect(browser.evaluate("$('a').first().text()")).to eq("Relative")
end
Expand Down Expand Up @@ -250,7 +250,7 @@
browser.go_to
expect(browser.evaluate(font_size)).to eq("16px")

browser.add_style_tag(url: "/ferrum/add_style_tag.css")
browser.add_style_tag(url: "/add_style_tag.css")

expect(browser.evaluate(font_size)).to eq("50px")
end
Expand Down
Loading