v155 · privacy sandbox · feature removal
What is left of window.fence
The ads reporting API was never global. window.fence is a property that holds something only inside a fenced frame, and the whole point of the removal is that there is no longer a way to be inside one. Enumerate the interface, call every method it declares, and read the exact refusal.
The interface, enumerated
Read off Fence.prototype at runtime rather than from documentation, because the set has already changed once: methods present in earlier Chrome versions are not present now.
| member | what it reported | calling it from this document | |
|---|---|---|---|
| Press the button. | |||
Where window.fence is not null
Four browsing contexts this page can actually create, plus the one it cannot. Each reports its own window.fence back.
| context | window.fence | notes |
|---|---|---|
| Press the button. | ||
what it was for
A fenced frame cannot talk to its embedder, which is exactly what makes it useful and exactly what makes reporting hard. An ad rendered inside one still needs to tell the buyer that it was clicked, and it cannot do that by messaging the page around it. fence.reportEvent() was the escape hatch: a call that leaves the frame through the browser rather than through the document, addressed to destinations the auction registered in advance.
// Inside a fenced frame, before the removal:
window.fence.reportEvent({
eventType: "click",
eventData: JSON.stringify({ slot: "hero" }),
destination: ["buyer", "seller"],
});
// Registered up front, so a top-level navigation still reports:
window.fence.setReportEventDataForAutomaticBeacons({
eventType: "reserved.top_navigation",
eventData: "…",
destination: ["buyer"],
});
Every one of those calls is reachable only from a document loaded into a fenced frame. With the auction gone, no such document can be loaded, so the API is unreachable code with an IDL entry — which is what Chrome 154 removes.
fence being null rather than undefined is worth noticing: the property exists on every window, and the value is what tells you where you are. A page testing if (window.fence) got the right answer; a page testing if ("fence" in window) got the wrong one. After the removal both are false, which is the one thing the two checks have ever agreed on.