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

Function startQUnit

test/purify-edge-node.js:62–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60const sanitizeTestSuite = require('./test-suite');
61
62async function startQUnit() {
63 const { default: tests } = await import('./fixtures/expect.mjs');
64 const xssTests = tests.filter((element) => /alert/.test(element.payload));
65
66 QUnit.assert.contains = function (actual, expected, message) {
67 const result = expected.indexOf(actual) > -1;
68 // Ref: https://api.qunitjs.com/assert/pushResult/
69 this.pushResult({
70 result: result,
71 actual: actual,
72 expected: expected,
73 message: message,
74 });
75 };
76
77 QUnit.config.autostart = false;
78 QUnit.config.filter = (SINKS ? '' : '!') + SINK_TESTS;
79
80 QUnit.module(
81 SINKS
82 ? 'DOMPurify in purify-edge (sinks in jsdom)'
83 : 'DOMPurify in purify-edge'
84 );
85
86 // DOMPurify is always built on the purify-edge window.
87 const DOMPurify = createDOMPurify(edge);
88 if (!DOMPurify.isSupported) {
89 console.error('DOMPurify reports isSupported === false under purify-edge');
90 process.exit(1);
91 }
92
93 window.alert = () => {
94 window.xssed = true;
95 };
96
97 sanitizeTestSuite(DOMPurify, window, tests, xssTests);
98
99 QUnit.start();
100}
101
102module.exports = startQUnit;

Callers

nothing calls this directly

Calls 1

createDOMPurifyFunction · 0.85

Tested by

no test coverage detected