Skip to content

Commit

Permalink
fixup! Add new window features to HB request
Browse files Browse the repository at this point in the history
  • Loading branch information
github-saad-elmahfoudi committed Dec 5, 2023
1 parent b5afcbe commit be5c80a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions modules/teadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ export const spec = {
timeToFirstByte: getTimeToFirstByte(window),
data: bids,
deviceWidth: screen.width,
screenOrientation: screen.orientation?.type,
screenOrientation: screen.orientation?.type || '',
historyLength: topWindow.history?.length,
viewportHeight: topWindow.visualViewport?.height,
viewportWidth: topWindow.visualViewport?.width,
hardwareConcurrency: topWindow.navigator?.hardwareConcurrency,
deviceMemory: topWindow.navigator?.deviceMemory,
hardwareConcurrency: topWindow.navigator?.hardwareConcurrency?.toString() || '',
deviceMemory: topWindow.navigator?.deviceMemory?.toString() || '',
hb_version: '$prebid.version$',
...getSharedViewerIdParameters(validBidRequests),
...getFirstPartyTeadsIdParameter(validBidRequests)
Expand Down
13 changes: 10 additions & 3 deletions test/spec/modules/teadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ describe('teadsBidAdapter', () => {
it('should add screenOrientation info to payload', function () {
const request = spec.buildRequests(bidRequests, bidderRequestDefault);
const payload = JSON.parse(request.data);
const screenOrientation = window.top.screen.orientation.type || ''

expect(payload.screenOrientation).to.exist;
expect(payload.screenOrientation).to.deep.equal(window.top.screen.orientation.type);
expect(payload.screenOrientation).to.deep.equal(screenOrientation);
});

it('should add historyLength info to payload', function () {
Expand Down Expand Up @@ -289,17 +290,23 @@ describe('teadsBidAdapter', () => {
it('should add hardwareConcurrency info to payload', function () {
const request = spec.buildRequests(bidRequests, bidderRequestDefault);
const payload = JSON.parse(request.data);
const hardwareConcurrency = window.top.navigator.hardwareConcurrency

expect(payload.hardwareConcurrency).to.exist;
expect(payload.hardwareConcurrency).to.deep.equal(window.top.navigator.hardwareConcurrency);
if (hardwareConcurrency) {
expect(payload.hardwareConcurrency).to.deep.equal(hardwareConcurrency.toString());
} else expect(payload.hardwareConcurrency).to.deep.equal('')
});

it('should add deviceMemory info to payload', function () {
const request = spec.buildRequests(bidRequests, bidderRequestDefault);
const payload = JSON.parse(request.data);
const deviceMemory = window.top.navigator.deviceMemory

expect(payload.deviceMemory).to.exist;
expect(payload.deviceMemory).to.deep.equal(window.top.navigator.deviceMemory);
if (deviceMemory) {
expect(payload.deviceMemory).to.deep.equal(deviceMemory.toString());
} else expect(payload.deviceMemory).to.deep.equal('')
});

describe('pageTitle', function () {
Expand Down

0 comments on commit be5c80a

Please sign in to comment.