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

EventBindingCalled Not Triggering #1337

Closed
oukrims opened this issue Jul 10, 2023 · 3 comments
Closed

EventBindingCalled Not Triggering #1337

oukrims opened this issue Jul 10, 2023 · 3 comments

Comments

@oukrims
Copy link

oukrims commented Jul 10, 2023

What versions are you running?

$ go list -m github.com/chromedp/chromedp
v0.9.1
$ google-chrome --version
Version 114.0.5735.198 (Official Build) (x86_64)
$ go version
go version go1.20.1 darwin/amd64

Description:

I'm having trouble with the EventBindingCalled event in the chromedp package. Despite enabling the Runtime domain and adding a binding via JavaScript in the browser, the EventBindingCalled event is not being triggered when I call the bound function. Here's a brief overview of the code I'm using:

switch ev := ev.(type) {
		case *runtime.EventBindingCalled:
		if err := c.WriteJSON(map[string]interface{}{
			"session_id":   sessionID,
			"message":      "BINDING_CALLED",
			"functionName": ev.Name,
			"payload":      ev.Payload,
			"contextId":    ev.ExecutionContextID,
			}); err != nil {
				log.Printf("Failed to send bindingCalled event to client: %v", err)
			}
		default:
				log.Printf("Received an event of a different type: %T", ev)
	}

What did you expect to see?

I expect the EventBindingCalled event to be triggered when I call the bound function in JavaScript.

What did you see instead?

I'm not receiving the bindingCalled event

to reproduce

  1. Enable the Runtime domain in chromedp.
  2. Add a binding in JavaScript using the Runtime.addBinding or Runtime.setBinding method.
  3. Call the bound function in JavaScript.
  4. Listen for the EventBindingCalled event in chromedp.
@ZekeLu
Copy link
Member

ZekeLu commented Jul 10, 2023

Please provide an executable reproducer so that we can find out what's wrong.

Please take a look at PR #1222 which tries to encapsulate the binding feature.

@hillguo
Copy link

hillguo commented Jul 25, 2023

@oukrims
can you provide a complete example?
I'm not sure how you call Runtime.addBinding or Runtime.setBinding.
It works good in PR #1222.

@oukrims
Copy link
Author

oukrims commented Aug 5, 2023

#1222 was helpful! I'm closing the issue

@oukrims oukrims closed this as completed Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants