| <?xml version="1.0" encoding="utf-8"?> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <title>mapping dynamic lang to -webkit-locale</title> |
| <script src="../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <p>This is tests mapping of lang/xml:lang to -webkit-locale with dynamic attribute changes. <a href="http://webkit.org/b/76364">bug 76364</a>.</p> |
| <div id="console"></div> |
| <div lang="ko" id="x1"><div id="x2"/><div id="x3" lang="ar"/></div> |
| <script> |
| function localeOfNode(id) { |
| var element = document.getElementById(id); |
| return window.getComputedStyle(element).webkitLocale; |
| } |
| var x1 = document.getElementById("x1"); |
| var x2 = document.getElementById("x2"); |
| var x3 = document.getElementById("x3"); |
| |
| shouldBeEqualToString("localeOfNode('x1')", "ko"); |
| shouldBeEqualToString("localeOfNode('x2')", "ko"); |
| shouldBeEqualToString("localeOfNode('x3')", "ar"); |
| |
| x1.lang = "ja"; |
| shouldBeEqualToString("localeOfNode('x1')", "ja"); |
| shouldBeEqualToString("localeOfNode('x2')", "ja"); |
| shouldBeEqualToString("localeOfNode('x3')", "ar"); |
| |
| x3.lang = ""; |
| shouldBeEqualToString("localeOfNode('x3')", "auto"); |
| |
| x3.removeAttribute("lang"); |
| shouldBeEqualToString("localeOfNode('x3')", "ja"); |
| |
| // The "lang" attribute in the XML namespace should affect locale (since this is an XHTML document). |
| var attr1 = document.createAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang"); |
| attr1.value = "zh"; |
| x2.setAttributeNodeNS(attr1); |
| shouldBeEqualToString("localeOfNode('x2')", "zh"); |
| |
| x2.removeAttributeNode(attr1); |
| shouldBeEqualToString("localeOfNode('x2')", "ja"); |
| |
| // An attribute with local name "lang" not in the XML namespace should not affect locale. |
| var attr2 = document.createAttributeNS("foobar", "fb:lang"); |
| attr2.value = "ph"; |
| x2.setAttributeNodeNS(attr2); |
| shouldBeEqualToString("localeOfNode('x2')", "ja"); |
| |
| </script> |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |