| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "content/browser/frame_host/navigation_entry_impl.h" | 10 #include "content/browser/frame_host/navigation_entry_impl.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 EXPECT_FALSE(entry2_->has_virtual_url()); | 60 EXPECT_FALSE(entry2_->has_virtual_url()); |
| 61 | 61 |
| 62 EXPECT_EQ(GURL(), entry1_->GetURL()); | 62 EXPECT_EQ(GURL(), entry1_->GetURL()); |
| 63 EXPECT_EQ(GURL(), entry1_->GetVirtualURL()); | 63 EXPECT_EQ(GURL(), entry1_->GetVirtualURL()); |
| 64 EXPECT_TRUE(entry1_->GetTitleForDisplay().empty()); | 64 EXPECT_TRUE(entry1_->GetTitleForDisplay().empty()); |
| 65 | 65 |
| 66 // Setting URL affects virtual_url and GetTitleForDisplay | 66 // Setting URL affects virtual_url and GetTitleForDisplay |
| 67 entry1_->SetURL(GURL("http://www.google.com")); | 67 entry1_->SetURL(GURL("http://www.google.com")); |
| 68 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetURL()); | 68 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetURL()); |
| 69 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetVirtualURL()); | 69 EXPECT_EQ(GURL("http://www.google.com"), entry1_->GetVirtualURL()); |
| 70 EXPECT_EQ(ASCIIToUTF16("www.google.com"), | 70 EXPECT_EQ(ASCIIToUTF16("www.google.com"), entry1_->GetTitleForDisplay()); |
| 71 |
| 72 // Setting URL with RTL characters causes it to be wrapped in an LTR |
| 73 // embedding. |
| 74 entry1_->SetURL(GURL("http://www.xn--rgba6eo.com")); |
| 75 EXPECT_EQ(base::WideToUTF16(L"\x202a" |
| 76 L"www.\x062c\x0648\x062c\x0644" |
| 77 L".com\x202c"), |
| 71 entry1_->GetTitleForDisplay()); | 78 entry1_->GetTitleForDisplay()); |
| 72 | 79 |
| 73 // file:/// URLs should only show the filename. | 80 // file:/// URLs should only show the filename. |
| 74 entry1_->SetURL(GURL("file:///foo/bar baz.txt")); | 81 entry1_->SetURL(GURL("file:///foo/bar baz.txt")); |
| 75 EXPECT_EQ(ASCIIToUTF16("bar baz.txt"), entry1_->GetTitleForDisplay()); | 82 EXPECT_EQ(ASCIIToUTF16("bar baz.txt"), entry1_->GetTitleForDisplay()); |
| 76 | 83 |
| 84 // file:/// URLs should *not* be wrapped in an LTR embedding. |
| 85 entry1_->SetURL(GURL("file:///foo/%D8%A7%D8%A8 %D8%AC%D8%AF.txt")); |
| 86 EXPECT_EQ(base::WideToUTF16(L"\x0627\x0628" |
| 87 L" \x062c\x062f" |
| 88 L".txt"), |
| 89 entry1_->GetTitleForDisplay()); |
| 90 |
| 77 // For file:/// URLs, make sure that slashes after the filename are ignored. | 91 // For file:/// URLs, make sure that slashes after the filename are ignored. |
| 78 // Regression test for https://crbug.com/503003. | 92 // Regression test for https://crbug.com/503003. |
| 79 entry1_->SetURL(GURL("file:///foo/bar baz.txt#foo/bar")); | 93 entry1_->SetURL(GURL("file:///foo/bar baz.txt#foo/bar")); |
| 80 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#foo/bar"), entry1_->GetTitleForDisplay()); | 94 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#foo/bar"), entry1_->GetTitleForDisplay()); |
| 81 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar")); | 95 entry1_->SetURL(GURL("file:///foo/bar baz.txt?x=foo/bar")); |
| 82 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar"), | 96 EXPECT_EQ(ASCIIToUTF16("bar baz.txt?x=foo/bar"), |
| 83 entry1_->GetTitleForDisplay()); | 97 entry1_->GetTitleForDisplay()); |
| 84 entry1_->SetURL(GURL("file:///foo/bar baz.txt#baz/boo?x=foo/bar")); | 98 entry1_->SetURL(GURL("file:///foo/bar baz.txt#baz/boo?x=foo/bar")); |
| 85 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#baz/boo?x=foo/bar"), | 99 EXPECT_EQ(ASCIIToUTF16("bar baz.txt#baz/boo?x=foo/bar"), |
| 86 entry1_->GetTitleForDisplay()); | 100 entry1_->GetTitleForDisplay()); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // Content in |output| is not modified if data is not present at the key. | 286 // Content in |output| is not modified if data is not present at the key. |
| 273 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); | 287 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output)); |
| 274 EXPECT_EQ(test_data, output); | 288 EXPECT_EQ(test_data, output); |
| 275 // Using an empty string shows that the data is not present in the map. | 289 // Using an empty string shows that the data is not present in the map. |
| 276 base::string16 output2; | 290 base::string16 output2; |
| 277 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); | 291 EXPECT_FALSE(entry1_->GetExtraData("search_terms", &output2)); |
| 278 EXPECT_EQ(ASCIIToUTF16(""), output2); | 292 EXPECT_EQ(ASCIIToUTF16(""), output2); |
| 279 } | 293 } |
| 280 | 294 |
| 281 } // namespace content | 295 } // namespace content |
| OLD | NEW |