Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1165)

Unified Diff: third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp

Issue 2803563004: Avoid using language hint in encoding detection (Closed)
Patch Set: fix bug Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp
diff --git a/third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp b/third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp
index 77be6baf7553959d5523a412f5a2311f70a310da..6d9b16d1143c0ed0b20319daecea40f463a18ab5 100644
--- a/third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp
+++ b/third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp
@@ -81,11 +81,19 @@ TEST(TextEncodingDetectorTest, LanguageHintHelpsEUCJP) {
EXPECT_EQ(WTF::TextEncoding("GBK"), encoding)
<< "Without language hint, it's detected as GBK";
+ KURL url(ParsedURLString, "http://example.com/");
result = detectTextEncoding(eucjpBytes.c_str(), eucjpBytes.length(), nullptr,
- KURL(), "ja", &encoding);
+ url, "ja", &encoding);
+ EXPECT_TRUE(result);
+ EXPECT_EQ(WTF::TextEncoding("GBK"), encoding)
+ << "Language hint doesn't help for normal URL. Should be detected as GBK";
+
+ KURL fileUrl(ParsedURLString, "file:///text.txt");
+ result = detectTextEncoding(eucjpBytes.c_str(), eucjpBytes.length(), nullptr,
+ fileUrl, "ja", &encoding);
EXPECT_TRUE(result);
EXPECT_EQ(WTF::TextEncoding("EUC-JP"), encoding)
- << "With language hint 'ja', it's detected as EUC-JP";
+ << "Language hint works for file resource. Should be detected as EUC-JP";
}
TEST(TextEncodingDetectorTest, UTF8DetectionShouldFail) {
« no previous file with comments | « third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698