Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /attribution-reporting/request-format.sub.https.html?method=a&expected-eligible=navigation-source - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=fetch - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=fetch&eligible={"eventSourceEligible":true,"triggerEligible":false}&expected-eligible=event-source - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=img&eligible&expected-eligible=event-source, trigger - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=img&expected-eligible=event-source, trigger - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=open&expected-eligible=navigation-source - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=script&eligible&expected-eligible=event-source, trigger - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=script&expected-eligible=event-source, trigger - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=xhr - WPT Dashboard Interop Dashboard
- /attribution-reporting/request-format.sub.https.html?method=xhr&eligible={"eventSourceEligible":true,"triggerEligible":false}&expected-eligible=event-source - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset=utf-8>
<meta name=timeout content=long>
<meta name=variant content="?method=a&expected-eligible=navigation-source">
<meta name=variant content="?method=img&expected-eligible=event-source, trigger">
<meta name=variant content="?method=img&eligible&expected-eligible=event-source, trigger">
<meta name=variant content="?method=open&expected-eligible=navigation-source">
<meta name=variant content="?method=script&expected-eligible=event-source, trigger">
<meta name=variant content="?method=script&eligible&expected-eligible=event-source, trigger">
<meta name=variant content="?method=fetch">
<meta name=variant content='?method=fetch&eligible={"eventSourceEligible":true,"triggerEligible":false}&expected-eligible=event-source'>
<meta name=variant content="?method=xhr">
<meta name=variant content='?method=xhr&eligible={"eventSourceEligible":true,"triggerEligible":false}&expected-eligible=event-source'>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/helpers.js"></script>
<body>
<script>
const waitForRequest = async () => {
const url = blankURL();
url.searchParams.set('get-requests', 'true');
for (let i = 0; i < 20; i++) {
const resp = await fetch(url);
const payload = await resp.json();
if (payload !== null && payload.length > 0) {
return payload;
}
await delay(100);
}
throw new Error('Timeout polling requests');
};
const searchParams = new URLSearchParams(location.search);
const expected_eligible =
searchParams.get('expected-eligible') === null ? undefined : searchParams.get('expected-eligible');
promise_test(async t => {
// Set mixed-case query params to ensure that they are propagated correctly.
registerAttributionSrc({
method: 'variant',
extraQueryParams: {'aB': 'Cd', 'store-request': 'true'},
});
const requests = await waitForRequest();
assert_equals(requests.length, 1);
assert_equals(requests[0].method, 'GET');
// TODO(apaseltiner): Check header values once WPT can parse structured dictionaries.
if (expected_eligible) {
assert_own_property(requests[0], 'attribution-reporting-eligible');
} else {
assert_not_own_property(requests[0], 'attribution-reporting-eligible');
}
// TODO(apaseltiner): Test cookie propagation.
const expectedURL = blankURL();
expectedURL.searchParams.set('aB', 'Cd');
expectedURL.searchParams.set('store-request', 'true');
assert_equals(requests[0].url, expectedURL.toString());
}, 'attributionsrc request has the proper format.');
</script>