Prerendering Revamped

Draft Community Group Report,

This version:
https://wicg.github.io/nav-speculation/prerendering.html
Issue Tracking:
GitHub
Inline In Spec
Editors:
(Google)
(Google)

Abstract

This document contains a collection of specification patches for well-specified prerendering.

Status of this document

This specification was published by the Web Platform Incubator Community Group. It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups.

1. Prerendering infrastructure

1.1. Extensions to the Document interface

We’d modify [HTML]'s centralized definition of Document as follows:

partial interface Document {
    readonly attribute boolean prerendering;

    // Under "special event handler IDL attributes that only apply to Document objects"
    attribute EventHandler onprerenderingchange;
};

The onprerenderingchange attribute is an event handler IDL attribute corresponding to the prerenderingchange event handler event type. (We would update the corresponding table in [HTML], which currently only contains onreadystatechange.)

As is customary for [HTML], the definition of prerendering would be located in another section of the spec; we’d place it in the new section introduced below:

1.2. Prerendering navigables

The following section would be added as a new sub-section of [HTML]'s Navigables section.

Every navigable has a loading mode, which is one of the following:

"default"

No special considerations are applied to content loaded in this navigable

"prerender"

This navigable is displaying prerendered content

By default, a navigable's loading mode is "default". A navigable whose loading mode is "prerender" is known as a prerendering navigable. A prerendering navigable that is also a top-level traversable is known as a prerendering traversable.

Although there are only two values for the loading mode, we use a flexible structure in anticipation of other future loading modes, such as those provided by fenced frames, portals, and uncredentialed (cross-site) prerendering. It’s not yet clear whether that anticipation is correct; if, as those features gain full specifications, it turns out not to be, we will instead convert this into a boolean.

document.prerendering
Returns true if the page is being presented in a non-interactive "prerendering-like" context. In the future, this would include a visible document in a <portal> element, both when loaded into it or via predecessor adoption.

The prerendering getter steps are to return true if this has a non-null node navigable that is a prerendering navigable; otherwise, false.


Every Document has a prerendering traversables map, which is an ordered map of URLs to prerendering traversables. This is used to fulfill navigations to a given URL by instead activating the corresponding prerendering traversable.

Every Document has a post-prerendering activation steps list, which is a list where each item is a series of algorithm steps. For convenience, we define the post-prerendering activation steps list for any platform object platformObject as:

If platformObject is a node
  1. Return platformObject’s node document's post-prerendering activation steps list.

Otherwise
  1. Assert: platformObject’s relevant global object is a Window object.

  1. Return platformObject’s relevant global object's associated Document's post-prerendering activation steps list.

Every Document has an activation start time, which is initially a DOMHighResTimeStamp with a time value of zero.

User agents may choose to initiate prerendering without a referrer document, for example as a result of the address bar or other browser user interactions.

To start user-agent initiated prerendering given a URL startingURL:

  1. Assert: startingURL’s scheme is an HTTP(S) scheme.

  2. Let prerenderingTraversable be the result of creating a new top-level traversable given null and the empty string.

  3. Set prerenderingTraversable’s loading mode to "prerender".

  4. Navigate prerenderingTraversable to startingURL using prerenderingTraversable’s active document.

    We treat this initial navigations as prerenderingTraversable navigating itself, which will ensure all relevant security checks pass.

  5. When the user indicates they wish to commit the navigation and create a new user-visible top-level traversable while doing so (e.g., by pressing Shift+Enter after typing in the address bar):

    1. Update the user agent’s user interface to present prerenderingTraversable, e.g., by creating a new tab/window.

    2. Finalize activation for prerenderingTraversable given startingURL’s origin.

  6. Alternately, when they use indicates they wish to commit the navigation into an existing top-level traversable predecessorTraversable (e.g., by pressing Enter after typing in the address bar):

    1. Activate prerenderingTraversable in place of predecessorTraversable given "push".

The user might never indicate such a commitment, or might take long enough to do so that the user agent needs to reclaim the resources used by the prerender for some more immediate task. In that case the user agent can destroy prerenderingTraversable.

