rstudio / chromote

Chrome Remote Interface for R
https://rstudio.github.io/chromote/
156 stars 20 forks source link

Allow changing of `auto_events` for specific domains. #186

Open ashbythorpe opened 1 month ago

ashbythorpe commented 1 month ago

Fixes #144 Alternative to #156 that allows more control.

Allows auto_events to be set both dynamically and on a per-domain level in Chromote and ChromoteSession. Does not change any default behaviour except for get_auto_events(), which returns a character vector of domains rather than a boolean.

Examples:

# By default, auto_events depends on the parent Chromote object
session <- ChromoteSession$new()

session$get_auto_events()
#>  [1] "Accessibility"        "Animation"            "Audits"              
#>  [4] "Autofill"             "CSS"                  "Cast"                
#>  [7] "DOM"                  "DOMSnapshot"          "DOMStorage"          
#> [10] "Database"             "HeadlessExperimental" "IndexedDB"           
#> [13] "Inspector"            "LayerTree"            "Log"                 
#> [16] "Network"              "Overlay"              "Page"                
#> [19] "Performance"          "PerformanceTimeline"  "Security"            
#> [22] "ServiceWorker"        "Fetch"                "WebAudio"            
#> [25] "WebAuthn"             "Media"                "DeviceAccess"        
#> [28] "Preload"              "FedCm"                "BluetoothEmulation"  
#> [31] "Console"              "Debugger"             "HeapProfiler"        
#> [34] "Profiler"             "Runtime"

# Disable auto_events for all domains
session$disable_auto_events()

session$get_auto_events()
#> character(0)

# Enable auto_events for just the Network domain
session$enable_auto_events("Network")

session$get_auto_events()
#> [1] "Network"

# Depend on the parent again
session$enable_auto_events(NULL)

session$get_auto_events()
#>  [1] "Accessibility"        "Animation"            "Audits"              
#>  [4] "Autofill"             "CSS"                  "Cast"                
#>  [7] "DOM"                  "DOMSnapshot"          "DOMStorage"          
#> [10] "Database"             "HeadlessExperimental" "IndexedDB"           
#> [13] "Inspector"            "LayerTree"            "Log"                 
#> [16] "Network"              "Overlay"              "Page"                
#> [19] "Performance"          "PerformanceTimeline"  "Security"            
#> [22] "ServiceWorker"        "Fetch"                "WebAudio"            
#> [25] "WebAuthn"             "Media"                "DeviceAccess"        
#> [28] "Preload"              "FedCm"                "BluetoothEmulation"  
#> [31] "Console"              "Debugger"             "HeapProfiler"        
#> [34] "Profiler"             "Runtime"