blob: e8bf45049c53ab23fee369c058ffe4904bed45ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
const TOPICS_PERMISSIONS_POLICY_ERROR_MESSAGE = 'The \"browsing-topics\" Permissions Policy denied the use of document.browsingTopics().';
function test_topics_feature_availability_in_subframe(test, is_same_origin, expect_feature_available_func) {
const same_origin_src = '/browsing-topics/resources/document-api-notify-parent.tentative.https.html';
const cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
same_origin_src;
let frame = document.createElement('iframe');
frame.src = is_same_origin ? same_origin_src : cross_origin_src;
window.addEventListener('message', test.step_func(function handler(evt) {
if (evt.source === frame.contentWindow) {
expect_feature_available_func(evt.data);
document.body.removeChild(frame);
window.removeEventListener('message', handler);
test.done();
}
}));
document.body.appendChild(frame);
}
function expect_topics_feature_unavailable(data) {
assert_equals(data.error, TOPICS_PERMISSIONS_POLICY_ERROR_MESSAGE);
}
function expect_topics_feature_available(data) {
assert_equals(data.error, 'No error');
}
|