blob: 65281b122f221184520e97c3e6a31cfbf3af5f29 [file] [log] [blame]
<!DOCTYPE html>
<title>Test window.fence.setReportEventDataForAutomaticBeacons</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/utils.js"></script>
<script src="/common/dispatcher/dispatcher.js"></script>
<script src="resources/utils.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<body>
<script>
promise_test(async (t) => {
const actions = new test_driver.Actions();
const fencedframe = await attachFencedFrameContext({
generator_api: "fledge",
automatic_beacon: true,
origin: get_host_info().HTTPS_REMOTE_ORIGIN
});
const new_url = new URL("resources/dummy.html", location.href);
const beacon_data = "This is the beacon data!";
await fencedframe.execute(
(new_url, beacon_data) => {
addEventListener("click", (event) => {
let beacon_event = {
eventType: "reserved.top_navigation_commit",
eventData: beacon_data,
destination: ["component-seller"],
};
window.fence.setReportEventDataForAutomaticBeacons(beacon_event);
window.open(new_url, "_blank");
});
},
[new_url, beacon_data]
);
await actions
.pointerMove(0, 0, { origin: fencedframe.element })
.pointerDown()
.pointerUp()
.send();
// An automatic beacon should be sent out, but no data should be sent as part
// of the beacon because the "buyer" destination was not specified in
// setReportEventDataForAutomaticBeacons().
const expected_data = "<No data>";
const beacon_initiator_origin = await nextAutomaticBeacon(expected_data);
assert_equals(beacon_initiator_origin, get_host_info().HTTPS_ORIGIN);
}, "Set and trigger an automatic beacon with no destination specified");
</script>
</body>