Been digging through Firefox's code trying to fix Web Components in extension content scripts (https://bugzilla.mozilla.org/show_bug.cgi?id=1492002).
I've found the core problem, it's specific for Firefox implementation, but now I'm not sure what "correct" solution should look like.
Right now Firefox's policy regarding normal JS objects looks like:
- content script sees page's objects only if explicitly asked (wrappedJSObject)
- page script sees extension's objects only if explicitly provided (exportFunction, cloneInto)
It seems reasonable to extend this policy to Web Components:
- content script sees page's component properties only if explicitly asked
- page script sees plain HTMLElement for content's components
but it may be just my narrow point of view.
Also right now window.customElements slightly breaks isolation between scripts (not sure if this is Firefox specific) since it is shared between contexts: if component was defined in page script, content script can't use the same name and vice versa.
Maybe "correct" solution would be disabling customElements in content scripts altogether?
Been digging through Firefox's code trying to fix Web Components in extension content scripts (https://bugzilla.mozilla.org/show_bug.cgi?id=1492002).
I've found the core problem, it's specific for Firefox implementation, but now I'm not sure what "correct" solution should look like.
Right now Firefox's policy regarding normal JS objects looks like:
It seems reasonable to extend this policy to Web Components:
but it may be just my narrow point of view.
Also right now window.customElements slightly breaks isolation between scripts (not sure if this is Firefox specific) since it is shared between contexts: if component was defined in page script, content script can't use the same name and vice versa.
Maybe "correct" solution would be disabling
customElementsin content scripts altogether?