Skip to content

Commit 7c0332b

Browse files
committed
Make "no-referrer" censor cross-document AppHistoryEntry URLs
Also be clear that, despite the shaky spec foundations, the intent after this fix is to expose session history entries across browsing context group swaps. Closes #71.
1 parent e8060a6 commit 7c0332b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

app_history.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ interface AppHistoryEntryEventMap {
5959
declare class AppHistoryEntry extends EventTarget {
6060
readonly key: string;
6161
readonly id: string;
62-
readonly url: string;
62+
readonly url: string|null;
6363
readonly index: number;
6464
readonly sameDocument: boolean;
6565

spec.bs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
3535
text: current entry; url: history.html#current-entry
3636
for: session history entry
3737
text: document; url: history.html#she-document
38+
text: policy container; url: history.html#she-policy-container
3839
text: URL; url: history.html#she-url
3940
for: history handling behavior
4041
text: default; url: browsing-the-web.html#hh-default
@@ -49,6 +50,8 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
4950
text: discard; url: window-object.html#a-browsing-context-is-discarded
5051
type: method
5152
for: Document; text: open(unused1, unused2); url: multipage/dynamic-markup-insertion.html#dom-document-open
53+
type: http-header
54+
text: Cross-Origin-Opener-Policy; url: multipage/iana.html#cross-origin-opener-policy-2
5255
spec: html; urlPrefix: https://whatpr.org/html/6315/
5356
type: dfn
5457
text: traversable navigable; for: navigable; url: history.html#nav-traversable
@@ -220,6 +223,12 @@ Each {{AppHistory}} object has an associated <dfn for="AppHistory">current index
220223

221224
1. Let |sessionHistory| be |appHistory|'s [=relevant global object=]'s [=Window/browsing context=]'s [=session history=].
222225

226+
<div class="note">
227+
<p>It is expected that this include session history entries in the entire [=browsing session=], including those in different <a spec="HTML">browsing context groups</a> due to \`<a http-header>`Cross-Origin-Opener-Policy`</a>\`-induced switches. This will be better-defined when <a href="https://github.com/whatwg/html/pull/6315">whatwg/html#6315</a> is finalized; see also <a href="https://github.com/whatwg/html/issues/6356">whatwg/html#6356</a> for some discussion of the impact of manual navigation on this "session" concept.
228+
229+
<p>Note that it is OK to expose the data in these entries to the current page through {{AppHistoryEntry}} instances, since any [=session history entry/app history state=] will have been put there affirmatively, and the [=session history entry/URL=] is hidden appropriately by the {{AppHistoryEntry/url|url}} getter when the [=session history entry/document=] indicates that its URL is sensitive through the <a>"`no-referrer`"</a> [=referrer policy=].
230+
</div>
231+
223232
1. Let |appHistorySHEs| be a new empty list.
224233

225234
1. Let |oldCurrentAHE| be the [=AppHistory/current entry=] of |appHistory|.
@@ -1343,7 +1352,7 @@ The <dfn attribute for="AppHistoryDestination">sameDocument</dfn> getter steps a
13431352
<xmp class="idl">
13441353
[Exposed=Window]
13451354
interface AppHistoryEntry : EventTarget {
1346-
readonly attribute USVString url;
1355+
readonly attribute USVString? url;
13471356
readonly attribute DOMString key;
13481357
readonly attribute DOMString id;
13491358
readonly attribute long long index;
@@ -1362,6 +1371,8 @@ interface AppHistoryEntry : EventTarget {
13621371
<dt><code><var ignore>entry</var>.{{AppHistoryEntry/url}}</code>
13631372
<dd>
13641373
<p>The URL of this app history entry.
1374+
1375+
<p>This can return null if the entry corresponds to a different {{Document}} than the current one (i.e. if {{AppHistoryEntry/sameDocument}} is false), and that {{Document}}'s [=policy container/referrer policy=] is <a>"`no-referrer`"</a>, since that indicates the {{Document}} in question is hiding its URL even from other same-origin pages.
13651376
</dd>
13661377

13671378
<dt><code><var ignore>entry</var>.{{AppHistoryEntry/key}}</code>
@@ -1419,7 +1430,9 @@ Each {{AppHistoryEntry}} has an associated <dfn for="AppHistoryEntry">index</dfn
14191430
<div algorithm>
14201431
The <dfn attribute for="AppHistoryEntry">url</dfn> getter steps are:
14211432

1422-
1. If [=this=]'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return the empty string.
1433+
1. If [=this=]'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully active=], then return null.
1434+
1. Let |she| be [=this=]'s [=AppHistoryEntry/session history entry=].
1435+
1. If |she|'s [=session history entry/document=] does not equal [=this=]'s [=relevant global object=]'s [=associated Document=], and |she|'s [=session history entry/policy container=]'s [=policy container/referrer policy=] is <a>"`no-referrer`"</a>, then return null.
14231436
1. Return [=this=]'s [=AppHistoryEntry/session history entry=]'s [=session history entry/URL=], [=URL serializer|serialized=].
14241437
</div>
14251438

0 commit comments

Comments
 (0)