From f6742e1fa2dca0677052c61572c386c9f401c705 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 14 Apr 2025 17:04:07 +0100 Subject: [PATCH 01/12] fetchLater corrections and updates --- .../web/api/deferredrequestinit/index.md | 15 +++------ .../fetchlater_api/fetchlater_quotas/index.md | 32 ++++++++++++++++--- .../en-us/web/api/window/fetchlater/index.md | 30 ++++++----------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/files/en-us/web/api/deferredrequestinit/index.md b/files/en-us/web/api/deferredrequestinit/index.md index da81e0bfbfd339d..f4e8075f41d1536 100644 --- a/files/en-us/web/api/deferredrequestinit/index.md +++ b/files/en-us/web/api/deferredrequestinit/index.md @@ -41,16 +41,11 @@ fetchLater("/send_beacon"); In this example we create a {{domxref("Request")}}, and provide an `activateAfter` value to delay sending the request for 60,000 milliseconds (or one minute): ```js -fetchLater( - { - url: "/send_beacon", - method: "POST", - body: getBeaconData(), - }, - { - activateAfter: 60000, // 1 minute - }, -); +fetchLater("/send_beacon", { + method: "POST", + body: getBeaconData(), + activateAfter: 60000, // 1 minute +}); ``` > [!NOTE] diff --git a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md index 5738834b342de56..ac18f51edd25d1e 100644 --- a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md +++ b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md @@ -150,13 +150,27 @@ Assuming a top-level document on `a.com`, which embeds a ` +``` + +This would not be seem as "same-origin" despite being hosted on the same origin as the top-level dcument as it is in it's own sandbox iframe. Therefore, by default, it should be allocated 8KiB quota from the shared 128KiB quota. + +### Disallowing `fetchLater()` from iframes + +You can use the `allow` attribute of ` +``` + +Where `allow="deferred-fetch"` is needed to prevent same-origin iframes using up the 512KiB quota, and `allow="deferred-fetch-minimal"` is needed to prevent cross-origin iframes using up the 128KiB quota, and including both will prevent either being used no matter what the `src`. ### Examples which throw a `QuotaExceededError` @@ -190,6 +204,14 @@ fetchLater("https://b.example.com", { method: "POST", body: a_40kb_body }); fetchLater("https://a.example.com", { method: "POST", body: a_40kb_body }); ``` +### Redirects of subframes back to the top-level origin allow use of the top-level quota + +Assuming a top-level document on `a.com`, which embeds a ` + ``` This would not be seem as "same-origin" despite being hosted on the same origin as the top-level dcument as it is in it's own sandbox iframe. Therefore, by default, it should be allocated 8KiB quota from the shared 128KiB quota. @@ -166,7 +166,7 @@ You can use the `allow` attribute of ` ``` From a38c97a767f0cbd58d13f9ca0e23e2d30b3d6a1f Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Tue, 15 Apr 2025 10:07:16 +0100 Subject: [PATCH 04/12] Update files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md --- files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md index 8afeedc043f4568..d28abdc01f429a8 100644 --- a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md +++ b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md @@ -152,7 +152,7 @@ Assuming a top-level document on `a.com`, which embeds a ` From 38c04d93fcdb84dc4719ea22487faa0e6d3e3e90 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Tue, 15 Apr 2025 10:08:53 +0100 Subject: [PATCH 05/12] Update files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md --- files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md index d28abdc01f429a8..d20aaf0a22b35d0 100644 --- a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md +++ b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md @@ -158,7 +158,7 @@ As an example, if the following ` ``` -This would not be seem as "same-origin" despite being hosted on the same origin as the top-level dcument as it is in it's own sandbox iframe. Therefore, by default, it should be allocated 8KiB quota from the shared 128KiB quota. +This would not be considered "same-origin", despite being hosted on the same origin as the top-level document, as the ` ``` -Where `allow="deferred-fetch"` is needed to prevent same-origin iframes using up the 512KiB quota, and `allow="deferred-fetch-minimal"` is needed to prevent cross-origin iframes using up the 128KiB quota, and including both will prevent either being used no matter what the `src`. +The `allow="deferred-fetch"` directive is needed to prevent same-origin iframes from using up the 512KiB quota, and the `allow="deferred-fetch-minimal"` directive is needed to prevent cross-origin iframes from using up the 128KiB quota. Including both will prevent both from being used, regardless of the `src` value. ### Examples which throw a `QuotaExceededError` From dd829754fcf798afc482709aaa3ec34966fc85b0 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Tue, 15 Apr 2025 15:26:55 +0100 Subject: [PATCH 11/12] Update files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md Co-authored-by: Chris Mills --- files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md index b94241339690bb0..5630a18c3a93787 100644 --- a/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md +++ b/files/en-us/web/api/fetchlater_api/fetchlater_quotas/index.md @@ -210,7 +210,7 @@ Assuming a top-level document at `a.com`, which embeds ` ``` -The `allow="deferred-fetch"` directive is needed to prevent same-origin iframes from using up the 512KiB quota, and the `allow="deferred-fetch-minimal"` directive is needed to prevent cross-origin iframes from using up the 128KiB quota. Including both will prevent both from being used, regardless of the `src` value. +The `allow="deferred-fetch"` directive is needed to prevent same-origin iframes from using up the 512KiB quota, and the `allow="deferred-fetch-minimal"` directive is needed to prevent cross-origin iframes from using up the 128KiB quota. Including both directives will prevent both quotas from being used, regardless of the `src` value. ### Examples which throw a `QuotaExceededError`