MCPcopy Create free account
hub / github.com/cure53/dompurify / startQUnit

Function startQUnit

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

createDOMPurifyFunction · 0.85

Tested by

no test coverage detected