text-transform-capitalize-036.html (2841B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>text-transform: capitalize innerText WPT tests</title> 6 <link rel="author" href="mailto:yezhizhenjiakang@gmail.com" title="Euclid Ye"> 7 <link rel="help" href="https://drafts.csswg.org/css-text/#propdef-text-transform"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 </head> 11 <body> 12 <div id="div1" style="text-transform: capitalize;">hello world</div> 13 <div id="div2" style="text-transform: capitalize;">foo-bar</div> 14 <div id="div3" style="text-transform: capitalize;">john's apple</div> 15 <!-- Test case 4 nested elements --> 16 <div id="div4" style="text-transform: capitalize;"> 17 hello <span>world</span> 18 </div> 19 <div id="div5" style="text-transform: capitalize;">foo_bar</div> 20 <!-- Test case 6 not starting at word boundary --> 21 a<span id="span1" style="text-transform: capitalize;">b</span>c 22 23 <script> 24 test(function () { 25 var div = document.getElementById("div1"); 26 assert_equals(div.innerText, "Hello World", 27 "innerText for 'hello world' should be 'Hello World'"); 28 }, "text-transform: capitalize test for 'hello world'"); 29 30 test(function () { 31 var div = document.getElementById("div2"); 32 assert_equals(div.innerText, "Foo-Bar", 33 "innerText for 'foo-bar' should be 'Foo-Bar'"); 34 }, "text-transform: capitalize test for 'foo-bar'"); 35 36 test(function () { 37 var div = document.getElementById("div3"); 38 assert_equals(div.innerText, "John's Apple", 39 "innerText for \"john's apple\" should be \"John's Apple\""); 40 }, "text-transform: capitalize test for \"john's apple\""); 41 42 // Test for nested elements: the text inside the span should also be affected. 43 test(function () { 44 var div = document.getElementById("div4"); 45 assert_equals(div.innerText, "Hello World", 46 "innerText for nested 'hello <span>world</span>' should be 'Hello World'"); 47 }, "text-transform: capitalize test for nested elements"); 48 49 // Test for underscore 50 test(function () { 51 var div = document.getElementById("div5"); 52 assert_equals(div.innerText.trim(), "Foo_bar", 53 "innerText for 'foo_bar' should be 'Foo_bar'"); 54 }, "text-transform: capitalize test for underscore"); 55 56 test(function () { 57 var div = document.getElementById("span1"); 58 assert_equals(div.innerText, "b", 59 "innerText for span in 'a<span style='text-transform: capitalize;'>b</span>c' should be 'b'"); 60 }, "text-transform: capitalize test for not starting at word boundary"); 61 </script> 62 </body> 63 </html>