Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions digital-credentials/allow-attribute-with-create.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
<script type="module">
import { makeCreateOptions } from "./support/helper.js";

const hostInfo = get_host_info();
const iframeDetails = [
{
Expand Down Expand Up @@ -100,14 +102,13 @@
for (const details of iframeDetails) {
promise_test(async (test) => {
const iframe = await loadIframe(details);
test.add_cleanup(() => {
document.body.removeChild(iframe);
});
const { expectIsAllowed } = details;
const action = "create";
const options = {
digital: {
// Results in TypeError when allowed, NotAllowedError when disallowed
requests: [],
},
};
// Results in TypeError when allowed, NotAllowedError when disallowed
const options = makeCreateOptions({ protocol: [] });
const { data } = await new Promise((resolve) => {
const callback = (e) => {
if (e.source === iframe.contentWindow) {
Expand All @@ -131,11 +132,11 @@
} else {
assert_equals(name, "NotAllowedError", fullMessage);
}
iframe.remove();
}, `With Create: Policy to use: ${details.policy}, is cross-origin: ${details.crossOrigin}, is allowed by policy: ${details.expectIsAllowed}`);
}
}
window.onload = runTests;
</script>
</head>
<body onload="runTests()"></body>
<body></body>
</html>
22 changes: 12 additions & 10 deletions digital-credentials/allow-attribute-with-get.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
<script type="module">
import { makeGetOptions } from "./support/helper.js";

const hostInfo = get_host_info();
const iframeDetails = [
{
Expand Down Expand Up @@ -90,6 +92,8 @@
: location.origin
).href;
iframe.dataset.expectIsAllowed = expectIsAllowed;
iframe.width = "400";
iframe.height = "200";
document.body.appendChild(iframe);
});
iframe.focus();
Expand All @@ -100,15 +104,12 @@
for (const details of iframeDetails) {
promise_test(async (test) => {
const iframe = await loadIframe(details);
test.add_cleanup(() => {
document.body.removeChild(iframe);
});
const { expectIsAllowed } = details;
const action = "get";
const options = {
digital: {
// Results in TypeError when allowed (since the requests list is empty),
// NotAllowedError when disallowed
requests: [],
},
};
const options = makeGetOptions({ protocol: [] });
await test_driver.bless("User activation");
const { data } = await new Promise((resolve) => {
const callback = (e) => {
Expand All @@ -133,11 +134,12 @@
// When the call is disallowed, it MUST result in a NotAllowedError.
assert_equals(name, "NotAllowedError", fullMessage);
}
iframe.remove();

}, `With Get: Policy to use: ${details.policy}, is cross-origin: ${details.crossOrigin}, is allowed by policy: ${details.expectIsAllowed}`);
}
}
window.onload = runTests;
</script>
</head>
<body onload="runTests()"></body>
<body></body>
</html>
5 changes: 2 additions & 3 deletions digital-credentials/create.tentative.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<script src="/resources/testdriver-vendor.js"></script>

<body>
<iframe id="same-origin"></iframe>
<iframe id="cross-origin" allow="digital-credentials-create"></iframe>
<iframe id="same-origin"></iframe>
</body>

<script type="module">
Expand Down Expand Up @@ -236,8 +236,7 @@
];

for (const badValue of throwingValues) {
const options = makeCreateOptions();
options.digital.requests[0].data = badValue;
const options = makeCreateOptions({ data: badValue });

await promise_rejects_js(
t,
Expand Down
30 changes: 26 additions & 4 deletions digital-credentials/dc-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@ export interface MobileDocumentRequest {
*/
export interface MakeGetOptionsConfig {
/**
* Protocol(s) to use for the request
* Protocol(s) to use for the request.
* Can be a single protocol, array of protocols, or empty array.
* If not provided, uses the default supported protocol.
*/
protocol?: GetProtocol | GetProtocol[];
/**
* Explicit credential requests.
* When provided, these are used in addition to any protocol-based requests.
*/
requests?: DigitalCredentialGetRequest[];
/**
* Optional data to override canonical data for protocol-based requests.
*/
data?: MobileDocumentRequest | object;
/**
* Credential mediation requirement
*/
Expand All @@ -51,9 +62,20 @@ export interface MakeGetOptionsConfig {
*/
export interface MakeCreateOptionsConfig {
/**
* Protocol(s) to use for the request
* Protocol(s) to use for the request.
* Can be a single protocol, array of protocols, or empty array.
* If not provided, uses the default supported protocol.
*/
protocol?: CreateProtocol | CreateProtocol[];
/**
* Explicit credential requests.
* When provided, these are used in addition to any protocol-based requests.
*/
requests?: DigitalCredentialCreateRequest[];
/**
* Optional data to override canonical data for protocol-based requests.
*/
data?: object;
/**
* Credential mediation requirement
*/
Expand Down Expand Up @@ -87,7 +109,7 @@ export interface DigitalCredentialRequestOptions {
*/
export interface CredentialRequestOptions {
digital: DigitalCredentialRequestOptions;
mediation: CredentialMediationRequirement;
mediation?: CredentialMediationRequirement;
signal?: AbortSignal;
}

Expand All @@ -114,7 +136,7 @@ export interface DigitalCredentialCreationOptions {
*/
export interface CredentialCreationOptions {
digital: DigitalCredentialCreationOptions;
mediation: CredentialMediationRequirement;
mediation?: CredentialMediationRequirement;
signal?: AbortSignal;
}

Expand Down
17 changes: 4 additions & 13 deletions digital-credentials/get.tentative.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<script src="/resources/testdriver-vendor.js"></script>

<body>
<iframe id="same-origin"></iframe>
<iframe id="cross-origin" allow="digital-credentials-get"></iframe>
<iframe id="same-origin"></iframe>
</body>
<script type="module">
import { makeGetOptions, sendMessage, loadIframe } from "./support/helper.js";
Expand All @@ -31,16 +31,8 @@
promise_test(async (t) => {
const invalidData = [null, undefined, "", 123, true, false];
for (const data of invalidData) {
const options = {
digital: {
requests: [
{
data,
protocol: "openid4vp-v1-unsigned",
},
],
},
};
const options = makeGetOptions({ data });
await test_driver.bless("user activation");
await promise_rejects_js(
t,
TypeError,
Expand Down Expand Up @@ -253,8 +245,7 @@
];

for (const badValue of throwingValues) {
const options = makeGetOptions();
options.digital.requests[0].data = badValue;
const options = makeGetOptions({ data: badValue });

await promise_rejects_js(
t,
Expand Down
2 changes: 1 addition & 1 deletion digital-credentials/non-fully-active.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
let iframe = await createIframe();
const DOMExceptionCtor = iframe.contentWindow.DOMException;
let stolenNavigator = iframe.contentWindow.navigator;
const request = makeGetOptions({ protocol: "openid4vp-v1-unsigned" });
const request = makeGetOptions();
await test_driver.bless("User activation", null, iframe.contentWindow);
await iframe.focus();
const p = promise_rejects_dom(
Expand Down
Loading
Loading