diff --git a/src/test/system/custom_element_test.js b/src/test/system/custom_element_test.js index 2e77e3fc4..787d99ac2 100644 --- a/src/test/system/custom_element_test.js +++ b/src/test/system/custom_element_test.js @@ -391,6 +391,12 @@ testGroup("Custom element API", { template: "editor_empty" }, () => { }) }) + test("element returns empty string when value is missing", async () => { + const element = getEditorElement() + + assert.equal(element.value, "") + }) + test("element serializes HTML after attribute changes", async () => { const element = getEditorElement() let serializedHTML = element.value @@ -440,9 +446,17 @@ testGroup("Custom element API", { template: "editor_empty" }, () => { return promise }) + test("editor resets to its original value on element reset", async () => { + const element = getEditorElement() + + await typeCharacters("hello") + element.reset() + expectDocument("\n") + }) + test("editor resets to its original value on form reset", async () => { const element = getEditorElement() - const { form } = element.inputElement + const { form } = element await typeCharacters("hello") form.reset() @@ -451,7 +465,7 @@ testGroup("Custom element API", { template: "editor_empty" }, () => { test("editor resets to last-set value on form reset", async () => { const element = getEditorElement() - const { form } = element.inputElement + const { form } = element element.value = "hi" await typeCharacters("hello") @@ -461,7 +475,7 @@ testGroup("Custom element API", { template: "editor_empty" }, () => { test("editor respects preventDefault on form reset", async () => { const element = getEditorElement() - const { form } = element.inputElement + const { form } = element const preventDefault = (event) => event.preventDefault() await typeCharacters("hello") @@ -473,6 +487,17 @@ testGroup("Custom element API", { template: "editor_empty" }, () => { }) }) +testGroup("HTML sanitization", { template: "editor_html" }, () => { + test("ignores text nodes in script elements", () => { + const element = getEditorElement() + element.value = "
safe
" + + expectDocument("safe\n") + assert.equal(element.innerHTML, "
safe
") + assert.equal(element.value, "
safe
") + }) +}) + testGroup("