Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions extensions/amp-a4a/0.1/amp-a4a.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {triggerAnalyticsEvent} from '#utils/analytics';
import {DomTransformStream} from '#utils/dom-transform-stream';
import {listenOnce} from '#utils/event-helper';
import {dev, devAssert, logHashParam, user, userAssert} from '#utils/log';
import {isAttributionReportingAllowed} from '#utils/privacy-sandbox-utils';

import {canSetCookie, getCookie} from 'src/cookies';

Expand Down Expand Up @@ -2071,11 +2070,7 @@ export class AmpA4A extends AMP.BaseElement {
// Block synchronous XHR in ad. These are very rare, but super bad for UX
// as they block the UI thread for the arbitrary amount of time until the
// request completes.
let featurePolicies = "sync-xhr 'none';";

if (isAttributionReportingAllowed(this.win.document)) {
featurePolicies += "attribution-reporting 'src';";
}
const featurePolicies = "sync-xhr 'none';";

mergedAttributes['allow'] = featurePolicies;

Expand Down
6 changes: 0 additions & 6 deletions extensions/amp-a4a/0.1/secure-frame.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {createElementWithAttributes, escapeHtml} from '#core/dom';

import {isAttributionReportingAllowed} from '#utils/privacy-sandbox-utils';

import {getFieSafeScriptSrcs} from '../../../src/friendly-iframe-embed';

// If making changes also change ALLOWED_FONT_REGEX in head-validation.js
Expand Down Expand Up @@ -85,9 +83,5 @@ export function createSecureFrame(win, title, height, width) {
})
);

if (isAttributionReportingAllowed(document)) {
iframe.setAttribute('allow', `attribution-reporting 'src'`);
}

return iframe;
}
85 changes: 0 additions & 85 deletions extensions/amp-a4a/0.1/test/test-amp-a4a.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {installRealTimeConfigServiceForDoc} from '#service/real-time-config/real

import * as analytics from '#utils/analytics';
import {dev, user} from '#utils/log';
import * as privacySandboxUtils from '#utils/privacy-sandbox-utils';

import {macroTask} from '#testing/helpers';
import {createIframePromise} from '#testing/iframe';
Expand Down Expand Up @@ -921,34 +920,6 @@ describes.realWin('amp-a4a', {amp: true}, (env) => {
verifyCachedContentIframeRender(a4aElement, TEST_URL, true);
expect(a4a.iframe.getAttribute('allow')).to.include("sync-xhr 'none';");
});

it('should set feature policy for attribution-reporting when supported', async () => {
env.sandbox
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
.returns(true);
a4a.sandboxHTMLCreativeFrame = () => true;
a4a.onLayoutMeasure();
await a4a.layoutCallback();
verifyCachedContentIframeRender(a4aElement, TEST_URL, true);
expect(a4a.iframe.getAttribute('allow')).to.include("sync-xhr 'none';");
expect(a4a.iframe.getAttribute('allow')).to.include(
"attribution-reporting 'src';"
);
});

it('should not set feature policy for attribution-reporting when not supported', async () => {
env.sandbox
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
.returns(false);
a4a.sandboxHTMLCreativeFrame = () => true;
a4a.onLayoutMeasure();
await a4a.layoutCallback();
verifyCachedContentIframeRender(a4aElement, TEST_URL, true);
expect(a4a.iframe.getAttribute('allow')).to.include("sync-xhr 'none';");
expect(a4a.iframe.getAttribute('allow')).to.not.include(
"attribution-reporting 'src';"
);
});
});

