Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Aug 21, 2024
1 parent 8a4f2e2 commit 5d04e65
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 60 deletions.
52 changes: 26 additions & 26 deletions digital-credentials/allow-attribute.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,66 @@
{
policy: null,
crossOrigin: false,
isAllowed: true,
expectIsAllowed: true,
},
{
policy: null,
crossOrigin: true,
isAllowed: false,
expectIsAllowed: false,
},
{
policy: "digital-credentials-get",
crossOrigin: false,
isAllowed: true,
expectIsAllowed: true,
},
{
policy: "digital-credentials-get",
crossOrigin: true,
isAllowed: true,
},
{
policy: "digital-credentials-get *",
crossOrigin: true,
isAllowed: true,
expectIsAllowed: true,
},
{
policy: "digital-credentials-get *",
crossOrigin: false,
isAllowed: true,
expectIsAllowed: true,
},
{
policy: "digital-credentials-get 'none'",
policy: "digital-credentials-get *",
crossOrigin: true,
isAllowed: false,
expectIsAllowed: true,
},
{
policy: "digital-credentials-get 'none'",
crossOrigin: false,
isAllowed: false,
expectIsAllowed: false,
},
{
policy: "digital-credentials-get 'self'",
policy: "digital-credentials-get 'none'",
crossOrigin: true,
isAllowed: false,
expectIsAllowed: false,
},
{
policy: "digital-credentials-get 'self'",
crossOrigin: false,
isAllowed: true,
expectIsAllowed: true,
},
{
policy: `digital-credentials-get ${hostInfo.HTTPS_REMOTE_ORIGIN}`,
policy: "digital-credentials-get 'self'",
crossOrigin: true,
isAllowed: true,
expectIsAllowed: false,
},
{
policy: `digital-credentials-get ${hostInfo.HTTPS_REMOTE_ORIGIN}`,
crossOrigin: false,
isAllowed: false,
expectIsAllowed: false,
},
{
policy: `digital-credentials-get ${hostInfo.HTTPS_REMOTE_ORIGIN}`,
crossOrigin: true,
expectIsAllowed: true,
},
];

async function loadIframe({ policy, crossOrigin, isAllowed }) {
async function loadIframe({ policy, crossOrigin, expectIsAllowed }) {
const iframe = document.createElement("iframe");
if (policy !== null) {
iframe.allow = policy;
Expand All @@ -87,7 +87,7 @@
? hostInfo.HTTPS_REMOTE_ORIGIN
: location.origin
).href;
iframe.dataset.isAllowed = isAllowed;
iframe.dataset.expectIsAllowed = expectIsAllowed;
document.body.appendChild(iframe);
});
iframe.focus();
Expand All @@ -98,7 +98,7 @@
for (const details of iframeDetails) {
promise_test(async (test) => {
const iframe = await loadIframe(details);
const { isAllowed } = details;
const { expectIsAllowed } = details;
const action = "get";
const options = {
digital: {
Expand All @@ -115,14 +115,14 @@
"*"
);
});
const { name, messsage } = data;
const { name, message } = data;
assert_equals(
name,
isAllowed ? "TypeError" : "NotAllowedError",
`${iframe.outerHTML} - ${messsage}`
expectIsAllowed ? "TypeError" : "NotAllowedError",
`${iframe.outerHTML} - ${message}`
);
iframe.remove();
}, `Policy to use: ${details.policy}, is cross-origin: ${details.crossOrigin}, is allowed by policy: ${details.isAllowed}`);
}, `Policy to use: ${details.policy}, is cross-origin: ${details.crossOrigin}, is allowed by policy: ${details.expectIsAllowed}`);
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const cross_origin_src = new URL(same_origin_src, HTTPS_REMOTE_ORIGIN).href;

promise_test(async (test) => {
await test_driver.bless("use activation");
await test_driver.bless("user activation");
await promise_rejects_js(
test,
TypeError,
Expand Down
33 changes: 0 additions & 33 deletions digital-credentials/get-user-activation.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<<<<<<< HEAD
<script src="support/helper.js" type="module"></script>
<body></body>
<script type="module">
Expand Down Expand Up @@ -36,36 +35,4 @@
"User activation should be consumed after navigator.identity.get()."
);
}, "navigator.identity.get() consumes user activation.");
=======
<body></body>
<script>
promise_test(async (t) => {
assert_false(
navigator.userActivation.isActive,
"User activation should not be active"
);
await promise_rejects_dom(
t,
"NotAllowedError",
navigator.identity.get({ digital: { providers: [] } })
);
}, "navigator.identity.get() calling the API without user activation should reject with NotAllowedError.");

promise_test(async (t) => {
await test_driver.bless();
assert_true(
navigator.userActivation.isActive,
"User activation should be active after test_driver.bless()."
);
await promise_rejects_js(
t,
TypeError,
navigator.identity.get({ digital: { providers: [] } })
);
assert_false(
navigator.userActivation.isActive,
"User activation should be consumed after navigator.identity.get()."
);
}, "navigator.identity.get() consumes user activation.");
>>>>>>> 39c10d1993 (Digital Credentials: digital-credentials-get Permissions Policy tests)
</script>

0 comments on commit 5d04e65

Please sign in to comment.