-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix JS script execution for cuprite driver
- Loading branch information
1 parent
3499c33
commit 6ccb242
Showing
9 changed files
with
79 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../../ext/rum" | ||
|
||
module Datadog | ||
module CI | ||
module Contrib | ||
module Cuprite | ||
class ScriptExecutor | ||
# Ferrum::Browser requires a JS script to be wrapped in a function() { ... } block | ||
WRAPPED_SCRIPTS = { | ||
CI::Ext::RUM::SCRIPT_IS_RUM_ACTIVE => "function() { #{CI::Ext::RUM::SCRIPT_IS_RUM_ACTIVE}; }", | ||
CI::Ext::RUM::SCRIPT_STOP_RUM_SESSION => <<~JS | ||
function() { | ||
#{CI::Ext::RUM::SCRIPT_STOP_RUM_SESSION}; | ||
} | ||
JS | ||
}.freeze | ||
|
||
def initialize(ferrum_browser) | ||
@ferrum_browser = ferrum_browser | ||
end | ||
|
||
def execute_script(script) | ||
script = WRAPPED_SCRIPTS.fetch(script, script) | ||
@ferrum_browser.evaluate_func(script) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Datadog | ||
module CI | ||
module Contrib | ||
module Cuprite | ||
class ScriptExecutor | ||
@ferrum_browser: Ferrum::Browser | ||
WRAPPED_SCRIPTS: ::Hash[::String, ::String] | ||
|
||
def initialize: (Ferrum::Browser ferrum_browser) -> void | ||
|
||
def execute_script: (String script) -> String | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters