Title: [131794] trunk

Diff

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language-against-equiv-expected.txt (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language-against-equiv-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language-against-equiv-expected.txt	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,11 @@
+Test for bug 97929: Extract HTTP Content-Language header.
+
+==> Value extracted from meta "http-equiv" and overriding HTTP "Content-Language"...
+PASS window.getComputedStyle(document.getElementById("x")).webkitLocale is "en-GB"
+==> Value set by div "lang" tag...
+PASS window.getComputedStyle(document.getElementById("y")).webkitLocale is "ar"
+==> All done...
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language-against-equiv.php (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language-against-equiv.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language-against-equiv.php	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,25 @@
+<?php
+  header("Content-Language: zh-CN");
+?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-language" content="en-GB">
+<script src=""
+</head>
+<body>
+<p>Test for <a href="" 97929</a>:
+Extract HTTP Content-Language header.</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+  debug('==> Value extracted from meta "http-equiv" and overriding HTTP "Content-Language"...');
+  shouldBe('window.getComputedStyle(document.getElementById("x")).webkitLocale', '"en-GB"')
+  debug('==> Value set by div "lang" tag...');
+  shouldBe('window.getComputedStyle(document.getElementById("y")).webkitLocale', '"ar"')
+  debug('==> All done...');
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language-expected.txt (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language-expected.txt	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,11 @@
+Test for bug 97929: Extract HTTP Content-Language header.
+
+==> Value extracted from HTTP "Content-Language" header...
+PASS window.getComputedStyle(document.getElementById("x")).webkitLocale is "zh-CN"
+==> Value set by div "lang" tag...
+PASS window.getComputedStyle(document.getElementById("y")).webkitLocale is "ar"
+==> All done...
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language-malformed-expected.txt (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language-malformed-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language-malformed-expected.txt	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,11 @@
+Test for bug 97929: Extract HTTP Content-Language header.
+
+==> Value extracted from malformed HTTP "Content-Language" header...
+PASS window.getComputedStyle(document.getElementById("x")).webkitLocale == "es" || window.getComputedStyle(document.getElementById("x")).webkitLocale == "auto" is true
+==> Value set by div "lang" tag...
+PASS window.getComputedStyle(document.getElementById("y")).webkitLocale is "ar"
+==> All done...
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language-malformed.php (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language-malformed.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language-malformed.php	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,26 @@
+<?php
+  header("Content-Language: ,es");
+?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script src=""
+</head>
+<body>
+<p>Test for <a href="" 97929</a>:
+Extract HTTP Content-Language header.</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+  debug('==> Value extracted from malformed HTTP "Content-Language" header...');
+  // A malformed header may be fixed by the browser ("es") or left bad and so remain unset ("auto").
+  // Chrome does the former; Safari does the latter.
+  shouldBeTrue('window.getComputedStyle(document.getElementById("x")).webkitLocale == "es" || window.getComputedStyle(document.getElementById("x")).webkitLocale == "auto"')
+  debug('==> Value set by div "lang" tag...');
+  shouldBe('window.getComputedStyle(document.getElementById("y")).webkitLocale', '"ar"')
+  debug('==> All done...');
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language-multiple-expected.txt (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language-multiple-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language-multiple-expected.txt	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,11 @@
+Test for bug 97929: Extract HTTP Content-Language header.
+
+==> Value extracted singly from HTTP "Content-Language" header...
+PASS window.getComputedStyle(document.getElementById("x")).webkitLocale is "fr"
+==> Value set by div "lang" tag...
+PASS window.getComputedStyle(document.getElementById("y")).webkitLocale is "ar"
+==> All done...
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language-multiple.php (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language-multiple.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language-multiple.php	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,24 @@
+<?php
+  header("Content-Language:  fr \t , fi ");
+?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script src=""
+</head>
+<body>
+<p>Test for <a href="" 97929</a>:
+Extract HTTP Content-Language header.</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+  debug('==> Value extracted singly from HTTP "Content-Language" header...');
+  shouldBe('window.getComputedStyle(document.getElementById("x")).webkitLocale', '"fr"')
+  debug('==> Value set by div "lang" tag...');
+  shouldBe('window.getComputedStyle(document.getElementById("y")).webkitLocale', '"ar"')
+  debug('==> All done...');
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/misc/extract-http-content-language.php (0 => 131794)


--- trunk/LayoutTests/http/tests/misc/extract-http-content-language.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/extract-http-content-language.php	2012-10-18 19:53:58 UTC (rev 131794)
@@ -0,0 +1,24 @@
+<?php
+  header("Content-Language: zh-CN");
+?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script src=""
+</head>
+<body>
+<p>Test for <a href="" 97929</a>:
+Extract HTTP Content-Language header.</p>
+<div id="console"></div>
+<div id="x"></div>
+<div id="y" lang="ar"></div>
+<script>
+  debug('==> Value extracted from HTTP "Content-Language" header...');
+  shouldBe('window.getComputedStyle(document.getElementById("x")).webkitLocale', '"zh-CN"')
+  debug('==> Value set by div "lang" tag...');
+  shouldBe('window.getComputedStyle(document.getElementById("y")).webkitLocale', '"ar"')
+  debug('==> All done...');
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (131793 => 131794)


--- trunk/Source/WebCore/ChangeLog	2012-10-18 19:53:38 UTC (rev 131793)
+++ trunk/Source/WebCore/ChangeLog	2012-10-18 19:53:58 UTC (rev 131794)
@@ -1,3 +1,16 @@
+2012-10-18  Brian White  <bcwh...@chromium.org>
+
+        WebKit Doesn't Recognize Content-Language HTTP Header
+        https://bugs.webkit.org/show_bug.cgi?id=97929
+
+        Reviewed by Alexey Proskuryakov.
+
+        The HTTP "Content-Language" header may be present and include the
+        language of the page contents (as opposed to an embedded meta tag).
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::didBeginDocument):
+
 2012-10-18  Jer Noble  <jer.no...@apple.com>
 
         Crash in WebCore::Document::webkitExitFullscreen + 618
Property changes on: trunk/Source/WebCore/ChangeLog
___________________________________________________________________

Added: svn:executable

Property changes: trunk/Source/WebCore/html/parser/HTMLParserIdioms.h


Added: svn:executable

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (131793 => 131794)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2012-10-18 19:53:38 UTC (rev 131793)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2012-10-18 19:53:58 UTC (rev 131794)
@@ -70,6 +70,7 @@
 #include "HTMLFormElement.h"
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
+#include "HTMLParserIdioms.h"
 #include "HTTPParsers.h"
 #include "HistoryItem.h"
 #include "InspectorController.h"
@@ -666,6 +667,15 @@
         String reportOnlyContentSecurityPolicy = m_documentLoader->response().httpHeaderField("X-WebKit-CSP-Report-Only");
         if (!reportOnlyContentSecurityPolicy.isEmpty())
             m_frame->document()->contentSecurityPolicy()->didReceiveHeader(reportOnlyContentSecurityPolicy, ContentSecurityPolicy::ReportOnly);
+
+        String headerContentLanguage = m_documentLoader->response().httpHeaderField("Content-Language");
+        if (!headerContentLanguage.isEmpty()) {
+            size_t commaIndex = headerContentLanguage.find(',');
+            headerContentLanguage.truncate(commaIndex); // notFound == -1 == don't truncate
+            headerContentLanguage = headerContentLanguage.stripWhiteSpace(isHTMLSpace);
+            if (!headerContentLanguage.isEmpty())
+                m_frame->document()->setContentLanguage(headerContentLanguage);
+        }
     }
 
     history()->restoreDocumentState();
Property changes on: trunk/Source/WebCore/loader/FrameLoader.cpp
___________________________________________________________________

Added: svn:executable

_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to