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

Skip injecting extensions on frame switch to prevent javascript errors #201

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hoffi
Copy link

@hoffi hoffi commented Jun 24, 2022

Fixes #200.

The extensions were injected again on every frame switch. That seemed unnecessary to me as they were already injected on page load by ferrum.
This resulted in some javascript errors, because some constants were redefined by the default cuprite extension.

This change fixes this problem and there does not seem to be anything missing inside the frames.

@route
Copy link
Member

route commented Nov 19, 2022

This was exactly the issue in the past as they weren't injected, in other words this is a workaround, I'll double check if Chrome fixed this.

Seems like this test isn't accurate because it doesn't check if there are extensions available in the frame.

@hoffi
Copy link
Author

hoffi commented Jan 17, 2024

Any info on this?

Or should this be handled in ferrum?
We could track all loaded extensions there and only execute them when they are not in the list.
Something like this here and here:

extension_digest = Digest::SHA256.hexdigest(extension)
extension_wrapper = <<~JS
  window._ferrum_loaded_extensions ||= [];
  if (window._ferrum_loaded_extensions.indexOf("#{extension_digest}") == -1) {
    window._ferrum_loaded_extensions.push("#{extension_digest}");
    #{extension}
  }
JS
command("Page.addScriptToEvaluateOnNewDocument", source: extension_wrapper)
[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Javascript errors triggered by cuprite on pages with iframes
2 participants