MCPcopy
hub / github.com/cure53/DOMPurify / loadDOMPurify

Function loadDOMPurify

test/bootstrap-test-suite.js:14–48  ·  view source on GitHub ↗
(
    assert,
    addScriptAttribute,
    setup,
    beforeOnLoad,
    onload
  )

Source from the content-addressed store, hash-verified

12 }
13
14 function loadDOMPurify(
15 assert,
16 addScriptAttribute,
17 setup,
18 beforeOnLoad,
19 onload
20 ) {
21 const testDone = assert.async();
22 const { window } = new JSDOM('<head></head>', {
23 runScripts: 'dangerously',
24 });
25 require('jquery')(window);
26 if (setup) {
27 setup(window);
28 }
29
30 const myLibrary = fs.readFileSync('dist/purify.js', { encoding: 'utf-8' });
31 const scriptEl = window.document.createElement('script');
32 if (addScriptAttribute)
33 scriptEl.setAttribute('data-tt-policy-suffix', 'suffix');
34
35 scriptEl.textContent = myLibrary;
36 window.document.body.appendChild(scriptEl);
37
38 assert.ok(window.DOMPurify.sanitize);
39
40 if (beforeOnLoad) {
41 beforeOnLoad(window);
42 }
43
44 if (onload) {
45 onload(window);
46 }
47 testDone();
48 }
49
50 function loadDOMPurifyWithSanityCheck(
51 assert,

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…