Bug 1819677 [wpt PR 38775] - [rsafor] Correct activation check in WPT, a=testonly

Automatic update from web-platform-tests
[rsafor] Correct activation check in WPT

Passing is blocked on the outcome of crrev.com/c/4289832

Bug: 1414468
Change-Id: I989af6f11cbfd1e2fb9b3f9644f6041825dd9e2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4300150
Reviewed-by: Chris Fredrickson <cfredric@chromium.org>
Commit-Queue: Matt Reichhoff <mreichhoff@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1111761}

--

wpt-commits: 04b986a61c42a98619998e6efcb2e2f1f2f82239
wpt-pr: 38775
This commit is contained in:
Matt Reichhoff 2023-03-06 13:57:43 +00:00 committed by moz-wptsync-bot
parent 540a98d380
commit 354b975444

View File

@ -28,6 +28,8 @@ queryParams.forEach((param) => {
}
});
const requestedOrigin = 'https://foo.com';
// TODO(crbug.com/1351540): when/if requestStorageAccessForOrigin is standardized,
// upstream with the Storage Access API helpers file.
function RunRequestStorageAccessForOriginInDetachedFrame(site) {
@ -52,6 +54,12 @@ test(
'[' + testPrefix +
'] document.requestStorageAccessForOrigin() should be supported on the document interface');
// Promise tests should all start with the feature in "prompt" state.
promise_setup(async () => {
await test_driver.set_permission(
{ name: 'top-level-storage-access', requestedOrigin }, 'prompt');
});
promise_test(
t => {
return promise_rejects_js(t, TypeError,
@ -65,7 +73,7 @@ if (topLevelDocument) {
promise_test(
t => {
return promise_rejects_dom(t, 'NotAllowedError',
document.requestStorageAccessForOrigin('https://test.com'),
document.requestStorageAccessForOrigin(requestedOrigin),
'document.requestStorageAccessForOrigin() call without user gesture');
},
'[' + testPrefix +
@ -75,7 +83,7 @@ if (topLevelDocument) {
const description =
'document.requestStorageAccessForOrigin() call in a detached frame';
// Can't use promise_rejects_dom here because the exception is from the wrong global.
return RunRequestStorageAccessForOriginInDetachedFrame('https://foo.com')
return RunRequestStorageAccessForOriginInDetachedFrame(requestedOrigin)
.then(t.unreached_func('Should have rejected: ' + description))
.catch((e) => {
assert_equals(e.name, 'InvalidStateError', description);
@ -85,13 +93,23 @@ if (topLevelDocument) {
promise_test(async t => {
const description =
'document.requestStorageAccessForOrigin() in a detached DOMParser result';
return RunRequestStorageAccessForOriginViaDomParser('https://foo.com')
return RunRequestStorageAccessForOriginViaDomParser(requestedOrigin)
.then(t.unreached_func('Should have rejected: ' + description))
.catch((e) => {
assert_equals(e.name, 'InvalidStateError', description);
});
}, '[non-fully-active] document.requestStorageAccessForOrigin() should not resolve when run in a detached DOMParser document');
promise_test(
async t => {
await test_driver.set_permission(
{ name: 'top-level-storage-access', requestedOrigin }, 'granted');
await document.requestStorageAccessForOrigin(requestedOrigin);
},
'[' + testPrefix +
'] document.requestStorageAccessForOrigin() should be resolved without a user gesture with an existing permission');
// Create a test with a single-child same-origin iframe.
// This will validate that calls to requestStorageAccessForOrigin are rejected
// in non-top-level contexts.
@ -124,18 +142,6 @@ if (topLevelDocument) {
'[' + testPrefix +
'] document.requestStorageAccessForOrigin() should be rejected when called with an opaque origin');
promise_test(
async t => {
await test_driver.set_permission(
{ name: 'top-level-storage-access', requestedOrigin: 'https://foo.com' }, 'granted');
await RunCallbackWithGesture(
() => document.requestStorageAccessForOrigin('https://foo.com'));
},
'[' + testPrefix +
'] document.requestStorageAccessForOrigin() should be resolved when called properly with a user gesture');
} else {
promise_test(
async t => {