serversideup / webext-bridge

💬 Messaging in Web Extensions made easy. Batteries included.
https://serversideup.net/open-source/webext-bridge
MIT License
547 stars 50 forks source link

fix: Firefox XRay vision prevents window<->content script messaging #83

Closed StyleT closed 7 months ago

StyleT commented 8 months ago

As current code modifies original message it causes the following error in latest version of Firefox:

Not allowed to define cross-origin object as property on [Object] or [Array] XrayWrapper
    <anonymous> content-script.js:26
    portP chunk-ICLXI4BR.js:56
    (Async: EventHandlerNonNull)
    acceptMessagingPort chunk-ICLXI4BR.js:8
    (Async: EventListener.handleEvent)
    promise chunk-ICLXI4BR.js:28
    getMessagePort chunk-ICLXI4BR.js:3
    setNamespace chunk-ICLXI4BR.js:56
    allowWindowMessaging content-script.js:46

More about Xray Vision here: https://firefox-source-docs.mozilla.org/dom/scriptSecurity/xray_vision.html

StyleT commented 8 months ago

Similar issues in other libraries:

StyleT commented 8 months ago

@danpastori @jaydrogers kind reminder here 👀

StyleT commented 7 months ago

@danpastori @jaydrogers Hi! Another very kind reminder to merge and publish this

danpastori commented 7 months ago

@StyleT This looks great here, I'll get this merged. Thanks so much for the contribution!

CharlieDigital commented 4 months ago

Ran into this issue today.

package.json:

  "dependencies": {
    ...
    "webext-bridge": "^6.0.1"
  },

What the debug console is showing:

image

And it looks like it didn't make it into the Apr 07 package:

https://www.npmjs.com/package/webext-bridge?activeTab=code

Is there a plan to ship this?

StyleT commented 4 months ago

@CharlieDigital I ended up fixing it in @webext-pegasus/rpc

CharlieDigital commented 4 months ago

@StyleT thanks for the pointer; will check it out