-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathplaintext-only-in-designMode.html
44 lines (40 loc) · 1.62 KB
/
plaintext-only-in-designMode.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="timeout" content="long">
<title>Delete editor in a shadow</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="../include/editor-test-utils.js"></script>
<script>
"use strict";
document.designMode = "on";
addEventListener("load", () => {
const div = document.querySelector("div[contenteditable=plaintext-only]");
const utils = new EditorTestUtils(div);
test(() => {
utils.setupEditingHost("[ABC]");
document.execCommand("bold");
assert_equals(div.outerHTML, `<div contenteditable="plaintext-only"><b>ABC</b></div>`);
}, "contenteditable=plaintext-only in the design mode should not prevent the style edit");
test(() => {
utils.setupEditingHost("A[B]C");
document.execCommand("insertHTML", false, "<b>b</b>");
assert_equals(div.outerHTML, `<div contenteditable="plaintext-only">A<b>b</b>C</div>`);
}, "contenteditable=plaintext-only in the design mode should not suppress style of inserting HTML");
promise_test(async () => {
utils.setupEditingHost("<p>A[]B</p>");
await utils.sendEnterKey();
assert_equals(div.outerHTML, `<div contenteditable="plaintext-only"><p>A</p><p>B</p></div>`);
}, "contenteditable=plaintext-only in the design mode should not cause inserting line break at typing Enter");
}, {once: true});
</script>
</head>
<body>
<div contenteditable="plaintext-only"></div>
</body>
</html>