summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/editing/other/delete-in-inline-editing-host-under-shadow-root.html
blob: c1a825a6452f31305d8677bccfb2804ba92dfd0d (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Backspace/Delete in inline editing host which is a shadow root</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";

addEventListener("load", () => {
  const shadowRoot = document.body.firstChild.attachShadow({mode: "open"});
  const editingHost = document.createElement("span");
  editingHost.setAttribute("contenteditable", "");
  shadowRoot.appendChild(editingHost);
  const utils = new EditorTestUtils(editingHost);

  promise_test(async t => {
    utils.setupEditingHost("ab[]c");
    await utils.sendBackspaceKey();
    assert_equals(
      editingHost.textContent,
      "ac"
    );
  }, "Backspace at <span contenteditable>ab[]c</span>");

  promise_test(async t => {
    utils.setupEditingHost("a[]bc");
    await utils.sendDeleteKey();
    assert_equals(
      editingHost.textContent,
      "ac"
    );
  }, "Delete at <span contenteditable>a[]bc</span>");

  promise_test(async t => {
    utils.setupEditingHost("a[b]c");
    await utils.sendBackspaceKey();
    assert_equals(
      editingHost.textContent,
      "ac"
    );
  }, "Backspace at <span contenteditable>a[b]c</span>");

  promise_test(async t => {
    utils.setupEditingHost("a[b]c");
    await utils.sendDeleteKey();
    assert_equals(
      editingHost.textContent,
      "ac"
    );
  }, "Delete at <span contenteditable>a[b]c</span>");
}, {once: true});
</script>
</head>
<body><div></div></body>
</html>