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

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

Issue 2742873002: Convert non-WHATWG text encoding to ASCII (Closed)
Patch Set: Created 3 years, 9 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 c8c8a0b40b40e51c6bd0525255efd935c67b625f..598dbf3cfcbf924ef9f3d9e6eb97c1ae8cd05b60 100644
--- a/third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp
+++ b/third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp
@@ -9,7 +9,7 @@
namespace blink {
-TEST(TextResourceDecoderTest, RespectIso2022Jp) {
+TEST(TextEncodingDetectorTest, RespectIso2022Jp) {
// ISO-2022-JP is the only 7-bit encoding defined in WHATWG standard.
std::string iso2022jp =
" \x1B"
@@ -21,7 +21,7 @@ TEST(TextResourceDecoderTest, RespectIso2022Jp) {
EXPECT_EQ(WTF::TextEncoding("ISO-2022-JP"), encoding);
}
-TEST(TextResourceDecoderTest, Ignore7BitEncoding) {
+TEST(TextEncodingDetectorTest, Ignore7BitEncoding) {
// 7-bit encodings except ISO-2022-JP are not supported by WHATWG.
// They should be detected as plain text (US-ASCII).
std::string hzGb2312 =
@@ -33,6 +33,19 @@ TEST(TextResourceDecoderTest, Ignore7BitEncoding) {
EXPECT_EQ(WTF::TextEncoding("US-ASCII"), encoding);
}
+TEST(TextEncodingDetectorTest, NonWHATWGEncodingBecomesAscii) {
+ std::string pseudoJpg =
+ "\xff\xd8\xff\xe0\x00\x10JFIF foo bar baz\xff\xe1\x00\xa5"
+ "\x01\xd7\xff\x01\x57\x33\x44\x55\x66\x77\xed\xcb\xa9\x87"
+ "\xff\xd7\xff\xe0\x00\x10JFIF foo bar baz\xff\xe1\x00\xa5"
+ "\x87\x01\xd7\xff\x01\x57\x33\x44\x55\x66\x77\xed\xcb\xa9";
+ WTF::TextEncoding encoding;
+ bool result = detectTextEncoding(pseudoJpg.c_str(), pseudoJpg.length(),
+ nullptr, nullptr, nullptr, &encoding);
+ EXPECT_TRUE(result);
+ EXPECT_EQ(WTF::TextEncoding("US-ASCII"), encoding);
+}
+
TEST(TextEncodingDetectorTest, UrlHintHelpsEUCJP) {
std::string eucjpBytes =
"<TITLE>"
« 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