From 61f1d5b1b9a415f6aa23aa7c049301e048514b9a Mon Sep 17 00:00:00 2001 From: Alex Pashkov Date: Wed, 9 Oct 2019 15:05:46 +0300 Subject: [PATCH] Handle null doc --- modules/viBidAdapter.js | 1 + test/spec/modules/viBidAdapter_spec.js | 1 + 2 files changed, 2 insertions(+) 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; }); });