Skip to content

Commit

Permalink
Bug 1793670 [wpt PR 36269] - HTML: contentEditable IDL attribute: pla…
Browse files Browse the repository at this point in the history
…intext-only , a=testonly

Automatic update from web-platform-tests
HTML: contentEditable IDL attribute: plaintext-only

See whatwg/html#8275

--

wpt-commits: 031a7dbc9f63c29aa6035094a7f63182b0965caf
wpt-pr: 36269
  • Loading branch information
zcorpan authored and moz-wptsync-bot committed Mar 8, 2023
1 parent a9fe08a commit e9b9b53
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,41 @@
<meta name="assert" content="@contenteditable values are ASCII case-insensitive">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div contenteditable="false"></div>
<div contenteditable="FaLsE"></div>
<div contenteditable="falſe"></div>
<div></div>

<script>
const div = document.querySelectorAll("div");
function testValue(value, isValid) {
const valueLower = value.toLowerCase();

test(() => {
const el = document.createElement('div');
if (valueLower !== "inherit") {
el.setAttribute('contenteditable', value);
}
assert_equals(el.contentEditable, isValid ? valueLower : "inherit");
}, `IDL attribute getter for attribute value "${value}"`);

test(() => {
const el = document.createElement('div');
if (isValid) {
el.contentEditable = value;
assert_equals(el.getAttribute('contenteditable'), valueLower === "inherit" ? null : valueLower);
} else {
assert_throws_dom("SyntaxError", () => {
el.contentEditable = value;
});
}
}, `IDL attribute setter for value "${value}"`);
}

const valid = ["true", "false", "inherit", "plaintext-only"]; // "inherit" is treated specially
const invalid = ["foobar", "falſe", "plaıntext-only", "plaİntext-only"];

test(() => {
assert_equals(div[0].contentEditable, "false", "lowercase valid");
assert_equals(div[1].contentEditable, "false", "mixed case valid");
assert_equals(div[2].contentEditable, "inherit", "non-ASCII invalid");
for (const value of valid) {
testValue(value, true);
testValue(value.toUpperCase(), true);
}

assert_throws_dom("SyntaxError", () => {
div[3].contentEditable = "falſe";
}, "non-ASCII rejected by IDL");
}, "keyword false");
for (const value of invalid) {
testValue(value, false);
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@
el.contentEditable = "true";
el.removeAttribute("contenteditable");
}, 'set contentEditable = "true" and then remove contenteditable attribute', false, "inherit");

testContentEditable(el => {
el.setAttribute("contenteditable", "plaintext-only");
}, "contentEditable=plaintext-only attribute", true, "plaintext-only");

testContentEditable(el => {
const parent = document.createElement("div");
parent.appendChild(el);
parent.contentEditable = "plaintext-only";
}, 'set parent element contentEditable = "plaintext-only"', true, "inherit");
</script>
</body>
</html>

0 comments on commit e9b9b53

Please sign in to comment.