prebid.js 9.4.1 → 9.6.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/.eslintrc.js +31 -5
- package/.github/workflows/jscpd.yml +2 -2
- package/.github/workflows/linter.yml +107 -0
- package/creative/crossDomain.js +6 -3
- package/dist/33acrossAnalyticsAdapter.js +1 -1
- package/dist/33acrossBidAdapter.js +1 -1
- package/dist/33acrossIdSystem.js +1 -1
- package/dist/BTBidAdapter.js +1 -1
- package/dist/adagioAnalyticsAdapter.js +1 -1
- package/dist/adagioBidAdapter.js +1 -1
- package/dist/adagioRtdProvider.js +1 -1
- package/dist/adagioUtils.js +1 -1
- package/dist/addefendBidAdapter.js +1 -1
- package/dist/adgenerationBidAdapter.js +1 -1
- package/dist/adkernelAdnBidAdapter.js +1 -1
- package/dist/adkernelBidAdapter.js +1 -1
- package/dist/adkernelUtils.js +1 -0
- package/dist/adlooxRtdProvider.js +1 -1
- package/dist/admixerBidAdapter.js +1 -1
- package/dist/adqueryBidAdapter.js +1 -1
- package/dist/adrelevantisBidAdapter.js +1 -1
- package/dist/adstirBidAdapter.js +1 -1
- package/dist/adtrgtmeBidAdapter.js +1 -1
- package/dist/advRedAnalyticsAdapter.js +1 -0
- package/dist/adxcgAnalyticsAdapter.js +1 -1
- package/dist/adxcgBidAdapter.js +1 -1
- package/dist/adyoulikeBidAdapter.js +1 -1
- package/dist/agmaAnalyticsAdapter.js +1 -1
- package/dist/aidemBidAdapter.js +1 -1
- package/dist/ajaBidAdapter.js +1 -1
- package/dist/akamaiDapRtdProvider.js +1 -1
- package/dist/amxBidAdapter.js +1 -1
- package/dist/amxIdSystem.js +1 -1
- package/dist/anonymisedRtdProvider.js +1 -1
- package/dist/apacdexBidAdapter.js +1 -1
- package/dist/appierAnalyticsAdapter.js +1 -1
- package/dist/appnexusBidAdapter.js +1 -1
- package/dist/asoBidAdapter.js +1 -1
- package/dist/axonixBidAdapter.js +1 -1
- package/dist/azerionedgeRtdProvider.js +1 -1
- package/dist/bidglassBidAdapter.js +1 -1
- package/dist/big-richmediaBidAdapter.js +1 -1
- package/dist/bridBidAdapter.js +1 -1
- package/dist/bridgewellBidAdapter.js +1 -1
- package/dist/brightMountainMediaBidAdapter.js +1 -1
- package/dist/carodaBidAdapter.js +1 -1
- package/dist/chtnwBidAdapter.js +1 -1
- package/dist/chunk-core.js +1 -1
- package/dist/concertBidAdapter.js +1 -1
- package/dist/connatixBidAdapter.js +1 -1
- package/dist/connectIdSystem.js +1 -1
- package/dist/connectadBidAdapter.js +1 -1
- package/dist/consumableBidAdapter.js +1 -1
- package/dist/contxtfulRtdProvider.js +1 -1
- package/dist/conversantAnalyticsAdapter.js +1 -1
- package/dist/conversantBidAdapter.js +1 -1
- package/dist/craftBidAdapter.js +1 -1
- package/dist/criteoBidAdapter.js +1 -1
- package/dist/currencyUtils.js +1 -1
- package/dist/cwireBidAdapter.js +1 -1
- package/dist/dailymotionBidAdapter.js +1 -1
- package/dist/debugging-standalone.js +1 -1
- package/dist/dependencies.json +69 -8
- package/dist/dfpAdServerVideo.js +1 -1
- package/dist/dfpAdpod.js +1 -1
- package/dist/dfpUtils.js +1 -1
- package/dist/discoveryBidAdapter.js +1 -1
- package/dist/dspxBidAdapter.js +1 -1
- package/dist/dxkultureBidAdapter.js +1 -1
- package/dist/eightPodAnalyticsAdapter.js +1 -1
- package/dist/eightPodBidAdapter.js +1 -1
- package/dist/eplanningBidAdapter.js +1 -1
- package/dist/euidIdSystem.js +1 -1
- package/dist/exadsBidAdapter.js +1 -1
- package/dist/feedadBidAdapter.js +1 -1
- package/dist/finativeBidAdapter.js +1 -1
- package/dist/fintezaAnalyticsAdapter.js +1 -1
- package/dist/fpdUtils.js +1 -0
- package/dist/freewheel-sspBidAdapter.js +1 -1
- package/dist/gmosspBidAdapter.js +1 -1
- package/dist/goldbachBidAdapter.js +1 -1
- package/dist/gptPreAuction.js +1 -1
- package/dist/gptUtils.js +1 -1
- package/dist/greenbidsAnalyticsAdapter.js +1 -1
- package/dist/greenbidsRtdProvider.js +1 -1
- package/dist/gridBidAdapter.js +1 -1
- package/dist/growthCodeAnalyticsAdapter.js +1 -1
- package/dist/growthCodeRtdProvider.js +1 -1
- package/dist/gumgumBidAdapter.js +1 -1
- package/dist/h12mediaBidAdapter.js +1 -1
- package/dist/hypelabBidAdapter.js +1 -1
- package/dist/id5AnalyticsAdapter.js +1 -1
- package/dist/id5IdSystem.js +1 -1
- package/dist/imdsBidAdapter.js +1 -1
- package/dist/improvedigitalBidAdapter.js +1 -1
- package/dist/insticatorBidAdapter.js +1 -1
- package/dist/intentIqAnalyticsAdapter.js +1 -0
- package/dist/ixBidAdapter.js +1 -1
- package/dist/jixieBidAdapter.js +1 -1
- package/dist/justpremiumBidAdapter.js +1 -1
- package/dist/jwplayerBidAdapter.js +1 -1
- package/dist/jwplayerRtdProvider.js +1 -1
- package/dist/kargoBidAdapter.js +1 -1
- package/dist/kimberliteBidAdapter.js +1 -1
- package/dist/konduitAnalyticsAdapter.js +1 -1
- package/dist/kueezBidAdapter.js +1 -1
- package/dist/lassoBidAdapter.js +1 -1
- package/dist/lifestreetBidAdapter.js +1 -1
- package/dist/liveIntentIdSystem.js +1 -1
- package/dist/logicadBidAdapter.js +1 -1
- package/dist/loglyliftBidAdapter.js +1 -1
- package/dist/luceadBidAdapter.js +1 -1
- package/dist/mabidderBidAdapter.js +1 -1
- package/dist/magniteAnalyticsAdapter.js +1 -1
- package/dist/malltvAnalyticsAdapter.js +1 -1
- package/dist/marsmediaBidAdapter.js +1 -1
- package/dist/mediafuseBidAdapter.js +1 -1
- package/dist/mediagoBidAdapter.js +1 -1
- package/dist/medianetAnalyticsAdapter.js +1 -1
- package/dist/medianetBidAdapter.js +1 -1
- package/dist/mediasquareBidAdapter.js +1 -1
- package/dist/mgidBidAdapter.js +1 -1
- package/dist/minutemediaBidAdapter.js +1 -1
- package/dist/missenaBidAdapter.js +1 -1
- package/dist/mobianRtdProvider.js +1 -1
- package/dist/nextMillenniumBidAdapter.js +1 -1
- package/dist/nexx360BidAdapter.js +1 -1
- package/dist/nobidAnalyticsAdapter.js +1 -1
- package/dist/nobidBidAdapter.js +1 -1
- package/dist/not-for-prod/prebid.js +208 -199
- package/dist/oguryBidAdapter.js +1 -1
- package/dist/onetagBidAdapter.js +1 -1
- package/dist/ooloAnalyticsAdapter.js +1 -1
- package/dist/openwebBidAdapter.js +1 -1
- package/dist/openxBidAdapter.js +1 -1
- package/dist/optidigitalBidAdapter.js +1 -1
- package/dist/optoutBidAdapter.js +1 -1
- package/dist/orbidderBidAdapter.js +1 -1
- package/dist/outbrainBidAdapter.js +1 -1
- package/dist/paapi.js +1 -1
- package/dist/permutiveRtdProvider.js +1 -1
- package/dist/pixfutureBidAdapter.js +1 -1
- package/dist/playdigoBidAdapter.js +1 -1
- package/dist/prebidServerBidAdapter.js +1 -1
- package/dist/programmaticaBidAdapter.js +1 -1
- package/dist/publinkIdSystem.js +1 -1
- package/dist/publirBidAdapter.js +1 -1
- package/dist/pubmaticAnalyticsAdapter.js +1 -1
- package/dist/pubmaticBidAdapter.js +1 -1
- package/dist/pubwiseAnalyticsAdapter.js +1 -1
- package/dist/pubxaiAnalyticsAdapter.js +1 -1
- package/dist/pxyzBidAdapter.js +1 -1
- package/dist/quantcastBidAdapter.js +1 -1
- package/dist/readpeakBidAdapter.js +1 -1
- package/dist/relaidoBidAdapter.js +1 -1
- package/dist/relevatehealthBidAdapter.js +1 -1
- package/dist/retailspotBidAdapter.js +1 -1
- package/dist/rhythmoneBidAdapter.js +1 -1
- package/dist/ringieraxelspringerBidAdapter.js +1 -1
- package/dist/riseBidAdapter.js +1 -1
- package/dist/riseUtils.js +1 -0
- package/dist/rubiconBidAdapter.js +1 -1
- package/dist/schainSerializer.js +1 -0
- package/dist/seedingAllianceBidAdapter.js +1 -1
- package/dist/seedtagBidAdapter.js +1 -1
- package/dist/sharethroughAnalyticsAdapter.js +1 -1
- package/dist/sharethroughBidAdapter.js +1 -1
- package/dist/shinezBidAdapter.js +1 -1
- package/dist/sizeMapping.js +1 -1
- package/dist/sizeUtils.js +1 -1
- package/dist/smaatoBidAdapter.js +1 -1
- package/dist/smartadserverBidAdapter.js +1 -1
- package/dist/smarthubBidAdapter.js +1 -1
- package/dist/smartxBidAdapter.js +1 -1
- package/dist/smilewantedBidAdapter.js +1 -1
- package/dist/snigelBidAdapter.js +1 -1
- package/dist/sonobiBidAdapter.js +1 -1
- package/dist/sovrnBidAdapter.js +1 -1
- package/dist/sspBCBidAdapter.js +1 -1
- package/dist/stnBidAdapter.js +1 -1
- package/dist/stvBidAdapter.js +1 -1
- package/dist/sublimeBidAdapter.js +1 -1
- package/dist/symitriDapRtdProvider.js +1 -0
- package/dist/taboolaBidAdapter.js +1 -1
- package/dist/tappxBidAdapter.js +1 -1
- package/dist/targetVideoBidAdapter.js +1 -1
- package/dist/targetVideoUtils.js +1 -0
- package/dist/teadsBidAdapter.js +1 -1
- package/dist/telariaBidAdapter.js +1 -1
- package/dist/teqblazeUtils.js +1 -1
- package/dist/terceptAnalyticsAdapter.js +1 -1
- package/dist/themoneytizerBidAdapter.js +1 -1
- package/dist/trionBidAdapter.js +1 -1
- package/dist/tripleliftBidAdapter.js +1 -1
- package/dist/ttdBidAdapter.js +1 -1
- package/dist/ucfunnelAnalyticsAdapter.js +1 -1
- package/dist/uid2IdSystem.js +1 -1
- package/dist/uid2IdSystem_shared.js +1 -1
- package/dist/underdogmediaBidAdapter.js +1 -1
- package/dist/undertoneBidAdapter.js +1 -1
- package/dist/unrulyBidAdapter.js +1 -1
- package/dist/userAgentUtils.js +1 -0
- package/dist/utiqIdSystem.js +1 -1
- package/dist/vidazooUtils.js +1 -1
- package/dist/videobyteBidAdapter.js +1 -1
- package/dist/visxBidAdapter.js +1 -1
- package/dist/vuukleBidAdapter.js +1 -1
- package/dist/widespaceBidAdapter.js +1 -1
- package/dist/winrBidAdapter.js +1 -1
- package/dist/yahooAdsBidAdapter.js +1 -1
- package/dist/yandexIdSystem.js +1 -1
- package/dist/yieldmoBidAdapter.js +1 -1
- package/dist/yieldoneAnalyticsAdapter.js +1 -1
- package/integrationExamples/gpt/x-domain/creative.html +1 -1
- package/libraries/adkernelUtils/adkernelUtils.js +11 -0
- package/libraries/currencyUtils/floor.js +23 -0
- package/libraries/dfpUtils/dfpUtils.js +7 -0
- package/libraries/fpdUtils/deviceInfo.js +58 -0
- package/libraries/fpdUtils/pageInfo.js +73 -0
- package/libraries/gptUtils/gptUtils.js +23 -1
- package/libraries/riseUtils/index.js +330 -0
- package/libraries/schainSerializer/schainSerializer.js +24 -0
- package/libraries/sizeUtils/tranformSize.js +43 -0
- package/libraries/targetVideoUtils/bidderUtils.js +178 -0
- package/libraries/targetVideoUtils/constants.js +23 -0
- package/libraries/teqblazeUtils/bidderUtils.js +15 -11
- package/libraries/userAgentUtils/index.js +58 -0
- package/libraries/userAgentUtils/userAgentTypes.enums.js +22 -0
- package/modules/.submodules.json +1 -0
- package/modules/33acrossAnalyticsAdapter.js +2 -0
- package/modules/adagioAnalyticsAdapter.js +101 -84
- package/modules/adagioAnalyticsAdapter.md +4 -0
- package/modules/adagioBidAdapter.js +5 -17
- package/modules/adagioRtdProvider.js +18 -4
- package/modules/adkernelAdnBidAdapter.js +1 -12
- package/modules/adkernelBidAdapter.js +4 -13
- package/modules/adlooxAnalyticsAdapter.js +1 -0
- package/modules/admixerBidAdapter.js +10 -6
- package/modules/admixerBidAdapter.md +7 -10
- package/modules/adtrgtmeBidAdapter.js +1 -1
- package/modules/advRedAnalyticsAdapter.js +198 -0
- package/modules/advRedAnalyticsAdapter.md +30 -0
- package/modules/aidemBidAdapter.js +2 -0
- package/modules/akamaiDapRtdProvider.js +19 -798
- package/modules/anonymisedRtdProvider.js +5 -1
- package/modules/anonymisedRtdProvider.md +1 -1
- package/modules/apacdexBidAdapter.js +1 -1
- package/modules/appnexusBidAdapter.js +56 -2
- package/modules/automatadAnalyticsAdapter.js +2 -0
- package/modules/azerionedgeRtdProvider.js +13 -3
- package/modules/azerionedgeRtdProvider.md +0 -17
- package/modules/bridBidAdapter.js +47 -47
- package/modules/cleanioRtdProvider.js +1 -0
- package/modules/concertBidAdapter.js +1 -1
- package/modules/connatixBidAdapter.js +36 -8
- package/modules/connectIdSystem.js +6 -2
- package/modules/contxtfulRtdProvider.js +20 -2
- package/modules/contxtfulRtdProvider.md +1 -0
- package/modules/craftBidAdapter.js +1 -1
- package/modules/criteoBidAdapter.js +1 -1
- package/modules/cwireBidAdapter.js +5 -1
- package/modules/dailymotionBidAdapter.js +85 -65
- package/modules/debugging/debugging.js +3 -0
- package/modules/dfpAdServerVideo.js +15 -33
- package/modules/dfpAdpod.js +2 -6
- package/modules/dgkeywordRtdProvider.js +2 -0
- package/modules/discoveryBidAdapter.js +26 -210
- package/modules/dspxBidAdapter.js +176 -54
- package/modules/eightPodAnalyticsAdapter.js +28 -34
- package/modules/eightPodBidAdapter.js +113 -57
- package/modules/fintezaAnalyticsAdapter.js +9 -4
- package/modules/goldbachBidAdapter.js +1 -1
- package/modules/gptPreAuction.js +63 -4
- package/modules/growthCodeAnalyticsAdapter.js +1 -1
- package/modules/growthCodeRtdProvider.js +1 -1
- package/modules/gumgumBidAdapter.js +14 -10
- package/modules/improvedigitalBidAdapter.js +1 -1
- package/modules/insticatorBidAdapter.js +35 -31
- package/modules/intentIqAnalyticsAdapter.js +234 -0
- package/modules/intentIqAnalyticsAdapter.md +27 -0
- package/modules/intentIqIdSystem.md +0 -0
- package/modules/jwplayerBidAdapter.js +1 -1
- package/modules/jwplayerRtdProvider.js +26 -6
- package/modules/jwplayerVideoProvider.js +6 -0
- package/modules/kargoBidAdapter.js +11 -14
- package/modules/kimberliteBidAdapter.js +24 -7
- package/modules/kimberliteBidAdapter.md +30 -1
- package/modules/mediafuseBidAdapter.js +1 -1
- package/modules/mediagoBidAdapter.js +7 -176
- package/modules/medianetBidAdapter.js +101 -40
- package/modules/mgidBidAdapter.js +3 -1
- package/modules/minutemediaBidAdapter.js +21 -398
- package/modules/mobianRtdProvider.js +16 -2
- package/modules/nextMillenniumBidAdapter.js +1 -27
- package/modules/nexx360BidAdapter.js +3 -2
- package/modules/nobidBidAdapter.js +1 -1
- package/modules/openwebBidAdapter.js +18 -396
- package/modules/optoutBidAdapter.js +1 -1
- package/modules/paapi.js +48 -35
- package/modules/permutiveRtdProvider.js +72 -22
- package/modules/playdigoBidAdapter.js +4 -2
- package/modules/prebidServerBidAdapter/index.js +4 -2
- package/modules/prebidServerBidAdapter/ortbConverter.js +1 -0
- package/modules/programmaticaBidAdapter.js +1 -1
- package/modules/publirBidAdapter.js +20 -273
- package/modules/pubmaticBidAdapter.js +12 -0
- package/modules/pubxaiAnalyticsAdapter.js +306 -164
- package/modules/relevatehealthBidAdapter.js +2 -1
- package/modules/resetdigitalBidAdapter.md +54 -45
- package/modules/richaudienceBidAdapter.js +1 -1
- package/modules/riseBidAdapter.js +19 -400
- package/modules/rtdModule/index.js +5 -3
- package/modules/shinezBidAdapter.js +17 -361
- package/modules/sirdataRtdProvider.js +2 -0
- package/modules/sizeMapping.js +2 -5
- package/modules/smaatoBidAdapter.js +18 -1
- package/modules/smarthubBidAdapter.js +45 -177
- package/modules/smilewantedBidAdapter.js +26 -22
- package/modules/snigelBidAdapter.js +1 -1
- package/modules/sonobiBidAdapter.js +5 -10
- package/modules/stnBidAdapter.js +22 -398
- package/modules/symitriDapRtdProvider.js +812 -0
- package/modules/symitriDapRtdProvider.md +49 -0
- package/modules/targetVideoBidAdapter.js +120 -152
- package/modules/targetVideoBidAdapter.md +20 -3
- package/modules/telariaBidAdapter.js +2 -32
- package/modules/uid2IdSystem_shared.js +51 -39
- package/modules/userId/eids.js +3 -0
- package/modules/utiqIdSystem.js +12 -10
- package/modules/validationFpdModule/index.js +22 -17
- package/modules/videojsVideoProvider.js +3 -0
- package/modules/visxBidAdapter.js +1 -1
- package/modules/winrBidAdapter.js +2 -27
- package/modules/yahooAdsBidAdapter.js +1 -1
- package/modules/yandexIdSystem.js +1 -1
- package/package.json +4 -4
- package/plugins/eslint/index.js +73 -45
- package/src/adloader.js +1 -0
- package/src/ajax.js +15 -0
- package/src/config.js +0 -4
- package/src/debugging.js +1 -0
- package/src/prebid.js +4 -0
- package/src/secureCreatives.js +1 -1
- package/src/storageManager.js +62 -73
- package/src/targeting.js +26 -20
- package/src/utils.js +9 -0
- package/test/pages/consent_mgt_gdpr.html +1 -1
- package/test/spec/ajax_spec.js +11 -0
- package/test/spec/creative/crossDomainCreative_spec.js +26 -9
- package/test/spec/fpd/gdpr_spec.js +1 -1
- package/test/spec/libraries/userAgentUtils_spec.js +109 -0
- package/test/spec/modules/adagioAnalyticsAdapter_spec.js +231 -141
- package/test/spec/modules/adagioBidAdapter_spec.js +32 -66
- package/test/spec/modules/adagioRtdProvider_spec.js +72 -0
- package/test/spec/modules/admixerBidAdapter_spec.js +21 -17
- package/test/spec/modules/advRedAnalyticsAdapter_spec.js +114 -0
- package/test/spec/modules/adxcgBidAdapter_spec.js +1 -1
- package/test/spec/modules/appnexusBidAdapter_spec.js +36 -0
- package/test/spec/modules/azerionedgeRtdProvider_spec.js +36 -21
- package/test/spec/modules/connatixBidAdapter_spec.js +55 -2
- package/test/spec/modules/connectIdSystem_spec.js +27 -28
- package/test/spec/modules/consentManagement_spec.js +1 -1
- package/test/spec/modules/contxtfulRtdProvider_spec.js +6 -0
- package/test/spec/modules/dailymotionBidAdapter_spec.js +497 -4
- package/test/spec/modules/discoveryBidAdapter_spec.js +9 -6
- package/test/spec/modules/dspxBidAdapter_spec.js +188 -7
- package/test/spec/modules/eightPodAnalyticsAdapter_spec.js +22 -13
- package/test/spec/modules/gptPreAuction_spec.js +143 -1
- package/test/spec/modules/gumgumBidAdapter_spec.js +17 -0
- package/test/spec/modules/insticatorBidAdapter_spec.js +8 -1
- package/test/spec/modules/intentIqAnalyticsAdapter_spec.js +172 -0
- package/test/spec/modules/jwplayerRtdProvider_spec.js +61 -0
- package/test/spec/modules/kargoBidAdapter_spec.js +7 -8
- package/test/spec/modules/kimberliteBidAdapter_spec.js +137 -65
- package/test/spec/modules/mediagoBidAdapter_spec.js +34 -37
- package/test/spec/modules/medianetBidAdapter_spec.js +297 -16
- package/test/spec/modules/mgidBidAdapter_spec.js +15 -5
- package/test/spec/modules/mobianRtdProvider_spec.js +1 -3
- package/test/spec/modules/nexx360BidAdapter_spec.js +1 -1
- package/test/spec/modules/paapi_spec.js +177 -111
- package/test/spec/modules/permutiveRtdProvider_spec.js +42 -8
- package/test/spec/modules/prebidServerBidAdapter_spec.js +17 -3
- package/test/spec/modules/proxistoreBidAdapter_spec.js +1 -1
- package/test/spec/modules/pubmaticBidAdapter_spec.js +40 -0
- package/test/spec/modules/pubxaiAnalyticsAdapter_spec.js +970 -603
- package/test/spec/modules/pulsepointBidAdapter_spec.js +4 -4
- package/test/spec/modules/smaatoBidAdapter_spec.js +36 -1
- package/test/spec/modules/smarthubBidAdapter_spec.js +6 -4
- package/test/spec/modules/smilewantedBidAdapter_spec.js +57 -1
- package/test/spec/modules/symitriDapRtdProvider_spec.js +600 -0
- package/test/spec/modules/targetVideoBidAdapter_spec.js +112 -11
- package/test/spec/modules/yandexIdSystem_spec.js +6 -1
- package/test/spec/schainSerializer/schainSerializer_spec.js +138 -0
- package/test/spec/unit/core/storageManager_spec.js +68 -51
- package/test/spec/unit/pbjs_api_spec.js +11 -0
- package/test/spec/utils_spec.js +19 -0
- /package/src/utils/{gpdr.js → gdpr.js} +0 -0
package/src/ajax.js
CHANGED
|
@@ -104,6 +104,7 @@ function toXHR({status, statusText = '', headers, url}, responseText) {
|
|
|
104
104
|
return xml;
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
+
// eslint-disable-next-line prebid/no-global
|
|
107
108
|
readyState: XMLHttpRequest.DONE,
|
|
108
109
|
status,
|
|
109
110
|
statusText,
|
|
@@ -147,5 +148,19 @@ export function ajaxBuilder(timeout = 3000, {request, done} = {}) {
|
|
|
147
148
|
};
|
|
148
149
|
}
|
|
149
150
|
|
|
151
|
+
/**
|
|
152
|
+
* simple wrapper around sendBeacon such that invocations of navigator.sendBeacon can be centrally maintained.
|
|
153
|
+
* verifies that the navigator and sendBeacon are defined for maximum compatibility
|
|
154
|
+
* @param {string} url The URL that will receive the data. Can be relative or absolute.
|
|
155
|
+
* @param {*} data An ArrayBuffer, a TypedArray, a DataView, a Blob, a string literal or object, a FormData or a URLSearchParams object containing the data to send.
|
|
156
|
+
* @returns {boolean} true if the user agent successfully queued the data for transfer. Otherwise, it returns false.
|
|
157
|
+
*/
|
|
158
|
+
export function sendBeacon(url, data) {
|
|
159
|
+
if (!window.navigator || !window.navigator.sendBeacon) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
return window.navigator.sendBeacon(url, data);
|
|
163
|
+
}
|
|
164
|
+
|
|
150
165
|
export const ajax = ajaxBuilder();
|
|
151
166
|
export const fetch = fetcherFactory();
|
package/src/config.js
CHANGED
|
@@ -38,8 +38,6 @@ const DEFAULT_DEVICE_ACCESS = true;
|
|
|
38
38
|
const DEFAULT_MAX_NESTED_IFRAMES = 10;
|
|
39
39
|
const DEFAULT_MAXBID_VALUE = 5000
|
|
40
40
|
|
|
41
|
-
const DEFAULT_TIMEOUTBUFFER = 400;
|
|
42
|
-
|
|
43
41
|
const DEFAULT_IFRAMES_CONFIG = {};
|
|
44
42
|
|
|
45
43
|
export const RANDOM = 'random';
|
|
@@ -157,8 +155,6 @@ export function newConfig() {
|
|
|
157
155
|
*/
|
|
158
156
|
deviceAccess: DEFAULT_DEVICE_ACCESS,
|
|
159
157
|
|
|
160
|
-
// timeout buffer to adjust for bidder CDN latency
|
|
161
|
-
timeoutBuffer: DEFAULT_TIMEOUTBUFFER,
|
|
162
158
|
disableAjaxTimeout: DEFAULT_DISABLE_AJAX_TIMEOUT,
|
|
163
159
|
|
|
164
160
|
// default max nested iframes for referer detection
|
package/src/debugging.js
CHANGED
package/src/prebid.js
CHANGED
|
@@ -869,6 +869,10 @@ pbjsInstance.getHighestCpmBids = function (adUnitCode) {
|
|
|
869
869
|
return targeting.getWinningBids(adUnitCode);
|
|
870
870
|
};
|
|
871
871
|
|
|
872
|
+
pbjsInstance.clearAllAuctions = function () {
|
|
873
|
+
auctionManager.clearAllAuctions();
|
|
874
|
+
};
|
|
875
|
+
|
|
872
876
|
if (FEATURES.VIDEO) {
|
|
873
877
|
/**
|
|
874
878
|
* Mark the winning bid as used, should only be used in conjunction with video
|
package/src/secureCreatives.js
CHANGED
|
@@ -144,7 +144,7 @@ export function resizeRemoteCreative({adId, adUnitCode, width, height}) {
|
|
|
144
144
|
elementStyle.width = getDimension(width)
|
|
145
145
|
elementStyle.height = getDimension(height);
|
|
146
146
|
} else {
|
|
147
|
-
|
|
147
|
+
logError(`Unable to locate matching page element for adUnitCode ${adUnitCode}. Can't resize it to ad's dimensions. Please review setup.`);
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
|
package/src/storageManager.js
CHANGED
|
@@ -18,6 +18,8 @@ export const STORAGE_TYPE_COOKIES = 'cookie';
|
|
|
18
18
|
|
|
19
19
|
export let storageCallbacks = [];
|
|
20
20
|
|
|
21
|
+
/* eslint-disable prebid/no-global */
|
|
22
|
+
|
|
21
23
|
/*
|
|
22
24
|
* Storage manager constructor. Consumers should prefer one of `getStorageManager` or `getCoreStorageManager`.
|
|
23
25
|
*/
|
|
@@ -64,6 +66,7 @@ export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = is
|
|
|
64
66
|
const expiresPortion = (expires && expires !== '') ? ` ;expires=${expires}` : '';
|
|
65
67
|
const isNone = (sameSite != null && sameSite.toLowerCase() == 'none')
|
|
66
68
|
const secure = (isNone) ? '; Secure' : '';
|
|
69
|
+
// eslint-disable-next-line prebid/no-member
|
|
67
70
|
document.cookie = `${key}=${encodeURIComponent(value)}${expiresPortion}; path=/${domainPortion}${sameSite ? `; SameSite=${sameSite}` : ''}${secure}`;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -85,27 +88,6 @@ export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = is
|
|
|
85
88
|
return schedule(cb, STORAGE_TYPE_COOKIES, done);
|
|
86
89
|
};
|
|
87
90
|
|
|
88
|
-
/**
|
|
89
|
-
* @returns {boolean}
|
|
90
|
-
*/
|
|
91
|
-
const localStorageIsEnabled = function (done) {
|
|
92
|
-
let cb = function (result) {
|
|
93
|
-
if (result && result.valid) {
|
|
94
|
-
try {
|
|
95
|
-
localStorage.setItem('prebid.cookieTest', '1');
|
|
96
|
-
return localStorage.getItem('prebid.cookieTest') === '1';
|
|
97
|
-
} catch (error) {
|
|
98
|
-
} finally {
|
|
99
|
-
try {
|
|
100
|
-
localStorage.removeItem('prebid.cookieTest');
|
|
101
|
-
} catch (error) {}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
91
|
/**
|
|
110
92
|
* @returns {boolean}
|
|
111
93
|
*/
|
|
@@ -119,60 +101,69 @@ export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = is
|
|
|
119
101
|
return schedule(cb, STORAGE_TYPE_COOKIES, done);
|
|
120
102
|
}
|
|
121
103
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
*/
|
|
126
|
-
const setDataInLocalStorage = function (key, value, done) {
|
|
127
|
-
let cb = function (result) {
|
|
128
|
-
if (result && result.valid && hasLocalStorage()) {
|
|
129
|
-
window.localStorage.setItem(key, value);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
133
|
-
}
|
|
104
|
+
function storageMethods(name) {
|
|
105
|
+
const capName = name.charAt(0).toUpperCase() + name.substring(1);
|
|
106
|
+
const backend = () => window[name];
|
|
134
107
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* @param {string} key
|
|
151
|
-
*/
|
|
152
|
-
const removeDataFromLocalStorage = function (key, done) {
|
|
153
|
-
let cb = function (result) {
|
|
154
|
-
if (result && result.valid && hasLocalStorage()) {
|
|
155
|
-
window.localStorage.removeItem(key);
|
|
108
|
+
const hasStorage = function (done) {
|
|
109
|
+
let cb = function (result) {
|
|
110
|
+
if (result && result.valid) {
|
|
111
|
+
try {
|
|
112
|
+
return !!backend();
|
|
113
|
+
} catch (e) {
|
|
114
|
+
logError(`${name} api disabled`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
156
118
|
}
|
|
119
|
+
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
157
120
|
}
|
|
158
|
-
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
159
|
-
}
|
|
160
121
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
122
|
+
return {
|
|
123
|
+
[`has${capName}`]: hasStorage,
|
|
124
|
+
[`${name}IsEnabled`](done) {
|
|
125
|
+
let cb = function (result) {
|
|
126
|
+
if (result && result.valid) {
|
|
127
|
+
try {
|
|
128
|
+
backend().setItem('prebid.cookieTest', '1');
|
|
129
|
+
return backend().getItem('prebid.cookieTest') === '1';
|
|
130
|
+
} catch (error) {
|
|
131
|
+
} finally {
|
|
132
|
+
try {
|
|
133
|
+
backend().removeItem('prebid.cookieTest');
|
|
134
|
+
} catch (error) {}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
171
138
|
}
|
|
139
|
+
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
140
|
+
},
|
|
141
|
+
[`setDataIn${capName}`](key, value, done) {
|
|
142
|
+
let cb = function (result) {
|
|
143
|
+
if (result && result.valid && hasStorage()) {
|
|
144
|
+
backend().setItem(key, value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
148
|
+
},
|
|
149
|
+
[`getDataFrom${capName}`](key, done) {
|
|
150
|
+
let cb = function (result) {
|
|
151
|
+
if (result && result.valid && hasStorage()) {
|
|
152
|
+
return backend().getItem(key);
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
157
|
+
},
|
|
158
|
+
[`removeDataFrom${capName}`](key, done) {
|
|
159
|
+
let cb = function (result) {
|
|
160
|
+
if (result && result.valid && hasStorage()) {
|
|
161
|
+
backend().removeItem(key);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
172
165
|
}
|
|
173
|
-
return false;
|
|
174
166
|
}
|
|
175
|
-
return schedule(cb, STORAGE_TYPE_LOCALSTORAGE, done);
|
|
176
167
|
}
|
|
177
168
|
|
|
178
169
|
/**
|
|
@@ -186,6 +177,7 @@ export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = is
|
|
|
186
177
|
if (result && result.valid) {
|
|
187
178
|
const all = [];
|
|
188
179
|
if (hasDeviceAccess()) {
|
|
180
|
+
// eslint-disable-next-line prebid/no-member
|
|
189
181
|
const cookies = document.cookie.split(';');
|
|
190
182
|
while (cookies.length) {
|
|
191
183
|
const cookie = cookies.pop();
|
|
@@ -207,12 +199,9 @@ export function newStorageManager({moduleName, moduleType} = {}, {isAllowed = is
|
|
|
207
199
|
return {
|
|
208
200
|
setCookie,
|
|
209
201
|
getCookie,
|
|
210
|
-
localStorageIsEnabled,
|
|
211
202
|
cookiesAreEnabled,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
removeDataFromLocalStorage,
|
|
215
|
-
hasLocalStorage,
|
|
203
|
+
...storageMethods('localStorage'),
|
|
204
|
+
...storageMethods('sessionStorage'),
|
|
216
205
|
findSimilarCookies
|
|
217
206
|
}
|
|
218
207
|
}
|
package/src/targeting.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import { auctionManager } from './auctionManager.js';
|
|
2
|
+
import { getTTL } from './bidTTL.js';
|
|
3
|
+
import { bidderSettings } from './bidderSettings.js';
|
|
4
|
+
import { config } from './config.js';
|
|
5
|
+
import {
|
|
6
|
+
BID_STATUS,
|
|
7
|
+
DEFAULT_TARGETING_KEYS,
|
|
8
|
+
EVENTS,
|
|
9
|
+
JSON_MAPPING,
|
|
10
|
+
NATIVE_KEYS,
|
|
11
|
+
STATUS,
|
|
12
|
+
TARGETING_KEYS
|
|
13
|
+
} from './constants.js';
|
|
14
|
+
import * as events from './events.js';
|
|
15
|
+
import { hook } from './hook.js';
|
|
16
|
+
import { ADPOD } from './mediaTypes.js';
|
|
17
|
+
import { NATIVE_TARGETING_KEYS } from './native.js';
|
|
18
|
+
import { find, includes } from './polyfill.js';
|
|
1
19
|
import {
|
|
2
20
|
deepAccess,
|
|
3
21
|
deepClone,
|
|
@@ -14,25 +32,7 @@ import {
|
|
|
14
32
|
timestamp,
|
|
15
33
|
uniques,
|
|
16
34
|
} from './utils.js';
|
|
17
|
-
import {
|
|
18
|
-
import {NATIVE_TARGETING_KEYS} from './native.js';
|
|
19
|
-
import {auctionManager} from './auctionManager.js';
|
|
20
|
-
import {ADPOD} from './mediaTypes.js';
|
|
21
|
-
import {hook} from './hook.js';
|
|
22
|
-
import {bidderSettings} from './bidderSettings.js';
|
|
23
|
-
import {find, includes} from './polyfill.js';
|
|
24
|
-
import {
|
|
25
|
-
BID_STATUS,
|
|
26
|
-
DEFAULT_TARGETING_KEYS,
|
|
27
|
-
EVENTS,
|
|
28
|
-
JSON_MAPPING,
|
|
29
|
-
NATIVE_KEYS,
|
|
30
|
-
STATUS,
|
|
31
|
-
TARGETING_KEYS
|
|
32
|
-
} from './constants.js';
|
|
33
|
-
import {getHighestCpm, getOldestHighestCpmBid} from './utils/reducers.js';
|
|
34
|
-
import {getTTL} from './bidTTL.js';
|
|
35
|
-
import * as events from './events.js';
|
|
35
|
+
import { getHighestCpm, getOldestHighestCpmBid } from './utils/reducers.js';
|
|
36
36
|
|
|
37
37
|
var pbTargetingKeys = [];
|
|
38
38
|
|
|
@@ -139,7 +139,7 @@ export function sortByDealAndPriceBucketOrCpm(useCpm = false) {
|
|
|
139
139
|
* @param {Array<String>} adUnitCodes
|
|
140
140
|
* @param customSlotMatching
|
|
141
141
|
* @param getSlots
|
|
142
|
-
* @return {
|
|
142
|
+
* @return {Object.<string,any>}
|
|
143
143
|
*/
|
|
144
144
|
export function getGPTSlotsForAdUnits(adUnitCodes, customSlotMatching, getSlots = () => window.googletag.pubads().getSlots()) {
|
|
145
145
|
return getSlots().reduce((auToSlots, slot) => {
|
|
@@ -461,10 +461,16 @@ export function newTargeting(auctionManager) {
|
|
|
461
461
|
});
|
|
462
462
|
});
|
|
463
463
|
|
|
464
|
+
targeting.targetingDone(targetingSet);
|
|
465
|
+
|
|
464
466
|
// emit event
|
|
465
467
|
events.emit(EVENTS.SET_TARGETING, targetingSet);
|
|
466
468
|
}, 'setTargetingForGPT');
|
|
467
469
|
|
|
470
|
+
targeting.targetingDone = hook('sync', function (targetingSet) {
|
|
471
|
+
return targetingSet;
|
|
472
|
+
}, 'targetingDone');
|
|
473
|
+
|
|
468
474
|
/**
|
|
469
475
|
* normlizes input to a `adUnit.code` array
|
|
470
476
|
* @param {(string|string[])} adUnitCode [description]
|
package/src/utils.js
CHANGED
|
@@ -748,6 +748,7 @@ export function hasDeviceAccess() {
|
|
|
748
748
|
* @returns {(boolean|undefined)}
|
|
749
749
|
*/
|
|
750
750
|
export function checkCookieSupport() {
|
|
751
|
+
// eslint-disable-next-line prebid/no-member
|
|
751
752
|
if (window.navigator.cookieEnabled || !!document.cookie.length) {
|
|
752
753
|
return true;
|
|
753
754
|
}
|
|
@@ -1109,6 +1110,14 @@ export function safeJSONParse(data) {
|
|
|
1109
1110
|
} catch (e) {}
|
|
1110
1111
|
}
|
|
1111
1112
|
|
|
1113
|
+
export function safeJSONEncode(data) {
|
|
1114
|
+
try {
|
|
1115
|
+
return JSON.stringify(data);
|
|
1116
|
+
} catch (e) {
|
|
1117
|
+
return '';
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1112
1121
|
/**
|
|
1113
1122
|
* Returns a memoized version of `fn`.
|
|
1114
1123
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
<head>
|
|
3
|
-
<script async src="http://localhost:4444/bundle?modules=appnexusBidAdapter&modules=consentManagement&modules=
|
|
3
|
+
<script async src="http://localhost:4444/bundle?modules=appnexusBidAdapter&modules=consentManagement&modules=gdprEnforcement"></script>
|
|
4
4
|
<script async src="https://www.googletagservices.com/tag/js/gpt.js"></script>
|
|
5
5
|
<script>
|
|
6
6
|
(function (window, document) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { sendBeacon } from '../../src/ajax.js'
|
|
3
|
+
|
|
4
|
+
describe('test sendBeacon wrapper', () => {
|
|
5
|
+
it('with legitimate behaviour', () => {
|
|
6
|
+
sinon.stub(navigator, 'sendBeacon').returns(true);
|
|
7
|
+
expect(sendBeacon('http://localhost:80/')).to.equal(true);
|
|
8
|
+
expect(navigator.sendBeacon.callCount).to.equal(1);
|
|
9
|
+
navigator.sendBeacon.restore();
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -72,12 +72,6 @@ describe('cross-domain creative', () => {
|
|
|
72
72
|
expect(messages[0].targetOrigin).to.eql('https://domain.com:123')
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
it('posts to first parent if no __pb_locator__ can be found', () => {
|
|
76
|
-
delete win.parent.frames['__pb_locator__'];
|
|
77
|
-
renderAd({pubUrl: 'https://www.example.com'});
|
|
78
|
-
expect(messages.length).to.eql(1);
|
|
79
|
-
})
|
|
80
|
-
|
|
81
75
|
describe('when there are multiple ancestors', () => {
|
|
82
76
|
let target;
|
|
83
77
|
beforeEach(() => {
|
|
@@ -88,16 +82,39 @@ describe('cross-domain creative', () => {
|
|
|
88
82
|
parent: {
|
|
89
83
|
...target,
|
|
90
84
|
parent: {
|
|
85
|
+
top,
|
|
91
86
|
frames: {'__pb_locator__': {}},
|
|
92
|
-
|
|
87
|
+
parent: {
|
|
88
|
+
top,
|
|
89
|
+
frames: {}
|
|
90
|
+
},
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
}
|
|
96
94
|
})
|
|
97
|
-
|
|
95
|
+
Object.entries({
|
|
96
|
+
'throws': () => { throw new DOMException() },
|
|
97
|
+
'does not throw': () => ({})
|
|
98
|
+
}).forEach(([t, getFrames]) => {
|
|
99
|
+
describe(`when an ancestor ${t}`, () => {
|
|
100
|
+
beforeEach(() => {
|
|
101
|
+
Object.defineProperty(win.parent.parent.parent.parent, 'frames', {get: getFrames})
|
|
102
|
+
})
|
|
103
|
+
it('posts message to the first ancestor with __pb_locator__ child', () => {
|
|
104
|
+
renderAd({pubUrl: 'https://www.example.com'});
|
|
105
|
+
expect(messages.length).to.eql(1);
|
|
106
|
+
});
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
it('posts to first restricted parent, if __pb_locator__ cannot be found', () => {
|
|
110
|
+
Object.defineProperty(win.parent.parent.parent, 'frames', {
|
|
111
|
+
get() {
|
|
112
|
+
throw new DOMException();
|
|
113
|
+
}
|
|
114
|
+
});
|
|
98
115
|
renderAd({pubUrl: 'https://www.example.com'});
|
|
99
116
|
expect(messages.length).to.eql(1);
|
|
100
|
-
})
|
|
117
|
+
})
|
|
101
118
|
})
|
|
102
119
|
|
|
103
120
|
it('generates request message with adId and clickUrl', () => {
|
|
@@ -34,7 +34,7 @@ describe('GDPR FPD enrichment', () => {
|
|
|
34
34
|
})
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
it('sets user.ext.consent, but not regs.ext.gdpr, if
|
|
37
|
+
it('sets user.ext.consent, but not regs.ext.gdpr, if gdprApplies is not a boolean', () => {
|
|
38
38
|
consent = {consentString: 'mock-consent'};
|
|
39
39
|
return callHook().then(ortb2 => {
|
|
40
40
|
expect(ortb2).to.eql({
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* globals describe, beforeEach, afterEach, sinon */
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { getDeviceType, getBrowser, getOS } from 'libraries/userAgentUtils';
|
|
4
|
+
import { deviceTypes, browserTypes, osTypes } from 'libraries/userAgentUtils/userAgentTypes.enums';
|
|
5
|
+
|
|
6
|
+
const ORIGINAL_USER_AGENT = window.navigator.userAgent;
|
|
7
|
+
const ORIGINAL_VENDOR = window.navigator.vendor;
|
|
8
|
+
const ORIGINAL_APP_VERSION = window.navigator.appVersion;
|
|
9
|
+
|
|
10
|
+
describe('Test user agent categorization', () => {
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
window.navigator.__defineGetter__('userAgent', () => ORIGINAL_USER_AGENT);
|
|
13
|
+
window.navigator.__defineGetter__('vendor', () => ORIGINAL_VENDOR);
|
|
14
|
+
window.navigator.__defineGetter__('appVersion', () => ORIGINAL_APP_VERSION);
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('test getDeviceType', () => {
|
|
18
|
+
it('user agent device type is tablet', () => {
|
|
19
|
+
const tabletUserAgent = 'Mozilla/5.0 (iPad; CPU OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4.17.9 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3'
|
|
20
|
+
window.navigator.__defineGetter__('userAgent', () => tabletUserAgent);
|
|
21
|
+
expect(getDeviceType()).to.equal(deviceTypes.TABLET);
|
|
22
|
+
})
|
|
23
|
+
it('user agent device type is mobile', () => {
|
|
24
|
+
const mobileUserAgent = 'Mozilla/5.0 (Linux; Android 12; M2102J20SG) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Mobile Safari/537.36'
|
|
25
|
+
window.navigator.__defineGetter__('userAgent', () => mobileUserAgent);
|
|
26
|
+
expect(getDeviceType()).to.equal(deviceTypes.MOBILE);
|
|
27
|
+
})
|
|
28
|
+
it('user agent device type is desktop', () => {
|
|
29
|
+
const desktopUserAgent = 'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36'
|
|
30
|
+
window.navigator.__defineGetter__('userAgent', () => desktopUserAgent);
|
|
31
|
+
expect(getDeviceType()).to.equal(deviceTypes.DESKTOP);
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
describe('test getBrowser', () => {
|
|
36
|
+
it('user agent browser is edge', () => {
|
|
37
|
+
const edgeUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10532'
|
|
38
|
+
window.navigator.__defineGetter__('userAgent', () => edgeUserAgent);
|
|
39
|
+
expect(getBrowser()).to.equal(browserTypes.EDGE);
|
|
40
|
+
})
|
|
41
|
+
it('user agent browser is chrome', () => {
|
|
42
|
+
const chromeUserAgent = 'Mozilla/5.0 (iPad; CPU OS 8_4 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) CriOS/44.0.2403.67 Mobile/12H143 Safari/600.1.4'
|
|
43
|
+
window.navigator.__defineGetter__('userAgent', () => chromeUserAgent);
|
|
44
|
+
expect(getBrowser()).to.equal(browserTypes.CHROME);
|
|
45
|
+
})
|
|
46
|
+
it('user agent browser is firefox', () => {
|
|
47
|
+
const firefoxUserAgent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:40.0) Gecko/20100101 Firefox/40.0.2 Waterfox/40.0.2'
|
|
48
|
+
window.navigator.__defineGetter__('userAgent', () => firefoxUserAgent);
|
|
49
|
+
expect(getBrowser()).to.equal(browserTypes.FIREFOX);
|
|
50
|
+
})
|
|
51
|
+
it('user agent browser is safari', () => {
|
|
52
|
+
const safariUserAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36'
|
|
53
|
+
window.navigator.__defineGetter__('userAgent', () => safariUserAgent);
|
|
54
|
+
window.navigator.__defineGetter__('vendor', () => 'Apple Computer, Inc.');
|
|
55
|
+
expect(getBrowser()).to.equal(browserTypes.SAFARI);
|
|
56
|
+
})
|
|
57
|
+
it('user agent browser is internet explorer', () => {
|
|
58
|
+
const internetexplorerUserAgent = 'Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko'
|
|
59
|
+
window.navigator.__defineGetter__('userAgent', () => internetexplorerUserAgent);
|
|
60
|
+
expect(getBrowser()).to.equal(browserTypes.INTERNET_EXPLORER);
|
|
61
|
+
})
|
|
62
|
+
it('user agent is other', () => {
|
|
63
|
+
const otherUserAgent = 'Dalvik/2.1.0 (Linux; U; Android 9; ADT-2 Build/PTT5.181126.002)'
|
|
64
|
+
window.navigator.__defineGetter__('userAgent', () => otherUserAgent);
|
|
65
|
+
expect(getBrowser()).to.equal(browserTypes.OTHER);
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe('test getOS', () => {
|
|
70
|
+
it('user agent is android', () => {
|
|
71
|
+
const androidUserAgent = 'Mozilla/5.0 (Android; Mobile; rv:40.0) Gecko/40.0 Firefox/40.0'
|
|
72
|
+
window.navigator.__defineGetter__('userAgent', () => androidUserAgent);
|
|
73
|
+
expect(getOS()).to.equal(osTypes.ANDROID);
|
|
74
|
+
})
|
|
75
|
+
it('user agent is ios', () => {
|
|
76
|
+
const iosUserAgent = 'Mozilla/5.0 (iPad; CPU OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12H321 Safari/600.1.4'
|
|
77
|
+
window.navigator.__defineGetter__('userAgent', () => iosUserAgent);
|
|
78
|
+
expect(getOS()).to.equal(osTypes.IOS);
|
|
79
|
+
})
|
|
80
|
+
it('user agent is windows', () => {
|
|
81
|
+
const windowsUserAgent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36'
|
|
82
|
+
window.navigator.__defineGetter__('userAgent', () => windowsUserAgent);
|
|
83
|
+
expect(getOS()).to.equal(osTypes.WINDOWS);
|
|
84
|
+
})
|
|
85
|
+
it('user agent is mac', () => {
|
|
86
|
+
const macUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:33.0) Gecko/20100101 Firefox/33.0'
|
|
87
|
+
window.navigator.__defineGetter__('userAgent', () => macUserAgent);
|
|
88
|
+
expect(getOS()).to.equal(osTypes.MAC);
|
|
89
|
+
})
|
|
90
|
+
it('user agent is linux', () => {
|
|
91
|
+
const linuxUserAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0'
|
|
92
|
+
window.navigator.__defineGetter__('userAgent', () => linuxUserAgent);
|
|
93
|
+
expect(getOS()).to.equal(osTypes.LINUX);
|
|
94
|
+
})
|
|
95
|
+
it('user agent is unix', () => {
|
|
96
|
+
const unixUserAgent = 'Mozilla/5.0 (X11; CrOS armv7l 7077.134.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.156 Safari/537.36'
|
|
97
|
+
const unixappVersion = '5.0 (X11; CrOS armv7l 7077.134.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.156 Safari/537.36'
|
|
98
|
+
window.navigator.__defineGetter__('userAgent', () => unixUserAgent);
|
|
99
|
+
window.navigator.__defineGetter__('appVersion', () => unixappVersion);
|
|
100
|
+
expect(getOS()).to.equal(osTypes.UNIX);
|
|
101
|
+
})
|
|
102
|
+
it('user agent is other', () => {
|
|
103
|
+
const otherUserAgent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
|
|
104
|
+
window.navigator.__defineGetter__('userAgent', () => otherUserAgent);
|
|
105
|
+
window.navigator.__defineGetter__('appVersion', () => '');
|
|
106
|
+
expect(getOS()).to.equal(osTypes.OTHER);
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
})
|