diff --git a/index.bs b/index.bs index f9a8a73..51d0f29 100644 --- a/index.bs +++ b/index.bs @@ -42,6 +42,9 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/ text: resulting URL record urlPrefix: webappapis.html text: script; url: concept-script +spec: page-visibility; urlPrefix: https://w3c.github.io/page-visibility/ + type: dfn + text: hidden; for: Document; url: dfn-hidden spec: geolocation; urlPrefix: https://w3c.github.io/geolocation-api/ type: method; for: Geolocation text: getCurrentPosition(successCallback, errorCallback, options); url: getcurrentposition-method @@ -68,6 +71,24 @@ spec: idle-detection; urlPrefix: https://wicg.github.io/idle-detection/ type: method; for: IdleDetector text: requestPermission(); url: api-idledetector-requestpermission text: start(); url: api-idledetector-start +spec: clipboard-apis; urlPrefix: https://w3c.github.io/clipboard-apis/ + type: method; for: Clipboard + text: read(); url: dom-clipboard-read + text: readText(); url: dom-clipboard-readtext + text: write(); url: dom-clipboard-write + text: writeText(); url: dom-clipboard-writetext +spec: screen-wake-lock; urlPrefix: https://w3c.github.io/screen-wake-lock/ + type: method; for: WakeLock + text: request(); url: the-request-method +spec: web-nfc; urlPrefix: https://w3c.github.io/web-nfc/ + type: method; for: NDEFReader + text: write(); url: dom-ndefreader-write + text: scan(); url: dom-ndefreader-scan +spec: battery; urlPrefix: https://w3c.github.io/battery/ + type: method; for: Navigator + text: getBattery(); url: dom-navigator-getbattery + type: dfn + text: battery promise; url: dfn-battery-promise
 {
@@ -548,7 +569,7 @@ Modify the downloads a hyperlink algorithm to ensure that downl
   1. If [=this=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then return.
 
 
-

Waiting before permissions checks

+

Delaying async API results

Many specifications need to be patched so that, if a given algorithm invoked in a [=prerendering browsing context=], most of its work is deferred until the browsing context is [=prerendering browsing context/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. @@ -627,7 +648,68 @@ TODO: what about the service worker API? Depends on what we're doing for service

The other interesting method, {{IdleDetector/requestPermission()|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. -

Activation-gated APIs

+

Clipboard APIs

+ +
+ Modify the {{Clipboard/write()}} method steps by inserting the following steps after the initial creation of |p|: + + 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then append the following steps to [=this=]'s [=platform object/post-prerendering activation steps list=] and return |p|. +
+ +
+ Modify the {{Clipboard/writeText()}} method steps by inserting the following steps after the initial creation of |p|: + + 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then append the following steps to [=this=]'s [=platform object/post-prerendering activation steps list=] and return |p|. +
+ +

Screen Wake Lock API

+ +
+ Modify the {{WakeLock/request()}} method steps by inserting the following steps after the mid-algorithm creation of |promise|: + + 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then append the following steps to [=this=]'s [=platform object/post-prerendering activation steps list=] and return |promise|. +
+ +

Prerendered documents do not count as [=Document/hidden=], so the part of the method steps which throw an exception in that case will not trigger.

+ +

Generic Sensor API

+ +
+ Modify the {{Sensor/start()}} method steps by inserting the following steps after the state is set to "`activating`": + + 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then append the following steps to [=this=]'s [=platform object/post-prerendering activation steps list=] and return. + 1. If [=this=].{{Sensor/[[state]]}} is "`idle`", then return. + +

This ensures that if this portion of the algorithm was delayed due to prerendering, and in the meantime {{Sensor/stop()}} was called, we do nothing upon activating the prerender. + + 1. Assert: [=this=].{{Sensor/[[state]]}} is "`activating`". +

+ +

Web NFC

+ +
+ Modify the {{NDEFReader/write()}} method steps by inserting the following steps after the initial creation of |p|: + + 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then append the following steps to [=this=]'s [=platform object/post-prerendering activation steps list=] and return |p|. +
+ +
+ Modify the {{NDEFReader/scan()}} method steps by inserting the following steps after the initial creation of |p|: + + 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then append the following steps to [=this=]'s [=platform object/post-prerendering activation steps list=] and return |p|. +
+ +

Battery Status API

+ +
+ First, we need w3c/battery#30 to be merged, so that the [=battery promise=] is never null. + + Once that's done, modify the {{Navigator/getBattery()}} method steps by prepending the following step: + + 1. If [=this=]'s [=relevant global object=]'s [=Window/browsing context=] is a [=prerendering browsing context=], then append the following steps to [=this=]'s [=platform object/post-prerendering activation steps list=] and return [=this=]'s [=battery promise=]. +
+ +

Activation-gated APIs

The following APIs do not need modifications, because they will automatically fail or no-op without [=transient activation=] or [=sticky activation=], which a [=prerendering browsing context=]'s [=browsing context/active window=] will never have. We list them here for completeness, to show which API surfaces we've audited. @@ -638,6 +720,8 @@ The following APIs do not need modifications, because they will automatically fa - {{PresentationRequest/start()|presentationRequest.start()}} [[PRESENTATION-API]] - {{Window/showOpenFilePicker()}}, {{Window/showSaveFilePicker()}}, and {{Window/showDirectoryPicker()}} [[FILE-SYSTEM-ACCESS]] - {{IdleDetector/requestPermission()|IdleDetector.requestPermission()}} [[IDLE-DETECTION]] +- Firing of clipboard events, as well as {{Clipboard/read()|navigator.clipboard.read()}} and {{Clipboard/readText()|navigator.clipboard.readText()}} [[CLIPBOARD-APIS]] +- {{Navigator/share()|navigator.share()}} [[WEB-SHARE]]

TODO