jsdom-node.js (DOMPurify-3.0.1) | : | jsdom-node.js (DOMPurify-3.0.2) | ||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
const { JSDOM, VirtualConsole } = jsdom; | const { JSDOM, VirtualConsole } = jsdom; | |||
const virtualConsole = new VirtualConsole(); | const virtualConsole = new VirtualConsole(); | |||
const { window } = new JSDOM( | const { window } = new JSDOM( | |||
`<html><head></head><body><div id="qunit-fixture"></div></body></html>`, | `<html><head></head><body><div id="qunit-fixture"></div></body></html>`, | |||
{ runScripts: 'dangerously', virtualConsole } | { runScripts: 'dangerously', virtualConsole } | |||
); | ); | |||
require('jquery')(window); | require('jquery')(window); | |||
const sanitizeTestSuite = require('./test-suite'); | const sanitizeTestSuite = require('./test-suite'); | |||
const bootstrapTestSuite = require('./bootstrap-test-suite'); | const bootstrapTestSuite = require('./bootstrap-test-suite'); | |||
const tests = require('./fixtures/expect'); | ||||
const xssTests = tests.filter((element) => /alert/.test(element.payload)); | ||||
QUnit.assert.contains = function (actual, expected, message) { | async function startQUnit() { | |||
const result = expected.indexOf(actual) > -1; | const { default: tests } = await import('./fixtures/expect.mjs'); | |||
// Ref: https://api.qunitjs.com/assert/pushResult/ | const xssTests = tests.filter((element) => /alert/.test(element.payload)); | |||
this.pushResult({ | ||||
result: result, | QUnit.assert.contains = function (actual, expected, message) { | |||
actual: actual, | const result = expected.indexOf(actual) > -1; | |||
expected: expected, | // Ref: https://api.qunitjs.com/assert/pushResult/ | |||
message: message, | this.pushResult({ | |||
}); | result: result, | |||
}; | actual: actual, | |||
expected: expected, | ||||
message: message, | ||||
}); | ||||
}; | ||||
QUnit.config.autostart = false; | ||||
QUnit.module('DOMPurify - bootstrap', bootstrapTestSuite(JSDOM)); | ||||
QUnit.module('DOMPurify in jsdom'); | ||||
if (!window.jQuery) { | ||||
console.warn('Unable to load jQuery'); | ||||
} | ||||
const DOMPurify = createDOMPurify(window); | ||||
if (!DOMPurify.isSupported) { | ||||
console.error('Unexpected error returned by jsdom.env():', err, err.stack); | ||||
process.exit(1); | ||||
} | ||||
window.alert = () => { | ||||
window.xssed = true; | ||||
}; | ||||
QUnit.config.autostart = false; | sanitizeTestSuite(DOMPurify, window, tests, xssTests); | |||
QUnit.start(); | ||||
QUnit.module('DOMPurify - bootstrap', bootstrapTestSuite(JSDOM)); | ||||
QUnit.module('DOMPurify in jsdom'); | ||||
if (!window.jQuery) { | ||||
console.warn('Unable to load jQuery'); | ||||
} | } | |||
const DOMPurify = createDOMPurify(window); | module.exports = startQUnit; | |||
if (!DOMPurify.isSupported) { | ||||
console.error('Unexpected error returned by jsdom.env():', err, err.stack); | ||||
process.exit(1); | ||||
} | ||||
window.alert = () => { | ||||
window.xssed = true; | ||||
}; | ||||
sanitizeTestSuite(DOMPurify, window, tests, xssTests); | ||||
QUnit.start(); | ||||
End of changes. 4 change blocks. | ||||
20 lines changed or deleted | 36 lines changed or added |