(
assert,
addScriptAttribute,
setup,
beforeOnLoad,
onload
)
| 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, |
no outgoing calls
no test coverage detected
searching dependent graphs…