GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — Test native web streams in modern browsers by twiss · Pull Request #1934 · openpgpjs/openpgpjs Conversation
|
| return detectNodeWebStreams() || import('web-streams-polyfill/polyfill'); | ||
| globalThis.loadStreamsPolyfill = async function() { | ||
| if (!globalThis.TransformStream) { | ||
| Object.assign(globalThis, await import('web-streams-polyfill')); |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why the assignment? (Instead of just importing the polyfill)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It doesn't work in the bundled browser tests, because the polyfill is bundled together with the tests, and overwrites the globals immediately (unconditionally), rather than only when await import is called
Sorry, something went wrong.
There was an error while loading. Please reload this page.
71e4761 to
7d6b63c
Compare
| openpgp.config.s2kIterationCountByte = 0; | ||
|
|
||
| if (!globalThis.TransformStream) { | ||
| Object.assign(globalThis, await import('web-streams-polyfill')); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The top-level await doesn't work in Safari 14.
But Since TransformsStreams are supported from Safari 14.1 and iOS Safari 14.5, meaning most platforms we will test on won't need it, I think we can just not await it (void import().then(...)), and eventually drop it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ah, right.
Since it's bundled anyway, we can also just do a top-level import and assign it conditionally rather than importing conditionally. This only hurts the Node tests performance a tiny bit but shouldn't really be significant.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Only load the web streams polyfill if needed.
7d6b63c to
25403cc
Compare
There was an error while loading. Please reload this page.
Mobile Safari, like Desktop Safari, triggers `unhandledrejection` events for handled Promise rejections. Ignore them in the browser tests.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.