diff --git a/modules/viBidAdapter.js b/modules/viBidAdapter.js index 8d8cb06e47e4..3e06e9617fef 100644 --- a/modules/viBidAdapter.js +++ b/modules/viBidAdapter.js @@ -303,6 +303,7 @@ export function mergeArrays(hashFn, ...args) { } export function documentFocus(doc) { + if (!doc) return undefined; return typeof doc.hasFocus === 'function' ? +doc.hasFocus() : undefined; } diff --git a/test/spec/modules/viBidAdapter_spec.js b/test/spec/modules/viBidAdapter_spec.js index 8f1c07047ec9..78b891201373 100644 --- a/test/spec/modules/viBidAdapter_spec.js +++ b/test/spec/modules/viBidAdapter_spec.js @@ -906,6 +906,7 @@ describe('documentFocus', () => { hasFocus: () => false }) ).to.equal(0); + expect(documentFocus()).to.be.undefined; expect(documentFocus({})).to.be.undefined; }); });