File: attr-null-namespace.xhtml

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (76 lines) | stat: -rw-r--r-- 3,228 bytes parent folder | download | duplicates (7)
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
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:nsfoo="http://nsfoo.org"
      xmlns:nsbar="http://nsbar.org">
  <head>
    <title>CSS Values: attr() substitution with implicit null namespace</title>
    <link rel="help" href="https://drafts.csswg.org/css-values-5/#attr-notation"/>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
    <div id="target"
         nsfoo:data-x="value1"
         nsbar:data-x="value2"
         data-x="value3"

         nsfoo:data-y="value4"
         nsbar:data-y="value5">
        Test
    </div>
    <style>
        #target {
            --x: attr(data-x type(*), fallback);
            --y: attr(data-y type(*), fallback);
            --z: attr(data-z type(*), fallback);
            --w: attr(data-w type(*), fallback);
        }
    </style>
    <script>
        test(() => {
            let e = document.getElementById("target");
            assert_equals("value1", e.getAttributeNS("http://nsfoo.org", "data-x"));
            assert_equals("value2", e.getAttributeNS("http://nsbar.org", "data-x"));
            assert_equals("value3", e.getAttributeNS(null, "data-x"));

            assert_equals("value4", e.getAttributeNS("http://nsfoo.org", "data-y"));
            assert_equals("value5", e.getAttributeNS("http://nsbar.org", "data-y"));
            assert_equals(null, e.getAttributeNS(null, "data-y"));
        }, "Sanity check");

        test(() => {
            let e = document.getElementById("target");
            assert_equals(getComputedStyle(e).getPropertyValue("--x"), "value3");
        }, "Attribute in null-namespace is substituted");

        test(() => {
            let e = document.getElementById("target");
            assert_equals(getComputedStyle(e).getPropertyValue("--y"), "fallback");
        }, "Fallback is taken when attribute does not exist in null-namespace");

        test((t) => {
            let e = document.getElementById("target");
            t.add_cleanup(() => {
                e.removeAttributeNS("http://nsfoo.org", "data-z");
                e.removeAttributeNS("http://nsbar.org", "data-z");
                e.removeAttributeNS(null, "data-z");
            });
            e.setAttributeNS("http://nsfoo.org", "data-z", "value6");
            e.setAttributeNS("http://nsbar.org", "data-z", "value7");
            e.setAttributeNS(null, "data-z", "value8");
            assert_equals(getComputedStyle(e).getPropertyValue("--z"), "value8");
        }, "Attribute in null-namespace is substituted (JS)");

        test((t) => {
            let e = document.getElementById("target");
            t.add_cleanup(() => {
                e.removeAttributeNS("http://nsfoo.org", "data-w");
                e.removeAttributeNS("http://nsbar.org", "data-w");
            });
            e.setAttributeNS("http://nsfoo.org", "data-w", "value9");
            e.setAttributeNS("http://nsbar.org", "data-w", "value10");
            assert_equals(getComputedStyle(e).getPropertyValue("--w"), "fallback");
        }, "Fallback is taken when attribute does not does exist in null-namespace (JS)");
    </script>
  </body>
</html>