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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/loader/TextResourceDecoderBuilder.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/loader/TextResourceDecoderBuilder.h"
6
7 #include "core/testing/DummyPageHolder.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace blink {
11
12 static const WTF::TextEncoding defaultEncodingForURL(const char* url)
13 {
14 OwnPtr<DummyPageHolder> pageHolder = DummyPageHolder::create(IntSize(0, 0));
15 Document& document = pageHolder->document();
16 document.setURL(KURL(KURL(), url));
17 TextResourceDecoderBuilder decoderBuilder("text/html", nullAtom);
18 return decoderBuilder.buildFor(&document)->encoding();
19 }
20
21 TEST(TextResourceDecoderBuilderTest, defaultEncodingComesFromTopLevelDomain)
22 {
23 EXPECT_EQ(WTF::TextEncoding("Shift_JIS"), defaultEncodingForURL("http://tsub otaa.la.coocan.jp"));
24 EXPECT_EQ(WTF::TextEncoding("windows-1251"), defaultEncodingForURL("http://u darenieru.ru/index.php"));
25 }
26
27 TEST(TextResourceDecoderBuilderTest, NoCountryDomainURLDefaultsToLatin1Encoding)
28 {
29 // Latin1 encoding is set in |TextResourceDecoder::defaultEncoding()|.
30 EXPECT_EQ(WTF::Latin1Encoding(), defaultEncodingForURL("http://arstechnica.c om/about-us"));
31 }
32
33 } // namespace blink
OLDNEW
« 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