Skip to content
Merged
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
12 changes: 12 additions & 0 deletions 3p/vendors/neuwo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// src/polyfills.js must be the first import.
import '#3p/polyfills';

import {register} from '#3p/3p';
import {draw3p, init} from '#3p/integration-lib';

import {neuwo} from '#ads/vendors/neuwo';

init(window);
register('neuwo', neuwo);

window.draw3p = draw3p;
4 changes: 4 additions & 0 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,10 @@ const adConfig = jsonConfiguration({
renderStartImplemented: true,
},

'neuwo': {
renderStartImplemented: true,
},

'noddus': {
prefetch: 'https://noddus.com/amp_loader.js',
renderStartImplemented: true,
Expand Down
23 changes: 23 additions & 0 deletions ads/vendors/neuwo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {validateData, writeScript} from '#3p/3p';

/**
* Neuwo Monetisation Platform.
* @param {!Window} global
* @param {!Object} data
*/
export function neuwo(global, data) {
validateData(data, ['scriptid'], []);

// The Neuwo SDK dispatches these custom events on the 3p-iframe window when a
// placement renders (fill) or has no fill. Bridge them to the AMP ad
// lifecycle so AMP can start rendering / fall back to the next slot.
global.addEventListener('neuwoAdRender', () => global.context.renderStart());
global.addEventListener('neuwoAdNoFill', () =>
global.context.noContentAvailable()
);

writeScript(
global,
'https://ads.neuwo.ai/loader/neuwo-ad.js?staticTagId=' + data['scriptid']
);
}
19 changes: 19 additions & 0 deletions ads/vendors/neuwo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Neuwo

Neuwo Monetisation Platform.

## Example

```html
<amp-ad width="300" height="250" type="neuwo" data-scriptid="91"> </amp-ad>
```

## Configuration

You need to get a `scriptid` (static tag ID) from your Neuwo account manager.

For testing purposes you can use `data-scriptid="91"`.

### Required parameters

- `data-scriptid`
5 changes: 5 additions & 0 deletions examples/amp-ad/ads.amp.esm.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
<option>navegg</option>
<option>nend</option>
<option>netletix</option>
<option>neuwo</option>
<option>noddus</option>
<option>nokta</option>
<option>nws</option>
Expand Down Expand Up @@ -1642,6 +1643,10 @@ <h2>NETLETIX</h2>
data-nxheight='250'>
</amp-ad>

<h2>Neuwo</h2>
<amp-ad width="300" height="250" type="neuwo" data-scriptid="91">
</amp-ad>

<h2>Noddus</h2>
<amp-ad width="300" height="300"
data-token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwbGFjZW1lbnRfaWQiOjY2MX0.OdD2QrgxMoI7MM09QBFCtbjMnUGuumiqBHb-FJF4UBs"
Expand Down
5 changes: 5 additions & 0 deletions examples/amp-ad/ads.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
<option>navegg</option>
<option>nend</option>
<option>netletix</option>
<option>neuwo</option>
<option>noddus</option>
<option>nokta</option>
<option>nws</option>
Expand Down Expand Up @@ -1486,6 +1487,10 @@ <h2>NETLETIX</h2>
data-nxunit='/60343726/netzathleten_.de' data-nxwidth='300' data-nxheight='250'>
</amp-ad>

<h2>Neuwo</h2>
<amp-ad width="300" height="250" type="neuwo" data-scriptid="91">
</amp-ad>

<h2>Noddus</h2>
<amp-ad width="300" height="300"
data-token="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwbGFjZW1lbnRfaWQiOjY2MX0.OdD2QrgxMoI7MM09QBFCtbjMnUGuumiqBHb-FJF4UBs"
Expand Down
1 change: 1 addition & 0 deletions extensions/amp-ad/amp-ad.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ See [amp-ad rules](validator-amp-ad.protoascii) in the AMP validator specificati
- [Navegg](../../ads/vendors/navegg.md)
- [Nend](../../ads/vendors/nend.md)
- [NETLETIX](../../ads/vendors/netletix.md)
- [Neuwo](../../ads/vendors/neuwo.md)
- [Noddus](../../ads/vendors/noddus.md)
- [Nokta](../../ads/vendors/nokta.md)
- [Newsroom AI](../../ads/vendors/nws.md)
Expand Down
53 changes: 53 additions & 0 deletions test/unit/ads/test-neuwo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as _3p from '#3p/3p';

import {neuwo} from '#ads/vendors/neuwo';

import {createIframePromise} from '#testing/iframe';

describes.fakeWin('amp-ad-neuwo', {}, (env) => {
let sandbox;
let win;

beforeEach(() => {
sandbox = env.sandbox;

return createIframePromise(true).then((iframe) => {
// Simulate the iframe that neuwo will be called inside.
win = iframe.win;
win.context = {
renderStart: sandbox.spy(),
noContentAvailable: sandbox.spy(),
referrer: null,
};
});
});

it('should require the scriptid parameter', () => {
allowConsoleError(() => {
expect(() => neuwo(win, {})).to.throw(/scriptid/);
});
});

it('should load the Neuwo static loader with the given scriptid', () => {
const writeScript = sandbox.stub(_3p, 'writeScript');
neuwo(win, {'scriptid': '91'});
expect(writeScript).to.be.calledOnce;
expect(writeScript.firstCall.args[1]).to.contain(
'ads.neuwo.ai/loader/neuwo-ad.js?staticTagId=91'
);
});

it('should bridge neuwoAdRender to renderStart()', () => {
sandbox.stub(_3p, 'writeScript');
neuwo(win, {'scriptid': '91'});
win.dispatchEvent(new win.Event('neuwoAdRender'));
expect(win.context.renderStart).to.be.calledOnce;
});

it('should bridge neuwoAdNoFill to noContentAvailable()', () => {
sandbox.stub(_3p, 'writeScript');
neuwo(win, {'scriptid': '91'});
win.dispatchEvent(new win.Event('neuwoAdNoFill'));
expect(win.context.noContentAvailable).to.be.calledOnce;
});
});
Loading