OLD | NEW |
(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 |
OLD | NEW |