jeroenheijmans / advent-of-code-charts

Inject charts in your private leaderboard page for Advent of Code
MIT License
121 stars 21 forks source link

Firefox addon throwing Xray Vision error (especially on initial load) #105

Open jeroenheijmans opened 1 day ago

jeroenheijmans commented 1 day ago

In Firefox the addon sometimes fails to load. It reliably fails the first time a leaderboard should be loaded for the first time.

Reproduce

Steps to reproduce this bug:

  1. Open Firefox with the add on installed
  2. Go to https://adventofcode.com/2024/leaderboard/private
  3. Open the developer tools, Storage tab, and clear al localStorage (leave dev tools open)
  4. Click the "[View]" link to show your own private leaderboard

Relevant console output:

ℹ️ [app.js:1814:17] Loading via readyState = interactive
ℹ️ [app.js:1809:17] Going to construct App
ℹ️ [app.js:793:21]  Constructing App
ℹ️ [app.js:485:17]  Getting cache aoc-data-v1-/2024/leaderboard/private/view/277259
ℹ️ [app.js:618:25]  Found cache null
ℹ️ [app.js:632:25]  Loading data from url https://adventofcode.com/2024/leaderboard/private/view/277259.json
ℹ️ [app.js:490:17]  Updating cache
🛑 [app.js:265:17]  Error: Not allowed to define cross-origin object as property on [Object] or [Array] XrayWrapper
🛑                  Uncaught (in promise) InternalError: Promise rejection value is a non-unwrappable cross-compartment wrapper.

In a screenshot:

screenshot as described above

Details

At least reproducible on:

Further resources

https://firefox-source-docs.mozilla.org/dom/scriptSecurity/xray_vision.html

jeroenheijmans commented 1 day ago

I have a hunch, but not a clear idea of what's causing this issue, or how to properly solve it. I presume it is because I rely on mutating an object here:

https://github.com/jeroenheijmans/advent-of-code-charts/blob/1fa3ce574103704b557625a4ad1f0ce71806915a/src/js/app.js#L255-L270

Especially line 265 (where it crashes).

Perhaps the solution would be to clone the json before I start mutating it like that?

I don't feel much for including Firefox-specific code in the addon to battle this (something with "waiving xray stuff" seems an alternative otherwise).

At this particular moment I have no bandwidth to fix it myself, but would welcome a simple PR that would fix things.

Luckily it seems Firefox will load the addon after a single refresh.