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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Happy DOM - window.Blob is not equal to globalThis.Blob #1323

Closed
6 tasks done
capricorn86 opened this issue May 16, 2022 · 3 comments 路 Fixed by #1340
Closed
6 tasks done

Happy DOM - window.Blob is not equal to globalThis.Blob #1323

capricorn86 opened this issue May 16, 2022 · 3 comments 路 Fixed by #1340

Comments

@capricorn86
Copy link
Contributor

capricorn86 commented May 16, 2022

Describe the bug

Hi! 馃檪

A bug was reported in Happy DOM related to "new Blob()" not being an instance of globalThis.Blob.

There seem to be two different implementations of Blob used in window.Blob vs globalThis.Blob. Node does not support Blob, so there must be something else adding the second implementation.

I investigated a bit further and I also noticed that window isn't the same as globalThis and global. Vitest should probably set global.window to be global.

Related bug in Happy DOM:
capricorn86/happy-dom#471

Reproduction

// Outputs "false"
console.log(window.globalThis === globalThis);

// Outputs "false"
console.log(window.Blob === globalThis.Blob);

// Outputs "false"
console.log(window.globalThis.Blob === globalThis.Blob);

// Outputs "false"
console.log(Blob === globalThis.Blob);

// Outputs "false"
console.log(Blob === globalThis.Blob);

System Info

System:
    OS: Linux 5.17 Pop!_OS 22.04 LTS
    CPU: (4) x64 Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz
    Memory: 6.43 GB / 15.56 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 16.15.0 - /usr/bin/node
    Yarn: 1.22.10 - ~/.npm-global/bin/yarn
    npm: 8.5.5 - /usr/bin/npm
  Browsers:
    Chrome: 101.0.4951.41
    Firefox: 100.0

Used Package Manager

npm

Validations

@capricorn86 capricorn86 changed the title window.Blob is not equal to globalThis.Blob Happy DOM - window.Blob is not equal to globalThis.Blob May 16, 2022
@nakleiderer
Copy link

I experienced this issue then upgrading from vitest@0.11.0 to vitest@0.12.0 and it resulted in this error:

TypeError: Class extends value does not have valid prototype property undefined
Object. node_modules/@web-std/file/dist/src/file.cjs:59:15
Object. node_modules/@web-std/file/dist/src/lib.node.cjs:6:12

@sheremet-va
Copy link
Member

There seem to be two different implementations of Blob used in window.Blob vs globalThis.Blob. Node does not support Blob, so there must be something else adding the second implementation.

It was actually because we binded function to window on each access resulting in a different function.

I investigated a bit further and I also noticed that window isn't the same as globalThis and global. Vitest should probably set global.window to be global.

We actually had a very over engineered implementation for accessing globals, because jsdom got itself into an infinite loop/failed on accessing EventTarget. I think I fixed it in #1340 tho, and we now use a more simplistic implementation, as you suggested.

@capricorn86
Copy link
Contributor Author

@sheremet-va nice to hear! 馃檪

@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants