summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-toggle/toggle-shorthand-serialization.tentative.html
blob: 682945c2e2bf930f8cbba606a1c7e7be37d6e7a4 (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
<!DOCTYPE HTML>
<meta charset="UTF-8">
<title>CSS Toggles: serialization of toggle shorthand</title>
<link rel="author" title="L. David Baron" href="https://dbaron.org/">
<link rel="author" title="Google" href="http://www.google.com/">
<link rel="help" href="https://tabatkins.github.io/css-toggle/#toggle-property">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<script>

let tests = [
  { "toggle-root": null,
    "toggle-trigger": "mytoggle",
    "expected": "" },
  { "toggle-root": "mytoggle",
    "toggle-trigger": null,
    "expected": "" },
  { "toggle-root": "none",
    "toggle-trigger": "mytoggle",
    "expected": "" },
  { "toggle-root": "mytoggle",
    "toggle-trigger": "none",
    "expected": "" },
  { "toggle-root": "none",
    "toggle-trigger": "none",
    "expected": "none" },
  { "toggle-root": "mytoggle",
    "toggle-trigger": "mytoggle",
    "expected": "mytoggle" },
  { "toggle-root": "mytoggle, yourtoggle",
    "toggle-trigger": "mytoggle",
    "expected": "" },
  { "toggle-root": "mytoggle",
    "toggle-trigger": "mytoggle, yourtoggle",
    "expected": "" },
  { "toggle-root": "mytoggle 2",
    "toggle-trigger": "mytoggle",
    "expected": "mytoggle 2" },
  { "toggle-root": "mytoggle 2",
    "toggle-trigger": "mytoggle 2",
    "expected": "" },
  { "toggle-root": "mytoggle 2 at 1",
    "toggle-trigger": "mytoggle",
    "expected": "mytoggle 2 at 1" },
  { "toggle-root": "mytoggle 2 at 1",
    "toggle-trigger": "mytoggle 1",
    "expected": "" },
  { "toggle-root": "mytoggle 2 at 1",
    "toggle-trigger": "mytoggle 2",
    "expected": "" },
  { "toggle-root": "mytoggle 2 at 1 sticky group self",
    "toggle-trigger": "mytoggle",
    "expected": "mytoggle 2 at 1 sticky group self" },
  { "toggle-root": "mytoggle 4 at 2 self sticky group",
    "toggle-trigger": "mytoggle",
    "expected": "mytoggle 4 at 2 sticky group self" },
  { "toggle-root": "mytoggle [one two three] at two self cycle-on group",
    "toggle-trigger": "mytoggle",
    "expected": "mytoggle [one two three] at two cycle-on group self" },
];

for (let t of tests) {
  test(function() {
    let element = document.createElement("div");
    document.body.appendChild(element);
    if (typeof(t["toggle-root"]) == "string")
      element.style["toggle-root"] = t["toggle-root"];
    if (typeof(t["toggle-trigger"]) == "string")
      element.style["toggle-trigger"] = t["toggle-trigger"];
    assert_equals(element.style.toggle, t["expected"]);
    element.remove();
  }, `Serialization of toggle shorthand with${t["toggle-root"] ? (" toggle-root: " + t["toggle-root"] + ";") : ""}${t["toggle-trigger"] ? (" toggle-trigger: " + t["toggle-trigger"] + ";") : ""}`);
}

</script>