-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bfcache] Add notRestoredReasons field in PerformanceNavigationTiming
This CL adds back/forward cache not restored reasons in Performance NavigationTiming API. It's proposed here: w3c/navigation-timing#171 Explainer: https://github.com/rubberyuzu/bfcache-not-retored-reason/blob/main/NotRestoredReason.md This CL... (main) - exposes not restored reasons to PerformanceNavigationTiming API - adds WPT (sub/refactor) - removes a flag from blink/common and adds one in RuntimeEnabled - changes blocklisted features' report string to be short - changes BackForwardCacheMetrics::UpdateNotRestoredReasonsForNavigation to be in SendCommitNavigation instead of DidCommitNavigation, so that at the time of sending the reasons it will be a complete list. Bug: 1349228 Change-Id: I8dd96a60188bdff94a21c4e4e34cacf181a823db
- Loading branch information
1 parent
d7111ad
commit 2d25341
Showing
6 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
performance-timeline/performance-navigation-timing-bfcache-reasons-stay.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// META: title=RemoteContextHelper navigation using BFCache | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/get-host-info.sub.js | ||
// META: script=/common/utils.js | ||
// META: script=/resources/testharness.js | ||
// META: script=/resources/testharnessreport.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js | ||
|
||
'use strict'; | ||
|
||
// Ensure that notRestoredReasons are only updated after non BFCache navigation. | ||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
// Open a window with noopener so that BFCache will work. | ||
const rc1 = await rcHelper.addWindow( | ||
/*config=*/ null, /*options=*/ {features: 'noopener'}); | ||
await rc1.executeScript(() => { | ||
window.bc = new BroadcastChannel('foo'); | ||
}); | ||
const rc1_url = await rc1.executeScript(() => { | ||
return location.href; | ||
}); | ||
|
||
// Navigate away. | ||
const rc2 = await rc1.navigateToNew(); | ||
|
||
// Navigate back. | ||
await rc2.historyBack(); | ||
// Check the reported reasons. | ||
await assertNotRestoredReasonsEquals( | ||
rc1, | ||
/*blocked=*/true, | ||
/*url=*/rc1_url, | ||
/*src=*/ "", | ||
/*id=*/"", | ||
/*name=*/"", | ||
/*reasons=*/["BroadcastChannel"], | ||
/*children=*/[]); | ||
|
||
await rc1.historyForward(); | ||
await rc2.historyBack(); | ||
// This time no blocking feature is used, so the page is restored | ||
// from BFCache. Ensure that the previous reasons stay there. | ||
await assertNotRestoredReasonsEquals( | ||
rc1, | ||
/*blocked=*/true, | ||
/*url=*/rc1_url, | ||
/*src=*/ "", | ||
/*id=*/"", | ||
/*name=*/"", | ||
/*reasons=*/["BroadcastChannel"], | ||
/*children=*/[]); | ||
}); |
31 changes: 31 additions & 0 deletions
31
performance-timeline/performance-navigation-timing-bfcache.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// META: title=RemoteContextHelper navigation using BFCache | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/get-host-info.sub.js | ||
// META: script=/common/utils.js | ||
// META: script=/resources/testharness.js | ||
// META: script=/resources/testharnessreport.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js | ||
|
||
'use strict'; | ||
|
||
// Ensure that notRestoredReasons is empty for successful BFCache restore. | ||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
|
||
// Open a window with noopener so that BFCache will work. | ||
const rc1 = await rcHelper.addWindow( | ||
/*config=*/ null, /*options=*/ {features: 'noopener'}); | ||
|
||
// Navigate away. | ||
const rc2 = await rc1.navigateToNew(); | ||
|
||
// Navigate back. | ||
await rc2.historyBack(); | ||
|
||
// Verify that no reasons are recorded for successful restore. | ||
assert_true(await rc1.executeScript(() => { | ||
let reasons = performance.getEntriesByType('navigation')[0].notRestoredReasons; | ||
return reasons == null; | ||
})); | ||
}); |
66 changes: 66 additions & 0 deletions
66
performance-timeline/performance-navigation-timing-cross-origin-bfcache.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// META: title=RemoteContextHelper navigation using BFCache | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/get-host-info.sub.js | ||
// META: script=/common/utils.js | ||
// META: script=/resources/testharness.js | ||
// META: script=/resources/testharnessreport.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js | ||
|
||
'use strict'; | ||
|
||
// Ensure that cross-origin subtree's reasons are not exposed to notRestoredReasons. | ||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
// Open a window with noopener so that BFCache will work. | ||
const rc1 = await rcHelper.addWindow( | ||
/*config=*/ null, /*options=*/ {features: 'noopener'}); | ||
const rc1_url = await rc1.executeScript(() => { | ||
return location.href; | ||
}); | ||
// Add a cross-origin iframe and use BroadcastChannel. | ||
const rc1_child = await rc1.addIframe( | ||
/*extraConfig=*/ { | ||
origin: 'HTTP_REMOTE_ORIGIN', | ||
scripts: [], | ||
headers: [], | ||
}, | ||
/*attributes=*/ {id: 'test-id'}, | ||
); | ||
await rc1_child.executeScript(() => { | ||
window.bc = new BroadcastChannel('foo'); | ||
}); | ||
const rc1_child_url = await rc1_child.executeScript(() => { | ||
return location.href; | ||
}); | ||
// Add a child to the iframe. | ||
const rc1_grand_child = await rc1_child.addIframe(); | ||
const rc1_grand_child_url = await rc1_grand_child.executeScript(() => { | ||
return location.href; | ||
}); | ||
|
||
// Navigate away. | ||
const rc2 = await rc1.navigateToNew(); | ||
|
||
// Navigate back. | ||
await rc2.historyBack(); | ||
|
||
// Check the reported reasons. | ||
await assertNotRestoredReasonsEquals( | ||
rc1, | ||
/*blocked=*/false, | ||
/*url=*/rc1_url, | ||
/*src=*/ "", | ||
/*id=*/"", | ||
/*name=*/"", | ||
/*reasons=*/[], | ||
/*children=*/[{ | ||
"blocked": true, | ||
"url": "", | ||
"src": "", | ||
"id": "", | ||
"name": "", | ||
"reasons": [], | ||
"children": [] | ||
}]); | ||
}); |
41 changes: 41 additions & 0 deletions
41
performance-timeline/performance-navigation-timing-not-bfcached.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// META: title=RemoteContextHelper navigation using BFCache | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/get-host-info.sub.js | ||
// META: script=/common/utils.js | ||
// META: script=/resources/testharness.js | ||
// META: script=/resources/testharnessreport.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js | ||
|
||
'use strict'; | ||
|
||
// Ensure that notRestoredReasons is populated when not restored. | ||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
// Open a window with noopener so that BFCache will work. | ||
const rc1 = await rcHelper.addWindow( | ||
/*config=*/ null, /*options=*/ {features: 'noopener'}); | ||
await rc1.executeScript(() => { | ||
window.bc = new BroadcastChannel('foo'); | ||
}); | ||
|
||
const rc1_url = await rc1.executeScript(() => { | ||
return location.href; | ||
}); | ||
|
||
// Navigate away. | ||
const rc2 = await rc1.navigateToNew(); | ||
|
||
// Navigate back. | ||
await rc2.historyBack(); | ||
// Check the reported reasons. | ||
await assertNotRestoredReasonsEquals( | ||
rc1, | ||
/*blocked=*/true, | ||
/*url=*/rc1_url, | ||
/*src=*/ "", | ||
/*id=*/"", | ||
/*name=*/"", | ||
/*reasons=*/["BroadcastChannel"], | ||
/*children=*/[]); | ||
}); |
69 changes: 69 additions & 0 deletions
69
performance-timeline/performance-navigation-timing-same-origin-bfcache.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// META: title=RemoteContextHelper navigation using BFCache | ||
// META: script=/common/dispatcher/dispatcher.js | ||
// META: script=/common/get-host-info.sub.js | ||
// META: script=/common/utils.js | ||
// META: script=/resources/testharness.js | ||
// META: script=/resources/testharnessreport.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js | ||
// META: script=/html/browsers/browsing-the-web/remote-context-helper-tests/resources/test-helper.js | ||
|
||
'use strict'; | ||
|
||
// Ensure that same-origin subtree's reasons are exposed to notRestoredReasons. | ||
promise_test(async t => { | ||
const rcHelper = new RemoteContextHelper(); | ||
// Open a window with noopener so that BFCache will work. | ||
const rc1 = await rcHelper.addWindow( | ||
/*config=*/ null, /*options=*/ {features: 'noopener'}); | ||
const rc1_url = await rc1.executeScript(() => { | ||
return location.href; | ||
}); | ||
// Add a same-origin iframe and use BroadcastChannel. | ||
const rc1_child = await rc1.addIframe(/*extra_config=*/{}, /*attributes=*/ {id: 'test-id'}); | ||
await rc1_child.executeScript(() => { | ||
window.bc = new BroadcastChannel('foo'); | ||
}); | ||
const rc1_child_url = await rc1_child.executeScript(() => { | ||
return location.href; | ||
}); | ||
// Add a child to the iframe. | ||
const rc1_grand_child = await rc1_child.addIframe(); | ||
const rc1_grand_child_url = await rc1_grand_child.executeScript(() => { | ||
return location.href; | ||
}); | ||
|
||
// Navigate away. | ||
const rc2 = await rc1.navigateToNew(); | ||
|
||
// Navigate back. | ||
await rc2.historyBack(); | ||
|
||
// Check the reported reasons. | ||
await assertNotRestoredReasonsEquals( | ||
rc1, | ||
/*blocked=*/false, | ||
/*url=*/rc1_url, | ||
/*src=*/ "", | ||
/*id=*/"", | ||
/*name=*/"", | ||
/*reasons=*/[], | ||
/*children=*/[{ | ||
"blocked": true, | ||
"url": rc1_child_url, | ||
"src": rc1_child_url, | ||
"id": "test-id", | ||
"name": "", | ||
"reasons": ["BroadcastChannel"], | ||
"children": [ | ||
{ | ||
"blocked": false, | ||
"url": rc1_grand_child_url, | ||
"src": rc1_grand_child_url, | ||
"id": "", | ||
"name": "", | ||
"reasons": [], | ||
"children": [] | ||
} | ||
] | ||
}]); | ||
}); |