summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/editing/other/typing-space-in-editable-summary.tentative.html
blob: 30a751d5239d378e70eaf9766c16fcb2e510bd36 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!doctype html>
<head>
<meta charset="utf-8">
<title>Tests for pressing space in editable summary element</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>
</head>
<body>
<details contenteditable><summary>HelloWorld</summary>Details</details>
<details><summary contenteditable>HelloWorld</summary>Details</details>
<details><summary><div contenteditable>HelloWorld</div></summary>Details</details>
<script>
"use strict";

promise_test(async () => {
  const details = document.querySelector("details[contenteditable]");
  const summary = details.querySelector("summary");
  getSelection().collapse(summary.firstChild, "Hello".length);
  summary.focus();
  await new this.window.test_driver.Actions()
      .keyDown("\uE00D")
      .keyUp("\uE00D")
      .send();
  assert_equals(
    details.innerHTML,
    "<summary>HelloWorld</summary>Details",
    "A space shouldn't be inserted into the focused <summary>"
  );
  assert_true(details.open, "<details> shouldn't keep collapsed");
}, "Type space key in editable <summary> should be handled by the <summary> when it's focused");

promise_test(async () => {
  const details = document.querySelector("details[contenteditable]");
  details.innerHTML = "<summary>HelloWorld</summary>Details";
  details.open = false;
  const summary = details.querySelector("summary");
  getSelection().collapse(summary.firstChild, "Hello".length);
  details.focus();
  await new this.window.test_driver.Actions()
      .keyDown("\uE00D")
      .keyUp("\uE00D")
      .send();
  assert_equals(
    details.innerHTML,
    "<summary>Hello World</summary>Details",
    "A space should be inserted into the <summary>"
  );
  assert_false(details.open, "<details> should keep collapsed");
}, "Type space key in editable <summary> shouldn't be handled by the <summary> when it's not focused");

promise_test(async () => {
  const details = document.querySelector("details > summary[contenteditable]").parentNode;
  const summary = details.querySelector("summary");
  getSelection().collapse(summary.firstChild, "Hello".length);
  summary.focus();
  await new this.window.test_driver.Actions()
      .keyDown("\uE00D")
      .keyUp("\uE00D")
      .send();
  assert_equals(
    details.innerHTML,
    '<summary contenteditable="">HelloWorld</summary>Details',
    "The content of <details> shouldn't be changed"
  );
  assert_true(details.open, "<details> shouldn't keep collapsed");
}, "Type space key in <summary contenteditable> should be handled by the <summary>");

promise_test(async () => {
  const details = document.querySelector("summary > div[contenteditable]").parentNode.parentNode;
  const summary = details.querySelector("summary");
  const editable = summary.querySelector("div[contenteditable]");
  editable.focus();
  getSelection().collapse(editable.firstChild, "Hello".length);
  await new this.window.test_driver.Actions()
      .keyDown("\uE00D")
      .keyUp("\uE00D")
      .send();
  assert_equals(
    details.innerHTML,
    '<summary><div contenteditable="">Hello World</div></summary>Details',
    "A space should be inserted"
  );
  assert_false(details.open, "<details> should keep collapsed");
}, "Type space key in editable element in <summary> shouldn't be handled by the <summary>");
</script>
</body>
</html>