prebid.js 6.3.0 → 6.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +1 -1
- package/gulpfile.js +87 -74
- package/integrationExamples/gpt/amp/creative.html +11 -33
- package/karma.conf.maker.js +1 -1
- package/modules/.submodules.json +2 -1
- package/modules/adbookpspBidAdapter.js +27 -10
- package/modules/adhashBidAdapter.js +3 -3
- package/modules/adkernelBidAdapter.js +148 -62
- package/modules/adlooxAdServerVideo.js +2 -2
- package/modules/adlooxAnalyticsAdapter.js +4 -4
- package/modules/admanBidAdapter.js +10 -4
- package/modules/adomikAnalyticsAdapter.js +27 -9
- package/modules/adqueryIdSystem.js +103 -0
- package/modules/adqueryIdSystem.md +35 -0
- package/modules/adyoulikeBidAdapter.js +13 -9
- package/modules/aniviewBidAdapter.js +1 -1
- package/modules/beopBidAdapter.js +1 -1
- package/modules/bidViewability.js +3 -3
- package/modules/bidViewabilityIO.js +3 -3
- package/modules/bliinkBidAdapter.js +3 -2
- package/modules/colossussspBidAdapter.js +12 -8
- package/modules/colossussspBidAdapter.md +15 -1
- package/modules/compassBidAdapter.js +208 -0
- package/modules/compassBidAdapter.md +79 -0
- package/modules/consentManagement.js +7 -1
- package/modules/consumableBidAdapter.md +1 -1
- package/modules/criteoBidAdapter.js +1 -1
- package/modules/criteoIdSystem.js +29 -7
- package/modules/currency.js +2 -2
- package/modules/dailyhuntBidAdapter.js +435 -0
- package/modules/dailyhuntBidAdapter.md +4 -0
- package/modules/docereeBidAdapter.js +10 -1
- package/modules/docereeBidAdapter.md +2 -0
- package/modules/engageyaBidAdapter.js +1 -1
- package/modules/feedadBidAdapter.js +2 -2
- package/modules/feedadBidAdapter.md +4 -2
- package/modules/glimpseBidAdapter.js +66 -44
- package/modules/gnetBidAdapter.js +3 -3
- package/modules/gnetBidAdapter.md +4 -4
- package/modules/gptPreAuction.js +55 -7
- package/modules/gridBidAdapter.js +4 -3
- package/modules/gumgumBidAdapter.js +4 -4
- package/modules/idImportLibrary.js +45 -8
- package/modules/idImportLibrary.md +4 -0
- package/modules/improvedigitalBidAdapter.js +42 -4
- package/modules/instreamTracking.js +4 -4
- package/modules/invibesBidAdapter.js +49 -5
- package/modules/invibesBidAdapter.md +2 -1
- package/modules/ixBidAdapter.js +53 -18
- package/modules/jwplayerRtdProvider.js +71 -6
- package/modules/jwplayerRtdProvider.md +27 -11
- package/modules/kargoBidAdapter.js +2 -2
- package/modules/limelightDigitalBidAdapter.js +2 -1
- package/modules/livewrappedAnalyticsAdapter.js +3 -1
- package/modules/livewrappedBidAdapter.js +8 -2
- package/modules/loglyliftBidAdapter.js +79 -0
- package/modules/loglyliftBidAdapter.md +55 -0
- package/modules/nextMillenniumBidAdapter.js +11 -7
- package/modules/oguryBidAdapter.js +9 -2
- package/modules/onetagBidAdapter.js +4 -2
- package/modules/optimeraRtdProvider.js +8 -1
- package/modules/ozoneBidAdapter.js +21 -64
- package/modules/pilotxBidAdapter.js +147 -0
- package/modules/pilotxBidAdapter.md +50 -0
- package/modules/proxistoreBidAdapter.js +0 -2
- package/modules/pubgeniusBidAdapter.js +1 -1
- package/modules/pubmaticAnalyticsAdapter.js +16 -0
- package/modules/pubxaiAnalyticsAdapter.js +17 -0
- package/modules/richaudienceBidAdapter.js +3 -2
- package/modules/riseBidAdapter.js +1 -1
- package/modules/rtbhouseBidAdapter.js +14 -4
- package/modules/rtdModule/index.js +14 -15
- package/modules/rubiconAnalyticsAdapter.js +3 -2
- package/modules/rubiconBidAdapter.js +21 -11
- package/modules/seedingAllianceBidAdapter.js +3 -3
- package/modules/sharethroughBidAdapter.js +12 -17
- package/modules/showheroes-bsBidAdapter.js +13 -2
- package/modules/synacormediaBidAdapter.js +31 -10
- package/modules/tappxBidAdapter.js +8 -5
- package/modules/teadsBidAdapter.js +1 -2
- package/modules/telariaBidAdapter.js +2 -2
- package/modules/trustxBidAdapter.js +8 -16
- package/modules/userId/eids.js +7 -1
- package/modules/userId/userId.md +8 -0
- package/modules/viewability.js +177 -0
- package/modules/viewability.md +87 -0
- package/modules/welectBidAdapter.js +106 -0
- package/modules/yieldmoBidAdapter.js +23 -5
- package/modules/zeta_global_sspAnalyticsAdapter.js +97 -0
- package/modules/zeta_global_sspAnalyticsAdapter.md +24 -0
- package/package.json +1 -1
- package/src/auction.js +2 -2
- package/src/config.js +27 -3
- package/src/hook.js +5 -1
- package/src/prebid.js +20 -4
- package/src/secureCreatives.js +3 -2
- package/src/utils.js +12 -1
- package/test/helpers/prebidGlobal.js +1 -0
- package/test/spec/config_spec.js +279 -0
- package/test/spec/modules/adbookpspBidAdapter_spec.js +17 -3
- package/test/spec/modules/adhashBidAdapter_spec.js +2 -2
- package/test/spec/modules/adlooxAnalyticsAdapter_spec.js +6 -6
- package/test/spec/modules/admanBidAdapter_spec.js +2 -2
- package/test/spec/modules/adomikAnalyticsAdapter_spec.js +9 -1
- package/test/spec/modules/adqueryIdSystem_spec.js +74 -0
- package/test/spec/modules/adyoulikeBidAdapter_spec.js +49 -0
- package/test/spec/modules/beopBidAdapter_spec.js +1 -1
- package/test/spec/modules/bidViewabilityIO_spec.js +2 -2
- package/test/spec/modules/bidViewability_spec.js +4 -4
- package/test/spec/modules/bliinkBidAdapter_spec.js +2 -0
- package/test/spec/modules/colossussspBidAdapter_spec.js +5 -2
- package/test/spec/modules/compassBidAdapter_spec.js +398 -0
- package/test/spec/modules/consentManagement_spec.js +20 -0
- package/test/spec/modules/criteoIdSystem_spec.js +6 -3
- package/test/spec/modules/dailyhuntBidAdapter_spec.js +404 -0
- package/test/spec/modules/docereeBidAdapter_spec.js +9 -1
- package/test/spec/modules/eids_spec.js +15 -0
- package/test/spec/modules/feedadBidAdapter_spec.js +15 -0
- package/test/spec/modules/glimpseBidAdapter_spec.js +0 -18
- package/test/spec/modules/gnetBidAdapter_spec.js +6 -6
- package/test/spec/modules/gptPreAuction_spec.js +177 -2
- package/test/spec/modules/idImportLibrary_spec.js +197 -10
- package/test/spec/modules/improvedigitalBidAdapter_spec.js +45 -1
- package/test/spec/modules/invibesBidAdapter_spec.js +119 -0
- package/test/spec/modules/ixBidAdapter_spec.js +112 -62
- package/test/spec/modules/jwplayerRtdProvider_spec.js +195 -2
- package/test/spec/modules/kargoBidAdapter_spec.js +1 -1
- package/test/spec/modules/limelightDigitalBidAdapter_spec.js +75 -17
- package/test/spec/modules/livewrappedAnalyticsAdapter_spec.js +22 -0
- package/test/spec/modules/livewrappedBidAdapter_spec.js +31 -0
- package/test/spec/modules/loglyliftBidAdapter_spec.js +172 -0
- package/test/spec/modules/nextMillenniumBidAdapter_spec.js +9 -2
- package/test/spec/modules/oguryBidAdapter_spec.js +10 -2
- package/test/spec/modules/optimeraRtdProvider_spec.js +14 -1
- package/test/spec/modules/ozoneBidAdapter_spec.js +43 -31
- package/test/spec/modules/pilotxBidAdapter_spec.js +244 -0
- package/test/spec/modules/pubgeniusBidAdapter_spec.js +3 -3
- package/test/spec/modules/pubmaticAnalyticsAdapter_spec.js +13 -1
- package/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +11 -0
- package/test/spec/modules/realTimeDataModule_spec.js +67 -5
- package/test/spec/modules/richaudienceBidAdapter_spec.js +40 -0
- package/test/spec/modules/riseBidAdapter_spec.js +1 -1
- package/test/spec/modules/rtbhouseBidAdapter_spec.js +20 -0
- package/test/spec/modules/rubiconAnalyticsAdapter_spec.js +30 -0
- package/test/spec/modules/rubiconBidAdapter_spec.js +48 -9
- package/test/spec/modules/sharethroughBidAdapter_spec.js +91 -6
- package/test/spec/modules/showheroes-bsBidAdapter_spec.js +2 -0
- package/test/spec/modules/synacormediaBidAdapter_spec.js +70 -0
- package/test/spec/modules/tappxBidAdapter_spec.js +0 -19
- package/test/spec/modules/teadsBidAdapter_spec.js +14 -59
- package/test/spec/modules/userId_spec.js +68 -19
- package/test/spec/modules/viewability_spec.js +280 -0
- package/test/spec/modules/welectBidAdapter_spec.js +211 -0
- package/test/spec/modules/zeta_global_sspAnalyticsAdapter_spec.js +427 -0
- package/test/spec/unit/pbjs_api_spec.js +3 -1
- package/test/test_deps.js +3 -0
- package/test/test_index.js +1 -3
|
@@ -49,6 +49,7 @@ import {flocIdSubmodule} from 'modules/flocIdSystem.js'
|
|
|
49
49
|
import {amxIdSubmodule} from '../../../modules/amxIdSystem.js';
|
|
50
50
|
import {akamaiDAPIdSubmodule} from 'modules/akamaiDAPIdSystem.js'
|
|
51
51
|
import {kinessoIdSubmodule} from 'modules/kinessoIdSystem.js'
|
|
52
|
+
import {adqueryIdSubmodule} from 'modules/adqueryIdSystem.js';
|
|
52
53
|
import * as mockGpt from '../integration/faker/googletag.js';
|
|
53
54
|
|
|
54
55
|
let assert = require('chai').assert;
|
|
@@ -559,7 +560,7 @@ describe('User ID', function () {
|
|
|
559
560
|
});
|
|
560
561
|
|
|
561
562
|
it('handles config with no usersync object', function () {
|
|
562
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
563
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
563
564
|
init(config);
|
|
564
565
|
config.setConfig({});
|
|
565
566
|
// usersync is undefined, and no logInfo message for 'User ID - usersync config updated'
|
|
@@ -567,14 +568,14 @@ describe('User ID', function () {
|
|
|
567
568
|
});
|
|
568
569
|
|
|
569
570
|
it('handles config with empty usersync object', function () {
|
|
570
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
571
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
571
572
|
init(config);
|
|
572
573
|
config.setConfig({userSync: {}});
|
|
573
574
|
expect(typeof utils.logInfo.args[0]).to.equal('undefined');
|
|
574
575
|
});
|
|
575
576
|
|
|
576
577
|
it('handles config with usersync and userIds that are empty objs', function () {
|
|
577
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
578
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
578
579
|
init(config);
|
|
579
580
|
config.setConfig({
|
|
580
581
|
userSync: {
|
|
@@ -585,7 +586,7 @@ describe('User ID', function () {
|
|
|
585
586
|
});
|
|
586
587
|
|
|
587
588
|
it('handles config with usersync and userIds with empty names or that dont match a submodule.name', function () {
|
|
588
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
589
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, merkleIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
589
590
|
init(config);
|
|
590
591
|
config.setConfig({
|
|
591
592
|
userSync: {
|
|
@@ -602,7 +603,7 @@ describe('User ID', function () {
|
|
|
602
603
|
});
|
|
603
604
|
|
|
604
605
|
it('config with 1 configurations should create 1 submodules', function () {
|
|
605
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
606
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
606
607
|
init(config);
|
|
607
608
|
config.setConfig(getConfigMock(['unifiedId', 'unifiedid', 'cookie']));
|
|
608
609
|
|
|
@@ -623,8 +624,8 @@ describe('User ID', function () {
|
|
|
623
624
|
expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 1 submodules');
|
|
624
625
|
});
|
|
625
626
|
|
|
626
|
-
it('config with
|
|
627
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
627
|
+
it('config with 24 configurations should result in 24 submodules add', function () {
|
|
628
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, liveIntentIdSubmodule, britepoolIdSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
628
629
|
init(config);
|
|
629
630
|
config.setConfig({
|
|
630
631
|
userSync: {
|
|
@@ -689,14 +690,17 @@ describe('User ID', function () {
|
|
|
689
690
|
}, {
|
|
690
691
|
name: 'kpuid',
|
|
691
692
|
storage: {name: 'kpuid', type: 'cookie'}
|
|
693
|
+
}, {
|
|
694
|
+
name: 'qid',
|
|
695
|
+
storage: {name: 'qid', type: 'html5'}
|
|
692
696
|
}]
|
|
693
697
|
}
|
|
694
698
|
});
|
|
695
|
-
expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for
|
|
699
|
+
expect(utils.logInfo.args[0][0]).to.exist.and.to.contain('User ID - usersync config updated for 24 submodules');
|
|
696
700
|
});
|
|
697
701
|
|
|
698
702
|
it('config syncDelay updates module correctly', function () {
|
|
699
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
703
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
700
704
|
|
|
701
705
|
init(config);
|
|
702
706
|
config.setConfig({
|
|
@@ -712,7 +716,7 @@ describe('User ID', function () {
|
|
|
712
716
|
});
|
|
713
717
|
|
|
714
718
|
it('config auctionDelay updates module correctly', function () {
|
|
715
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
719
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
716
720
|
init(config);
|
|
717
721
|
config.setConfig({
|
|
718
722
|
userSync: {
|
|
@@ -727,7 +731,7 @@ describe('User ID', function () {
|
|
|
727
731
|
});
|
|
728
732
|
|
|
729
733
|
it('config auctionDelay defaults to 0 if not a number', function () {
|
|
730
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
734
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, netIdSubmodule, nextrollIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, pubProvidedIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, flocIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
731
735
|
init(config);
|
|
732
736
|
config.setConfig({
|
|
733
737
|
userSync: {
|
|
@@ -1823,7 +1827,38 @@ describe('User ID', function () {
|
|
|
1823
1827
|
}, {adUnits});
|
|
1824
1828
|
});
|
|
1825
1829
|
|
|
1826
|
-
it('test hook
|
|
1830
|
+
it('test hook from qid html5', (done) => {
|
|
1831
|
+
// simulate existing localStorage values
|
|
1832
|
+
localStorage.setItem('qid', 'testqid');
|
|
1833
|
+
localStorage.setItem('qid_exp', '');
|
|
1834
|
+
|
|
1835
|
+
setSubmoduleRegistry([adqueryIdSubmodule]);
|
|
1836
|
+
init(config);
|
|
1837
|
+
config.setConfig(getConfigMock(['qid', 'qid', 'html5']));
|
|
1838
|
+
|
|
1839
|
+
requestBidsHook(() => {
|
|
1840
|
+
adUnits.forEach((adUnit) => {
|
|
1841
|
+
adUnit.bids.forEach((bid) => {
|
|
1842
|
+
expect(bid).to.have.deep.nested.property('userId.qid');
|
|
1843
|
+
expect(bid.userId.qid).to.equal('testqid');
|
|
1844
|
+
expect(bid.userIdAsEids[0]).to.deep.equal({
|
|
1845
|
+
source: 'adquery.io',
|
|
1846
|
+
uids: [{
|
|
1847
|
+
id: 'testqid',
|
|
1848
|
+
atype: 1,
|
|
1849
|
+
}]
|
|
1850
|
+
});
|
|
1851
|
+
});
|
|
1852
|
+
});
|
|
1853
|
+
|
|
1854
|
+
// clear LS
|
|
1855
|
+
localStorage.removeItem('qid');
|
|
1856
|
+
localStorage.removeItem('qid_exp');
|
|
1857
|
+
done();
|
|
1858
|
+
}, {adUnits});
|
|
1859
|
+
});
|
|
1860
|
+
|
|
1861
|
+
it('test hook when pubCommonId, unifiedId, id5Id, identityLink, britepoolId, intentIqId, zeotapIdPlus, netId, haloId, Criteo, UID 2.0, admixerId, amxId, dmdId, kpuid, qid and mwOpenLinkId have data to pass', function (done) {
|
|
1827
1862
|
coreStorage.setCookie('pubcid', 'testpubcid', (new Date(Date.now() + 5000).toUTCString()));
|
|
1828
1863
|
coreStorage.setCookie('unifiedid', JSON.stringify({'TDID': 'testunifiedid'}), (new Date(Date.now() + 5000).toUTCString()));
|
|
1829
1864
|
coreStorage.setCookie('id5id', JSON.stringify({'universal_uid': 'testid5id'}), (new Date(Date.now() + 5000).toUTCString()));
|
|
@@ -1840,12 +1875,13 @@ describe('User ID', function () {
|
|
|
1840
1875
|
coreStorage.setCookie('admixerId', 'testadmixerId', (new Date(Date.now() + 5000).toUTCString()));
|
|
1841
1876
|
coreStorage.setCookie('deepintentId', 'testdeepintentId', (new Date(Date.now() + 5000).toUTCString()));
|
|
1842
1877
|
coreStorage.setCookie('kpuid', 'KINESSO_ID', (new Date(Date.now() + 5000).toUTCString()));
|
|
1843
|
-
|
|
1844
1878
|
// amxId only supports localStorage
|
|
1845
1879
|
localStorage.setItem('amxId', 'test_amxid_id');
|
|
1846
1880
|
localStorage.setItem('amxId_exp', (new Date(Date.now() + 5000)).toUTCString());
|
|
1847
|
-
|
|
1848
|
-
|
|
1881
|
+
// qid only supports localStorage
|
|
1882
|
+
localStorage.setItem('qid', 'testqid');
|
|
1883
|
+
localStorage.setItem('qid_exp', (new Date(Date.now() + 5000)).toUTCString());
|
|
1884
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, criteoIdSubmodule, mwOpenLinkIdSubModule, tapadIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
1849
1885
|
init(config);
|
|
1850
1886
|
config.setConfig(getConfigMock(['pubCommonId', 'pubcid', 'cookie'],
|
|
1851
1887
|
['unifiedId', 'unifiedid', 'cookie'],
|
|
@@ -1864,7 +1900,8 @@ describe('User ID', function () {
|
|
|
1864
1900
|
['admixerId', 'admixerId', 'cookie'],
|
|
1865
1901
|
['amxId', 'amxId', 'html5'],
|
|
1866
1902
|
['deepintentId', 'deepintentId', 'cookie'],
|
|
1867
|
-
['kpuid', 'kpuid', 'cookie']
|
|
1903
|
+
['kpuid', 'kpuid', 'cookie'],
|
|
1904
|
+
['qid', 'qid', 'html5']));
|
|
1868
1905
|
|
|
1869
1906
|
requestBidsHook(function () {
|
|
1870
1907
|
adUnits.forEach(unit => {
|
|
@@ -1922,7 +1959,10 @@ describe('User ID', function () {
|
|
|
1922
1959
|
expect(bid).to.have.deep.nested.property('userId.kpuid');
|
|
1923
1960
|
expect(bid.userId.kpuid).to.equal('KINESSO_ID');
|
|
1924
1961
|
|
|
1925
|
-
expect(bid
|
|
1962
|
+
expect(bid).to.have.deep.nested.property('userId.qid');
|
|
1963
|
+
expect(bid.userId.qid).to.equal('testqid');
|
|
1964
|
+
|
|
1965
|
+
expect(bid.userIdAsEids.length).to.equal(18);
|
|
1926
1966
|
});
|
|
1927
1967
|
});
|
|
1928
1968
|
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
|
|
@@ -1943,6 +1983,8 @@ describe('User ID', function () {
|
|
|
1943
1983
|
coreStorage.setCookie('kpuid', EXPIRED_COOKIE_DATE);
|
|
1944
1984
|
localStorage.removeItem('amxId');
|
|
1945
1985
|
localStorage.removeItem('amxId_exp');
|
|
1986
|
+
localStorage.removeItem('qid');
|
|
1987
|
+
localStorage.removeItem('qid_exp');
|
|
1946
1988
|
done();
|
|
1947
1989
|
}, {adUnits});
|
|
1948
1990
|
});
|
|
@@ -2132,8 +2174,10 @@ describe('User ID', function () {
|
|
|
2132
2174
|
localStorage.setItem('amxId', 'test_amxid_id');
|
|
2133
2175
|
localStorage.setItem('amxId_exp', new Date(Date.now() + 5000).toUTCString())
|
|
2134
2176
|
coreStorage.setCookie('kpuid', 'KINESSO_ID', (new Date(Date.now() + 5000).toUTCString()));
|
|
2177
|
+
localStorage.setItem('qid', 'testqid');
|
|
2178
|
+
localStorage.setItem('qid_exp', new Date(Date.now() + 5000).toUTCString())
|
|
2135
2179
|
|
|
2136
|
-
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule]);
|
|
2180
|
+
setSubmoduleRegistry([sharedIdSystemSubmodule, unifiedIdSubmodule, id5IdSubmodule, identityLinkSubmodule, britepoolIdSubmodule, netIdSubmodule, intentIqIdSubmodule, zeotapIdPlusSubmodule, haloIdSubmodule, uid2IdSubmodule, admixerIdSubmodule, deepintentDpesSubmodule, dmdIdSubmodule, akamaiDAPIdSubmodule, amxIdSubmodule, kinessoIdSubmodule, adqueryIdSubmodule]);
|
|
2137
2181
|
init(config);
|
|
2138
2182
|
|
|
2139
2183
|
config.setConfig({
|
|
@@ -2171,6 +2215,8 @@ describe('User ID', function () {
|
|
|
2171
2215
|
name: 'amxId', storage: {name: 'amxId', type: 'html5'}
|
|
2172
2216
|
}, {
|
|
2173
2217
|
name: 'kpuid', storage: {name: 'kpuid', type: 'cookie'}
|
|
2218
|
+
}, {
|
|
2219
|
+
name: 'qid', storage: {name: 'qid', type: 'html5'}
|
|
2174
2220
|
}]
|
|
2175
2221
|
}
|
|
2176
2222
|
});
|
|
@@ -2242,7 +2288,10 @@ describe('User ID', function () {
|
|
|
2242
2288
|
|
|
2243
2289
|
expect(bid).to.have.deep.nested.property('userId.kpuid');
|
|
2244
2290
|
expect(bid.userId.kpuid).to.equal('KINESSO_ID');
|
|
2245
|
-
|
|
2291
|
+
|
|
2292
|
+
expect(bid).to.have.deep.nested.property('userId.qid');
|
|
2293
|
+
expect(bid.userId.qid).to.equal('testqid');
|
|
2294
|
+
expect(bid.userIdAsEids.length).to.equal(16);
|
|
2246
2295
|
});
|
|
2247
2296
|
});
|
|
2248
2297
|
coreStorage.setCookie('pubcid', '', EXPIRED_COOKIE_DATE);
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import * as sinon from 'sinon';
|
|
3
|
+
import * as utils from 'src/utils.js';
|
|
4
|
+
import * as viewability from 'modules/viewability.js';
|
|
5
|
+
|
|
6
|
+
describe('viewability test', () => {
|
|
7
|
+
describe('start measurement', () => {
|
|
8
|
+
let sandbox;
|
|
9
|
+
let intersectionObserverStub;
|
|
10
|
+
let setTimeoutStub;
|
|
11
|
+
let observeCalled;
|
|
12
|
+
let unobserveCalled;
|
|
13
|
+
let ti = 1;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
observeCalled = false;
|
|
16
|
+
unobserveCalled = false;
|
|
17
|
+
sandbox = sinon.sandbox.create();
|
|
18
|
+
|
|
19
|
+
let fakeIntersectionObserver = (stateChange, options) => {
|
|
20
|
+
return {
|
|
21
|
+
observe: (element) => {
|
|
22
|
+
observeCalled = true;
|
|
23
|
+
stateChange([{ isIntersecting: true }]);
|
|
24
|
+
},
|
|
25
|
+
unobserve: (element) => {
|
|
26
|
+
unobserveCalled = true;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver);
|
|
32
|
+
setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => {
|
|
33
|
+
callback();
|
|
34
|
+
return ti++;
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
sandbox.restore();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should trigger appropriate callbacks', () => {
|
|
43
|
+
viewability.startMeasurement('0', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
44
|
+
|
|
45
|
+
sinon.assert.called(intersectionObserverStub);
|
|
46
|
+
sinon.assert.called(setTimeoutStub);
|
|
47
|
+
expect(observeCalled).to.equal(true);
|
|
48
|
+
expect(unobserveCalled).to.equal(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should trigger img tracker', () => {
|
|
52
|
+
let triggerPixelSpy = sandbox.spy(utils, ['triggerPixel']);
|
|
53
|
+
viewability.startMeasurement('1', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
54
|
+
expect(triggerPixelSpy.callCount).to.equal(1);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should trigger js tracker', () => {
|
|
58
|
+
let insertHtmlIntoIframeSpy = sandbox.spy(utils, ['insertHtmlIntoIframe']);
|
|
59
|
+
viewability.startMeasurement('2', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
60
|
+
expect(insertHtmlIntoIframeSpy.callCount).to.equal(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should trigger callback tracker', () => {
|
|
64
|
+
let callbackFired = false;
|
|
65
|
+
viewability.startMeasurement('3', {}, { method: 'callback', value: () => { callbackFired = true; } }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
66
|
+
expect(callbackFired).to.equal(true);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should check for vid uniqueness', () => {
|
|
70
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
71
|
+
viewability.startMeasurement('4', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
72
|
+
expect(logWarnSpy.callCount).to.equal(0);
|
|
73
|
+
|
|
74
|
+
viewability.startMeasurement('4', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
75
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
76
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: must provide an unregistered vid`, '4')).to.equal(true);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should check for valid criteria', () => {
|
|
80
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
81
|
+
viewability.startMeasurement('5', {}, { method: 'js', value: 'http://my.tracker/123.js' }, { timeInView: 1000 });
|
|
82
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
83
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: missing criteria`, { timeInView: 1000 })).to.equal(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should check for valid tracker', () => {
|
|
87
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
88
|
+
viewability.startMeasurement('6', {}, { method: 'callback', value: 'string' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
89
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
90
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: invalid tracker`, { method: 'callback', value: 'string' })).to.equal(true);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should check if element provided', () => {
|
|
94
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
95
|
+
viewability.startMeasurement('7', undefined, { method: 'js', value: 'http://my.tracker/123.js' }, { timeInView: 1000 });
|
|
96
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
97
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: no html element provided`)).to.equal(true);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('stop measurement', () => {
|
|
102
|
+
let sandbox;
|
|
103
|
+
let intersectionObserverStub;
|
|
104
|
+
let setTimeoutStub;
|
|
105
|
+
let clearTimeoutStub;
|
|
106
|
+
let observeCalled;
|
|
107
|
+
let unobserveCalled;
|
|
108
|
+
let stateChangeBackup;
|
|
109
|
+
let ti = 1;
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
observeCalled = false;
|
|
112
|
+
unobserveCalled = false;
|
|
113
|
+
sandbox = sinon.sandbox.create();
|
|
114
|
+
|
|
115
|
+
let fakeIntersectionObserver = (stateChange, options) => {
|
|
116
|
+
return {
|
|
117
|
+
observe: (element) => {
|
|
118
|
+
stateChangeBackup = stateChange;
|
|
119
|
+
observeCalled = true;
|
|
120
|
+
stateChange([{ isIntersecting: true }]);
|
|
121
|
+
},
|
|
122
|
+
unobserve: (element) => {
|
|
123
|
+
unobserveCalled = true;
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver);
|
|
129
|
+
setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => {
|
|
130
|
+
// skipping the callback
|
|
131
|
+
return ti++;
|
|
132
|
+
});
|
|
133
|
+
clearTimeoutStub = sandbox.stub(window, 'clearTimeout').callsFake((timeoutId) => { });
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
afterEach(() => {
|
|
137
|
+
sandbox.restore();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should clear the timeout', () => {
|
|
141
|
+
viewability.startMeasurement('10', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
142
|
+
stateChangeBackup([{ isIntersecting: false }]);
|
|
143
|
+
sinon.assert.called(intersectionObserverStub);
|
|
144
|
+
sinon.assert.called(setTimeoutStub);
|
|
145
|
+
sinon.assert.called(clearTimeoutStub);
|
|
146
|
+
expect(observeCalled).to.equal(true);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should unobserve', () => {
|
|
150
|
+
viewability.startMeasurement('11', {}, { method: 'img', value: 'http://my.tracker/123' }, { inViewThreshold: 0.5, timeInView: 1000 });
|
|
151
|
+
sinon.assert.called(intersectionObserverStub);
|
|
152
|
+
sinon.assert.called(setTimeoutStub);
|
|
153
|
+
expect(observeCalled).to.equal(true);
|
|
154
|
+
expect(unobserveCalled).to.equal(false);
|
|
155
|
+
|
|
156
|
+
viewability.stopMeasurement('11');
|
|
157
|
+
expect(unobserveCalled).to.equal(true);
|
|
158
|
+
sinon.assert.called(clearTimeoutStub);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should check for vid existence', () => {
|
|
162
|
+
let logWarnSpy = sandbox.spy(utils, 'logWarn');
|
|
163
|
+
viewability.stopMeasurement('100');
|
|
164
|
+
expect(logWarnSpy.callCount).to.equal(1);
|
|
165
|
+
expect(logWarnSpy.calledWith(`${viewability.MODULE_NAME}: must provide a registered vid`, '100')).to.equal(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('handle creative messages', () => {
|
|
170
|
+
let sandbox;
|
|
171
|
+
let intersectionObserverStub;
|
|
172
|
+
let setTimeoutStub;
|
|
173
|
+
let observeCalled;
|
|
174
|
+
let unobserveCalled;
|
|
175
|
+
let ti = 1;
|
|
176
|
+
let getElementsByTagStub;
|
|
177
|
+
let getElementByIdStub;
|
|
178
|
+
|
|
179
|
+
let fakeContentWindow = {};
|
|
180
|
+
beforeEach(() => {
|
|
181
|
+
observeCalled = false;
|
|
182
|
+
unobserveCalled = false;
|
|
183
|
+
sandbox = sinon.sandbox.create();
|
|
184
|
+
|
|
185
|
+
let fakeIntersectionObserver = (stateChange, options) => {
|
|
186
|
+
return {
|
|
187
|
+
observe: (element) => {
|
|
188
|
+
observeCalled = true;
|
|
189
|
+
stateChange([{ isIntersecting: true }]);
|
|
190
|
+
},
|
|
191
|
+
unobserve: (element) => {
|
|
192
|
+
unobserveCalled = true;
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
intersectionObserverStub = sandbox.stub(window, 'IntersectionObserver').callsFake(fakeIntersectionObserver);
|
|
198
|
+
setTimeoutStub = sandbox.stub(window, 'setTimeout').callsFake((callback, timeout) => {
|
|
199
|
+
callback();
|
|
200
|
+
return ti++;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
getElementsByTagStub = sandbox.stub(document, 'getElementsByTagName').callsFake((tagName) => {
|
|
204
|
+
return [{
|
|
205
|
+
contentWindow: fakeContentWindow,
|
|
206
|
+
}];
|
|
207
|
+
});
|
|
208
|
+
getElementByIdStub = sandbox.stub(document, 'getElementById').callsFake((id) => {
|
|
209
|
+
return {};
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
afterEach(() => {
|
|
214
|
+
sandbox.restore();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('should find element by contentWindow', () => {
|
|
218
|
+
let viewabilityRecord = {
|
|
219
|
+
vid: 1000,
|
|
220
|
+
tracker: {
|
|
221
|
+
value: 'http://my.tracker/123',
|
|
222
|
+
method: 'img',
|
|
223
|
+
},
|
|
224
|
+
criteria: { inViewThreshold: 0.5, timeInView: 1000 },
|
|
225
|
+
message: 'Prebid Viewability',
|
|
226
|
+
action: 'startMeasurement',
|
|
227
|
+
};
|
|
228
|
+
let data = JSON.stringify(viewabilityRecord);
|
|
229
|
+
|
|
230
|
+
viewability.receiveMessage({
|
|
231
|
+
data: data,
|
|
232
|
+
source: fakeContentWindow,
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
sinon.assert.called(getElementsByTagStub);
|
|
236
|
+
sinon.assert.called(intersectionObserverStub);
|
|
237
|
+
sinon.assert.called(setTimeoutStub);
|
|
238
|
+
expect(observeCalled).to.equal(true);
|
|
239
|
+
expect(unobserveCalled).to.equal(true);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('should find element by id', () => {
|
|
243
|
+
let viewabilityRecord = {
|
|
244
|
+
vid: 1001,
|
|
245
|
+
tracker: {
|
|
246
|
+
value: 'http://my.tracker/123',
|
|
247
|
+
method: 'img',
|
|
248
|
+
},
|
|
249
|
+
criteria: { inViewThreshold: 0.5, timeInView: 1000 },
|
|
250
|
+
message: 'Prebid Viewability',
|
|
251
|
+
action: 'startMeasurement',
|
|
252
|
+
elementId: '1',
|
|
253
|
+
};
|
|
254
|
+
let data = JSON.stringify(viewabilityRecord);
|
|
255
|
+
viewability.receiveMessage({
|
|
256
|
+
data: data,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
sinon.assert.called(getElementByIdStub);
|
|
260
|
+
sinon.assert.called(intersectionObserverStub);
|
|
261
|
+
sinon.assert.called(setTimeoutStub);
|
|
262
|
+
expect(observeCalled).to.equal(true);
|
|
263
|
+
expect(unobserveCalled).to.equal(true);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('should stop measurement', () => {
|
|
267
|
+
let viewabilityRecord = {
|
|
268
|
+
vid: 1001,
|
|
269
|
+
message: 'Prebid Viewability',
|
|
270
|
+
action: 'stopMeasurement',
|
|
271
|
+
};
|
|
272
|
+
let data = JSON.stringify(viewabilityRecord);
|
|
273
|
+
viewability.receiveMessage({
|
|
274
|
+
data: data,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
expect(unobserveCalled).to.equal(true);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
});
|