To start referrer-initiated prerendering given a URL startingURL, a Document referrerDoc, and a referrer policy referrerPolicy:
  1. Assert: startingURL’s scheme is an HTTP(S) scheme.

  2. If referrerDoc’s node navigable is not a top-level traversable, then return.

    Currently, prerendering from inside a child navigable is not specified or implemented. Doing so would involve tricky considerations around how the prerendered navigable appears in the navigable tree.

  3. If referrerDoc’s browsing context is an auxiliary browsing context, then return.

    This avoids having to deal with any potential opener relationship between the prerendering traversable and referrerDoc’s browsing context's opener browsing context.

  4. If referrerDoc’s origin is not same site with startingURL’s origin, then return.

    Currently, cross-site prerendering is not specified or implemented, although we have various ideas about how it could work in this repository’s explainers.

  5. If referrerDoc’s prerendering traversables map[startingURL] exists, then return.

  6. Let prerenderingTraversable be the result of creating a new top-level traversable.

  7. Set prerenderingTraversable’s loading mode to "prerender".

  8. Set referrerDoc’s prerendering traversables map[startingURL] to prerenderingTraversable.

  9. Set prerenderingTraversable’s remove from referrer to be an algorithm which removes referrerDoc[startingURL].

    As with all top-level traversables, the prerendering traversable can be destroyed for any reason, for example if it becomes unresponsive, performs a restricted operation, or if the user agent believes prerendering takes too many resources.

  10. Navigate prerenderingTraversable to startingURL using referrerDoc, with referrerPolicy set to referrerPolicy.

