Open Bug 1817675 Opened 2 years ago Updated 6 months ago

ShadowRoot.adoptedStylesheets returns an opaque object in content scripts

Categories

(WebExtensions :: General, defect, P3)

Desktop
All
defect

Tracking

(firefox-esr102 affected, firefox110 affected, firefox111 affected, firefox112 affected)

Tracking Status
firefox-esr102 --- affected
firefox110 --- affected
firefox111 --- affected
firefox112 --- affected

People

(Reporter: gildas.lormeau, Unassigned)

References

(Depends on 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/111.0

Steps to reproduce:

This issue can be reproduced with SingleFile:

  1. Install SingleFile from here: https://addons.mozilla.org/en-US/firefox/addon/single-file/
  2. Save with SingleFile this page: https://www.virustotal.com/gui/file/49184a08df66331b671fbe93b40c34afe3b943475bca0568a22bebd1208e1164/details
  3. Open the saved page

Actual results:

The layout of the page is broken.

Expected results:

The layout of the page should be OK. Also, this bug does not happen if you do the same test in a Chromium-based browser.

The bug is due to the fact that ShadowRoot.adoptedStyleSheets can't be read in a content script and throws an exception.

Component: Untriaged → Extension Compatibility
OS: Unspecified → All
Hardware: Unspecified → All

[Tracking Requested - why for this release]:

Hello,

following the indicated steps, I have reproduced the issue on
MacOS 12.5 and Win 11, with Fx versions: Nightly 112.0a1 (21-Feb-2023) and 101.0b1-candidates.

This seems to be a regression:

  • last good release: 100.0
  • first bad release: 101.0

I used these in mozregression and found:
pushlog_url: https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=23768574eb6d1c1191228316adbc082aaf3a7fd5&tochange=6d8eefa220596a138aceee2b8e93529128c98451

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Hardware: All → Desktop
Version: Firefox 110 → Trunk

Any news about this regression? I'm still surprised that if I use Element#openOrClosedShadowRoot then ShadowRoot.adoptedStyleSheets can be opaque. This is also a compatibility issue since this bug does not exist in Chromium-based browsers.

For the record, I've implemented a workaround for this bug in SingleFile. It consists in injecting a script into the web page in order to read the adoptedStylesheets property and communicate the serialized content to the content script of the extension.

This is not a regression, this was never implemented correctly (the range you found shows the initial implementation of constructable stylesheets), which is an architectural problem in Firefox's XRays. As a workaround you can use document.wrappedJSObject.adoptedStyleSheets directly from the content script without injecting anything. It's still unsafe, of course, and in some cases may require using cloneInto helper function.

Severity: S3 → --
Component: Extension Compatibility → General
Depends on: 1751346
Product: Firefox → WebExtensions
See Also: → 1770592

The severity field is not set for this bug.
:zombie, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(tomica)
Severity: -- → S3
Flags: needinfo?(tomica)
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: