Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace instanceof Object with typeof checks #13657

Merged
merged 1 commit into from
Jul 3, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

Using instanceof Object is generally problematic, since it's not guaranteed to always do the right thing for all Objects.
(I stumbled upon this while working on another patch, when I noticed that the outlineView was broken with workers disabled.)

Using `instanceof Object` is generally problematic, since it's not guaranteed to always do the right thing for all Objects.
(I stumbled upon this while working on another patch, when I noticed that the `outlineView` was broken with workers disabled.)
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2021

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/246445bae803c28/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2021

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/1903cc3620eb60f/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/1903cc3620eb60f/output.txt

Total script time: 30.38 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 9
  different first/second rendering: 1

Image differences available at: http://54.67.70.0:8877/1903cc3620eb60f/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2021

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/246445bae803c28/output.txt

Total script time: 34.81 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 9
  different first/second rendering: 1

Image differences available at: http://3.101.106.178:8877/246445bae803c28/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2021

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/915f52a0e39bc28/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2021

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/915f52a0e39bc28/output.txt

Total script time: 5.05 mins

Published

@timvandermeij
Copy link
Contributor

I couldn't immediately figure out from the given description in which cases this would fail, but some Googling showed me that this happens for objects without prototypes, which we use. From the console:

> const foo = Object.create(null);
undefined
> foo instanceof Object
false
> typeof foo === "object" && foo !== null
true

I'm adding this for future reference.

@timvandermeij timvandermeij merged commit 227d0b0 into mozilla:master Jul 3, 2021
@timvandermeij
Copy link
Contributor

Thanks!

@Snuffleupagus Snuffleupagus deleted the rm-instanceof-Object branch July 3, 2021 13:43
@Snuffleupagus
Copy link
Collaborator Author

I couldn't immediately figure out from the given description in which cases this would fail,

My apologies; I should have included more details in the commit message!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants