diff --git a/test/javascripts/lib/tooltip-test.js.es6 b/test/javascripts/lib/tooltip-test.js.es6 new file mode 100644 index 00000000000..f65d326da53 --- /dev/null +++ b/test/javascripts/lib/tooltip-test.js.es6 @@ -0,0 +1,25 @@ +import { registerTooltip } from "discourse/lib/tooltip"; + +// prettier-ignore +QUnit.module("lib:tooltip", { + beforeEach() { + fixture().html( + "test" + ); + } +}); + +QUnit.test("it prevents XSS injection", assert => { + const $testLink = fixture(".test-link"); + registerTooltip($testLink); + $testLink.click(); + + andThen(() => { + assert.equal( + fixture(".tooltip-content") + .html() + .trim(), + "XSS<s onmouseover=alert(document.domain)>XSS" + ); + }); +});