summaryrefslogtreecommitdiff
path: root/qa/qa/runtime/browser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/runtime/browser.rb')
-rw-r--r--qa/qa/runtime/browser.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb
index f1d93ce376a..89e84f414b1 100644
--- a/qa/qa/runtime/browser.rb
+++ b/qa/qa/runtime/browser.rb
@@ -194,6 +194,8 @@ module QA
def initialize(instance, page_class)
@session_address = Runtime::Address.new(instance, page_class)
@page_class = page_class
+
+ Session.enable_interception if Runtime::Env.can_intercept?
end
def url
@@ -255,6 +257,27 @@ module QA
@network_conditions_configured = false
end
+ def self.enable_interception
+ script = File.read("#{__dir__}/script_extensions/interceptor.js")
+ command = {
+ cmd: 'Page.addScriptToEvaluateOnNewDocument',
+ params: {
+ source: script
+ }
+ }
+ @interceptor_script_params = Capybara.current_session.driver.browser.send(:bridge).send_command(command)
+ end
+
+ def self.disable_interception
+ return unless @interceptor_script_params
+
+ command = {
+ cmd: 'Page.removeScriptToEvaluateOnNewDocument',
+ params: @interceptor_script_params
+ }
+ Capybara.current_session.driver.browser.send(:bridge).send_command(command)
+ end
+
private
def simulate_slow_connection