-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prerender: Test "throw" restriction APIs using wpt-internal
This CL changes the following prerender browser tests to wpt-internal: - LocalFileSystemAccessError - AsyncClipboardAccessError - PointerLockError It also changes the expected message sent from the prerendering page while testing the PresentationRequest API. Bug: 1158250 Change-Id: Ie60c81fc480be2d62530a6e93309deb86bf22249 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2784538 Commit-Queue: Lingqi Chi <lingqi@chromium.org> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Cr-Commit-Position: refs/heads/master@{#868019}
- Loading branch information
Showing
12 changed files
with
173 additions
and
143 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
20 changes: 0 additions & 20 deletions
20
content/test/data/prerender/restriction_broadcast_channel.html
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
third_party/blink/web_tests/wpt_internal/prerender/resources/async-clipboard.html
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,23 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
assert_true(document.prerendering); | ||
|
||
async function asyncAccessClipboard(){ | ||
const bc = new BroadcastChannel('prerender-channel'); | ||
|
||
try { | ||
const _ = await navigator.clipboard.writeText(location.href); | ||
bc.postMessage('unexpected success'); | ||
} catch (err){ | ||
bc.postMessage(err.name); | ||
} finally { | ||
bc.close(); | ||
} | ||
} | ||
|
||
asyncAccessClipboard(); | ||
|
||
</script> |
23 changes: 23 additions & 0 deletions
23
third_party/blink/web_tests/wpt_internal/prerender/resources/file-picker.html
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,23 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
assert_true(document.prerendering); | ||
|
||
async function showFilePicker(){ | ||
const bc = new BroadcastChannel('prerender-channel'); | ||
|
||
try { | ||
const _ = await window.showOpenFilePicker() | ||
bc.postMessage('unexpected success'); | ||
} catch (err){ | ||
bc.postMessage(err.name); | ||
} finally { | ||
bc.close(); | ||
} | ||
} | ||
|
||
showFilePicker(); | ||
|
||
</script> |
26 changes: 26 additions & 0 deletions
26
third_party/blink/web_tests/wpt_internal/prerender/resources/pointer-lock.html
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,26 @@ | ||
<!DOCTYPE html> | ||
<canvas id="pcanvas" width="320" height="320"> | ||
This is a canvas. | ||
</canvas> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
assert_true(document.prerendering); | ||
|
||
async function requestPointerLock(){ | ||
const bc = new BroadcastChannel('prerender-channel'); | ||
try { | ||
const canvas = document.getElementById('pcanvas'); | ||
const _ = await canvas.requestPointerLock(); | ||
bc.postMessage('unexpected success'); | ||
} catch (err){ | ||
bc.postMessage(err.name); | ||
} finally { | ||
bc.close(); | ||
} | ||
} | ||
|
||
requestPointerLock(); | ||
|
||
</script> |
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
31 changes: 31 additions & 0 deletions
31
third_party/blink/web_tests/wpt_internal/prerender/restriction-async-clipboard.https.html
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 @@ | ||
<!DOCTYPE html> | ||
<!-- This cannot be upstreamed as a WPT test because the spec (probably) will | ||
require that no error is thrown until activation. --> | ||
<title>Same-origin prerendering cannot access the Async Clipboard API</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
<body> | ||
<script> | ||
|
||
promise_test(async t => { | ||
const bc = new BroadcastChannel('prerender-channel'); | ||
|
||
const gotMessage = new Promise(resolve => { | ||
bc.addEventListener('message', e => { | ||
resolve(e.data); | ||
}, { | ||
once: true | ||
}); | ||
}); | ||
|
||
// Start prerendering a page that attempts to access the clipboard via the | ||
// Async Clipboard API. | ||
startPrerendering(`resources/async-clipboard.html`); | ||
const result = await gotMessage; | ||
assert_equals(result, 'NotAllowedError'); | ||
}, `prerendering pages should not be able to access the clipboard via the ` + | ||
`Async Clipboard API.`); | ||
|
||
</script> | ||
</body> |
30 changes: 30 additions & 0 deletions
30
...ty/blink/web_tests/wpt_internal/prerender/restriction-local-file-system-access.https.html
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,30 @@ | ||
<!DOCTYPE html> | ||
<!-- This cannot be upstreamed as a WPT test because the spec (probably) will | ||
require that no error is thrown until activation. --> | ||
<title>Same-origin prerendering cannot access local file system</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
<body> | ||
<script> | ||
|
||
promise_test(async t => { | ||
const bc = new BroadcastChannel('prerender-channel'); | ||
|
||
const gotMessage = new Promise(resolve => { | ||
bc.addEventListener('message', e => { | ||
resolve(e.data); | ||
}, { | ||
once: true | ||
}); | ||
}); | ||
|
||
// Start prerendering a page that attempts to show a local file picker. | ||
startPrerendering(`resources/file-picker.html`); | ||
const result = await gotMessage; | ||
assert_equals(result, 'SecurityError') | ||
}, `prerendering pages should not be able to access the local file system ` + | ||
`via the File System Access API`); | ||
|
||
</script> | ||
</body> |
29 changes: 29 additions & 0 deletions
29
third_party/blink/web_tests/wpt_internal/prerender/restriction-pointer-lock.html
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,29 @@ | ||
<!DOCTYPE html> | ||
<!-- This cannot be upstreamed as a WPT test because the spec (probably) will | ||
require that no error is thrown until activation. --> | ||
<title>Same-origin prerendering cannot request PointerLock</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/utils.js"></script> | ||
<body> | ||
<script> | ||
|
||
promise_test(async t => { | ||
const bc = new BroadcastChannel('prerender-channel'); | ||
|
||
const gotMessage = new Promise(resolve => { | ||
bc.addEventListener('message', e => { | ||
resolve(e.data); | ||
}, { | ||
once: true | ||
}); | ||
}); | ||
|
||
// Start prerendering a page that attempts to request pointer lock. | ||
startPrerendering(`resources/pointer-lock.html`); | ||
const result = await gotMessage; | ||
assert_equals(result, 'WrongDocumentError'); | ||
}, 'prerendering pages should not be able to request pointer lock'); | ||
|
||
</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