| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/ui/webui/log_web_ui_url.h" | 5 #include "chrome/browser/ui/webui/log_web_ui_url.h" |
| 6 | 6 |
| 7 #include "extensions/features/features.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 9 | 10 |
| 10 TEST(LogWebUIUrlTest, ValidUrls) { | 11 TEST(LogWebUIUrlTest, ValidUrls) { |
| 11 // Typical WebUI page. | 12 // Typical WebUI page. |
| 12 EXPECT_TRUE(webui::LogWebUIUrl(GURL("chrome://downloads"))); | 13 EXPECT_TRUE(webui::LogWebUIUrl(GURL("chrome://downloads"))); |
| 13 | 14 |
| 14 // WebUI page with a subpage. | 15 // WebUI page with a subpage. |
| 15 EXPECT_TRUE(webui::LogWebUIUrl(GURL("chrome://settings/clearBrowserData"))); | 16 EXPECT_TRUE(webui::LogWebUIUrl(GURL("chrome://settings/clearBrowserData"))); |
| 16 | 17 |
| 17 // Developer tools scheme. | 18 // Developer tools scheme. |
| 18 EXPECT_TRUE(webui::LogWebUIUrl(GURL("chrome-devtools://devtools"))); | 19 EXPECT_TRUE(webui::LogWebUIUrl(GURL("chrome-devtools://devtools"))); |
| 19 | 20 |
| 20 #if defined(ENABLE_EXTENSIONS) | 21 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 21 // Bookmarks Manager (the only currently allowed extension). | 22 // Bookmarks Manager (the only currently allowed extension). |
| 22 EXPECT_TRUE(webui::LogWebUIUrl(GURL( | 23 EXPECT_TRUE(webui::LogWebUIUrl(GURL( |
| 23 "chrome-extension://eemcgdkfndhakfknompkggombfjjjeno"))); | 24 "chrome-extension://eemcgdkfndhakfknompkggombfjjjeno"))); |
| 24 #endif | 25 #endif |
| 25 } | 26 } |
| 26 | 27 |
| 27 TEST(LogWebUIUrlTest, InvalidUrls) { | 28 TEST(LogWebUIUrlTest, InvalidUrls) { |
| 28 // HTTP/HTTPS/FTP/etc. schemes should be ignored. | 29 // HTTP/HTTPS/FTP/etc. schemes should be ignored. |
| 29 EXPECT_FALSE(webui::LogWebUIUrl(GURL("http://google.com?q=pii"))); | 30 EXPECT_FALSE(webui::LogWebUIUrl(GURL("http://google.com?q=pii"))); |
| 30 EXPECT_FALSE(webui::LogWebUIUrl(GURL("https://facebook.com"))); | 31 EXPECT_FALSE(webui::LogWebUIUrl(GURL("https://facebook.com"))); |
| 31 EXPECT_FALSE(webui::LogWebUIUrl(GURL("ftp://ftp.mysite.com"))); | 32 EXPECT_FALSE(webui::LogWebUIUrl(GURL("ftp://ftp.mysite.com"))); |
| 32 | 33 |
| 33 // Extensions other than the Bookmarks Manager should also be ignored. | 34 // Extensions other than the Bookmarks Manager should also be ignored. |
| 34 EXPECT_FALSE(webui::LogWebUIUrl(GURL( | 35 EXPECT_FALSE(webui::LogWebUIUrl(GURL( |
| 35 "chrome-extension://mfehgcgbbipciphmccgaenjidiccnmng"))); | 36 "chrome-extension://mfehgcgbbipciphmccgaenjidiccnmng"))); |
| 36 } | 37 } |
| OLD | NEW |