Skip to content

Commit ada88fa

Browse files
authored
Kargo bid adapter: fix safari 15.6 error from storage stubbing (prebid#13243)
* Expand AGENTS guidelines * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * Update AGENTS.md * adapter: handle Safari localStorage stubs * Delete AGENTS.md
1 parent edbbcac commit ada88fa

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

test/spec/modules/kargoBidAdapter_spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { expect } from 'chai';
22
import { spec } from 'modules/kargoBidAdapter.js';
33
import { config } from 'src/config.js';
4+
import { getStorageManager } from 'src/storageManager.js';
45
const utils = require('src/utils');
6+
const STORAGE = getStorageManager({bidderCode: 'kargo'});
57

68
describe('kargo adapter tests', function() {
79
let bid, outstreamBid, testBids, sandbox, clock, frozenNow = new Date(), oldBidderSettings;
@@ -1001,9 +1003,9 @@ describe('kargo adapter tests', function() {
10011003
});
10021004

10031005
it('retrieves CRB from cookies if localstorage is not functional', function() {
1004-
// Note: this does not cause localStorage to throw an error in Firefox so in that browser this
1005-
// test is not 100% true to its name
1006-
sandbox.stub(localStorage, 'getItem').throws();
1006+
// Safari does not allow stubbing localStorage methods directly.
1007+
// Stub the storage manager instead so all browsers behave consistently.
1008+
sandbox.stub(STORAGE, 'getDataFromLocalStorage').throws();
10071009
setCrb('valid', 'invalid');
10081010

10091011
const payload = getPayloadFromTestBids(testBids, bidderRequest);
@@ -1269,7 +1271,7 @@ describe('kargo adapter tests', function() {
12691271
});
12701272

12711273
it('fails gracefully if there is no localStorage', function() {
1272-
sandbox.stub(localStorage, 'getItem').throws();
1274+
sandbox.stub(STORAGE, 'getDataFromLocalStorage').throws();
12731275
let payload = getPayloadFromTestBids(testBids);
12741276
expect(payload.user).to.deep.equal({
12751277
crbIDs: {},
@@ -1589,7 +1591,7 @@ describe('kargo adapter tests', function() {
15891591
});
15901592

15911593
it('fails gracefully without localStorage', function() {
1592-
sandbox.stub(localStorage, 'getItem').throws();
1594+
sandbox.stub(STORAGE, 'getDataFromLocalStorage').throws();
15931595
let payload = getPayloadFromTestBids(testBids);
15941596
expect(payload.page).to.be.undefined;
15951597
});

0 commit comments

Comments
 (0)