<!DOCTYPE html>
<meta charset="utf-8">
<title>Tests the prototype Private Token API's functionality through its XHR interface.</title>
<link rel="help" href="https://github.com/WICG/trust-token-api#trust-token-redemption" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';
async_test((t) => {
let request = new XMLHttpRequest();
request.open('GET', 'https://trusttoken.test');
request.setPrivateToken({
version: 1,
operation: 'token-request'
});
request.onerror = t.step_func(e => {
assert_equals(request.status, 0, "Expected HTTP status code 0 for network errors");
if (window.testRunner)
window.testRunner.clearTrustTokenState(t.step_func_done(() => {}));
});
request.send();
}, 'No keys for the issuer -> expect issuance to fail');
async_test((t) => {
let request = new XMLHttpRequest();
request.open('GET', 'https://trusttoken.test');
request.setPrivateToken({
version: 1,
operation: 'token-redemption'
});
request.onerror = t.step_func(() => {
assert_equals(request.status, 0, "Expected HTTP status code 0 for network errors");
if (window.testRunner)
window.testRunner.clearTrustTokenState(t.step_func_done(() => {}));
});
request.send();
}, 'No keys for the issuer -> expect redemption to fail');
</script>