File: text-transform-capitalize-036.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (63 lines) | stat: -rw-r--r-- 2,841 bytes parent folder | download | duplicates (4)
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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>text-transform: capitalize innerText WPT tests</title>
    <link rel="author" href="mailto:yezhizhenjiakang@gmail.com" title="Euclid Ye">
    <link rel="help" href="https://drafts.csswg.org/css-text/#propdef-text-transform">
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
</head>
<body>
    <div id="div1" style="text-transform: capitalize;">hello world</div>
    <div id="div2" style="text-transform: capitalize;">foo-bar</div>
    <div id="div3" style="text-transform: capitalize;">john's apple</div>
    <!-- Test case 4 nested elements -->
    <div id="div4" style="text-transform: capitalize;">
        hello <span>world</span>
    </div>
    <div id="div5" style="text-transform: capitalize;">foo_bar</div>
    <!-- Test case 6 not starting at word boundary -->
    a<span id="span1" style="text-transform: capitalize;">b</span>c

    <script>
        test(function () {
            var div = document.getElementById("div1");
            assert_equals(div.innerText, "Hello World",
                "innerText for 'hello world' should be 'Hello World'");
        }, "text-transform: capitalize test for 'hello world'");

        test(function () {
            var div = document.getElementById("div2");
            assert_equals(div.innerText, "Foo-Bar",
                "innerText for 'foo-bar' should be 'Foo-Bar'");
        }, "text-transform: capitalize test for 'foo-bar'");

        test(function () {
            var div = document.getElementById("div3");
            assert_equals(div.innerText, "John's Apple",
                "innerText for \"john's apple\" should be \"John's Apple\"");
        }, "text-transform: capitalize test for \"john's apple\"");

        // Test for nested elements: the text inside the span should also be affected.
        test(function () {
            var div = document.getElementById("div4");
            assert_equals(div.innerText, "Hello World",
                "innerText for nested 'hello <span>world</span>' should be 'Hello World'");
        }, "text-transform: capitalize test for nested elements");

        // Test for underscore
        test(function () {
            var div = document.getElementById("div5");
            assert_equals(div.innerText.trim(), "Foo_bar",
                "innerText for 'foo_bar' should be 'Foo_bar'");
        }, "text-transform: capitalize test for underscore");

        test(function () {
            var div = document.getElementById("span1");
            assert_equals(div.innerText, "b",
                "innerText for span in 'a<span style='text-transform: capitalize;'>b</span>c' should be 'b'");
        }, "text-transform: capitalize test for not starting at word boundary");
    </script>
</body>
</html>