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

Unified Diff: third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp

Issue 1725283002: Top-level domain-based default encoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 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/core/loader/TextResourceDecoderBuilder.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/core/loader/TextResourceDecoderBuilderTest.cpp
diff --git a/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp b/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eaf7950bc2994f73c81caa335869e9c49f77e8c2
--- /dev/null
+++ b/third_party/WebKit/Source/core/loader/TextResourceDecoderBuilderTest.cpp
@@ -0,0 +1,33 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/loader/TextResourceDecoderBuilder.h"
+
+#include "core/testing/DummyPageHolder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+static const WTF::TextEncoding defaultEncodingForURL(const char* url)
+{
+ OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(0, 0));
+ Document& document = pageHolder->document();
+ document.setURL(KURL(KURL(), url));
+ TextResourceDecoderBuilder decoderBuilder("text/html", nullAtom);
+ return decoderBuilder.buildFor(&document)->encoding();
+}
+
+TEST(TextResourceDecoderBuilderTest, defaultEncodingComesFromTopLevelDomain)
+{
+ EXPECT_EQ(WTF::TextEncoding("Shift_JIS"), defaultEncodingForURL("http://tsubotaa.la.coocan.jp"));
+ EXPECT_EQ(WTF::TextEncoding("windows-1251"), defaultEncodingForURL("http://udarenieru.ru/index.php"));
+}
+
+TEST(TextResourceDecoderBuilderTest, NoCountryDomainURLDefaultsToLatin1Encoding)
+{
+ // Latin1 encoding is set in |TextResourceDecoder::defaultEncoding()|.
+ EXPECT_EQ(WTF::Latin1Encoding(), defaultEncodingForURL("http://arstechnica.com/about-us"));
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/loader/TextResourceDecoderBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698