Improve http-equiv content-language parsing
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2012 01:41:45 +0000 (01:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Feb 2012 01:41:45 +0000 (01:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77724

Patch by Matt Falkenhagen <falken@chromium.org> on 2012-02-08
Reviewed by Alexey Proskuryakov.

Add more tests for mapping http-equiv content-language to -webkit-locale. The desired behavior of some
of these is not yet decided, so some of the tests currently fail and the expectations may change. See comments in bug and in the tests.

* fast/text/content-language-case-insensitivity-expected.txt:
* fast/text/content-language-case-insensitivity.html: Style fixes.
* fast/text/content-language-empty-expected.txt: Added.
* fast/text/content-language-empty.html: Added.
* fast/text/content-language-late-expected.txt: Added.
* fast/text/content-language-late.html: Added.
* fast/text/content-language-mapped-to-webkit-locale-expected.txt:
* fast/text/content-language-mapped-to-webkit-locale.html: Style fixes.
* fast/text/content-language-multiple-expected.txt: Added.
* fast/text/content-language-multiple.html: Added.
* fast/text/content-language-no-content-expected.txt: Added.
* fast/text/content-language-no-content.html: Added.
* fast/text/content-language-only-whitespace-expected.txt: Added.
* fast/text/content-language-only-whitespace.html: Added.
* fast/text/content-language-with-whitespace-expected.txt: Added.
* fast/text/content-language-with-whitespace.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107159 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/content-language-case-insensitivity-expected.txt
LayoutTests/fast/text/content-language-case-insensitivity.html
LayoutTests/fast/text/content-language-empty-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/content-language-empty.html [new file with mode: 0644]
LayoutTests/fast/text/content-language-late-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/content-language-late.html [new file with mode: 0644]
LayoutTests/fast/text/content-language-mapped-to-webkit-locale-expected.txt
LayoutTests/fast/text/content-language-mapped-to-webkit-locale.html
LayoutTests/fast/text/content-language-multiple-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/content-language-multiple.html [new file with mode: 0644]
LayoutTests/fast/text/content-language-no-content-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/content-language-no-content.html [new file with mode: 0644]
LayoutTests/fast/text/content-language-only-whitespace-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/content-language-only-whitespace.html [new file with mode: 0644]
LayoutTests/fast/text/content-language-with-whitespace-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/content-language-with-whitespace.html [new file with mode: 0644]

index a8ccfd4..73139a6 100644 (file)
@@ -1,3 +1,30 @@
+2012-02-08  Matt Falkenhagen  <falken@chromium.org>
+
+        Improve http-equiv content-language parsing
+        https://bugs.webkit.org/show_bug.cgi?id=77724
+
+        Reviewed by Alexey Proskuryakov.
+
+        Add more tests for mapping http-equiv content-language to -webkit-locale. The desired behavior of some
+        of these is not yet decided, so some of the tests currently fail and the expectations may change. See comments in bug and in the tests.
+
+        * fast/text/content-language-case-insensitivity-expected.txt:
+        * fast/text/content-language-case-insensitivity.html: Style fixes.
+        * fast/text/content-language-empty-expected.txt: Added.
+        * fast/text/content-language-empty.html: Added.
+        * fast/text/content-language-late-expected.txt: Added.
+        * fast/text/content-language-late.html: Added.
+        * fast/text/content-language-mapped-to-webkit-locale-expected.txt: 
+        * fast/text/content-language-mapped-to-webkit-locale.html: Style fixes.
+        * fast/text/content-language-multiple-expected.txt: Added.
+        * fast/text/content-language-multiple.html: Added.
+        * fast/text/content-language-no-content-expected.txt: Added.
+        * fast/text/content-language-no-content.html: Added.
+        * fast/text/content-language-only-whitespace-expected.txt: Added.
+        * fast/text/content-language-only-whitespace.html: Added.
+        * fast/text/content-language-with-whitespace-expected.txt: Added.
+        * fast/text/content-language-with-whitespace.html: Added.
+
 2012-02-08  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Unreviewed gardening.
index 5f0b4db..315c45a 100644 (file)
@@ -1,6 +1,6 @@
 Test for bug 76701: map content-language to -webkit-locale. This particular test tests that the matching of the http-equiv attribute to the content-language state is case insensitive.
 
-PASS languageOfNode('x1') is "ja-JP"
+PASS languageOfNode('x') is "ja-JP"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index b975bf3..dd7aa3f 100644 (file)
@@ -12,15 +12,13 @@ matching of the http-equiv attribute to the content-language state is case
 insensitive.
 </p>
 <div id="console"></div>
-<div id="x1"/>
+<div id="x"></div>
 <script>
 function languageOfNode(id) {
     var element = document.getElementById(id);
     return window.getComputedStyle(element).webkitLocale;
 }
-shouldBeEqualToString("languageOfNode('x1')", "ja-JP");
-
-var successfullyParsed = true;
+shouldBeEqualToString("languageOfNode('x')", "ja-JP");
 </script>
 <script src="../js/resources/js-test-post.js"></script>
 </body>
diff --git a/LayoutTests/fast/text/content-language-empty-expected.txt b/LayoutTests/fast/text/content-language-empty-expected.txt
new file mode 100644 (file)
index 0000000..0d27f59
--- /dev/null
@@ -0,0 +1,8 @@
+Test for bug 76701: map HTTP-EQUIV content-language to -webkit-locale. This particular test tests that a content-language of empty string is ignored. This expectation may change, see bug. HTML5 decrees that the meta element be ignored in case of the empty string. It's unclear what other browsers do.
+
+FAIL languageOfNode('x') should be auto. Was ''.
+PASS languageOfNode('y') is "ar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/text/content-language-empty.html b/LayoutTests/fast/text/content-language-empty.html
new file mode 100644 (file)
index 0000000..c043a18
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-language" content="">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76701">bug 76701</a>:
+map HTTP-EQUIV content-language to -webkit-locale. This particular test tests
+that a content-language of empty string is ignored. This expectation may
+change, see bug. HTML5 decrees that the meta element be ignored in case of the
+empty string. It's unclear what other browsers do.
+</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+function languageOfNode(id) {
+    var element = document.getElementById(id);
+    return window.getComputedStyle(element).webkitLocale;
+}
+shouldBeEqualToString("languageOfNode('x')", "auto");
+shouldBeEqualToString("languageOfNode('y')", "ar");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/content-language-late-expected.txt b/LayoutTests/fast/text/content-language-late-expected.txt
new file mode 100644 (file)
index 0000000..55d4273
--- /dev/null
@@ -0,0 +1,8 @@
+Test for bug 76701: map HTTP-EQUIV content-language to -webkit-locale. This particular test tests that a content-language is used even if it appears at the end of the document. This expectation may change, see bug. According to the HTML 5 spec, a meta element should be processed when it is inserted into the document, regardless of where. IE and Firefox also seem to process the content-language at the end of the document.
+
+FAIL languageOfNode('x') should be ja-JP. Was auto.
+PASS languageOfNode('y') is "ar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/text/content-language-late.html b/LayoutTests/fast/text/content-language-late.html
new file mode 100644 (file)
index 0000000..b5c7d3e
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76701">bug 76701</a>:
+map HTTP-EQUIV content-language to -webkit-locale. This particular test tests
+that a content-language is used even if it appears at the end of the document.
+This expectation may change, see bug.  According to the HTML 5 spec, a meta
+element should be processed when it is inserted into the document, regardless
+of where. IE and Firefox also seem to process the content-language at the end
+of the document.
+</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+function languageOfNode(id) {
+    var element = document.getElementById(id);
+    return window.getComputedStyle(element).webkitLocale;
+}
+shouldBeEqualToString("languageOfNode('x')", "ja-JP");
+shouldBeEqualToString("languageOfNode('y')", "ar");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+<meta http-equiv="content-language" content="ja-JP">
+</body>
+</html>
index 7c79078..66ba83a 100644 (file)
@@ -1,7 +1,7 @@
 Test for bug 76701: map content-language to -webkit-locale.
 
-PASS languageOfNode('x1') is "zh-CN"
-PASS languageOfNode('m1') is "ar"
+PASS languageOfNode('x') is "zh-CN"
+PASS languageOfNode('y') is "ar"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index bb61ea1..9ff0fd6 100644 (file)
@@ -9,17 +9,15 @@
 <p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76701">bug 76701</a>:
 map content-language to -webkit-locale.</p>
 <div id="console"></div>
-<div id="x1"/>
-<div lang="ar" id="m1"/>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
 <script>
 function languageOfNode(id) {
     var element = document.getElementById(id);
     return window.getComputedStyle(element).webkitLocale;
 }
-shouldBeEqualToString("languageOfNode('x1')", "zh-CN");
-shouldBeEqualToString("languageOfNode('m1')", "ar");
-
-var successfullyParsed = true;
+shouldBeEqualToString("languageOfNode('x')", "zh-CN");
+shouldBeEqualToString("languageOfNode('y')", "ar");
 </script>
 <script src="../js/resources/js-test-post.js"></script>
 </body>
diff --git a/LayoutTests/fast/text/content-language-multiple-expected.txt b/LayoutTests/fast/text/content-language-multiple-expected.txt
new file mode 100644 (file)
index 0000000..5981ef8
--- /dev/null
@@ -0,0 +1,8 @@
+Test for bug 76701: map HTTP-EQUIV content-language to -webkit-locale. This particular test tests that in the event of multiple content-languages, the final content-language is used as the pragma-set default language. This expectation may change, see bug. The HTML5 spec decrees that the first successfully processed one be used. Firefox and IE seem to use the final one.
+
+PASS languageOfNode('x') is "zh_CN"
+PASS languageOfNode('y') is "ar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/text/content-language-multiple.html b/LayoutTests/fast/text/content-language-multiple.html
new file mode 100644 (file)
index 0000000..44ea63c
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-language" content="   ">
+<meta http-equiv="content-language" content="ja_JP">
+<meta http-equiv="content-language" content="zh_CN">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76701">bug 76701</a>:
+map HTTP-EQUIV content-language to -webkit-locale. This particular test tests
+that in the event of multiple content-languages, the final content-language is
+used as the pragma-set default language. This expectation may change, see bug.
+The HTML5 spec decrees that the first successfully processed one be used.
+Firefox and IE seem to use the final one.
+</p>
+<div id="console"></div>
+<div id="x" lang="zh_CN"></div>
+<div id="y" lang="ar"></div>
+<script>
+function languageOfNode(id) {
+    var element = document.getElementById(id);
+    return window.getComputedStyle(element).webkitLocale;
+}
+shouldBeEqualToString("languageOfNode('x')", "zh_CN");
+shouldBeEqualToString("languageOfNode('y')", "ar");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/content-language-no-content-expected.txt b/LayoutTests/fast/text/content-language-no-content-expected.txt
new file mode 100644 (file)
index 0000000..b88dc92
--- /dev/null
@@ -0,0 +1,8 @@
+Test for bug 76701: map HTTP-EQUIV content-language to -webkit-locale. This particular test tests that a content-language with missing content is effectively ignored. This expectation may change, see comments in bug.
+
+PASS languageOfNode('x') is "auto"
+PASS languageOfNode('y') is "ar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/text/content-language-no-content.html b/LayoutTests/fast/text/content-language-no-content.html
new file mode 100644 (file)
index 0000000..8839b22
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-language">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76701">bug 76701</a>:
+map HTTP-EQUIV content-language to -webkit-locale. This particular test tests that
+a content-language with missing content is effectively ignored. This expectation
+may change, see comments in bug.
+</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+function languageOfNode(id) {
+    var element = document.getElementById(id);
+    return window.getComputedStyle(element).webkitLocale;
+}
+shouldBeEqualToString("languageOfNode('x')", "auto");
+shouldBeEqualToString("languageOfNode('y')", "ar");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/content-language-only-whitespace-expected.txt b/LayoutTests/fast/text/content-language-only-whitespace-expected.txt
new file mode 100644 (file)
index 0000000..5d14508
--- /dev/null
@@ -0,0 +1,8 @@
+Test for bug 76701: map HTTP-EQUIV content-language to -webkit-locale. This particular test tests that a content-language with whitespace-only content is ignored. This expectation may change, see bug. HTML5 decrees that the meta element be ignored in case of whitespace only content. It's unclear what other browsers do.
+
+FAIL languageOfNode('x') should be auto. Was '  \9\a  '.
+PASS languageOfNode('y') is "ar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/text/content-language-only-whitespace.html b/LayoutTests/fast/text/content-language-only-whitespace.html
new file mode 100644 (file)
index 0000000..88e82ed
--- /dev/null
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-language" content="          
+ ">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76701">bug 76701</a>:
+map HTTP-EQUIV content-language to -webkit-locale. This particular test tests
+that a content-language with whitespace-only content is ignored. This
+expectation may change, see bug. HTML5 decrees that the meta element be ignored
+in case of whitespace only content.  It's unclear what other browsers do.</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+function languageOfNode(id) {
+    var element = document.getElementById(id);
+    return window.getComputedStyle(element).webkitLocale;
+}
+shouldBeEqualToString("languageOfNode('x')", "auto");
+shouldBeEqualToString("languageOfNode('y')", "ar");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/text/content-language-with-whitespace-expected.txt b/LayoutTests/fast/text/content-language-with-whitespace-expected.txt
new file mode 100644 (file)
index 0000000..ba01c72
--- /dev/null
@@ -0,0 +1,8 @@
+Test for bug 76701: map HTTP-EQUIV content-language to -webkit-locale. This particular test tests that the the pragma-set default language is set to the first sequence of non-whitespace characters of the content-language content. This expectation may change, see bug. This expectation is as per the HTML 5 spec. It appears that Firefox does not exactly do this, but trims the leading and trailing whitespace. It's unclear what IE does.
+
+FAIL languageOfNode('x') should be ja_JP. Was '  \a\9\9ja-JP   \9  zh_CN \9\a\a\9\9'.
+PASS languageOfNode('y') is "ar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/text/content-language-with-whitespace.html b/LayoutTests/fast/text/content-language-with-whitespace.html
new file mode 100644 (file)
index 0000000..a8658e7
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-language" content="  
+               ja-JP            zh_CN  
+
+               ">
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76701">bug 76701</a>:
+map HTTP-EQUIV content-language to -webkit-locale. This particular test tests
+that the the pragma-set default language is set to the first sequence of
+non-whitespace characters of the content-language content. This expectation may
+change, see bug. This expectation is as per the HTML 5 spec. It appears that
+Firefox does not exactly do this, but trims the leading and trailing
+whitespace.  It's unclear what IE does.
+</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+function languageOfNode(id) {
+    var element = document.getElementById(id);
+    return window.getComputedStyle(element).webkitLocale;
+}
+shouldBeEqualToString("languageOfNode('x')", "ja_JP");
+shouldBeEqualToString("languageOfNode('y')", "ar");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>