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: 9 additions & 3 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ function _createBidResponse(response) {
}

function _isViewabilityMeasurable() {
return !isIframe() && utils.getWindowTop().document.visibilityState === 'visible';
return !_isIframe();
}

function _getViewability(element, topWin, { w, h } = {}) {
return utils.getWindowTop().document.visibilityState === 'visible'
? _getPercentInView(element, topWin, { w, h })
: 0;
}

// Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request
Expand All @@ -41,7 +47,7 @@ function _createServerRequest(bidRequest, gdprConsent) {
const minSize = _getMinSize(sizes);

const viewabilityAmount = _isViewabilityMeasurable()
? _getPercentInView(element, utils.getWindowTop(), minSize)
? _getViewability(element, utils.getWindowTop(), minSize)
: NON_MEASURABLE;

const contributeViewability = ViewabilityContributor(viewabilityAmount);
Expand Down Expand Up @@ -221,7 +227,7 @@ function ViewabilityContributor(viewabilityAmount) {
return contributeViewability;
}

function isIframe() {
function _isIframe() {
try {
return utils.getWindowSelf() !== utils.getWindowTop();
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/33acrossBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ describe('33acrossBidAdapter:', function () {
});

context('when tab is inactive', function() {
it('returns \'nm\'', function() {
it('returns 0', function() {
const ttxRequest = new TtxRequestBuilder()
.withViewabiliuty({amount: spec.NON_MEASURABLE})
.withViewabiliuty({amount: 0})
.build();
const serverRequest = new ServerRequestBuilder()
.withData(ttxRequest)
Expand Down