describe('illegal render mode value', () => {
Expand Down Expand Up @@ -1038,30 +1009,6 @@ describes.realWin('amp-a4a', {amp: true}, (env) => {
expect(fetchMock.called('ad')).to.be.true;
});

it('should set feature policy for attribution-reporting when supported', async () => {
env.sandbox
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
.returns(true);
a4a.sandboxHTMLCreativeFrame = () => false;
a4a.onLayoutMeasure();
await a4a.layoutCallback();
verifyNameFrameRender(a4aElement, false /* shouldSandbox */);
expect(a4a.iframe.getAttribute('allow')).to.equal(
"sync-xhr 'none';attribution-reporting 'src';"
);
});

it('should not set feature policy for attribution-reporting when not supported', async () => {
env.sandbox
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
.returns(false);
a4a.sandboxHTMLCreativeFrame = () => false;
a4a.onLayoutMeasure();
await a4a.layoutCallback();
verifyNameFrameRender(a4aElement, false /* shouldSandbox */);
expect(a4a.iframe.getAttribute('allow')).to.equal("sync-xhr 'none';");
});

['', 'client_cache', 'safeframe', 'some_random_thing'].forEach(
(headerVal) => {
it(`should not attach a NameFrame when header is ${headerVal}`, async () => {
Expand Down Expand Up @@ -1171,38 +1118,6 @@ describes.realWin('amp-a4a', {amp: true}, (env) => {
expect(fetchMock.called('ad')).to.be.true;
});

it('should set feature policy for attribution-reporting when supported', async () => {
env.sandbox
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
.returns(true);
a4a.sandboxHTMLCreativeFrame = () => false;
a4a.onLayoutMeasure();
await a4a.layoutCallback();
verifySafeFrameRender(
a4aElement,
DEFAULT_SAFEFRAME_VERSION,
false /* shouldSandbox */
);
expect(a4a.iframe.getAttribute('allow')).to.equal(
"sync-xhr 'none';attribution-reporting 'src';"
);
});

it('should not set feature policy for attribution-reporting when not supported', async () => {
env.sandbox
.stub(privacySandboxUtils, 'isAttributionReportingAllowed')
.returns(false);
a4a.sandboxHTMLCreativeFrame = () => false;
a4a.onLayoutMeasure();
await a4a.layoutCallback();
verifySafeFrameRender(
a4aElement,
DEFAULT_SAFEFRAME_VERSION,
false /* shouldSandbox */
);
expect(a4a.iframe.getAttribute('allow')).to.equal("sync-xhr 'none';");
});

['', 'client_cache', 'nameframe', 'some_random_thing'].forEach(
(headerVal) => {
it(`should not attach a SafeFrame when header is ${headerVal}`, async () => {
Expand Down
79 changes: 4 additions & 75 deletions extensions/amp-ad-exit/0.1/amp-ad-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import {Services} from '#service';

import {getData} from '#utils/event-helper';
import {dev, devAssert, user, userAssert} from '#utils/log';
import {
AttributionReportingStatus,
isAttributionReportingAllowed,
} from '#utils/privacy-sandbox-utils';

import {TransportMode, assertConfig, assertVendor} from './config';
import {makeClickDelaySpec} from './filters/click-delay';
Expand Down Expand Up @@ -93,8 +89,7 @@ export class AmpAdExit extends AMP.BaseElement {
this.expectedOriginToVendor_ = {};

/** @private @const {boolean} */
this.isAttributionReportingSupported_ =
this.detectAttributionReportingSupport();
this.isAttributionReportingSupported_ = false;
}

/**
Expand Down Expand Up @@ -191,10 +186,8 @@ export class AmpAdExit extends AMP.BaseElement {
getUrlVariableRewriter_(args, event, target) {
const substitutionFunctions = {
'ATTRIBUTION_REPORTING_STATUS': () =>
getAttributionReportingStatus(
this.isAttributionReportingSupported_,
target
),
// ARA removed
this.isAttributionReportingSupported_,
Comment on lines +189 to +190
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ATTRIBUTION_REPORTING_STATUS macro now returns a boolean value (false), which will be stringified to "false" when used in URLs. Previously, it returned numeric status codes (0, 4, 5, or 6) from the AttributionReportingStatus enum. Since ARA is being removed, this should return a constant numeric value to maintain backward compatibility with any URLs using this macro. Based on the previous implementation, it should return either 0 (ATTRIBUTION_DATA_UNSPECIFIED) or 4 (ATTRIBUTION_MACRO_PRESENT) to indicate the macro exists but the feature is disabled.

Suggested change
// ARA removed
this.isAttributionReportingSupported_,
// ARA removed; return constant numeric status for backward compatibility
4,

Copilot uses AI. Check for mistakes.
'CLICK_X': () => event.clientX,
'CLICK_Y': () => event.clientY,
};
Expand Down Expand Up @@ -389,17 +382,7 @@ export class AmpAdExit extends AMP.BaseElement {
.filter(Boolean),
behaviors: target['behaviors'] || {},
};
if (
this.isAttributionReportingSupported_ &&
target?.behaviors?.browserAdConversion
) {
this.targets_[name]['windowFeatures'] =
this.getAttributionReportingValues_(
target?.behaviors?.browserAdConversion
);
} else {
this.targets_[name]['trackingUrls'] = target['trackingUrls'] || [];
}
this.targets_[name]['trackingUrls'] = target['trackingUrls'] || [];

// Build a map of {vendor, origin} for 3p custom variables in the config
for (const customVar in target['vars']) {
Expand Down Expand Up @@ -430,37 +413,6 @@ export class AmpAdExit extends AMP.BaseElement {
this.init3pResponseListener_();
}

/**
* Determine if `attribution-reporting` is supported by user-agent. Should only return
* true for Chrome 92+.
* @visibleForTesting
* @return {boolean}
*/
detectAttributionReportingSupport() {
return isAttributionReportingAllowed(this.win.document);
}

/**
* Extracts the keys from the `browserAdConversion` data creates a
* string to be used as the `features` param for the `window.open()` call.
* @param {JsonObject} adConversionData
* @return {?string}
*/
getAttributionReportingValues_(adConversionData) {
if (!adConversionData || !Object.keys(adConversionData)) {
return;
}

// `noopener` is probably redundant here but left as defense in depth.
// https://groups.google.com/a/chromium.org/g/blink-dev/c/FFX6VkvladY/m/QgaWHK6ZBAAJ
const parts = ['noopener'];
for (const key of Object.keys(adConversionData)) {
const encoded = encodeURIComponent(adConversionData[key]);
parts.push(`${key.toLowerCase()}=${encoded}`);
}
return parts.join(',');
}

/**
* Gets the resource ID of the amp-ad element containing this amp-ad-exit tag.
* This is a pass-through for the version in service.js, solely because
Expand Down Expand Up @@ -580,26 +532,3 @@ export class AmpAdExit extends AMP.BaseElement {
AMP.extension(TAG, '0.1', (AMP) => {
AMP.registerElement(TAG, AmpAdExit);
});

/**
* Resolves the ATTRIBUTION_REPORTING_STATUS macro to the appropriate value
* based on the given config and browser support.
* @param {boolean} isAttributionReportingSupported
* @param {!NavigationTargetDef} target
* @return {AttributionReportingStatus}
* @visibleForTesting
*/
export function getAttributionReportingStatus(
isAttributionReportingSupported,
target
) {
if (
target?.behaviors?.browserAdConversion &&
isAttributionReportingSupported
) {
return AttributionReportingStatus.ATTRIBUTION_DATA_PRESENT_AND_POLICY_ENABLED;
} else if (target?.behaviors?.browserAdConversion?.attributionsrc) {
return AttributionReportingStatus.ATTRIBUTION_DATA_PRESENT;
}
return AttributionReportingStatus.ATTRIBUTION_MACRO_PRESENT;
}
Loading
Loading