Skip to content

Commit

Permalink
Merge branch 'master' into highlightcolor
Browse files Browse the repository at this point in the history
  • Loading branch information
yunabe committed Dec 10, 2018
2 parents d668d33 + 08d876d commit 788d92d
Show file tree
Hide file tree
Showing 154 changed files with 4,008 additions and 1,176 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -63,7 +63,7 @@
"amphtml-internal/no-is-amp-alt": 2,
"amphtml-internal/no-mixed-operators": 2,
"amphtml-internal/no-module-exports": 2,
"amphtml-internal/no-non-string-log-args": 1,
"amphtml-internal/no-non-string-log-args": 0,
"amphtml-internal/no-spread": 2,
"amphtml-internal/no-style-display": 2,
"amphtml-internal/no-style-property-setting": 2,
Expand Down
13 changes: 10 additions & 3 deletions 3p/README.md
Expand Up @@ -21,7 +21,7 @@ Examples: Youtube, Vimeo videos; Tweets, Instagrams; comment systems; polls; qui
- All JS on container page must be open source and bundled with AMP.
- JavaScript loaded into iframe should be reasonable with respect to functionality.
- Use the `sandbox` attribute on iframe if possible.
- Provide unit and integration tests.
- Provide unit and [integration tests](#adding-proper-integration-tests).
- Embeds that require browser plugins, such as Flash, Java, ActiveX, Silverlight, etc. are disallowed unless necessary. Special review required. We cannot currently see a reason why these should be allowed.

## Ads
Expand All @@ -34,7 +34,7 @@ Examples: Youtube, Vimeo videos; Tweets, Instagrams; comment systems; polls; qui
- Support viewability and other metrics/instrumentation as supplied by AMP (via postMessage API)
- Try to keep overall iframe count at one per ad. Explain why more are needed.
- Share JS between iframes on the same page.
- Provide unit and integration tests.
- Provide unit and [integration tests](#adding-proper-integration-tests).
- Provide test accounts for inclusion in our open source repository for integration tests.

The following aren't hard requirements, but are performance optimizations we should strive to incorporate. Please provide a timeline as to when you expect to follow these guidelines:
Expand All @@ -59,4 +59,11 @@ 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 [`<amp-font>`](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` and `https://amp.cloudflare.com`.

# Adding proper integration tests
You should ensure there are integration tests for your extension. These should be added to the AMP
repo where it makes sense. In some cases this won't be possible because it relies on bringing up
third-party infrastructure. In these cases you should maintain testing for the extension on your
infrastructure against both production AMP and [canary](https://github.com/ampproject/amphtml/blob/master/contributing/release-schedule.md#amp-dev-channel).
Upon any monitored failures, an escalation can be raised in [regular AMP communication channel](https://github.com/ampproject/amphtml/blob/master/CONTRIBUTING.md#discussion-channels).
4 changes: 4 additions & 0 deletions 3p/integration.js
Expand Up @@ -112,6 +112,7 @@ import {amoad} from '../ads/amoad';
import {appnexus} from '../ads/appnexus';
import {appvador} from '../ads/appvador';
import {atomx} from '../ads/atomx';
import {baidu} from '../ads/baidu';
import {bidtellect} from '../ads/bidtellect';
import {brainy} from '../ads/brainy';
import {bringhub} from '../ads/bringhub';
Expand Down Expand Up @@ -141,6 +142,7 @@ import {f1h} from '../ads/f1h';
import {felmat} from '../ads/felmat';
import {flite} from '../ads/flite';
import {fluct} from '../ads/fluct';
import {freewheel} from '../ads/freewheel';
import {fusion} from '../ads/fusion';
import {genieessp} from '../ads/genieessp';
import {giraff} from '../ads/giraff';
Expand Down Expand Up @@ -329,6 +331,7 @@ register('amoad', amoad);
register('appnexus', appnexus);
register('appvador', appvador);
register('atomx', atomx);
register('baidu', baidu);
register('beopinion', beopinion);
register('bidtellect', bidtellect);
register('bodymovinanimation', bodymovinanimation);
Expand Down Expand Up @@ -362,6 +365,7 @@ register('facebook', facebook);
register('felmat', felmat);
register('flite', flite);
register('fluct', fluct);
register('freewheel', freewheel);
register('fusion', fusion);
register('genieessp', genieessp);
register('giraff', giraff);
Expand Down
1 change: 1 addition & 0 deletions ads/README.md
Expand Up @@ -351,6 +351,7 @@ To speed up the review process, please run `gulp lint` and `gulp check-types`, t

### Other tips

- It's highly recommended to maintain [an integration test outside AMP repo](../3p/README.md#adding-proper-integration-tests).
- Please consider implementing the `render-start` and `no-content-available` APIs (see [Available APIs](#available-apis)), which helps AMP to provide user a much better ad loading experience.
- [CLA](../CONTRIBUTING.md#contributing-code): for anyone who has trouble to pass the automatic CLA check in a pull request, try to follow the guidelines provided by the CLA Bot. Common mistakes are:
1. Using a different email address in the git commit.
Expand Down
10 changes: 10 additions & 0 deletions ads/_config.js
Expand Up @@ -461,6 +461,11 @@ export const adConfig = {
],
},

'freewheel': {
prefetch: 'https://cdn.stickyadstv.com/prime-time/fw-amp.min.js',
renderStartImplemented: true,
},

'fusion': {
prefetch: 'https://assets.adtomafusion.net/fusion/latest/fusion-amp.min.js',
},
Expand Down Expand Up @@ -1068,4 +1073,9 @@ export const adConfig = {
],
},

'baidu': {
prefetch: 'https://dup.baidustatic.com/js/dm.js',
renderStartImplemented: true,
},

};
58 changes: 58 additions & 0 deletions ads/baidu.js
@@ -0,0 +1,58 @@
/**
* 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.
*/

import {
loadScript,
validateData,
} from '../3p/3p';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function baidu(global, data) {
validateData(data, ['cproid']);

const id = '_' + Math.random().toString(36).slice(2);
const container = global.document.createElement('div');
container.id = id;
global.document.getElementById('c').appendChild(container);

global.slotbydup = global.slotbydup || [];
global.slotbydup.push({
id: data['cproid'],
container: id,
display: 'inlay-fix',
async: true,
});

global.addEventListener('message', () => {
global.context.renderStart();
});

loadScript(
global,
'https://dup.baidustatic.com/js/dm.js',
() => {},
() => {
// noContentAvailable should be called,
// if parent iframe receives no message.
// setTimeout can work, but it's not that reliable.
// So, only the faliure of JS loading is dealed with for now.
global.context.noContentAvailable();
}
);
}
34 changes: 34 additions & 0 deletions ads/baidu.md
@@ -0,0 +1,34 @@
<!---
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.
-->

# Baidu

## Example

```html
<amp-ad width="300" height="250"
type="baidu"
data-cproid="{cproid}">
</amp-ad>
```

## Configuration

For additional detials and support, see [baidu ad union website](http://union.baidu.com/product/prod-cpro.html).

### Required Parameters

* `data-cproid` - baidu union ad id
38 changes: 38 additions & 0 deletions ads/freewheel.js
@@ -0,0 +1,38 @@
/**
* Copyright 2018 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 {loadScript, validateData} from '../3p/3p';

/**
* @param {!Window} global
* @param {!Object} data
*/
export function freewheel(global, data) {
/*eslint "google-camelcase/google-camelcase": 0*/
global._freewheel_amp = {
data,
};

validateData(
data,
['zone'],
['zone','gdpr','gdpr_consent','useCMP','zIndex','blurDisplay',
'timeline','soundButton','defaultMute','onOver','closeAction',
'errorAction','pauseRatio','label','vastUrlParams']
);

loadScript(global, 'https://cdn.stickyadstv.com/prime-time/fw-amp.min.js');
}
61 changes: 61 additions & 0 deletions ads/freewheel.md
@@ -0,0 +1,61 @@
<!---
Copyright 2018 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.
-->

# FreeWheel

## Example

### Expand-banner

```html
<amp-ad width="300" height="250"
type="freewheel"
data-zone="2003"
layout="responsive">
</amp-ad>
```

### FloorAd

```html
<amp-sticky-ad layout=”nodisplay”>
<amp-ad width="350" height="150"
type="freewheel"
data-zone="2003">
</amp-ad>
</amp-sticky-ad>
```

## Configuration

For details on the configuration semantics, please contact the FreeWheel support team : clientsidesdk@freewheel.tv

Supported parameters:
All parameters are optional, unless otherwise stated
- `data-zone` [required]
- `data-blurDisplay`
- `data-timeline`
- `data-soundButton`
- `data-defaultMute`
- `data-onOver`
- `data-closeAction`
- `data-errorAction`
- `data-pauseRatio`
- `data-label`
- `data-vastUrlParams`
- `data-gdpr`
- `data-gdpr_consent`
- `data-useCMP`
9 changes: 7 additions & 2 deletions ads/inabox/inabox-messaging-host.js
Expand Up @@ -359,9 +359,14 @@ export class InaboxMessagingHost {
* @private
*/
function canInspectWindow_(win) {
// TODO: this is not reliable. The compiler assumes that property reads are
// side-effect free. The recommended fix is to use goog.reflect.sinkValue
// but since we're not using the closure library I'm not sure how to do this.
// See https://github.com/google/closure-compiler/issues/3156
try {
const unused = !!win.location.href && win['test']; // eslint-disable-line no-unused-vars
return true;
// win['test'] could be truthy but not true the compiler shouldn't be able
// to optimize this check away.
return !!win.location.href && (win['test'] || true);
} catch (unusedErr) { // eslint-disable-line no-unused-vars
return false;
}
Expand Down

0 comments on commit 788d92d

Please sign in to comment.