-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instrument back/forward cache navigations (#70)
* Allow tests to opt out of no-cache headers * Support more than one route HTML file per test * New e2e test case: back/forward cache behaviour * Move pageshow listener into the ttvc library * Capture navigationType for the measurement in question * Extend browser's builtin navigation type * Clarify relationship between navigationType and NavigationTimingType in documentation --------- Co-authored-by: Andrew Hyndman <[email protected]>
- Loading branch information
Showing
7 changed files
with
110 additions
and
7 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
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
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
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,8 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">About</h1> | ||
</body> |
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,8 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello world!</h1> | ||
</body> |
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 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 1000; | ||
|
||
test.describe('TTVC', () => { | ||
test('a static HTML document', async ({page}) => { | ||
await page.goto(`/test/bfcache?delay=${PAGELOAD_DELAY}&cache=true`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
let entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0].duration).toBeGreaterThanOrEqual(PAGELOAD_DELAY); | ||
expect(entries[0].duration).toBeLessThanOrEqual(PAGELOAD_DELAY + FUDGE); | ||
expect(entries[0].detail.navigationType).toBe('navigate'); | ||
|
||
await page.goto(`/test/bfcache/about?delay=${PAGELOAD_DELAY}&cache=true`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0].duration).toBeGreaterThanOrEqual(PAGELOAD_DELAY); | ||
expect(entries[0].duration).toBeLessThanOrEqual(PAGELOAD_DELAY + FUDGE); | ||
expect(entries[0].detail.navigationType).toBe('navigate'); | ||
|
||
await page.goBack({waitUntil: 'networkidle'}); | ||
|
||
entries = await getEntries(page); | ||
|
||
// note: webkit clears previous values from this list on page restore | ||
expect(entries[entries.length - 1].duration).toBeGreaterThanOrEqual(0); | ||
expect(entries[entries.length - 1].duration).toBeLessThanOrEqual(FUDGE); | ||
expect(entries[entries.length - 1].detail.navigationType).toBe('back_forward'); | ||
}); | ||
}); |
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