• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prebid / Prebid.js / #285

03 Mar 2025 04:58PM UTC coverage: 90.452% (-0.07%) from 90.523%
#285

push

travis-ci

prebidjs-release
Prebid 9.33.0 release

42181 of 52890 branches covered (79.75%)

62679 of 69295 relevant lines covered (90.45%)

222.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

16.0
/modules/debugging/responses.js
1
import {BANNER, NATIVE, VIDEO} from '../../src/mediaTypes.js';
2
import {Renderer} from '../../src/Renderer.js';
3
import {getGptSlotInfoForAdUnitCode} from '../../libraries/gptUtils/gptUtils.js';
4

5
const ORTB_NATIVE_ASSET_TYPES = ['img', 'video', 'link', 'data', 'title'];
1✔
6

7
export default {
8
  [BANNER]: (bid, bidResponse) => {
9
    if (!bidResponse.hasOwnProperty('ad') && !bidResponse.hasOwnProperty('adUrl')) {
18!
10
      const [size, repeat] = bidResponse.width < bidResponse.height ? [bidResponse.width, 'repeat-y'] : [bidResponse.height, 'repeat-x'];
18!
11
      bidResponse.ad = `<html><body><div style="display: inline-block; height: ${bidResponse.height}px; width: ${bidResponse.width}px; background-image: url(https://vcdn.adnxs.com/p/creative-image/27/c0/52/67/27c05267-5a6d-4874-834e-18e218493c32.png); background-size: ${size}px; background-repeat: ${repeat}"></div></body></html>`;
18✔
12
    }
13
  },
14
  [VIDEO]: (bid, bidResponse) => {
15
    if (!bidResponse.hasOwnProperty('vastXml') && !bidResponse.hasOwnProperty('vastUrl')) {
×
16
      bidResponse.vastXml = '<?xml version="1.0" encoding="UTF-8"?><VAST version="3.0"><Ad><InLine><AdSystem>GDFP</AdSystem><AdTitle>Demo</AdTitle><Description><![CDATA[Demo]]></Description><Creatives><Creative><Linear ><Duration>00:00:11</Duration><VideoClicks><ClickThrough><![CDATA[https://prebid.org/]]></ClickThrough></VideoClicks><MediaFiles><MediaFile delivery="progressive" width="640" height="360" type="video/mp4" scalable="true" maintainAspectRatio="true"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>';
×
17
      bidResponse.renderer = Renderer.install({
×
18
        url: 'https://cdn.jwplayer.com/libraries/l5MchIxB.js',
19
      });
20
      bidResponse.renderer.setRender(function (bid, doc) {
×
21
        const parentId = getGptSlotInfoForAdUnitCode(bid.adUnitCode).divId ?? bid.adUnitCode;
×
22
        const div = doc.createElement('div');
×
23
        div.id = `${parentId}-video-player`;
×
24
        doc.getElementById(parentId).appendChild(div);
×
25
        const player = window.jwplayer(div.id).setup({
×
26
          debug: true,
27
          width: bidResponse.width,
28
          height: bidResponse.height,
29
          advertising: {
30
            client: 'vast',
31
            outstream: true,
32
            endstate: 'close'
33
          },
34
        });
35
        player.on('ready', async function () {
×
36
          if (bid.vastUrl) {
×
37
            player.loadAdTag(bid.vastUrl);
×
38
          } else {
39
            player.loadAdXml(bid.vastXml);
×
40
          }
41
        });
42
      })
43
    }
44
  },
45
  [NATIVE]: (bid, bidResponse) => {
46
    if (!bidResponse.hasOwnProperty('native')) {
×
47
      bidResponse.native = {
×
48
        ortb: {
49
          link: {
50
            url: 'https://www.link.example',
51
            clicktrackers: ['https://impression.example']
52
          },
53
          assets: bid.nativeOrtbRequest.assets.map(mapDefaultNativeOrtbAsset)
54
        }
55
      }
56
    }
57
  }
58
}
59

60
function mapDefaultNativeOrtbAsset(asset) {
61
  const assetType = ORTB_NATIVE_ASSET_TYPES.find(type => asset.hasOwnProperty(type));
×
62
  switch (assetType) {
×
63
    case 'img':
64
      return {
×
65
        ...asset,
66
        img: {
67
          type: 3,
68
          w: 600,
69
          h: 500,
70
          url: 'https://vcdn.adnxs.com/p/creative-image/27/c0/52/67/27c05267-5a6d-4874-834e-18e218493c32.png',
71
        }
72
      }
73
    case 'video':
74
      return {
×
75
        ...asset,
76
        video: {
77
          vasttag: '<?xml version=\"1.0\" encoding=\"UTF-8\"?><VAST version=\"3.0\"><Ad><InLine><AdSystem>GDFP</AdSystem><AdTitle>Demo</AdTitle><Description><![CDATA[Demo]]></Description><Creatives><Creative><Linear ><Duration>00:00:11</Duration><VideoClicks><ClickThrough><![CDATA[https://prebid.org/]]></ClickThrough></VideoClicks><MediaFiles><MediaFile delivery=\"progressive\" width=\"640\" height=\"360\" type=\"video/mp4\" scalable=\"true\" maintainAspectRatio=\"true\"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile></MediaFiles></Linear></Creative></Creatives></InLine></Ad></VAST>'
78
        }
79
      }
80
    case 'data': {
81
      return {
×
82
        ...asset,
83
        data: {
84
          value: '5 stars'
85
        }
86
      }
87
    }
88
    case 'title': {
89
      return {
×
90
        ...asset,
91
        title: {
92
          text: 'Prebid Native Example'
93
        }
94
      }
95
    }
96
  }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc