From 3667bede480f239c9b47f944e0f9562b3fa9d118 Mon Sep 17 00:00:00 2001 From: Oli Yu Date: Fri, 21 Feb 2020 18:03:27 -0600 Subject: [PATCH] Remove deprecated Cloudflare AMP Cache and A4A support. --- 3p/README.md | 2 +- ads/_a4a-config.js | 11 - ads/dianomi.md | 43 ---- build-system/compile/bundles.config.js | 24 --- build-system/global-configs/caches.json | 8 - build-system/tasks/caches-json.js | 2 +- build-system/test-configs/dep-check-config.js | 11 - examples/a4a.amp.html | 38 ---- .../0.1/amp-ad-network-cloudflare-impl.js | 128 ------------ .../0.1/cloudflare-a4a-config.js | 28 --- .../0.1/data/fake_a4a.html | 19 -- .../0.1/data/fake_a4a.json | 4 - .../test-amp-ad-network-cloudflare-impl.js | 190 ------------------ .../0.1/vendors.js | 42 ---- .../amp-ad-network-cloudflare-impl/OWNERS | 10 - ...amp-ad-network-cloudflare-impl-internal.md | 75 ------- .../0.1/amp-ad-network-gmossp-impl.js | 68 ------- .../0.1/gmossp-a4a-config.js | 40 ---- .../test/test-amp-ad-network-gmossp-impl.js | 147 -------------- extensions/amp-ad-network-gmossp-impl/OWNERS | 10 - .../amp-ad-network-gmossp-impl-internal.md | 57 ------ .../0.1/amp-ad-network-mytarget-impl.js | 101 ---------- .../0.1/mytarget-a4a-config.js | 29 --- .../test/test-amp-ad-network-mytarget-impl.js | 146 -------------- .../amp-ad-network-mytarget-impl/OWNERS | 10 - .../amp-ad-network-mytarget-impl-internal.md | 66 ------ .../0.1/amp-ad-network-triplelift-impl.js | 65 ------ .../test-amp-ad-network-triplelift-impl.js | 122 ----------- .../0.1/triplelift-a4a-config.js | 33 --- .../amp-ad-network-triplelift-impl/OWNERS | 10 - spec/amp-cache-guidelines.md | 1 - spec/amp-cors-requests.md | 5 - test/size.txt | 5 +- validator/engine/validator-in-browser.js | 4 +- 34 files changed, 4 insertions(+), 1550 deletions(-) delete mode 100644 ads/dianomi.md delete mode 100644 extensions/amp-ad-network-cloudflare-impl/0.1/amp-ad-network-cloudflare-impl.js delete mode 100644 extensions/amp-ad-network-cloudflare-impl/0.1/cloudflare-a4a-config.js delete mode 100644 extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.html delete mode 100644 extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.json delete mode 100644 extensions/amp-ad-network-cloudflare-impl/0.1/test/test-amp-ad-network-cloudflare-impl.js delete mode 100644 extensions/amp-ad-network-cloudflare-impl/0.1/vendors.js delete mode 100644 extensions/amp-ad-network-cloudflare-impl/OWNERS delete mode 100644 extensions/amp-ad-network-cloudflare-impl/amp-ad-network-cloudflare-impl-internal.md delete mode 100644 extensions/amp-ad-network-gmossp-impl/0.1/amp-ad-network-gmossp-impl.js delete mode 100644 extensions/amp-ad-network-gmossp-impl/0.1/gmossp-a4a-config.js delete mode 100644 extensions/amp-ad-network-gmossp-impl/0.1/test/test-amp-ad-network-gmossp-impl.js delete mode 100644 extensions/amp-ad-network-gmossp-impl/OWNERS delete mode 100644 extensions/amp-ad-network-gmossp-impl/amp-ad-network-gmossp-impl-internal.md delete mode 100644 extensions/amp-ad-network-mytarget-impl/0.1/amp-ad-network-mytarget-impl.js delete mode 100644 extensions/amp-ad-network-mytarget-impl/0.1/mytarget-a4a-config.js delete mode 100644 extensions/amp-ad-network-mytarget-impl/0.1/test/test-amp-ad-network-mytarget-impl.js delete mode 100644 extensions/amp-ad-network-mytarget-impl/OWNERS delete mode 100644 extensions/amp-ad-network-mytarget-impl/amp-ad-network-mytarget-impl-internal.md delete mode 100644 extensions/amp-ad-network-triplelift-impl/0.1/amp-ad-network-triplelift-impl.js delete mode 100644 extensions/amp-ad-network-triplelift-impl/0.1/test/test-amp-ad-network-triplelift-impl.js delete mode 100644 extensions/amp-ad-network-triplelift-impl/0.1/triplelift-a4a-config.js delete mode 100644 extensions/amp-ad-network-triplelift-impl/OWNERS diff --git a/3p/README.md b/3p/README.md index 49b5af83fbe96..01ed9e3275d9e 100644 --- a/3p/README.md +++ b/3p/README.md @@ -59,7 +59,7 @@ Review the [ads/README](../ads/README.md) for further details on ad integration. - JavaScript can not be involved with the initiation of font loading. - Font loading gets controlled (but not initiated) by [``](https://github.com/ampproject/amphtml/issues/648). - AMP by default does not allow inclusion of external stylesheets, but it is happy to whitelist URL prefixes of font providers for font inclusion via link tags. These link tags and their fonts must be served via HTTPS. -- If a font provider does referrer based "security" it needs to whitelist the AMP proxy origins before being included in the link tag whitelist. AMP proxy sends the appropriate referrer header such as `https://cdn.ampproject.org` and `https://amp.cloudflare.com`. +- If a font provider does referrer based "security" it needs to whitelist the AMP proxy origins before being included in the link tag whitelist. AMP proxy sends the appropriate referrer header such as `https://cdn.ampproject.org`. # Adding proper integration tests diff --git a/ads/_a4a-config.js b/ads/_a4a-config.js index 1df08463d19a8..744303ae7d91e 100644 --- a/ads/_a4a-config.js +++ b/ads/_a4a-config.js @@ -14,11 +14,7 @@ * limitations under the License. */ -import {cloudflareIsA4AEnabled} from '../extensions/amp-ad-network-cloudflare-impl/0.1/cloudflare-a4a-config'; -import {gmosspIsA4AEnabled} from '../extensions/amp-ad-network-gmossp-impl/0.1/gmossp-a4a-config'; import {map} from '../src/utils/object'; -import {myTargetIsA4AEnabled} from '../extensions/amp-ad-network-mytarget-impl/0.1/mytarget-a4a-config'; -import {tripleliftIsA4AEnabled} from '../extensions/amp-ad-network-triplelift-impl/0.1/triplelift-a4a-config'; /** * Registry for A4A (AMP Ads for AMPHTML pages) "is supported" predicates. @@ -45,10 +41,6 @@ export function getA4ARegistry() { 'adsense': () => true, 'adzerk': () => true, 'doubleclick': () => true, - 'triplelift': tripleliftIsA4AEnabled, - 'mytarget': myTargetIsA4AEnabled, - 'cloudflare': cloudflareIsA4AEnabled, - 'gmossp': gmosspIsA4AEnabled, 'fake': () => true, // TODO: Add new ad network implementation "is enabled" functions here. // Note: if you add a function here that requires a new "import", above, @@ -68,7 +60,4 @@ export function getA4ARegistry() { export const signingServerURLs = { 'google': 'https://cdn.ampproject.org/amp-ad-verifying-keyset.json', 'google-dev': 'https://cdn.ampproject.org/amp-ad-verifying-keyset-dev.json', - 'cloudflare': 'https://amp.cloudflare.com/amp-ad-verifying-keyset.json', - 'cloudflare-dev': - 'https://amp.cloudflare.com/amp-ad-verifying-keyset-dev.json', }; diff --git a/ads/dianomi.md b/ads/dianomi.md deleted file mode 100644 index 02fdbb04177fc..0000000000000 --- a/ads/dianomi.md +++ /dev/null @@ -1,43 +0,0 @@ - - -# Dianomi Exchange - -## Example - -```html - -``` - -## Configuration - -For configuration semantics and to learn more about how we can help you deliver AMP Ads, please [contact dianomi](http://www.dianomi.com/). - -### Supported parameters - -- `data-id` -- `width` -- `height` -- `data-cf-a4a` -- `src` - -### Required parameters - -- `data-cf-network` -- `type` diff --git a/build-system/compile/bundles.config.js b/build-system/compile/bundles.config.js index 6ca64b7454d78..61c598a34dedc 100644 --- a/build-system/compile/bundles.config.js +++ b/build-system/compile/bundles.config.js @@ -292,30 +292,6 @@ exports.extensionBundles = [ latestVersion: '0.1', type: TYPES.AD, }, - { - name: 'amp-ad-network-triplelift-impl', - version: '0.1', - latestVersion: '0.1', - type: TYPES.AD, - }, - { - name: 'amp-ad-network-cloudflare-impl', - version: '0.1', - latestVersion: '0.1', - type: TYPES.AD, - }, - { - name: 'amp-ad-network-gmossp-impl', - version: '0.1', - latestVersion: '0.1', - type: TYPES.AD, - }, - { - name: 'amp-ad-network-mytarget-impl', - version: '0.1', - latestVersion: '0.1', - type: TYPES.AD, - }, { name: 'amp-ad-exit', version: '0.1', diff --git a/build-system/global-configs/caches.json b/build-system/global-configs/caches.json index 0c3edcd3c3e2f..16837265c242f 100644 --- a/build-system/global-configs/caches.json +++ b/build-system/global-configs/caches.json @@ -8,14 +8,6 @@ "updateCacheApiDomainSuffix": "cdn.ampproject.org", "thirdPartyFrameDomainSuffix": "ampproject.net" }, - { - "id": "cloudflare", - "name": "Cloudflare AMP Cache", - "docs": "https://amp.cloudflare.com/", - "cacheDomain": "amp.cloudflare.com", - "updateCacheApiDomainSuffix": "amp.cloudflare.com", - "thirdPartyFrameDomainSuffix": "cloudflareamp.net" - }, { "id": "bing", "name": "Bing AMP Cache", diff --git a/build-system/tasks/caches-json.js b/build-system/tasks/caches-json.js index 699cece8cbc6b..9c32abe2f2dd7 100644 --- a/build-system/tasks/caches-json.js +++ b/build-system/tasks/caches-json.js @@ -20,7 +20,7 @@ const gulp = require('gulp'); const log = require('fancy-log'); const through2 = require('through2'); -const expectedCaches = ['cloudflare', 'google']; +const expectedCaches = ['google']; const cachesJsonPath = 'build-system/global-configs/caches.json'; diff --git a/build-system/test-configs/dep-check-config.js b/build-system/test-configs/dep-check-config.js index be3d4f7169541..4063af1d024c8 100644 --- a/build-system/test-configs/dep-check-config.js +++ b/build-system/test-configs/dep-check-config.js @@ -162,13 +162,6 @@ exports.rules = [ allowlist: [ // See todo note in ads/_a4a-config.js 'ads/_a4a-config.js->' + - 'extensions/amp-ad-network-triplelift-impl/0.1/triplelift-a4a-config.js', - 'ads/_a4a-config.js->' + - 'extensions/amp-ad-network-cloudflare-impl/0.1/cloudflare-a4a-config.js', - 'ads/_a4a-config.js->' + - 'extensions/amp-ad-network-gmossp-impl/0.1/gmossp-a4a-config.js', - 'ads/_a4a-config.js->' + - 'extensions/amp-ad-network-mytarget-impl/0.1/mytarget-a4a-config.js', ], }, // Rules for extensions and main src. @@ -188,14 +181,10 @@ exports.rules = [ allowlist: [ // a4a ads depend on a4a. 'extensions/amp-ad-network-fake-impl/0.1/amp-ad-network-fake-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', - 'extensions/amp-ad-network-gmossp-impl/0.1/amp-ad-network-gmossp-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', - 'extensions/amp-ad-network-triplelift-impl/0.1/amp-ad-network-triplelift-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', - 'extensions/amp-ad-network-cloudflare-impl/0.1/amp-ad-network-cloudflare-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', 'extensions/amp-ad-network-adzerk-impl/0.1/amp-ad-network-adzerk-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', 'extensions/amp-ad-network-doubleclick-impl/0.1/sra-utils.js->extensions/amp-a4a/0.1/amp-a4a.js', 'extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', 'extensions/amp-ad-network-doubleclick-impl/0.1/amp-ad-network-doubleclick-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', - 'extensions/amp-ad-network-mytarget-impl/0.1/amp-ad-network-mytarget-impl.js->extensions/amp-a4a/0.1/amp-a4a.js', // And a few mrore things depend on a4a. 'extensions/amp-ad-custom/0.1/amp-ad-custom.js->extensions/amp-a4a/0.1/amp-ad-network-base.js', diff --git a/examples/a4a.amp.html b/examples/a4a.amp.html index 5097e22622978..4232d67087e74 100644 --- a/examples/a4a.amp.html +++ b/examples/a4a.amp.html @@ -53,44 +53,6 @@

Fake ad network

-

TripleLift ad network

- -
-
-
- -

myTarget ad network

- -
-
-
- -

Fake cloudflare as ad network ad

- -
-
-
- -

GMOSSP ad network

- -
-
-
-

Regular ad

} values to use in the replacements - * @return {string} result with replaced tokens - */ - replacements(str, values) { - // allow injection of width and height as parameters - str = str.replace(/SLOT_WIDTH/g, values.slotWidth); - str = str.replace(/SLOT_HEIGHT/g, values.slotHeight); - - return str; - } - - /** @override */ - getAdUrl() { - const rect = this.getIntersectionElementLayoutBox(); - const el = this.element; - - const network = NETWORKS[el.getAttribute('data-cf-network')]; - const a4a = el.getAttribute('data-cf-a4a') !== 'false'; - const {base} = network; - - // Get URL for ad creative - let url = el.getAttribute('src') || network.src; - - // optionally convert to a4a endpoint - if (a4a && url.substr(base.length, 6) != '/_a4a/') { - url = base + '/_a4a' + url.slice(base.length); - } - - // compute replacement values - const values = { - slotWidth: (rect.width || 0).toString(), - slotHeight: (rect.height || 0).toString(), - }; - - // encode for safety - url = encodeURI(this.replacements(url, values)); - - // include other data attributes as query parameters - let pre = url.indexOf('?') < 0 ? '?' : '&'; - for (let i = 0; i < el.attributes.length; i++) { - const attrib = el.attributes[i]; - if ( - attrib.specified && - startsWith(attrib.name, 'data-') && - !startsWith(attrib.name, 'data-cf-') - ) { - url += - pre + - encodeURIComponent(attrib.name.substring(5)) + - '=' + - encodeURIComponent(this.replacements(attrib.value, values)); - pre = '&'; - } - } - - return url; - } -} - -AMP.extension('amp-ad-network-cloudflare-impl', '0.1', AMP => { - AMP.registerElement( - 'amp-ad-network-cloudflare-impl', - AmpAdNetworkCloudflareImpl - ); -}); diff --git a/extensions/amp-ad-network-cloudflare-impl/0.1/cloudflare-a4a-config.js b/extensions/amp-ad-network-cloudflare-impl/0.1/cloudflare-a4a-config.js deleted file mode 100644 index ccc9f6eaedb74..0000000000000 --- a/extensions/amp-ad-network-cloudflare-impl/0.1/cloudflare-a4a-config.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2016 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Determines which tags desire A4A handling - * @param {!Window} win - * @param {!Element} element - * @param {boolean} useRemoteHtml - * @return {boolean} - */ -export function cloudflareIsA4AEnabled(win, element, useRemoteHtml) { - // We assume fast fetch for all content, but this will gracefully degrade, - // when non-a4a content is delivered - return !useRemoteHtml; -} diff --git a/extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.html b/extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.html deleted file mode 100644 index a3f3f4807c65c..0000000000000 --- a/extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - -

Cloudflare

- - diff --git a/extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.json b/extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.json deleted file mode 100644 index c7a6ff282028d..0000000000000 --- a/extensions/amp-ad-network-cloudflare-impl/0.1/data/fake_a4a.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "creative": "\n\n\n\n\n\n\n\n\n\n

Cloudflare

\n\n\n", - "signature": "AIU2ewuxnYQC6hv93XtCGLTT5o6G49AiVshh52r-Ovv-c3a7wDOZqZijx1lFP3W2UNKIlvkrDA84ZEJ8zc4eQgc7LB5fYrRv_Wfg73VTvnyq65zb68u0KJaOJAxfqLeAqAmAv9Co2R1t8n_rvpdPptGnBTjqk8SmU-P5E1AOjmTqc4RF_aXCDSFmYTM1bq_IJb0rabMIk-ZLhXU2d2gf-rokLFdphSRmenBYlQk-gGJST0tDJSzxAsNbySkDMP3xSosFo1lbmjM5LfM8osuiW-16wLtf3Bqaq9Do1nxQ3PNwVJSgHkwwk5qiHOPcH5m2V2hDj35z8COqVdBi98uxXRMH4MT9" -} diff --git a/extensions/amp-ad-network-cloudflare-impl/0.1/test/test-amp-ad-network-cloudflare-impl.js b/extensions/amp-ad-network-cloudflare-impl/0.1/test/test-amp-ad-network-cloudflare-impl.js deleted file mode 100644 index a9f48cf200484..0000000000000 --- a/extensions/amp-ad-network-cloudflare-impl/0.1/test/test-amp-ad-network-cloudflare-impl.js +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Copyright 2016 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import '../../../amp-ad/0.1/amp-ad'; -import * as vendors from '../vendors'; -import {AmpAdNetworkCloudflareImpl} from '../amp-ad-network-cloudflare-impl'; -import { - AmpAdXOriginIframeHandler, // eslint-disable-line no-unused-vars -} from '../../../amp-ad/0.1/amp-ad-xorigin-iframe-handler'; -import {cloudflareIsA4AEnabled} from '../cloudflare-a4a-config'; -import {createElementWithAttributes} from '../../../../src/dom'; - -describes.realWin( - 'cloudflare-a4a-config', - { - amp: { - extensions: ['amp-ad', 'amp-ad-network-cloudflare-impl'], - }, - }, - env => { - let doc; - let win; - beforeEach(() => { - win = env.win; - doc = env.win.document; - }); - it('should pass a4a config predicate', () => { - const el = createElementWithAttributes(doc, 'amp-ad', { - 'data-cf-network': 'cloudflare', - src: '/ad.html', - 'data-cf-a4a': 'true', - }); - expect(cloudflareIsA4AEnabled(win, el)).to.be.true; - }); - - it('should not pass a4a config predicate when useRemoteHtml is true', () => { - const el = createElementWithAttributes(doc, 'amp-ad', { - 'data-cf-network': 'cloudflare', - src: '/ad.html', - 'data-cf-a4a': 'true', - }); - const useRemoteHtml = true; - expect(cloudflareIsA4AEnabled(win, el, useRemoteHtml)).to.be.false; - }); - } -); - -describes.realWin( - 'amp-ad-network-cloudflare-impl', - { - amp: { - extensions: ['amp-ad', 'amp-ad-network-cloudflare-impl'], - }, - }, - env => { - let cloudflareImpl; - let el; - let doc; - - beforeEach(() => { - doc = env.win.document; - el = doc.createElement('amp-ad'); - el.setAttribute('type', 'cloudflare'); - el.setAttribute('data-cf-network', 'cloudflare'); - el.setAttribute('src', 'https://firebolt.cloudflaredemo.com/a4a-ad.html'); - env.sandbox - .stub(AmpAdNetworkCloudflareImpl.prototype, 'getSigningServiceNames') - .callsFake(() => { - return ['cloudflare', 'cloudflare-dev']; - }); - env.sandbox.stub(vendors, 'NETWORKS').callsFake({ - cloudflare: { - base: 'https://firebolt.cloudflaredemo.com', - }, - - 'cf-test': { - base: 'https://cf-test.com', - src: - 'https://cf-test.com/path/ad?width=SLOT_WIDTH&height=SLOT_HEIGHT', - }, - }); - env.sandbox.stub(el, 'tryUpgrade_').callsFake(() => {}); - doc.body.appendChild(el); - cloudflareImpl = new AmpAdNetworkCloudflareImpl(el); - }); - - describe('#isValidElement', () => { - it('should be valid', () => { - expect(cloudflareImpl.isValidElement()).to.be.true; - }); - it('should NOT be valid (impl tag name)', () => { - el = doc.createElement('amp-ad-network-cloudflare-impl'); - el.setAttribute('type', 'cloudflare'); - cloudflareImpl = new AmpAdNetworkCloudflareImpl(el); - expect(cloudflareImpl.isValidElement()).to.be.false; - }); - }); - - describe('#getAdUrl', () => { - it('should be valid', () => { - expect(cloudflareImpl.getAdUrl()).to.equal( - 'https://firebolt.cloudflaredemo.com/_a4a/a4a-ad.html' - ); - }); - - it('should handle non-a4a URLs', () => { - el.setAttribute('data-cf-a4a', 'false'); - expect(cloudflareImpl.getAdUrl()).to.equal( - 'https://firebolt.cloudflaredemo.com/a4a-ad.html' - ); - }); - - it('should accept a4a src', () => { - el.setAttribute( - 'src', - 'https://firebolt.cloudflaredemo.com/_a4a/a4a-ad.html' - ); - expect(cloudflareImpl.getAdUrl()).to.equal( - 'https://firebolt.cloudflaredemo.com/_a4a/a4a-ad.html' - ); - }); - - it('should handle additional templated width/height', () => { - el.setAttribute( - 'src', - 'https://firebolt.cloudflaredemo.com/' + - 'ad?width=SLOT_WIDTH&height=SLOT_HEIGHT' - ); - expect(cloudflareImpl.getAdUrl()).to.equal( - 'https://firebolt.cloudflaredemo.com/_a4a/ad?width=0&height=0' - ); - }); - - function parseQuery(query) { - const kvs = query.split(/&/); - const params = {}; - for (let i = 0; i < kvs.length; i++) { - const parts = kvs[i].match(/^([^=]+)=?(.*)/); - params[parts[1]] = parts[2]; - } - return params; - } - - it('should handle data parameters', () => { - el.setAttribute('src', 'https://firebolt.cloudflaredemo.com/ad'); - el.setAttribute('data-key', 'value'); - el.setAttribute('data-another', 'more'); - - const url = cloudflareImpl.getAdUrl(); - const base = 'https://firebolt.cloudflaredemo.com/_a4a/ad?'; - expect(url.substring(0, base.length)).to.equal(base); - expect(parseQuery(url.substring(base.length))).to.deep.equal({ - another: 'more', - key: 'value', - }); - }); - - // TODO(bradfrizzell, #12476): Make this test work with sinon 4.0. - it.skip('should handle default src with data parameters', () => { - el.setAttribute('data-cf-network', 'cf-test'); - el.removeAttribute('src'); - el.setAttribute('data-key', 'value'); - el.setAttribute('data-another', 'more'); - - const url = cloudflareImpl.getAdUrl(); - const base = 'https://cf-test.com/_a4a/path/ad?'; - expect(url.substring(0, base.length)).to.equal(base); - expect(parseQuery(url.substring(base.length))).to.deep.equal({ - another: 'more', - height: '0', - key: 'value', - width: '0', - }); - }); - }); - } -); diff --git a/extensions/amp-ad-network-cloudflare-impl/0.1/vendors.js b/extensions/amp-ad-network-cloudflare-impl/0.1/vendors.js deleted file mode 100644 index 3ff55817aab4f..0000000000000 --- a/extensions/amp-ad-network-cloudflare-impl/0.1/vendors.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2015 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @const {!JsonObject} - */ -export const NETWORKS = /** @type {!JsonObject} */ ({ - 'cloudflare': { - 'base': 'https://firebolt.cloudflaredemo.com', - }, - - 'adzerk': { - 'base': 'https://engine.betazerk.com', - }, - - 'celtra': { - 'base': 'https://ads-amp.celtra.com', - }, - - 'dianomi': { - 'base': 'https://www.dianomi.com', - 'src': 'https://www.dianomi.com/smartads.pl?format=a4a', - }, - - 'yieldmo': { - 'base': 'https://yieldmo-amp.club', - 'src': 'https://yieldmo-amp.club/ads', - }, -}); diff --git a/extensions/amp-ad-network-cloudflare-impl/OWNERS b/extensions/amp-ad-network-cloudflare-impl/OWNERS deleted file mode 100644 index adea4f475ee97..0000000000000 --- a/extensions/amp-ad-network-cloudflare-impl/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -// For an explanation of the OWNERS rules and syntax, see: -// https://github.com/ampproject/amp-github-apps/blob/master/owners/OWNERS.example - -{ - rules: [ - { - owners: [{name: 'oliy'}], - }, - ], -} diff --git a/extensions/amp-ad-network-cloudflare-impl/amp-ad-network-cloudflare-impl-internal.md b/extensions/amp-ad-network-cloudflare-impl/amp-ad-network-cloudflare-impl-internal.md deleted file mode 100644 index 86b5e8d7f473d..0000000000000 --- a/extensions/amp-ad-network-cloudflare-impl/amp-ad-network-cloudflare-impl-internal.md +++ /dev/null @@ -1,75 +0,0 @@ - - -### `amp-ad-network-cloudflare-impl` - - - - - - - - - - - - - - -
DescriptionCloudflare implementation of AMP Ad tag which integrates with - Cloudflare's transparent creative signing. Cloudflare based Ad networks - can use this tag to have publishers point to signed AMP creatives on the - Ad network. -
AvailabilityIn Development
Required Script<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
- -#### Examples - -Example - Simple Ad - -```html - - -``` - -Example - Ad with additional parameters and replacements - -```html - - -``` - -#### Attributes - -- data-cf-network - ad network to use (contact Cloudflare to integrate new ones) -- data-cf-a4a - disables Fast-Fetch Amp4Ads when false (still displays ad) -- src - Path to the ad creative on a Ad network (can use the following replacement tokens) - - SLOT_WIDTH - width of the target slot - - SLOT_HEIGHT - height of the target slot -- data- - additional query parameters to the URL diff --git a/extensions/amp-ad-network-gmossp-impl/0.1/amp-ad-network-gmossp-impl.js b/extensions/amp-ad-network-gmossp-impl/0.1/amp-ad-network-gmossp-impl.js deleted file mode 100644 index 71a1f74fe9204..0000000000000 --- a/extensions/amp-ad-network-gmossp-impl/0.1/amp-ad-network-gmossp-impl.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright 2016 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {AmpA4A} from '../../amp-a4a/0.1/amp-a4a'; -import {startsWith} from '../../../src/string'; - -/** - * GMOSSP base URL - * - * @type {string} - * @private - */ -const GMOSSP_BASE_URL_ = 'https://sp.gmossp-sp.jp/'; - -/** - * GMOSSP A4A base URL - * - * @type {string} - * @private - */ -const GMOSSP_BASE_A4A_URL_ = 'https://amp.sp.gmossp-sp.jp/_a4a/'; - -/** - * This is a minimalistic AmpA4A implementation that primarily gets an Ad - * through a source URL and extracts the generated signature - * from a HTTP header. This is then given to A4A to validate against - * the cloudflare signing key. - */ -export class AmpAdNetworkGmosspImpl extends AmpA4A { - /** @override */ - isValidElement() { - const src = this.element.getAttribute('src') || ''; - return ( - this.isAmpAdElement() && - (startsWith(src, GMOSSP_BASE_URL_) || - startsWith(src, GMOSSP_BASE_A4A_URL_)) - ); - } - - /** @override */ - getSigningServiceNames() { - return ['cloudflare']; - } - - /** @override */ - getAdUrl() { - return this.element - .getAttribute('src') - .replace(GMOSSP_BASE_URL_, GMOSSP_BASE_A4A_URL_); - } -} - -AMP.extension('amp-ad-network-gmossp-impl', '0.1', AMP => { - AMP.registerElement('amp-ad-network-gmossp-impl', AmpAdNetworkGmosspImpl); -}); diff --git a/extensions/amp-ad-network-gmossp-impl/0.1/gmossp-a4a-config.js b/extensions/amp-ad-network-gmossp-impl/0.1/gmossp-a4a-config.js deleted file mode 100644 index 9a9ba60937d05..0000000000000 --- a/extensions/amp-ad-network-gmossp-impl/0.1/gmossp-a4a-config.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2017 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {startsWith} from '../../../src/string'; - -/** @const @private {string} */ -const GMOSSP_SRC_PREFIX_ = 'https://sp.gmossp-sp.jp/'; - -/** @const @private {string} */ -const GMOSSP_SRC_A4A_PREFIX_ = 'https://amp.sp.gmossp-sp.jp/_a4a/'; - -/** - * @param {!Window} win - * @param {!Element} element - * @param {boolean} useRemoteHtml - * @return {boolean} - */ -export function gmosspIsA4AEnabled(win, element, useRemoteHtml) { - let src; - return ( - !useRemoteHtml && - !!(src = element.getAttribute('src')) && - !!element.getAttribute('data-use-a4a') && - (startsWith(src, GMOSSP_SRC_PREFIX_) || - startsWith(src, GMOSSP_SRC_A4A_PREFIX_)) - ); -} diff --git a/extensions/amp-ad-network-gmossp-impl/0.1/test/test-amp-ad-network-gmossp-impl.js b/extensions/amp-ad-network-gmossp-impl/0.1/test/test-amp-ad-network-gmossp-impl.js deleted file mode 100644 index 2a085991cdfc7..0000000000000 --- a/extensions/amp-ad-network-gmossp-impl/0.1/test/test-amp-ad-network-gmossp-impl.js +++ /dev/null @@ -1,147 +0,0 @@ -/** - * Copyright 2016 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {AmpAdNetworkGmosspImpl} from '../amp-ad-network-gmossp-impl'; -import { - AmpAdUIHandler, // eslint-disable-line no-unused-vars -} from '../../../amp-ad/0.1/amp-ad-ui'; -import { - AmpAdXOriginIframeHandler, // eslint-disable-line no-unused-vars -} from '../../../amp-ad/0.1/amp-ad-xorigin-iframe-handler'; -import {createElementWithAttributes} from '../../../../src/dom'; -import {gmosspIsA4AEnabled} from '../gmossp-a4a-config'; - -describes.realWin('gmossp-a4a-config', {amp: false}, env => { - let doc; - let win; - beforeEach(() => { - win = env.win; - doc = win.document; - }); - it('should pass a4a config predicate', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: 'https://sp.gmossp-sp.jp/ads/ssp.ad?space_id=33303&is_a4a=1', - 'data-use-a4a': 'true', - }); - expect(gmosspIsA4AEnabled(win, element)).to.be.true; - }); - it('should pass a4a config predicate', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: - 'https://amp.sp.gmossp-sp.jp/_a4a/ads/ssp.ad?space_id=33303&is_a4a=1', - 'data-use-a4a': 'true', - }); - expect(gmosspIsA4AEnabled(win, element)).to.be.true; - }); - it('should fail a4a config predicate due to useRemoteHtml', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: - 'https://amp.sp.gmossp-sp.jp/_a4a/ads/ssp.ad?space_id=33303&is_a4a=1', - 'data-use-a4a': 'true', - }); - const useRemoteHtml = true; - expect(gmosspIsA4AEnabled(win, element, useRemoteHtml)).to.be.false; - }); - it('should fail a4a config predicate due to missing use-a4a', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: 'https://sp.gmossp-sp.jp/ads/ssp.ad?space_id=33303&is_a4a=1', - }); - expect(gmosspIsA4AEnabled(win, element)).to.be.false; - }); - it('should fail a4a config predicate due to missing src', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - 'data-use-a4a': 'true', - }); - expect(gmosspIsA4AEnabled(win, element)).to.be.false; - }); - it('should fail a4a config predicate due to invalid src', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: 'https://evil.com?hello=world&https://sp.gmossp-sp.jp', - 'data-use-a4a': 'true', - }); - expect(gmosspIsA4AEnabled(win, element)).to.be.false; - }); -}); - -describes.realWin( - 'amp-ad-network-gmossp-impl', - { - amp: { - extensions: ['amp-ad-network-gmossp-impl'], - }, - }, - env => { - let win, doc; - let gmosspImpl; - let gmosspImplElem; - - beforeEach(() => { - win = env.win; - doc = win.document; - gmosspImplElem = doc.createElement('amp-ad'); - gmosspImplElem.setAttribute('type', 'gmossp'); - gmosspImplElem.setAttribute('data-use-a4a', 'true'); - env.sandbox - .stub(AmpAdNetworkGmosspImpl.prototype, 'getSigningServiceNames') - .callsFake(() => { - return ['google']; - }); - gmosspImpl = new AmpAdNetworkGmosspImpl(gmosspImplElem); - }); - - describe('#isValidElement', () => { - it('should be valid', () => { - gmosspImplElem.setAttribute( - 'src', - 'https://amp.sp.gmossp-sp.jp/_a4a/ads/ssp.ad?space_id=33303&is_a4a=1' - ); - expect(gmosspImpl.isValidElement()).to.be.true; - }); - it('should be valid', () => { - gmosspImplElem.setAttribute( - 'src', - 'https://sp.gmossp-sp.jp/ads/ssp.ad?space_id=33303&is_a4a=1' - ); - expect(gmosspImpl.isValidElement()).to.be.true; - }); - it('should NOT be valid (impl tag name)', () => { - gmosspImplElem = doc.createElement('amp-ad-network-gmossp-impl'); - gmosspImplElem.setAttribute('type', 'gmossp'); - gmosspImpl = new AmpAdNetworkGmosspImpl(gmosspImplElem); - expect(gmosspImpl.isValidElement()).to.be.false; - }); - }); - - describe('#getAdUrl', () => { - it('should be valid', () => { - gmosspImplElem.setAttribute( - 'src', - 'https://amp.sp.gmossp-sp.jp/_a4a/ads/ssp.ad?space_id=33303&is_a4a=1' - ); - const base = 'https://amp.sp.gmossp-sp.jp/_a4a/ads/ssp.ad?'; - expect(gmosspImpl.getAdUrl().substring(0, base.length)).to.equal(base); - }); - it('should be valid', () => { - gmosspImplElem.setAttribute( - 'src', - 'https://sp.gmossp-sp.jp/ads/ssp.ad?space_id=33303&is_a4a=1' - ); - const base = 'https://amp.sp.gmossp-sp.jp/_a4a/ads/ssp.ad?'; - expect(gmosspImpl.getAdUrl().substring(0, base.length)).to.equal(base); - }); - }); - } -); diff --git a/extensions/amp-ad-network-gmossp-impl/OWNERS b/extensions/amp-ad-network-gmossp-impl/OWNERS deleted file mode 100644 index 9cc48924e3979..0000000000000 --- a/extensions/amp-ad-network-gmossp-impl/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -// For an explanation of the OWNERS rules and syntax, see: -// https://github.com/ampproject/amp-github-apps/blob/master/owners/OWNERS.example - -{ - rules: [ - { - owners: [{name: 'ampproject/wg-ads'}], - }, - ], -} diff --git a/extensions/amp-ad-network-gmossp-impl/amp-ad-network-gmossp-impl-internal.md b/extensions/amp-ad-network-gmossp-impl/amp-ad-network-gmossp-impl-internal.md deleted file mode 100644 index 19cad9a2f99b3..0000000000000 --- a/extensions/amp-ad-network-gmossp-impl/amp-ad-network-gmossp-impl-internal.md +++ /dev/null @@ -1,57 +0,0 @@ - - -# amp-ad-network-gmossp-impl - -GMOSSP implementation of AMP Ad tag which requests early by XHR and renders natively within the page if a valid AMP Ad is returned. Should not be directly referenced by pages and instead is dynamically loaded via the amp-ad tag. However, in order to remove an async script load of this library, publishers can include its script declaration. - - - - - - - - - - -
AvailabilityIn Development
Required Script<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
- -## Example - -```html - - -``` - -## Attributes - -GMOSSP impl uses the same tags as ``. - - - - - - -
data-use-a4aIf non-empty, GMOSSP will attempt to render via the A4A - pathway (i.e., fast rendering for AMP creatives). Otherwise, it will attempt - to render via the delayed iframe path.
diff --git a/extensions/amp-ad-network-mytarget-impl/0.1/amp-ad-network-mytarget-impl.js b/extensions/amp-ad-network-mytarget-impl/0.1/amp-ad-network-mytarget-impl.js deleted file mode 100644 index b3ef717c9eaca..0000000000000 --- a/extensions/amp-ad-network-mytarget-impl/0.1/amp-ad-network-mytarget-impl.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright 2019 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {AmpA4A, XORIGIN_MODE} from '../../amp-a4a/0.1/amp-a4a'; -import { - addParamToUrl, - addParamsToUrl, - parseQueryString, -} from '../../../src/url'; - -/** - * myTarget base URL - * - * @type {string} - * @private - */ -const MYTARGET_BASE_URL_ = 'https://ad.mail.ru/adp/'; - -/** - * This is a minimalistic AmpA4A implementation that primarily gets an Ad - * through a source URL and parse HTML markup from json response. - * This is then given to A4A to render via crossdomain frame. - */ -export class AmpAdNetworkMyTargetImpl extends AmpA4A { - /** @override */ - isValidElement() { - return this.isAmpAdElement(); - } - - /** @override */ - getAdUrl() { - const slot = this.element.getAttribute('data-ad-slot'); - const query = this.element.getAttribute('data-ad-query'); - - let url = addParamToUrl(MYTARGET_BASE_URL_, 'q', slot); - - // Additionally encode optional parameters - if (query) { - const queryMap = parseQueryString(query); - url = addParamsToUrl(url, queryMap); - } - - return url; - } - - /** @override */ - getNonAmpCreativeRenderingMethod() { - return XORIGIN_MODE.NAMEFRAME; - } - - /** @override */ - sendXhrRequest(adUrl) { - return super.sendXhrRequest(adUrl).then(response => { - if (!response) { - return null; - } - - const { - status, - headers, - } = /** @type {{status: number, headers: !Headers}} */ (response); - - return response - .json() - .then(responseJson => { - const creativeBody = - responseJson && - responseJson[0] && - responseJson[0].html && - responseJson[0].html.trim(); - - return creativeBody - ? new Response(creativeBody, {status, headers}) - : null; - }) - .catch(() => null); - }); - } - - /** @override */ - onNetworkFailure() { - return {frameGetDisabled: true}; - } -} - -AMP.extension('amp-ad-network-mytarget-impl', '0.1', AMP => { - AMP.registerElement('amp-ad-network-mytarget-impl', AmpAdNetworkMyTargetImpl); -}); diff --git a/extensions/amp-ad-network-mytarget-impl/0.1/mytarget-a4a-config.js b/extensions/amp-ad-network-mytarget-impl/0.1/mytarget-a4a-config.js deleted file mode 100644 index c787874923501..0000000000000 --- a/extensions/amp-ad-network-mytarget-impl/0.1/mytarget-a4a-config.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright 2019 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @param {!Window} win - * @param {!Element} element - * @param {boolean} useRemoteHtml - * @return {boolean} - */ -export function myTargetIsA4AEnabled(win, element, useRemoteHtml) { - return ( - !useRemoteHtml && - !!element.getAttribute('data-use-a4a') && - !!element.getAttribute('data-ad-slot') - ); -} diff --git a/extensions/amp-ad-network-mytarget-impl/0.1/test/test-amp-ad-network-mytarget-impl.js b/extensions/amp-ad-network-mytarget-impl/0.1/test/test-amp-ad-network-mytarget-impl.js deleted file mode 100644 index 97d3ce47fc0bf..0000000000000 --- a/extensions/amp-ad-network-mytarget-impl/0.1/test/test-amp-ad-network-mytarget-impl.js +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Copyright 2019 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {AmpAdNetworkMyTargetImpl} from '../amp-ad-network-mytarget-impl'; -import { - AmpAdUIHandler, // eslint-disable-line no-unused-vars -} from '../../../amp-ad/0.1/amp-ad-ui'; -import { - AmpAdXOriginIframeHandler, // eslint-disable-line no-unused-vars -} from '../../../amp-ad/0.1/amp-ad-xorigin-iframe-handler'; -import {createElementWithAttributes} from '../../../../src/dom'; -import {myTargetIsA4AEnabled} from '../mytarget-a4a-config'; - -describes.realWin('mytarget-a4a-config', {amp: false}, env => { - let doc; - let win; - beforeEach(() => { - win = env.win; - doc = win.document; - }); - it('should pass a4a config predicate', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - 'data-ad-slot': '197378', - 'data-use-a4a': 'true', - }); - expect(myTargetIsA4AEnabled(win, element)).to.be.true; - }); - it('should fail a4a config predicate due to useRemoteHtml', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - 'data-ad-slot': '197378', - 'data-use-a4a': 'true', - }); - const useRemoteHtml = true; - expect(myTargetIsA4AEnabled(win, element, useRemoteHtml)).to.be.false; - }); - it('should fail a4a config predicate due to missing use-a4a', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - 'data-ad-slot': '197378', - }); - expect(myTargetIsA4AEnabled(win, element)).to.be.false; - }); - it('should fail a4a config predicate due to missing data-ad-slot', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - 'data-use-a4a': 'true', - }); - expect(myTargetIsA4AEnabled(win, element)).to.be.false; - }); - it('should fail a4a config predicate due to empty data-ad-slot', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - 'data-ad-slot': '', - 'data-use-a4a': 'true', - }); - expect(myTargetIsA4AEnabled(win, element)).to.be.false; - }); -}); - -describes.realWin( - 'amp-ad-network-mytarget-impl', - { - amp: { - extensions: ['amp-ad-network-mytarget-impl'], - }, - }, - env => { - let win, doc; - let mytargetImpl; - let mytargetImplElem; - - beforeEach(() => { - win = env.win; - doc = win.document; - mytargetImplElem = doc.createElement('amp-ad'); - mytargetImplElem.setAttribute('type', 'mytarget'); - mytargetImplElem.setAttribute('data-ad-slot', '197378'); - mytargetImplElem.setAttribute('data-use-a4a', 'true'); - env.sandbox - .stub(AmpAdNetworkMyTargetImpl.prototype, 'getSigningServiceNames') - .callsFake(() => { - return ['cloudflare']; - }); - mytargetImpl = new AmpAdNetworkMyTargetImpl(mytargetImplElem); - }); - - describe('#isValidElement', () => { - it('should be valid', () => { - expect(mytargetImpl.isValidElement()).to.be.true; - }); - it('should NOT be valid (impl tag name)', () => { - mytargetImplElem = doc.createElement('amp-ad-network-mytarget-impl'); - mytargetImplElem.setAttribute('type', 'triplelift'); - mytargetImpl = new AmpAdNetworkMyTargetImpl(mytargetImplElem); - expect(mytargetImpl.isValidElement()).to.be.false; - }); - }); - - describe('#getRenderingMethod', () => { - it('should be equal to "nameframe"', () => { - expect(mytargetImpl.getNonAmpCreativeRenderingMethod()).to.equal( - 'nameframe' - ); - }); - }); - - describe('#getAdUrl', () => { - it('should be valid', () => { - expect(mytargetImpl.getAdUrl()).to.equal( - 'https://ad.mail.ru/adp/?q=197378' - ); - }); - }); - - describe('#getAdUrl with query parameters', () => { - it('should add query parameters', () => { - mytargetImplElem.setAttribute('data-ad-query', 'preview=1'); - mytargetImpl = new AmpAdNetworkMyTargetImpl(mytargetImplElem); - expect(mytargetImpl.getAdUrl()).to.equal( - 'https://ad.mail.ru/adp/?q=197378&preview=1' - ); - }); - - it('should encode query parameters', () => { - mytargetImplElem.setAttribute( - 'data-ad-query', - 'preview=1&test=foo|bar' - ); - mytargetImpl = new AmpAdNetworkMyTargetImpl(mytargetImplElem); - expect(mytargetImpl.getAdUrl()).to.equal( - 'https://ad.mail.ru/adp/?q=197378&preview=1&test=foo%7Cbar' - ); - }); - }); - } -); diff --git a/extensions/amp-ad-network-mytarget-impl/OWNERS b/extensions/amp-ad-network-mytarget-impl/OWNERS deleted file mode 100644 index 095a47d58d7df..0000000000000 --- a/extensions/amp-ad-network-mytarget-impl/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -// For an explanation of the OWNERS rules and syntax, see: -// https://github.com/ampproject/amp-github-apps/blob/master/owners/OWNERS.example - -{ - rules: [ - { - owners: [{name: 'ampproject/wg-ads'}, {name: 'vfedoseev'}], - }, - ], -} diff --git a/extensions/amp-ad-network-mytarget-impl/amp-ad-network-mytarget-impl-internal.md b/extensions/amp-ad-network-mytarget-impl/amp-ad-network-mytarget-impl-internal.md deleted file mode 100644 index 74434183c538c..0000000000000 --- a/extensions/amp-ad-network-mytarget-impl/amp-ad-network-mytarget-impl-internal.md +++ /dev/null @@ -1,66 +0,0 @@ - - -# myTarget Ad Network - -### amp-ad-network-mytarget-impl - -myTarget implementation of AMP Ad tag which requests early by XHR and renders natively within the page if a valid AMP Ad is returned. Should not be directly referenced by pages and instead is dynamically loaded via the amp-ad tag. However, in order to remove an async script load of this library, publishers can include its script declaration. - - - - - - - - - - -
AvailabilityIn Development
Required Script<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
- -## Example - -```html - - -``` - -## Attributes - -myTarget impl uses the same tags as ``. - - - - - - - - - - - - - - -
data-use-a4aIf non-empty, myTarget will attempt to render via the A4A - pathway (i.e., fast rendering for AMP creatives). Otherwise, it will attempt - to render via the delayed iframe path.
data-ad-slotMy target AdSlot ID
data-ad-queryOptional Ad query
diff --git a/extensions/amp-ad-network-triplelift-impl/0.1/amp-ad-network-triplelift-impl.js b/extensions/amp-ad-network-triplelift-impl/0.1/amp-ad-network-triplelift-impl.js deleted file mode 100644 index 10293f73d09fd..0000000000000 --- a/extensions/amp-ad-network-triplelift-impl/0.1/amp-ad-network-triplelift-impl.js +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2016 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {AmpA4A} from '../../amp-a4a/0.1/amp-a4a'; - -/** - * TripleLift base URL - * - * @type {string} - * @private - */ -const TRIPLELIFT_BASE_URL_ = 'ib.3lift.com/ttj'; - -/** - * TripleLift A4A base URL - * - * @type {string} - * @private - */ -const TRIPLELIFT_BASE_A4A_URL_ = 'amp.3lift.com/_a4a/amp/auction'; - -/** - * This is a minimalistic AmpA4A implementation that primarily gets an Ad - * through a source URL and extracts the generated signature - * from a HTTP header. This is then given to A4A to validate against - * the cloudflare signing key. - */ -export class AmpAdNetworkTripleliftImpl extends AmpA4A { - /** @override */ - isValidElement() { - return this.isAmpAdElement(); - } - - /** @override */ - getSigningServiceNames() { - return ['cloudflare']; - } - - /** @override */ - getAdUrl() { - return this.element - .getAttribute('src') - .replace(TRIPLELIFT_BASE_URL_, TRIPLELIFT_BASE_A4A_URL_); - } -} - -AMP.extension('amp-ad-network-triplelift-impl', '0.1', AMP => { - AMP.registerElement( - 'amp-ad-network-triplelift-impl', - AmpAdNetworkTripleliftImpl - ); -}); diff --git a/extensions/amp-ad-network-triplelift-impl/0.1/test/test-amp-ad-network-triplelift-impl.js b/extensions/amp-ad-network-triplelift-impl/0.1/test/test-amp-ad-network-triplelift-impl.js deleted file mode 100644 index 751c27e452f43..0000000000000 --- a/extensions/amp-ad-network-triplelift-impl/0.1/test/test-amp-ad-network-triplelift-impl.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright 2016 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {AmpAdNetworkTripleliftImpl} from '../amp-ad-network-triplelift-impl'; -import { - AmpAdUIHandler, // eslint-disable-line no-unused-vars -} from '../../../amp-ad/0.1/amp-ad-ui'; -import { - AmpAdXOriginIframeHandler, // eslint-disable-line no-unused-vars -} from '../../../amp-ad/0.1/amp-ad-xorigin-iframe-handler'; -import {createElementWithAttributes} from '../../../../src/dom'; -import {tripleliftIsA4AEnabled} from '../triplelift-a4a-config'; - -describes.realWin('triplelift-a4a-config', {amp: false}, env => { - let doc; - let win; - beforeEach(() => { - win = env.win; - doc = win.document; - }); - it('should pass a4a config predicate', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: 'https://ib.3lift.com/ttj?inv_code=ampforadstest_main_feed', - 'data-use-a4a': 'true', - }); - expect(tripleliftIsA4AEnabled(win, element)).to.be.true; - }); - it('should fail a4a config predicate due to useRemoteHtml', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: 'https://ib.3lift.com/ttj?inv_code=ampforadstest_main_feed', - 'data-use-a4a': 'true', - }); - const useRemoteHtml = true; - expect(tripleliftIsA4AEnabled(win, element, useRemoteHtml)).to.be.false; - }); - it('should fail a4a config predicate due to missing use-a4a', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: 'https://ib.3lift.com/ttj?inv_code=ampforadstest_main_feed', - }); - expect(tripleliftIsA4AEnabled(win, element)).to.be.false; - }); - it('should fail a4a config predicate due to missing src', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - 'data-use-a4a': 'true', - }); - expect(tripleliftIsA4AEnabled(win, element)).to.be.false; - }); - it('should fail a4a config predicate due to invalid src', () => { - const element = createElementWithAttributes(doc, 'amp-ad', { - src: 'https://evil.com?hello=world&https://ib.3lift.com', - 'data-use-a4a': 'true', - }); - expect(tripleliftIsA4AEnabled(win, element)).to.be.false; - }); -}); - -describes.realWin( - 'amp-ad-network-triplelift-impl', - { - amp: { - extensions: ['amp-ad-network-triplelift-impl'], - }, - }, - env => { - let win, doc; - let tripleliftImpl; - let tripleliftImplElem; - - beforeEach(() => { - win = env.win; - doc = win.document; - tripleliftImplElem = doc.createElement('amp-ad'); - tripleliftImplElem.setAttribute('type', 'triplelift'); - tripleliftImplElem.setAttribute( - 'src', - 'https://ib.3lift.com/ttj?inv_code=ampforadstest_main_feed' - ); - tripleliftImplElem.setAttribute('data-use-a4a', 'true'); - env.sandbox - .stub(AmpAdNetworkTripleliftImpl.prototype, 'getSigningServiceNames') - .callsFake(() => { - return ['cloudflare']; - }); - tripleliftImpl = new AmpAdNetworkTripleliftImpl(tripleliftImplElem); - }); - - describe('#isValidElement', () => { - it('should be valid', () => { - expect(tripleliftImpl.isValidElement()).to.be.true; - }); - it('should NOT be valid (impl tag name)', () => { - tripleliftImplElem = doc.createElement( - 'amp-ad-network-triplelift-impl' - ); - tripleliftImplElem.setAttribute('type', 'triplelift'); - tripleliftImpl = new AmpAdNetworkTripleliftImpl(tripleliftImplElem); - expect(tripleliftImpl.isValidElement()).to.be.false; - }); - }); - - describe('#getAdUrl', () => { - it('should be valid', () => { - expect(tripleliftImpl.getAdUrl()).to.equal( - 'https://amp.3lift.com/_a4a/amp/auction?inv_code=ampforadstest_main_feed' - ); - }); - }); - } -); diff --git a/extensions/amp-ad-network-triplelift-impl/0.1/triplelift-a4a-config.js b/extensions/amp-ad-network-triplelift-impl/0.1/triplelift-a4a-config.js deleted file mode 100644 index faebfda22154c..0000000000000 --- a/extensions/amp-ad-network-triplelift-impl/0.1/triplelift-a4a-config.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2016 The AMP HTML Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS-IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** @const @private {string} */ -const SRC_PREFIX_ = 'https://ib.3lift.com/'; -/** - * @param {!Window} win - * @param {!Element} element - * @param {boolean} useRemoteHtml - * @return {boolean} - */ -export function tripleliftIsA4AEnabled(win, element, useRemoteHtml) { - let src; - return ( - !useRemoteHtml && - !!element.getAttribute('data-use-a4a') && - !!(src = element.getAttribute('src')) && - src.indexOf(SRC_PREFIX_) == 0 - ); -} diff --git a/extensions/amp-ad-network-triplelift-impl/OWNERS b/extensions/amp-ad-network-triplelift-impl/OWNERS deleted file mode 100644 index 38bf0b8c9ab72..0000000000000 --- a/extensions/amp-ad-network-triplelift-impl/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -// For an explanation of the OWNERS rules and syntax, see: -// https://github.com/ampproject/amp-github-apps/blob/master/owners/OWNERS.example - -{ - rules: [ - { - owners: [{name: 'ampproject/wg-ads'}, {name: 'szach'}], - }, - ], -} diff --git a/spec/amp-cache-guidelines.md b/spec/amp-cache-guidelines.md index 5570214ded84a..4197b8d7bd2f7 100644 --- a/spec/amp-cache-guidelines.md +++ b/spec/amp-cache-guidelines.md @@ -105,7 +105,6 @@ For resources (i.e., HTML, images, fonts) that are larger than 12 MB, you may no ## References -- [Cloudflare AMP Cache](https://amp.cloudflare.com/) - [Bing AMP Cache](https://www.bing.com/webmaster/help/bing-amp-cache-bc1c884c) - [Bing AMP Cache announcement](https://blogs.bing.com/Webmaster-Blog/September-2018/Introducing-Bing-AMP-viewer-and-Bing-AMP-cache) - [Google AMP Cache](https://developers.google.com/amp/cache/) diff --git a/spec/amp-cors-requests.md b/spec/amp-cors-requests.md index 5b9e757aaaf19..4be2ad783ac50 100644 --- a/spec/amp-cors-requests.md +++ b/spec/amp-cors-requests.md @@ -143,13 +143,11 @@ Endpoints should only allow requests from: (1) the publisher's own origin; and For example, endpoints should allow requests from: - Google AMP Cache subdomain: `https://.cdn.ampproject.org`
(for example, `https://nytimes-com.cdn.ampproject.org`) -- Cloudflare AMP Cache: `https://.amp.cloudflare.com` {% call callout('Read on', type='read') %} For information on AMP Cache URL formats, see these resources: - [Google AMP Cache Overview](https://developers.google.com/amp/cache/overview) -- [Cloudflare AMP Cache](https://amp.cloudflare.com/) {% endcall %} #### 2) Allow same-origin requests @@ -195,7 +193,6 @@ following: response: - `.cdn.ampproject.org` - - `.amp.cloudflare.com` - the publisher's origin (aka yours) where `*` represents a wildcard match, and not an actual asterisk ( \* ). @@ -229,7 +226,6 @@ Based on what we know about CORS and AMP (from [Verify CORS requests](#verify-co - `example.com` --- Publisher's domain - `example-com.cdn.ampproject.org` --- Google AMP Cache subdomain -- `example.com.amp.cloudflare.com`--- Cloudflare AMP Cache subdomain ### Response headers for allowed requests @@ -276,7 +272,6 @@ function assertCors(req, res, opt_validMethods, opt_exposeHeaders) { var allowedOrigins = [ 'https://example.com', 'https://example-com.cdn.ampproject.org', - 'https://example.com.amp.cloudflare.com', 'https://cdn.ampproject.org', ]; var allowedSourceOrigin = 'https://example.com'; //publisher's origin diff --git a/test/size.txt b/test/size.txt index 5bc07d69406a9..0fc0ef29409b7 100644 --- a/test/size.txt +++ b/test/size.txt @@ -18,11 +18,8 @@ 367 kB | 12.1 kB | 4.88 kB | v0/amp-ad-exit-0.1.js 926 kB | 70.9 kB | 24.8 kB | v0/amp-ad-network-adsense-impl-0.1.js 848 kB | 52.6 kB | 18.5 kB | v0/amp-ad-network-adzerk-impl-0.1.js - 832 kB | 51.5 kB | 18.3 kB | v0/amp-ad-network-cloudflare-impl-0.1.js 1.12 MB | 102 kB | 34.8 kB | v0/amp-ad-network-doubleclick-impl-0.1.js 832 kB | 51.6 kB | 18.3 kB | v0/amp-ad-network-fake-impl-0.1.js - 828 kB | 50.4 kB | 17.9 kB | v0/amp-ad-network-gmossp-impl-0.1.js - 828 kB | 50.2 kB | 17.9 kB | v0/amp-ad-network-triplelift-impl-0.1.js 433 kB | 18.2 kB | 7.32 kB | v0/amp-addthis-0.1.js 969 kB | 107 kB | 33.4 kB | v0/amp-analytics-0.1.js 112 kB | 4.08 kB | 1.99 kB | v0/amp-anim-0.1.js @@ -117,4 +114,4 @@ 618 kB | 52.3 kB | 16.5 kB | v0/amp-youtube-0.1.js 165 kB | 11.4 kB | 4.35 kB | current-min/ampcontext-v0.js / current/ampcontext-lib.js 670 kB | 136 kB | 44.1 kB | current-min/f.js / current/integration.js - 112 kB | 7.97 kB | 3.13 kB | current-min/iframe-transport-client-v0.js / current/iframe-transport-client-lib.js \ No newline at end of file + 112 kB | 7.97 kB | 3.13 kB | current-min/iframe-transport-client-v0.js / current/iframe-transport-client-lib.js diff --git a/validator/engine/validator-in-browser.js b/validator/engine/validator-in-browser.js index 3b84e4e6a437f..a688faf91a709 100644 --- a/validator/engine/validator-in-browser.js +++ b/validator/engine/validator-in-browser.js @@ -51,9 +51,7 @@ function getUrl(url) { * @return {boolean} */ amp.validator.isAmpCacheUrl = function(url) { - return ( - url.toLowerCase().indexOf('cdn.ampproject.org') !== -1 || // lgtm [js/incomplete-url-substring-sanitization] - url.toLowerCase().indexOf('amp.cloudflare.com') !== -1); // lgtm [js/incomplete-url-substring-sanitization] + return url.toLowerCase().indexOf('cdn.ampproject.org') !== -1; // lgtm [js/incomplete-url-substring-sanitization] }; /**