Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,44 @@ it is not always *sufficient*
to protect users from invasive behaviours,
and seeking [meaningful consent](#consent) is also important.

<h3 id="handle-destroyed-contexts">Handle non-fully-active documents (and destroyed execution contexts)</h3>

When an <{iframe}> (or similar) is removed or navigated,
its document stops being [=Document/fully active=]
and its [=ECMAScript/execution contexts=] can get destroyed.
However, references to objects from that document
can remain reachable from other documents
or from other realms.

Specifications should say what happens both at call time
and after an operation has begun:
otherwise background work may keep running after a page is gone,
UI can hang, and user agents diverge in abort/cleanup behavior.

If the [=relevant global object=]'s [=associated Document=]
is not [=Document/fully active=] at call time,
then [=throw=], or return [=a promise rejected with=],
with {{InvalidStateError}}.

If, after starting an asynchronous operation,
that [=associated Document=] becomes non-[=Document/fully active=]
or the [=relevant global object=]'s [=ECMAScript/execution context=] is destroyed,
abort the operation and reject with {{AbortError}}.
If the operation presents UI (e.g., a picker, chooser, or prompt),
dismiss it when the context becomes non-[=Document/fully active=]
and settle with {{AbortError}}.

When [=queue a task|queueing=] subsequent work
(e.g., for an event, settling a promise, a time-based operation),
include an early exit:
if the [=associated Document=] is not [=Document/fully active=],
gracefully terminate the [=task=].
Do not rely on garbage collection to define these semantics.

See also: [[#support-non-fully-active]] for the BFCache case;
most of the same principles apply to detached iframes
and other torn-down [=All Execution Contexts/realms=].

<h3 id="support-non-fully-active">Support non-fully active BFCached documents</h3>

Specify how your feature behaves
Expand Down Expand Up @@ -1615,7 +1653,7 @@ Unlike dictionaries, interfaces:
(i.e., one can check if it is an `instanceof` a particular class on the global scope),

Defining an interface also exposes it on the global scope, allowing for the specification of static methods.
For example, the `canParse()` static method of the URL interface.
For example, the `canParse()` static method of the URL interface.

```JS
if (URL.canParse(someURL)) {
Expand Down