-
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.
Handle iframe with src="about:blank" (#84)
* Write e2e test case for <iframe src="about:blank"> * Fix edge case --------- Co-authored-by: Andrew Hyndman <[email protected]>
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello world!</h1> | ||
|
||
<script> | ||
// <iframe src="/stub.html?delay=500"></iframe> | ||
const iframe = document.createElement('iframe'); | ||
// "src" is technically a required field in HTML iframes. Many libraries work around | ||
// this by specifying the url "about:blank". we should handle this scenario. | ||
iframe.src = 'about:blank'; | ||
|
||
// append iframe after "load" event fires | ||
window.addEventListener('load', () => document.body.appendChild(iframe)); | ||
</script> | ||
</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,20 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
|
||
test.describe('TTVC', () => { | ||
test('an iframe with src="about:blank"', async ({page}) => { | ||
await page.goto(`/test/iframe3?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0].duration).toBeGreaterThanOrEqual(PAGELOAD_DELAY); | ||
expect(entries[0].duration).toBeLessThanOrEqual(PAGELOAD_DELAY + FUDGE); | ||
}); | ||
}); |