blob: d24d82f68db7025d9dc972842318411b251998de [file] [log] [blame]
<?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.js"></script>
<script>
function localeOfNode(id) {
var element = document.getElementById(id);
return window.getComputedStyle(element).webkitLocale;
}
function runTest() {
description('This tests mapping of lang/xml:lang to -webkit-locale with dynamic attribute changes. WebKit bug 76364');
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"');
// If we include js-test-post.js directly, the "TEST COMPLETE" output comes out of order.
wasPostTestScriptParsed = true;
finishJSTest();
}
</script>
</head>
<body onload="runTest();">
<div lang="ko" id="x1"><div id="x2"/><div id="x3" lang="ar"/></div>
</body>
</html>