diff --git a/src/adapters/wideorbit.js b/src/adapters/wideorbit.js index 42356991577..b9e00ba7a82 100644 --- a/src/adapters/wideorbit.js +++ b/src/adapters/wideorbit.js @@ -133,6 +133,7 @@ var WideOrbitAdapter = function WideOrbitAdapter() { createdElem; utils._each(userMatchings, function (userMatching) { + createdElem = undefined; switch (userMatching.Type) { case 'redirect': createdElem = document.createElement('img'); @@ -146,8 +147,10 @@ var WideOrbitAdapter = function WideOrbitAdapter() { createdElem.async = true; break; } - createdElem.src = decodeURIComponent(userMatching.Url); - headElem.insertBefore(createdElem, headElem.firstChild); + if (createdElem) { + createdElem.src = decodeURIComponent(userMatching.Url); + headElem.insertBefore(createdElem, headElem.firstChild); + } }); } diff --git a/test/spec/adapters/wideorbit_spec.js b/test/spec/adapters/wideorbit_spec.js index 6f02ccbe316..2daeed974e6 100644 --- a/test/spec/adapters/wideorbit_spec.js +++ b/test/spec/adapters/wideorbit_spec.js @@ -489,6 +489,25 @@ describe('wideorbit adapter tests', function () { stubAddBidResponse.restore(); }); + it('should do nothing when type is set to unrecognized type', function () { + + var stubAddBidResponse = sinon.stub(bidmanager, 'addBidResponse'); + + var response = { + UserMatchings: [ + { + Type: 'unrecognized', + Url: 'http%3A%2F%2Fwww.admeta.com%2F1.js' + } + ], + Placements: placements + }; + + $$PREBID_GLOBAL$$.handleWideOrbitCallback(response); + + stubAddBidResponse.restore(); + }); + }); });