Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/devextreme/js/ui/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ export function isWebFontLoaded(text, fontWeight) {
testElement.style.fontFamily = etalonFont;
testElement.style.fontSize = '250px';
testElement.style.fontWeight = fontWeight;
testElement.innerHTML = text;
testElement.textContent = text;

document.body.appendChild(testElement);

Expand Down
20 changes: 20 additions & 0 deletions packages/devextreme/testing/tests/DevExpress.ui/themes.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,26 @@ QUnit.module('web font checker', () => {
assert.equal(diff, 0, 'Element\'s count are the same after method call');
});

[
'<img src="x" onerror="window.xssFired = true">',
'&lt;img src=x onerror=alert(1)&gt;',
].forEach((text) => {
test(`isWebFontLoaded measures "${text}" as plain text`, function(assert) {
const appendChild = sinon.spy(document.body, 'appendChild');

try {
themes.isWebFontLoaded(text, 400);

const element = appendChild.getCall(0).args[0];

assert.strictEqual(element.children.length, 0, 'no elements are created from the text');
assert.strictEqual(element.textContent, text, 'text is kept as it is');
} finally {
appendChild.restore();
}
});
});

testInActiveWindow('waitWebFont: function resolve by timeout if the font is not loaded', function(assert) {
const done = assert.async();
themes.waitWebFont('test text', 400).then((success) => {
Expand Down
Loading