Skip to content

Simplify the FileSpec class, and remove no longer needed polyfills#20596

Merged
timvandermeij merged 5 commits intomozilla:masterfrom
Snuffleupagus:FileSpec-fixes
Jan 29, 2026
Merged

Simplify the FileSpec class, and remove no longer needed polyfills#20596
timvandermeij merged 5 commits intomozilla:masterfrom
Snuffleupagus:FileSpec-fixes

Conversation

@Snuffleupagus
Copy link
Collaborator

No description provided.

Also, tweak code/comment used when handling "GoToR" destinations.
…e code

Given that only the `FileSpec.prototype.serializable` getter is ever invoked from "outside" of the class, and only once per `FileSpec`-instance, the caching/shadowing isn't actually necessary.

Furthermore the `_contentRef`-caching wasn't actually correct, since it ended up storing a `BaseStream`-instance and those should *generally* never be cached.
(Since calling `BaseStream.prototype.getBytes()` more than once, without resetting the stream in between, will return an empty TypedArray after the first time.)
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/8e4202c8d4a1b03/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/7390f958a03e63c/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/7390f958a03e63c/output.txt

Total script time: 41.68 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.241.84.105:8877/7390f958a03e63c/reftest-analyzer.html#web=eq.log

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/8e4202c8d4a1b03/output.txt

Total script time: 81.73 mins

  • Unit tests: FAILED
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.193.163.58:8877/8e4202c8d4a1b03/reftest-analyzer.html#web=eq.log

…totype.serializable`

It's more correct to return the `rawFilename` as-is, and limit the fallback for empty filenames to only the `filename` property.
(During rebasing of the previous patches I happened to look at the polyfills and noticed that this one could be removed now.)

Note:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/try#browser_compatibility
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1928493
…se64()`, and `Uint8Array.fromBase64()` polyfills

(During rebasing of the previous patches I happened to look at the polyfills and noticed that this one could be removed now.)

See:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toHex#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/toBase64#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64#browser_compatibility

Note that technically this functionality can still be disabled via a preference in Firefox, however that's slated for removal in [bug 1985120](https://bugzilla.mozilla.org/show_bug.cgi?id=1985120).
Looking at the Firefox source-code, see https://searchfox.org/firefox-main/search?q=array.tobase64%28%29&path=&case=false&regexp=false, you can see that it's already being used *unconditionally* elsewhere in the browser hence removing the polyfills ought to be fine (since toggling the preference would break other parts of the browser).
@timvandermeij timvandermeij merged commit 471adfd into mozilla:master Jan 29, 2026
10 checks passed
@timvandermeij
Copy link
Contributor

Thank you for improving this code!

@timvandermeij timvandermeij removed the request for review from calixteman January 29, 2026 21:04
@Snuffleupagus Snuffleupagus deleted the FileSpec-fixes branch January 30, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants