Skip to content

Remove Object.hasOwn usage from the src/core/xref.js file#20663

Merged
Snuffleupagus merged 1 commit intomozilla:masterfrom
Snuffleupagus:xref-rm-Object-hasOwn
Feb 16, 2026
Merged

Remove Object.hasOwn usage from the src/core/xref.js file#20663
Snuffleupagus merged 1 commit intomozilla:masterfrom
Snuffleupagus:xref-rm-Object-hasOwn

Conversation

@Snuffleupagus
Copy link
Collaborator

This should not be necessary, given the following checks done early during the worker initialization:

pdf.js/src/core/worker.js

Lines 124 to 141 in c574694

if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
// Fail early, and predictably, rather than having (some) fonts fail to
// load/render with slightly cryptic error messages in environments where
// the `{Object, Array}.prototype` has been *incorrectly* extended.
//
// PLEASE NOTE: We do *not* want to slow down font parsing by adding
// `hasOwnProperty` checks all over the code-base.
const buildMsg = (type, prop) =>
`The \`${type}.prototype\` contains unexpected enumerable property ` +
`"${prop}", thus breaking e.g. \`for...in\` iteration of ${type}s.`;
for (const prop in {}) {
throw new Error(buildMsg("Object", prop));
}
for (const prop in []) {
throw new Error(buildMsg("Array", prop));
}
}

@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.83%. Comparing base (c574694) to head (0a91764).

Files with missing lines Patch % Lines
src/core/xref.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20663      +/-   ##
==========================================
+ Coverage   59.79%   59.83%   +0.03%     
==========================================
  Files         169      169              
  Lines       90158    90158              
==========================================
+ Hits        53907    53943      +36     
+ Misses      36251    36215      -36     
Flag Coverage Δ
unittestcli 59.83% <0.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, with passing tests, but since this was added somewhat recently in af144be I'd like @calixteman to also sign off on this. Thanks!

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@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/9eb4d30996624c0/output.txt

@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/e8ca7ba61ca6f2f/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/9eb4d30996624c0/output.txt

Total script time: 42.09 mins

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

Image differences available at: http://54.241.84.105:8877/9eb4d30996624c0/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/e8ca7ba61ca6f2f/output.txt

Total script time: 82.68 mins

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

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

@Snuffleupagus Snuffleupagus merged commit 8319fff into mozilla:master Feb 16, 2026
12 checks passed
@Snuffleupagus Snuffleupagus deleted the xref-rm-Object-hasOwn branch February 16, 2026 19:38
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.

5 participants