From 1c7b8000d81092676daf789bee1129ff492c6f52 Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Fri, 24 Jun 2022 14:39:20 +0200 Subject: [PATCH] Do not inject extensions on every frame switch, they were already injected by ferrum on page load --- lib/capybara/cuprite/page.rb | 1 - spec/features/session_spec.rb | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/capybara/cuprite/page.rb b/lib/capybara/cuprite/page.rb index a059f076..12289dea 100644 --- a/lib/capybara/cuprite/page.rb +++ b/lib/capybara/cuprite/page.rb @@ -116,7 +116,6 @@ def switch_to_frame(handle) @frame_stack = [] else @frame_stack << handle - inject_extensions end end diff --git a/spec/features/session_spec.rb b/spec/features/session_spec.rb index 2a398ee6..30ba721a 100644 --- a/spec/features/session_spec.rb +++ b/spec/features/session_spec.rb @@ -826,6 +826,18 @@ expect(e).to be_a(Capybara::ElementNotFound) end) end + + it "generates no javascript errors when switching into a frame" do + @driver.browser.evaluate_on_new_document( + "window.errors ||= []; window.onerror = function(msg) { window.errors += msg; };" + ) + + @session.visit "/cuprite/frames" + @session.within_frame(0) do + expect(@session.evaluate_script("window.errors")).to be_empty + end + expect(@session.evaluate_script("window.errors")).to be_empty + end end it "handles obsolete node during an attach_file" do