Giter VIP home page Giter VIP logo

Comments (3)

blmage avatar blmage commented on September 13, 2024

This is due to the fact that both the content script and the page script of a Chrome extension share the same window, but not the same global variables (see the content scripts documentation).

In your case, when post-robot sends back the result by using postMessage on the event source, the message is first handled by the content script window, on which the listener that was specifically registered to handle it is not accessible, resulting in the error you mentioned.

Not sure if there is any (general) work-around for this (after encountering this I ended up directly using postMessage and addEventListener - in a much less readable fashion), but I would definitely be interested if that could be the case!

from post-robot.

datgrog avatar datgrog commented on September 13, 2024

Also interested! But even with the snippet from above what it weird is that the injected_script does indeed get the callback with the result from the listener in the content_script but then throw 3 times both (so 6 errors):

  • Uncaught Error: No handler found for post message ack for message: message from
  • Uncaught Error: No handler found for post message response for message: message from

What I don't understand is that still, if my injected_script has a button which fire a postRobot.send, it still works each time, but message above seems to say that the listener is not alive anymore whichs feels like a bug given that it still works.

from post-robot.

afeld avatar afeld commented on September 13, 2024

@angela-tran discovered that this was due to the Cross-Origin-Opener-Policy header being set to same-origin by our server. Not sure if relevant, but sharing just in case.

from post-robot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.