mirror of
https://github.com/discourse/discourse.git
synced 2025-06-10 19:59:12 +08:00
Revert "Rename all test files from JS -> ES6"
This reverts commit 2abe85b8344de1102c1589a9ac9421a8b296f2b5.
This commit is contained in:
@ -1,60 +0,0 @@
|
||||
import { registerTooltip, registerHoverTooltip } from "discourse/lib/tooltip";
|
||||
import { fixture } from "helpers/qunit-helpers";
|
||||
|
||||
// prettier-ignore
|
||||
QUnit.module("lib:tooltip", {
|
||||
beforeEach() {
|
||||
fixture().html(
|
||||
`
|
||||
<a class='test-text-link' data-tooltip='XSS<s onmouseover\=alert(document.domain)>XSS'>test</a>
|
||||
<a class='test-html-link' data-html-tooltip='<p>test</p>'>test</a>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("text support", async assert => {
|
||||
const $testTextLink = fixture(".test-text-link");
|
||||
registerTooltip($testTextLink);
|
||||
|
||||
await $testTextLink.click();
|
||||
|
||||
assert.equal(
|
||||
fixture(".tooltip-content")
|
||||
.html()
|
||||
.trim(),
|
||||
"XSS<s onmouseover=alert(document.domain)>XSS",
|
||||
"it prevents XSS injection"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
fixture(".tooltip-content")
|
||||
.text()
|
||||
.trim(),
|
||||
"XSS<s onmouseover=alert(document.domain)>XSS",
|
||||
"it returns content as plain text"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("html support", async assert => {
|
||||
const $testHtmlLink = fixture(".test-html-link");
|
||||
registerHoverTooltip($testHtmlLink);
|
||||
|
||||
await $testHtmlLink.click();
|
||||
|
||||
assert.equal(
|
||||
fixture(".tooltip-content")
|
||||
.html()
|
||||
.trim(),
|
||||
"<p>test</p>",
|
||||
"it doesn’t escape HTML"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
fixture(".tooltip-content")
|
||||
.text()
|
||||
.trim(),
|
||||
"test",
|
||||
"it returns content as plain text"
|
||||
);
|
||||
});
|
Reference in New Issue
Block a user