• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

prebid / Prebid.js / 16598347968

29 Jul 2025 02:01PM UTC coverage: 96.259% (+0.002%) from 96.257%
16598347968

push

github

web-flow
programmaticXBidAdapter: fix tests (#13688)

* programmaticXBidAdapter: fix tests

* Update adplusAnalyticsAdapter_spec.js

---------

Co-authored-by: Patrick McCann <patmmccann@gmail.com>

39401 of 48422 branches covered (81.37%)

51 of 51 new or added lines in 2 files covered. (100.0%)

219 existing lines in 37 files now uncovered.

194969 of 202547 relevant lines covered (96.26%)

83.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.48
/src/debugging.js
1
import {config} from './config.js';
2
import {getHook, hook} from './hook.js';
3
import {getGlobal} from './prebidGlobal.js';
4
import {logMessage, prefixLog} from './utils.js';
5
import {createBid} from './bidfactory.js';
6
import {loadExternalScript} from './adloader.js';
7
import {PbPromise} from './utils/promise.js';
8
import { MODULE_TYPE_PREBID } from './activities/modules.js';
9

10
import {getDistUrlBase, getGlobalVarName} from './buildOptions.js';
11

12
export const DEBUG_KEY = `__${getGlobalVarName()}_debugging__`;
4✔
13

14
function isDebuggingInstalled() {
15
  return getGlobal().installedModules.includes('debugging');
1✔
16
}
17

18
function loadScript(url) {
UNCOV
19
  return new PbPromise((resolve) => {
×
UNCOV
20
    loadExternalScript(url, MODULE_TYPE_PREBID, 'debugging', resolve);
×
21
  });
22
}
23

24
export function debuggingModuleLoader({alreadyInstalled = isDebuggingInstalled, script = loadScript} = {}) {
8✔
25
  let loading = null;
8✔
26
  return function () {
8✔
27
    if (loading == null) {
6✔
28
      loading = new PbPromise((resolve, reject) => {
5✔
29
        // run this in a 0-delay timeout to give installedModules time to be populated
30
        setTimeout(() => {
5✔
31
          if (alreadyInstalled()) {
5✔
32
            resolve();
2✔
33
          } else {
34
            const url = `${getDistUrlBase()}debugging-standalone.js`;
3✔
35
            logMessage(`Debugging module not installed, loading it from "${url}"...`);
3✔
36
            getGlobal()._installDebugging = true;
3✔
37
            script(url).then(() => {
3✔
38
              getGlobal()._installDebugging({DEBUG_KEY, hook, config, createBid, logger: prefixLog('DEBUG:')});
2✔
39
            }).then(resolve, reject);
40
          }
41
        });
42
      })
43
    }
44
    return loading;
6✔
45
  }
46
}
47

48
export function debuggingControls({load = debuggingModuleLoader(), hook = getHook('requestBids')} = {}) {
6✔
49
  let promise = null;
6✔
50
  let enabled = false;
6✔
51
  function waitForDebugging(next, ...args) {
2!
52
    return (promise || PbPromise.resolve()).then(() => next.apply(this, args))
1!
53
  }
54
  function enable() {
55
    if (!enabled) {
3✔
56
      promise = load();
3✔
57
      // set debugging to high priority so that it has the opportunity to mess with most things
58
      hook.before(waitForDebugging, 99);
3✔
59
      enabled = true;
3✔
60
    }
61
  }
62
  function disable() {
63
    hook.getHooks({hook: waitForDebugging}).remove();
10✔
64
    enabled = false;
10✔
65
  }
66
  function reset() {
67
    promise = null;
8✔
68
    disable();
8✔
69
  }
70
  return {enable, disable, reset};
6✔
71
}
72

73
const ctl = debuggingControls();
4✔
74
export const reset = ctl.reset;
4✔
75

76
export function loadSession() {
77
  let storage = null;
4✔
78
  try {
4✔
79
    // eslint-disable-next-line no-restricted-properties
80
    storage = window.sessionStorage;
4✔
81
  } catch (e) {}
82

83
  if (storage !== null) {
4✔
84
    const debugging = ctl;
4✔
85
    let config = null;
4✔
86
    try {
4✔
87
      config = storage.getItem(DEBUG_KEY);
4✔
88
    } catch (e) {}
89
    if (config !== null) {
4!
90
      // just make sure the module runs; it will take care of parsing the config (and disabling itself if necessary)
UNCOV
91
      debugging.enable();
×
92
    }
93
  }
94
}
95

96
config.getConfig('debugging', function ({debugging}) {
5✔
97
  debugging?.enabled ? ctl.enable() : ctl.disable();
2✔
98
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc