Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow enable() methods to be called manually #144

Open
ashbythorpe opened this issue Feb 9, 2024 · 0 comments · May be fixed by #156 or #186
Open

Allow enable() methods to be called manually #144

ashbythorpe opened this issue Feb 9, 2024 · 0 comments · May be fixed by #156 or #186

Comments

@ashbythorpe
Copy link

ashbythorpe commented Feb 9, 2024

I would like to call Fetch.enable using the patterns and handleAuthRequests arguments. However, since chromote calls Fetch.enable automatically when a callback is attached to a Fetch event, the method is called twice, which causes an error. I would like not to set the auto_events field to FALSE, since I can't change this value after it has been set.

For example:

library(chromote)

session <- ChromoteSession$new()

session$Fetch$enable(
  patterns = list(
    list(urlPattern = "*")
  ),
  handleAuthRequests = TRUE
)

authenticate <- function(x) {
  id <- x$requestId
  
  response <- list(
    response = "ProvideCredentials",
    username = "USERNAME",
    password = "PASSWORD"
  )
  
  session$Fetch$continueWithAuth(
    requestId = id,
    authChallengeResponse = response
  )
}

continue_request <- function(x) {
  id <- x$requestId
  
  session$Fetch$continueRequest(requestId = id)
}

session$Fetch$requestPaused(
  callback_ = continue_request
)

session$Fetch$authRequired(
  callback_ = authenticate
)

session$Page$navigate("https://google.com")

The session$Page$navigate() call causes the following warning:

#> In callbacks$invoke(params) :
#>  1 errors occurred while executing callbacks:
#>  code: -32602
#>  message: Invalid InterceptionId.

It would be useful if either:

  • chromote detected when a .enable method is called, and did not call it again when a callback is registered.
  • chromote allowed the auto_events field to be modified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant