First, when an iframe gets removed, its document's browsing context is set to null.
When an iframe element is removed from a document, the user agent must discard
the element's nested browsing context, if it is not null, and then set the
element's nested browsing context to null.
To discard a browsing context browsingContext, run these steps:
1. Discard all Document objects for all the entries in browsingContext's session history.
To discard a Document document:
7. Set document's browsing context to null.
HostEnqueuePromiseJob says it doesn't run the job if the document's "browsing context" is null.
6. Queue a microtask on the surrounding agent's event loop to perform the
1. If job settings is not null, then check if we can run script with job
settings. If this returns "do not run" then return.
The steps to check if we can run script with an environment settings object
settings are as follows. They return either "run" or "do not run".
1. If the global object specified by settings is a Window object whose
Document object is not fully active, then return "do not run".
A Document d is said to be fully active when d's browsing context is non-null,
d's browsing context's active document is d, and either d's browsing context is
a top-level browsing context, or d's container document is fully active.
This means a promise reaction is ignored if the global is dying,
unless there's something else that cleans up pending promises when the global dies.
I'll look into the spec some more.