polyfills icon indicating copy to clipboard operation
polyfills copied to clipboard

[scoped-custom-element-registry] Add basic jsdom tests

Open bicknellr opened this issue 3 years ago • 4 comments

jsdom currently has a bug where it reads the global custom elements registry by looking through the sandbox-facing customElements property of its global object. This means that scripts running in that context can break jsdom's custom elements implementation by overwriting or deleting the customElements global.

I'm making a PR to fix jsdom upstream. Once jsdom and jest-environment-jsdom are released with updated versions, these tests should pass.

  • [x] https://github.com/jsdom/jsdom/pull/3454

Closes https://github.com/webcomponents/polyfills/issues/459.

bicknellr avatar Oct 24 '22 23:10 bicknellr

jsdom 20.0.2 contains the PR with the fix. jest-environment-jsdom depends on jsdom@^20.0.0 so its not guaranteed to use 20.0.2. Adding jsdom@^20.0.2 as a dev dependency here would satisfy node's deduping during installation of jest-environment-jsdom, but I don't think it's a great idea to rely on that behavior so I'll keep this open until it depends on at least 20.0.2.

bicknellr avatar Oct 31 '22 21:10 bicknellr

Adding jsdom@^20.0.2 as a dev dependency here would satisfy node's deduping during installation of jest-environment-jsdom

I'm trying this out here: https://github.com/webcomponents/polyfills/commit/39e3f06c7b2be69bbe9b0b1c3220480a81409095

bicknellr avatar Oct 31 '22 21:10 bicknellr

Except for the formatting, the tests passed on that commit. I reformatted and pushed here. (These still won't pass until jest-environment-jsdom is updated.)

bicknellr avatar Oct 31 '22 21:10 bicknellr

Added "Skip Changelog" label because there are no user-facing changes.

bicknellr avatar Oct 31 '22 21:10 bicknellr