MCPcopy Index your code
hub / github.com/cure53/DOMPurify / startQUnit

Function startQUnit

test/jsdom-node.js:21–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19const bootstrapTestSuite = require('./bootstrap-test-suite');
20
21async function startQUnit() {
22 const { default: tests } = await import('./fixtures/expect.mjs');
23 const xssTests = tests.filter((element) => /alert/.test(element.payload));
24
25 QUnit.assert.contains = function (actual, expected, message) {
26 const result = expected.indexOf(actual) > -1;
27 // Ref: https://api.qunitjs.com/assert/pushResult/
28 this.pushResult({
29 result: result,
30 actual: actual,
31 expected: expected,
32 message: message,
33 });
34 };
35
36 QUnit.config.autostart = false;
37
38 QUnit.module('DOMPurify - bootstrap', bootstrapTestSuite(JSDOM));
39
40 QUnit.module('DOMPurify in jsdom');
41
42 if (!window.jQuery) {
43 console.warn('Unable to load jQuery');
44 }
45
46 const DOMPurify = createDOMPurify(window);
47 if (!DOMPurify.isSupported) {
48 console.error('Unexpected error returned by jsdom.env():', err, err.stack);
49 process.exit(1);
50 }
51
52 window.alert = () => {
53 window.xssed = true;
54 };
55
56 sanitizeTestSuite(DOMPurify, window, tests, xssTests);
57
58 if (process.env.DOMPURIFY_COV) {
59 QUnit.done(() => {
60 const fs = require('fs');
61 fs.mkdirSync('.nyc_output', { recursive: true });
62 fs.writeFileSync(
63 '.nyc_output/out.json',
64 JSON.stringify(global.__coverage__ || {})
65 );
66 });
67 }
68
69 QUnit.start();
70}
71
72module.exports = startQUnit;

Callers 2

Calls 1

createDOMPurifyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…