OLD | NEW |
1 <?xml version="1.0" encoding="utf-8"?> | 1 <?xml version="1.0" encoding="utf-8"?> |
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or
g/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or
g/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
3 <html xmlns="http://www.w3.org/1999/xhtml"> | 3 <html xmlns="http://www.w3.org/1999/xhtml"> |
4 <head> | 4 <head> |
5 <title>mapping dynamic lang to -webkit-locale</title> | 5 <title>mapping dynamic lang to -webkit-locale</title> |
6 <script src="../../resources/js-test.js"></script> | 6 <script src="../../resources/js-test.js"></script> |
7 <script> | 7 <script> |
8 function localeOfNode(id) { | 8 function localeOfNode(id) { |
9 var element = document.getElementById(id); | 9 var element = document.getElementById(id); |
10 return window.getComputedStyle(element).webkitLocale; | 10 return window.getComputedStyle(element).webkitLocale; |
11 } | 11 } |
12 | 12 |
13 function runTest() { | 13 function runTest() { |
14 description('This tests mapping of lang/xml:lang to -webkit-locale with dyna
mic attribute changes. WebKit bug 76364'); | 14 description('This tests mapping of lang/xml:lang to -webkit-locale with dyna
mic attribute changes. WebKit bug 76364'); |
15 var x1 = document.getElementById("x1"); | 15 var x1 = document.getElementById("x1"); |
16 var x2 = document.getElementById("x2"); | 16 var x2 = document.getElementById("x2"); |
17 var x3 = document.getElementById("x3"); | 17 var x3 = document.getElementById("x3"); |
18 | 18 |
19 shouldBeEqualToString("localeOfNode('x1')", "ko"); | 19 shouldBeEqualToString("localeOfNode('x1')", "'ko'"); |
20 shouldBeEqualToString("localeOfNode('x2')", "ko"); | 20 shouldBeEqualToString("localeOfNode('x2')", "'ko'"); |
21 shouldBeEqualToString("localeOfNode('x3')", "ar"); | 21 shouldBeEqualToString("localeOfNode('x3')", "'ar'"); |
22 | 22 |
23 x1.lang = "ja"; | 23 x1.lang = "ja"; |
24 shouldBeEqualToString("localeOfNode('x1')", "ja"); | 24 shouldBeEqualToString("localeOfNode('x1')", "'ja'"); |
25 shouldBeEqualToString("localeOfNode('x2')", "ja"); | 25 shouldBeEqualToString("localeOfNode('x2')", "'ja'"); |
26 shouldBeEqualToString("localeOfNode('x3')", "ar"); | 26 shouldBeEqualToString("localeOfNode('x3')", "'ar'"); |
27 | 27 |
28 x3.lang = ""; | 28 x3.lang = ""; |
29 shouldBeEqualToString("localeOfNode('x3')", "auto"); | 29 shouldBeEqualToString("localeOfNode('x3')", "auto"); |
30 | 30 |
31 x3.removeAttribute("lang"); | 31 x3.removeAttribute("lang"); |
32 shouldBeEqualToString("localeOfNode('x3')", "ja"); | 32 shouldBeEqualToString("localeOfNode('x3')", "'ja'"); |
33 | 33 |
34 // The "lang" attribute in the XML namespace should affect locale (since thi
s is an XHTML document). | 34 // The "lang" attribute in the XML namespace should affect locale (since thi
s is an XHTML document). |
35 var attr1 = document.createAttributeNS("http://www.w3.org/XML/1998/namespace
", "xml:lang"); | 35 var attr1 = document.createAttributeNS("http://www.w3.org/XML/1998/namespace
", "xml:lang"); |
36 attr1.value = "zh"; | 36 attr1.value = "zh"; |
37 x2.setAttributeNodeNS(attr1); | 37 x2.setAttributeNodeNS(attr1); |
38 shouldBeEqualToString("localeOfNode('x2')", "zh"); | 38 shouldBeEqualToString("localeOfNode('x2')", "'zh'"); |
39 | 39 |
40 x2.removeAttributeNode(attr1); | 40 x2.removeAttributeNode(attr1); |
41 shouldBeEqualToString("localeOfNode('x2')", "ja"); | 41 shouldBeEqualToString("localeOfNode('x2')", "'ja'"); |
42 | 42 |
43 // An attribute with local name "lang" not in the XML namespace should not a
ffect locale. | 43 // An attribute with local name "lang" not in the XML namespace should not a
ffect locale. |
44 var attr2 = document.createAttributeNS("foobar", "fb:lang"); | 44 var attr2 = document.createAttributeNS("foobar", "fb:lang"); |
45 attr2.value = "ph"; | 45 attr2.value = "ph"; |
46 x2.setAttributeNodeNS(attr2); | 46 x2.setAttributeNodeNS(attr2); |
47 shouldBeEqualToString("localeOfNode('x2')", "ja"); | 47 shouldBeEqualToString("localeOfNode('x2')", "'ja'"); |
48 | 48 |
49 // If we include js-test-post.js directly, the "TEST COMPLETE" output comes
out of order. | 49 // If we include js-test-post.js directly, the "TEST COMPLETE" output comes
out of order. |
50 wasPostTestScriptParsed = true; | 50 wasPostTestScriptParsed = true; |
51 finishJSTest(); | 51 finishJSTest(); |
52 } | 52 } |
53 </script> | 53 </script> |
54 </head> | 54 </head> |
55 <body onload="runTest();"> | 55 <body onload="runTest();"> |
56 <div lang="ko" id="x1"><div id="x2"/><div id="x3" lang="ar"/></div> | 56 <div lang="ko" id="x1"><div id="x2"/><div id="x3" lang="ar"/></div> |
57 </body> | 57 </body> |
58 </html> | 58 </html> |
OLD | NEW |