-
Notifications
You must be signed in to change notification settings - Fork 177
Description
Most places in HTML that use prepare to run script call check if we can run script beforehand, and bail out if you can't:
- run a classic script
- run a module script
- HostEnqueueFinalizationRegistryCleanupJob
- HostEnqueuePromiseJob
However, Web IDL notably does not! See:
This is important because the first step in "check if we can run the script" is to return false if the given realm (in this case, the realm of the callback or of the object) comes from a non-fully-active document, e.g. a detached iframe or a bfcached page.
Chrome seems to include such a "check if we can run script" check for Web IDL callbacks: see https://jsfiddle.net/shaseley/w4nsq2oj/7/ which runs the task in Firefox and Safari but does not run the task in Chrome. Discovered by @shaseley @natechapin.
Worse, https://jsfiddle.net/n04m3jpo/ shows a variant with promise handlers (instead of setTimeout
's Web IDL callbacks) where Chrome and Safari do run the promise handler, and Firefox does not.
(On the spec side, I think we cargo-culted the "check if we can run script" check into HostEnqueueFinalizationRegistryCleanupJob and HostEnqueuePromiseJob without testing, because I thought it was about the user disabling scripting, and I forgot it was also about non-fully-active documents.)
My instinct is that we should be uniform here and not run the handler in any cases. /cc @smaug---- @rakina for bfcache connection, @syg for promise/finalization registry connection.
Related: whatwg/html#2621