Skip to content

Commit

Permalink
🚮 Remove tcf-post-message-proxy-api experiment (#35551)
Browse files Browse the repository at this point in the history
Launched ~5 months ago, getting ahead of the automated removal at the beginning of next month.
  • Loading branch information
alanorozco committed Aug 9, 2021
1 parent 365c6c3 commit 3170de8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 53 deletions.
1 change: 0 additions & 1 deletion build-system/global-configs/canary-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"amp-cid-backup": 1,
"flexible-bitrate": 0.1,
"layout-aspect-ratio-css": 1,
"tcf-post-message-proxy-api": 1,
"disable-a4a-non-sd": 1,
"story-ad-auto-advance": 1,
"story-ad-placements": 1,
Expand Down
1 change: 0 additions & 1 deletion build-system/global-configs/prod-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"ios-fixed-no-transfer": 0,
"layout-aspect-ratio-css": 0,
"disable-a4a-non-sd": 1,
"tcf-post-message-proxy-api": 1,
"amp-cid-backup": 1,
"story-ad-placements": 0.01,
"story-disable-animations-first-page": 0.5,
Expand Down
5 changes: 0 additions & 5 deletions examples/amp-consent/amp-consent-3p-postmessage.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
<script async custom-element="amp-video-iframe" src="https://cdn.ampproject.org/v0/amp-video-iframe-0.1.js"></script>
<script async custom-element="amp-consent" src="https://cdn.ampproject.org/v0/amp-consent-0.1.js"></script>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script>
(self.AMP = self.AMP || []).push(function(AMP) {
AMP.toggleExperiment('tcf-post-message-proxy-api', true);
});
</script>
<style amp-custom>
body {
max-width: 527px;
Expand Down
49 changes: 17 additions & 32 deletions extensions/amp-consent/0.1/amp-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ import {getServicePromiseForDoc} from '../../../src/service-helpers';
import {isArray, isEnumValue, isObject} from '#core/types';
import {realChildElements} from '#core/dom/query';

import {isExperimentOn} from '#experiments';

import {toggle} from '#core/dom/style';

const CONSENT_STATE_MANAGER = 'consentStateManager';
Expand Down Expand Up @@ -124,19 +122,8 @@ export class AmpConsent extends AMP.BaseElement {
/** @private {?string} */
this.matchedGeoGroup_ = null;

/** @private {?boolean} */
this.isTcfPostMessageProxyExperimentOn_ = isExperimentOn(
this.win,
'tcf-post-message-proxy-api'
);

/** @private {?Promise<?Array>} */
this.purposeConsentRequired_ = null;

/** @private @const {?Function} */
this.boundHandleIframeMessages_ = this.isTcfPostMessageProxyExperimentOn_
? this.handleIframeMessages_.bind(this)
: null;
}

/** @override */
Expand Down Expand Up @@ -972,27 +959,25 @@ export class AmpConsent extends AMP.BaseElement {
* that the document supports the tcfPostMessage API.
*/
maybeSetUpTcfPostMessageProxy_() {
if (
!this.isTcfPostMessageProxyExperimentOn_ ||
!this.consentConfig_['exposesTcfApi']
) {
if (!this.consentConfig_['exposesTcfApi']) {
return;
}
// Check if __tcfApiLocator API already exists (dirty AMP)
if (!this.win.frames[TCF_API_LOCATOR]) {
this.tcfApiCommandManager_ = new TcfApiCommandManager(
this.consentPolicyManager_
);
// Add window listener for 3p iframe PostMessages
this.win.addEventListener('message', this.boundHandleIframeMessages_);

// Set up the __tcfApiLocator window to singal PostMessage support
const iframe = this.element.ownerDocument.createElement('iframe');
iframe.setAttribute('name', TCF_API_LOCATOR);
toggle(iframe, false);
iframe.setAttribute('aria-hidden', true);
this.element.appendChild(dev().assertElement(iframe));
// Bail if __tcfApiLocator API already exists (dirty AMP)
if (this.win.frames[TCF_API_LOCATOR]) {
return;
}
this.tcfApiCommandManager_ = new TcfApiCommandManager(
this.consentPolicyManager_
);
// Add window listener for 3p iframe postMessages
this.win.addEventListener('message', (e) => this.handleTcfMessage_(e));

// Set up the __tcfApiLocator window to signal postMessage support
const iframe = this.element.ownerDocument.createElement('iframe');
iframe.setAttribute('name', TCF_API_LOCATOR);
iframe.setAttribute('aria-hidden', 'true');
toggle(iframe, false);
this.element.appendChild(dev().assertElement(iframe));
}

/**
Expand All @@ -1011,7 +996,7 @@ export class AmpConsent extends AMP.BaseElement {
*
* @param {!Event} event
*/
handleIframeMessages_(event) {
handleTcfMessage_(event) {
const data = getData(event);

if (!data || !data['__tcfapiCall']) {
Expand Down
9 changes: 0 additions & 9 deletions extensions/amp-consent/0.1/test/test-amp-consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
resetServiceForTesting,
} from '../../../../src/service-helpers';
import {removeSearch} from '../../../../src/url';
import {toggleExperiment} from '#experiments';
import {xhrServiceForTesting} from '#service/xhr-impl';

describes.realWin(
Expand Down Expand Up @@ -938,14 +937,6 @@ describes.realWin(
let ampConsent;
let consentElement;

beforeEach(() => {
toggleExperiment(win, 'tcf-post-message-proxy-api', true);
});

afterEach(() => {
toggleExperiment(win, 'tcf-post-message-proxy-api', false);
});

describe('config', () => {
it('shoud expose if in config', async () => {
consentElement = createConsentElement(
Expand Down
5 changes: 0 additions & 5 deletions tools/experiments/experiments-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ export const EXPERIMENTS = [
name: 'Responsive layouts implemented via aspect-ratio CSS',
spec: 'https://github.com/ampproject/amphtml/issues/30291',
},
{
id: 'tcf-post-message-proxy-api',
name: 'Proxy for TCF PostMessageAPI to send TCData to 3p iframes',
spec: 'https://github.com/ampproject/amphtml/issues/30385',
},
{
id: 'dfp-render-on-idle-cwv-exp',
name: 'To measure the CWV impact of ads idle rendering',
Expand Down

0 comments on commit 3170de8

Please sign in to comment.