To activate a prerendering traversable successorTraversable in place of a top-level traversable predecessorTraversable given a history handling behavior historyHandling and an optional navigation ID navigationId:
  1. Assert: successorTraversable’s active document's is initial about:blank is false.

  2. If navigationId is not given, then let navigationId be the result of generating a random UUID.

  3. Let referrerOrigin be predecessorTraversable’s active document's origin.

  4. Set predecessorTraversable’s ongoing navigation to navigationId.

    This will have the effect of aborting any other ongoing navigations of predecessorTraversable.

  5. In parallel, run these steps:

    1. Let unloadPromptCanceled be the result of checking if unloading is user-canceled for predecessorTraversable’s active document's inclusive descendant navigables.

    2. If unloadPromptCanceled is true, or predecessorTraversable’s ongoing navigation is no longer navigationId, then abort these steps.

    3. Queue a global task on the navigation and traversal task source given predecessorTraversable’s active window to abort predecessorTraversable’s active document.

    4. Append session history traversal steps to predecessorTraversable to perform the following steps:

      1. Assert: successorTraversable’s current session history step is 0.

      2. Assert: successorTraversable’s session history entries's size is 1.

      3. Let successorEntry be successorTraversable’s session history entries[0].

      4. Remove successorEntry from successorTraversable’s session history entries.

        At this point, successorTraversable is empty and can be unobservably destroyed. (As long as the implementation takes care to keep successorEntry, including its document and that Document's browsing context, alive for the next step.)

      5. Finalize a cross-document navigation given predecessorTraversable, historyHandling, and successorEntry.

        Because we have moved the entire session history entry, including the contained document's browsing context, this means traversing across the associated history entries will cause a browsing context group switch, similar to what happens with the `Cross-Origin-Opener-Policy` header. Importantly, this will sever any opener relationships, in the same way as COOP. Such traversal includes both the actual activation process here, where we make successorEntry active, but also e.g. the user pressing the back button (or the page using history.back()) after activation, which will switch in the other direction.

      6. Update the user agent’s user interface to reflect this change, e.g., by updating the tab/window contents and the browser chrome.

      7. Finalize activation for successorTraversable given referrerOrigin.

      8. Perhaps we should do something with WebDriver BiDi here? See w3c/webdriver-bidi#321. Right now the pre-in parallel part of the navigate algorithm will send WebDriver BiDi navigation started as if it were a normal navigation, but then nothing will happen to indicate the navigation finishes.

To finalize activation of a top-level traversable traversable given an origin origin:
  1. For each navigable of traversable’s active document's inclusive descendant navigables, queue a global task on the navigation and traversal task source, given navigable’s active window, to perform the following steps:

    1. For each originhintSet in navigable’s prerender-scoped Accept-CH cache:

      1. Set Accept-CH cache[origin] to hintSet.

    2. Let doc be navigable’s active document.

    3. We should really propagate the loading mode change here, in the posted task. This is where implementations would update what is returned by document.prerendering. However, right now it lives on the traversable, so it gets magically updated when we move over the session history entry. Probably we need to move it to the Document.

    4. If doc’s origin is the same as origin, then set doc’s activation start time to the current high resolution time for doc’s relevant global object.

    5. Fire an event named prerenderingchange at doc.

    6. For each steps in doc’s post-prerendering activation steps list:

      1. Run steps.

        These steps might return something, like a Promise. That is just an artifact of how the spec is modified; such return values can always be ignored.

      2. Assert: running steps did not throw an exception.

      The order here is observable for Documents that share an event loop, but not for those in separate event loops.

A prerendering traversable has an associated remove from referrer, which is null or an algorithm with no arguments, initially set to null.

To ensure that the references for a prerendering traversable are cleared once it is destroyed, modify destroy a top-level traversable by appending the following step:

  1. If traversable is a prerendering traversable and traversable’s remove from referrer is not null, then call traversable’s remove from referrer.

1.3. Modifications to creating navigables

To ensure that any child navigables inherit their parent's loading mode, modify create a new nested navigable by appending the following step:
  1. Set navigable’s loading mode to element’s node navigable's loading mode.

To get the matching prerendering navigable given a navigable navigable, a URL url, a string cspNavigationType, and a POST resource, string, or null documentResource:
  1. If any of the following conditions hold:

    then return null.

  2. Return navigable’s active document's prerendering traversables map[url], if it exists; otherwise return null.

Patch the navigate algorithm to allow the activation of a prerendering traversable in place of a normal navigation as follows:

In navigate, insert the following steps as the first ones after we go in parallel:
  1. Let matchingPrerenderedNavigable be the result of getting the matching prerendering navigable given navigable, url, cspNavigationType, and documentResource.

  2. If matchingPrerenderedNavigable is not null, then:

    1. Wait until either matchingPrerenderedNavigable’s active document's is initial about:blank is false, or matchingPrerenderedNavigable is destroyed.

    2. If matchingPrerenderedNavigable was not destroyed, then:

      1. Activate matchingPrerenderedNavigable in place of navigable given historyHandling and navigationId.

      2. Abort these steps.

In create navigation params by fetching, add the following step near the top of the algorithm:
  1. Let initiatorOrigin be entry’s document state's initiator origin.

Append the following steps after the first sub-step under "While true:":

  1. If navigable is a prerendering navigable and currentURL’s origin is not same site with initiatorOrigin, then:

    1. If navigable is a top-level traversable, then return null.

    2. Otherwise, the user agent must wait to continue this algorithm until navigable’s loading mode becomes "normal". At any point during this wait (including immediately), it may instead choose to destroy navigable’s top-level traversable and return null from this algorithm.

Append the following steps toward the end of the algorithm, after the steps which check locationURL:

  1. If navigable is a prerendering navigable, and responseOrigin is not same origin with initiatorOrigin, then:

    1. Let loadingModes be the result of getting the supported loading modes for response.

    2. If loadingModes does not contain `credentialed-prerender`, then return null.

      In the future we could possibly also allow the uncredentialed-prerender token to work here. However, since that is primarily intended for the cross site case, which isn’t specified or implemented yet, we don’t want to encourage its use in the wild, so for now we specify that prerendering fails if only the uncredentialed-prerender token is found.

In attempt to populate the history entry’s document, append the following after the steps which establish the value of failure, but before the other steps which act on it:
  1. If navigable is a prerendering navigable, and any of the following hold:

    • failure is true;

    • navigationParams’s request is null;

    • navigationParams’s request's current URL's scheme is not a HTTP(S) scheme;

    • navigationParams’s response does not support prefetch;

      Responses which are ineligible for prefetch, e.g. because they have an error status, are not eligible for prerender either. A future version of this specification might allow responses to more clearly delineate the two.
    • navigationParams’s response has a `Content-Disposition` header specifying the attachment disposition type; or

    • navigationParams’s response's status is 204 or 205,

    then:

    1. Destroy navigable’s top-level traversable.

    2. Return.

In hand-off to external software, prepend the following step:
  1. If navigable is a prerendering navigable, then return without invoking the external software package.

We could also allow prerendering activations in place of redirects, not just in place of navigations. We’ve omitted that for now as it adds complexity and is not yet implemented anywhere to our knowledge.

2.3. Maintaining a trivial session history

Patch the navigate algorithm to ensure the session history of a prerendering navigable stays trivial by prepending the following step before all others:
  1. If navigable is a prerendering navigable, then set historyHandling to "replace".

Patch the URL and history update steps by adding the following step after step 1:
  1. If navigable is a prerendering navigable, then set historyHandling to "replace".

2.4. Interaction with worker lifetime

In The worker’s lifetime, modify the definition of active needed worker, to count workers with a prerendering navigable owner as not active:

A worker is said to be an active needed worker if any of its owners are either Document objects that are fully active and their node navigable is not a prerendering navigable, or active needed workers.

This means that the worker’s script would load, but the execution would be suspended until the document is activated.

2.5. Cleanup upon discarding a Document

Modify the destroy algorithm for Documents by appending the following step:

  1. Empty document’s post-prerendering activation steps list.

3. Interaction with other specifications and concepts

3.1. Interaction with Page Visibility

Documents in prerendering navigables always have a visibility state of "hidden".

We should probably explicitly update this, similar to how we need to update document.prerendering.

3.2. Interaction with system focus

Prerendering traversables never have system focus.

3.3. Extensions to the PerformanceNavigationTiming interface

Extend the PerformanceNavigationTiming interface as follows:

partial interface PerformanceNavigationTiming {
    readonly attribute DOMHighResTimeStamp activationStart;
};

The activationStart getter steps are:

  1. Return this's relevant global object's associated Document's activation start time.

3.4. Interaction with Client Hint Cache

We need to ensure that the Accept-CH cache, which is owned by user agent as a global storage, is not modified while prerendering, but is properly updated after activation. The following modifications ensure this.

Each prerendering navigable has a prerender-scoped Accept-CH cache, which is an ordered map of origin to client hints sets.

This stores which client hints each origin has opted into receiving, until it can be copied to the global Accept-CH cache when activation is finalized.

Modify the update the client hints set from cache algorithm, by replacing the second step with the following steps.
  1. Let navigable be settingsObject’s global object's navigable.

  2. Let originMatchingEntries be the entries in the Accept-CH cache whose origin is same origin with settingsObject’s origin.

  3. If navigable is a prerendering navigable, then:

    1. Let prerenderAcceptClientHintsCache be navigable’s prerender-scoped Accept-CH cache.

    2. Let origin be settingsObject’s origin.

    3. If prerenderAcceptClientHintsCache[origin] exists, then let originMatchingEntries be the entries in the prerenderAcceptClientHintsCache whose origin is same origin with origin.

Modify the create or override the cached client hints set algorithm, by updating the last step.
  1. Let navigable be settingsObject’s global object's navigable.

  2. If navigable is a prerendering navigable, set navigable’s prerender-scoped Accept-CH cache[origin] to hintSet.

  3. Otherwise, set Accept-CH cache[origin] to hintSet.

4. The `Supports-Loading-Mode` HTTP response header

The following section would be added as a sub-section of [HTML]'s Loading web pages section.

In some cases, cross-origin web pages might not be prepared to be loaded in a novel context. To allow them to opt in to being loaded in such ways, the `Supports-Loading-Mode` HTTP response header can be used. This header is a structured header; if present its value must be one or more of the tokens listed below.

The parsing is actually done as a list of tokens, and unknown tokens will be ignored.

The `credentialed-prerender` token indicates that the response can be used to create a prerendering navigable, despite the prerendering being initiated by a cross-origin same-site referrer. Without this opt-in, such prerenders will fail, as outlined in § 2.2 Navigation fetch changes.

The `uncredentialed-prefetch` token indicates that the response is suitable to use even if a top-level navigation to this URL would ordinarily send credentials such as cookies. For instance, the response may be identical or it may be semantically equivalent (e.g., an HTML resource containing script which can update the document after navigation, when local user state is available).

To get the supported loading modes for a response response:

  1. If response is a network error, then return an empty list.

  2. Let slmHeader be the result of getting a structured field value given `Supports-Loading-Mode` and "list" from response’s header list.

  3. Return a list containing all elements of slmHeader that are tokens.

5. Preventing nonsensical behaviors

Some behaviors might make sense in most navigables, but do not make sense in prerendering navigables. This section enumerates specification patches to enforce such restrictions.

5.1. APIs for creating and navigating browsing contexts by name

Modify the definition of script-closable to prevent window closing while in a prerendering navigable:

A navigable is script-closable if either of the following is true:

6. Preventing intrusive behaviors

Various behaviors are disallowed in prerendering navigables because they would be intrusive to the user, since the prerendered content is not being actively interacted with.

6.1. Downloading resources

Modify the download the hyperlink algorithm to ensure that downloads inside prerendering navigable are delayed until activation, by inserting the following before the step which goes in parallel:

  1. If subject’s node navigable is a prerendering navigable, then append the following step to subject’s post-prerendering activation steps list and return.

6.2. User prompts

Modify the cannot show simple dialogs algorithm, given a Window window, by prepending the following step:
  1. If window’s navigable is a prerendering navigable, then return true.

Modify the print() method steps by prepending the following step:
  1. If this's navigable is a prerendering navigable, then return.

6.3. Delaying async API results

Many specifications need to be patched so that, if a given algorithm invoked in a prerendering navigable, most of its work is deferred until the navigable’s top-level traversable is activated. This is tricky to do uniformly, as many of these specifications do not have great hygeine around using the event loop. Nevertheless, the following sections give our best attempt.

6.3.1. The [DelayWhilePrerendering] extended attribute

To abstract away some of the boilerplate involved in delaying the action of asynchronous methods until activation, we introduce the [DelayWhilePrerendering] Web IDL extended attribute. It indicates that when a given method is called in a prerendering navigable, it will immediately return a pending promise and do nothing else. Only upon activation will the usual method steps take place, with their result being used to resolve or reject the previously-returned promise.

The [DelayWhilePrerendering] extended attribute must take no arguments, and must only appear on a regular or static operation whose return type is a promise type or undefined, and whose exposure set contains only Window.

The method steps for any operation annotated with the [DelayWhilePrerendering] extended attribute are replaced with the following:
  1. Let realm be the current realm.

  2. If the operation in question is a regular operation, then set realm to the relevant realm of this.

  3. If realm’s global object's navigable is a prerendering navigable, then:

    1. Let promise be a new promise, created in realm.

    2. Append the following steps to this's post-prerendering activation steps list:

      1. Let result be the result of running the originally-specified steps for this operation, with the same this and arguments.

      2. Resolve promise with result.

    3. If this operation’s return type is a promise type, then return promise.

  4. Otherwise, return the result of running the originally-specified steps for this operation, with the same this and arguments.

6.3.2. Service Workers

Add [DelayWhilePrerendering] to update(), unregister(), register(scriptURL, options), postMessage(message, transfer), and postMessage(message, options).

This allows prerendered page to take advantage of existing service workers, but not have any effect on the state of service worker registrations.

6.3.3. BroadcastChannel

Add [DelayWhilePrerendering] to postMessage().

6.3.4. Geolocation API

Modify the getCurrentPosition() method steps by prepending the following step:
  1. If this's relevant global object's navigable is a prerendering navigable, then append the following steps to this's post-prerendering activation steps list and return.

Modify the watchPosition() method steps by prepending the following step:
  1. If this's relevant global object's navigable is a prerendering navigable, then:

    1. Let watchId be an implementation-defined unsigned long, and note it as a post-prerendering activation geolocation watch process ID.

    2. Append the following steps to this's post-prerendering activation steps list, with the modification that the watchId generated must use watchId as its ID, and return watchId.

Modify the clearWatch(watchId) method steps by prepending the following step:
  1. If this's relevant global object's navigable is a prerendering navigable, then:

    1. If watchId is a post-prerendering activation geolocation watch process ID, then remove its corresponding steps from this's post-prerendering activation steps list.

    2. Return.

6.3.5. Web Serial API

Add [DelayWhilePrerendering] to requestPort().

TODO: the below could probably be done by generalizing [DelayWhilePrerendering] to use owner document while in dedicated workers.

Modify the getPorts() method steps by inserting the following steps after the initial creation of promise:
  1. Let document be this's relevant global object's associated Document, if this's relevant global object is a Window, or this's relevant global object's owner document, if this's relevant global object is a DedicatedWorkerGlobalScope.

  2. If document is null, then return a promise rejected with a "SecurityError" DOMException.

  3. If document’s node navigable is a prerendering navigable, then append the following steps to document’s post-prerendering activation steps list and return promise.

6.3.6. Notifications API

Add [DelayWhilePrerendering] to requestPermission().

Modify the Notification() constructor steps by replacing the step which goes in parallel with the following:
  1. If this's relevant global object's navigable is a prerendering navigable, then append these steps to this's post-prerendering activation steps list. Otherwise, run these steps in parallel.

Modify the permission static getter steps by replacing them with the following:
  1. If the current global object's navigable is a prerendering navigable, then return "default".

    This allows implementations to avoid looking up the actual permission state, which might not be synchronously accessible especially in the case of prerendering navigables. Web developers can then call Notification.requestPermission(), which per the above modifications will only actually do anything after activation. At that time we might discover that the permission is "granted" or "denied", so the browser might not actually ask the user like would normally be the case with "default". But that’s OK: it’s not observable to web developer code.

  2. Otherwise, get the notifications permission state and return it.

6.3.7. Web MIDI API

Add [DelayWhilePrerendering] to requestMIDIAccess().

6.3.8. Idle Detection API

Add [DelayWhilePrerendering] to start().

The other interesting method, IdleDetector.requestPermission(), is gated on transient activation. However, even if permission was previously granted for the origin in question, we delay starting any idle detectors while prerendering.

6.3.9. Generic Sensor API

Modify the start() method steps by inserting the following steps after the state is set to "activating":
  1. If this's relevant global object's navigable is a prerendering navigable, then append the following steps to this's post-prerendering activation steps list and return.

  2. If this.[[state]] is "idle", then return.

    This ensures that if this portion of the algorithm was delayed due to prerendering, and in the meantime stop() was called, we do nothing upon activating the prerender.

  3. Assert: this.[[state]] is "activating".

6.3.10. Web NFC

Add [DelayWhilePrerendering] to write() and scan().

6.3.11. Battery Status API

Modify the getBattery() method steps by prepending the following step:
  1. If this's relevant global object's navigable is a prerendering navigable, then append the following steps to this's post-prerendering activation steps list and return this.[[BatteryPromise]].

6.3.12. Screen Orientation API

Modify the apply orientation lock algorithm steps by overwriting the first few steps, before it goes in parallel, as follows:
  1. Let promise be a new promise.

  2. If this's relevant global object's navigable is a prerendering navigable, then append the following steps to this's post-prerendering activation steps list and return promise.

  3. If the user agent does not support locking the screen orientation, then reject promise with a "NotSupportedError" DOMException and return promise.

  4. If the document's active sandboxing flag set has the sandboxed orientation lock browsing context flag set, or the user agent doesn’t meet the pre-lock conditions to perform an orientation change, then reject promise with a "SecurityError" DOMException and return promise.

  5. Set the document's [[orientationPendingPromise]] to promise.

Add [DelayWhilePrerendering] to unlock().

This latter modification is necessary to ensure that code that calls screen.orientation.lock() followed by screen.orientation.unlock() produces the expected results.

6.3.13. Gamepad

Modify the getGamepads() method steps by prepending the following step:
  1. If this's relevant global object's navigable is a prerendering navigable, then return an empty sequence.

Modify the discussion of the gamepadconnected and gamepaddisconnected events to specify that the user agent must not dispatch these events if the Window object’s navigable is a prerendering navigable.

Modify the gamepadconnected section to indicate that every Document document’s post-prerendering activation steps list should gain the following steps:
  1. If document is allowed to use the "gamepad" feature, and document’s relevant settings object is a secure context, and any gamepads are connected, then for each connected gamepad, fire an event named gamepadconnected at document’s relevant global object using GamepadEvent, with its gamepad attribute initialized to a new Gamepad object representing the connected gamepad.

6.3.14. Encrypted Media Extensions

Add [DelayWhilePrerendering] to requestMediaKeySystemAccess().

6.3.15. Media Autoplay

Modify the playing the media resource section to indicate that the the current playback position of a HTMLMediaElement must increase monotonically only when the Document is not prerendering.

6.3.16. Media Capture and Streams

Add [DelayWhilePrerendering] to getUserMedia(), getUserMedia() and enumerateDevices().

Modify the MediaDevices section by prepending the following step to the device change notification steps:
  1. If this's relevant global object's navigable is a prerendering navigable, then return.

6.3.17. Audio Output Devices API

Add [DelayWhilePrerendering] to selectAudioOutput().

6.3.18. Push API

Add [DelayWhilePrerendering] to subscribe().

6.3.19. Background Fetch

Add [DelayWhilePrerendering] to fetch().

6.3.20. Storage API

Add [DelayWhilePrerendering] to persist().

6.3.21. WebUSB API

Add [DelayWhilePrerendering] to getDevices() and requestDevice().

6.3.22. Web Bluetooth

Add [DelayWhilePrerendering] to getDevices() and requestDevice().

6.3.23. WebHID API

Add [DelayWhilePrerendering] to getDevices() and requestDevice().

6.3.24. WebXR Device API

Add [DelayWhilePrerendering] to requestSession().

6.3.25. Credential Management

Add [DelayWhilePrerendering] to get(), store(), and create().

6.3.26. Web Speech API

Add [DelayWhilePrerendering] to speak(utterance), cancel(), pause(), and resume().

Add [DelayWhilePrerendering] to start(), stop(), and abort().

6.3.27. Web Locks API

Add [DelayWhilePrerendering] to request(name, callback), request(name, options, callback), and query().

6.4. Implicitly restricted APIs

Some APIs do not need modifications because they will automatically fail or no-op without a property that a prerendering navigable, its active window, or its active document will never have. These properties include:

We list known APIs here for completeness, to show which API surfaces we’ve audited.

APIs that require transient activation or sticky activation:

APIs that require system focus:

APIs that require the "visible" visibility state:

More complicated cases:

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[AUDIO-OUTPUT]
Justin Uberti; Guido Urdaneta; youenn fablet. Audio Output Devices API. URL: https://w3c.github.io/mediacapture-output/
[BACKGROUND-FETCH]
Background Fetch. cg-draft. URL: https://wicg.github.io/background-fetch/
[BATTERY-STATUS]
Anssi Kostiainen; Mounir Lamouri; Raphael Kubo da Costa. Battery Status API. URL: https://w3c.github.io/battery/
[CLIENT-HINTS-INFRASTRUCTURE]
Client Hints Infrastructure. cg-draft. URL: https://wicg.github.io/client-hints-infrastructure/
[CLIPBOARD-APIS]
Gary Kacmarcik; Grisha Lyukshin. Clipboard API and events. URL: https://w3c.github.io/clipboard-apis/
[CREDENTIAL-MANAGEMENT-1]
Mike West. Credential Management Level 1. URL: https://w3c.github.io/webappsec-credential-management/
[DOM]
Anne van Kesteren. DOM Standard. Living Standard. URL: https://dom.spec.whatwg.org/
[ENCRYPTED-MEDIA]
David Dorwin; et al. Encrypted Media Extensions. URL: https://w3c.github.io/encrypted-media/
[FETCH]
Anne van Kesteren. Fetch Standard. Living Standard. URL: https://fetch.spec.whatwg.org/
[FILE-SYSTEM-ACCESS]
File System Access. cg-draft. URL: https://wicg.github.io/file-system-access/
[FULLSCREEN]
Philip Jägenstedt. Fullscreen API Standard. Living Standard. URL: https://fullscreen.spec.whatwg.org/
[GAMEPAD]
Steve Agoston; James Hollyer; Matthew Reynolds. Gamepad. URL: https://w3c.github.io/gamepad/
[GENERIC-SENSOR]
Rick Waldron. Generic Sensor API. URL: https://w3c.github.io/sensors/
[GEOLOCATION]
Marcos Caceres; Reilly Grant. Geolocation API. URL: https://w3c.github.io/geolocation-api/
[HR-TIME-3]
Yoav Weiss. High Resolution Time. URL: https://w3c.github.io/hr-time/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[IDLE-DETECTION]
Reilly Grant. Idle Detection API. CG-DRAFT. URL: https://wicg.github.io/idle-detection/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[KEYBOARD-LOCK]
Keyboard Lock. cg-draft. URL: https://wicg.github.io/keyboard-lock/
[MEDIACAPTURE-STREAMS]
Cullen Jennings; et al. Media Capture and Streams. URL: https://w3c.github.io/mediacapture-main/
[NAVIGATION-TIMING-2]
Yoav Weiss; Noam Rosenthal. Navigation Timing Level 2. URL: https://w3c.github.io/navigation-timing/
[NOTIFICATIONS]
Anne van Kesteren. Notifications API Standard. Living Standard. URL: https://notifications.spec.whatwg.org/
[PAYMENT-REQUEST-1.1]
Marcos Caceres; Rouslan Solomakhin; Ian Jacobs. Payment Request API 1.1. URL: https://w3c.github.io/payment-request/
[PICTURE-IN-PICTURE]
Francois Beaufort. Picture-in-Picture. URL: https://w3c.github.io/picture-in-picture/
[POINTERLOCK-2]
Navid Zolghadr; Mustaq Ahmed. Pointer Lock 2.0. URL: https://w3c.github.io/pointerlock/
[PRESENTATION-API]
Mark Foltz; Dominik Röttsches. Presentation API. URL: https://w3c.github.io/presentation-api/
[PUSH-API]
Peter Beverloo; Martin Thomson; Marcos Caceres. Push API. URL: https://w3c.github.io/push-api/
[RDF11-MT]
Patrick Hayes; Peter Patel-Schneider. RDF 1.1 Semantics. 25 February 2014. REC. URL: https://www.w3.org/TR/rdf11-mt/
[REFERRER-POLICY]
Jochen Eisinger; Emily Stark. Referrer Policy. URL: https://w3c.github.io/webappsec-referrer-policy/
[RFC8941]
M. Nottingham; P-H. Kamp. Structured Field Values for HTTP. February 2021. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc8941
[SCREEN-CAPTURE]
Jan-Ivar Bruaroey; Elad Alon. Screen Capture. URL: https://w3c.github.io/mediacapture-screen-share/
[SCREEN-ORIENTATION]
Marcos Caceres. Screen Orientation. URL: https://w3c.github.io/screen-orientation/
[SCREEN-WAKE-LOCK]
Kenneth Christiansen; Raphael Kubo da Costa. Screen Wake Lock API. URL: https://w3c.github.io/screen-wake-lock/
[SERIAL]
Web Serial API URL: https://wicg.github.io/serial/
[SERVICE-WORKERS]
Jake Archibald; Marijn Kruisselbrink. Service Workers. URL: https://w3c.github.io/ServiceWorker/
[SPEECH-API]
Web Speech API. cg-draft. URL: https://wicg.github.io/speech-api/
[STORAGE]
Anne van Kesteren. Storage Standard. Living Standard. URL: https://storage.spec.whatwg.org/
[URL]
Anne van Kesteren. URL Standard. Living Standard. URL: https://url.spec.whatwg.org/
[WEB-BLUETOOTH]
Jeffrey Yasskin. Web Bluetooth. URL: https://webbluetoothcg.github.io/web-bluetooth/
[WEB-LOCKS]
Joshua Bell; Kagami Rosylight. Web Locks API. ED. URL: https://w3c.github.io/web-locks/
[WEB-NFC]
Web NFC API. ED. URL: https://w3c.github.io/web-nfc/
[WEB-SHARE]
Matt Giuca; Eric Willigers; Marcos Caceres. Web Share API. URL: https://w3c.github.io/web-share/
[WebCryptoAPI]
Mark Watson. Web Cryptography API. URL: https://w3c.github.io/webcrypto/
[WEBDRIVER-BIDI]
WebDriver BiDi URL: https://w3c.github.io/webdriver-bidi/
[WEBHID]
WebHID API URL: https://wicg.github.io/webhid/
[WEBIDL]
Edgar Chen; Timothy Gu. Web IDL Standard. Living Standard. URL: https://webidl.spec.whatwg.org/
[WEBMIDI]
Chris Wilson; Jussi Kalliokoski. Web MIDI API. URL: https://webaudio.github.io/web-midi-api/
[WEBUSB]
WebUSB API. cg-draft. URL: https://wicg.github.io/webusb/
[WEBXR]
Brandon Jones; Manish Goregaokar; Rik Cabanier. WebXR Device API. URL: https://immersive-web.github.io/webxr/

Informative References

[PAYMENT-REQUEST]
Marcos Caceres; Rouslan Solomakhin; Ian Jacobs. Payment Request API. URL: https://w3c.github.io/payment-request/
[POINTERLOCK]
Vincent Scheib. Pointer Lock. URL: https://w3c.github.io/pointerlock/

IDL Index

partial interface Document {
    readonly attribute boolean prerendering;

    // Under "special event handler IDL attributes that only apply to Document objects"
    attribute EventHandler onprerenderingchange;
};

partial interface PerformanceNavigationTiming {
    readonly attribute DOMHighResTimeStamp activationStart;
};

Issues Index

The concept of a fenced frame navigable is not yet defined but we need to link to it once it exists.