Closed Bug 1766909 Opened 4 years ago Closed 4 years ago

ObservableArray constructable stylesheets breaks Dark Reader add-on (Error: Accessing from Xray wrapper is not supported.)

Categories

(Core :: DOM: Bindings (WebIDL), defect)

defect

Tracking

()

RESOLVED FIXED
102 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox99 --- unaffected
firefox100 --- unaffected
firefox101 + fixed
firefox102 --- fixed

People

(Reporter: aminomancer, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

I'm still trying to work out details but here's what I noticed. Patch for bug 1766227 causes Dark Reader to fail to apply styles on some websites. I noticed it on phabricator which is the most obvious example I found.

To test you just need Nightly and to enable layout.css.constructable-stylesheets.enabled and go to https://phabricator.services.mozilla.com and then reload the page. It seems to succeed on initial load and fail on reload or history navigation (whereupon I guess it falls back to some baseline styles that make the page monochrome gray and white). If you force reload and skip cache (Shift+Accel+R) it seems to fail to apply the fallback styles too, resulting in the normal phabricator theme. You can also try building from D144547

Bisection: mozregression --addon .../addon@darkreader.org.xpi --pref layout.css.constructable-stylesheets.enabled:true --arg="https://phabricator.services.mozilla.com" --good=99

Pushlog

Flags: needinfo?(emilio)

Set release status flags based on info from the regressing bug 1766227

I don't see any of the adopted stylesheets code in DocumentOrShadowRoot.cpp getting hit, which makes this particularly hilarious.

Ok, so this took a ridiculous amount of time to find (well, since my last comment), because dark reader is catching all the exceptions. But the TLDR is that accessing adoptedStyleSheets from an extension now throws:

Error: Accessing from Xray wrapper is not supported.

And that breaks the extension awfully since they do expect adoptedStyleSheets to work.

Edgar, Peter, do you know if we can relax this restriction?

Maybe we can turn the ObservableArray into a plain sequence on getting, at least? Or should I just send a patch to the darkreader add-on to wrap observableArray access in a try-catch? That could probably do for now, but it will bite us in the future, I suspect...

Flags: needinfo?(peterv)
Flags: needinfo?(emilio)
Flags: needinfo?(echen)
Component: DOM: CSS Object Model → DOM: Bindings (WebIDL)
Summary: ObservableArray constructable stylesheets breaks Dark Reader add-on → ObservableArray constructable stylesheets breaks Dark Reader add-on (Error: Accessing from Xray wrapper is not supported.)

[Tracking Requested - why for this release]: If this is not easy to fix or work around we should consider not shipping this feature in 101.

This will still prevent them from accessing stuff (.length will be
undefined, etc), but seems better than unexpectedly throwing. This fixes
the issue at hand at least.

With this patch, we reject length accesses here:

https://searchfox.org/mozilla-central/rev/86c98c486f03b598d0f80356b69163fd400ec8aa/js/xpconnect/wrappers/XrayWrapper.cpp#229-233

Your call on whether this patch is enough as-is, or more work is needed.
Also your call on whether if more work is needed that needs to happen on
this bug or somewhere else.

I'm not sure what we'd need to do to support this more "properly",
presumably we'd need to add special XRay support to
ObservableArrayProxyHandler or so? Pointers (or patches of course ;))
welcome.

Also unsure about the setter situation, I think it's fine not to throw
given the code I read, but please sanity-check.

Assignee: nobody → emilio
Status: NEW → ASSIGNED
Depends on: 1751346
Flags: needinfo?(echen)
Has Regression Range: --- → yes

Set release status flags based on info from the regressing bug 1766227

Attached file Bindings diff.

Instead of generating complicated code to deal with something that can't
happen.

Attachment #9275236 - Attachment is obsolete: true
See Also: → 1767995
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e8eab3bfc4ef Wrap ObservableArray proxy on getter, rather than throwing. r=peterv
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch

Is this ready for a Beta approval request?

Flags: needinfo?(emilio)

Comment on attachment 9274364 [details]
Bug 1766909 - Wrap ObservableArray proxy on getter, rather than throwing. r=peterv,edgar

Beta/Release Uplift Approval Request

  • User impact if declined: None known (the relevant add-on was fixed), but potential fallout from other add-ons.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: none
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Simple patch returning an opaque object rather than throwing.
  • String changes made/needed: none
  • Is Android affected?: Unknown
Flags: needinfo?(emilio)
Attachment #9274364 - Flags: approval-mozilla-beta?

Comment on attachment 9274364 [details]
Bug 1766909 - Wrap ObservableArray proxy on getter, rather than throwing. r=peterv,edgar

Approved for 101.0b8.

Attachment #9274364 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
See Also: → 1827104
Flags: needinfo?(peterv)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: