[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame^] | 1 | // Copyright (c) 2010 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 "base/basictypes.h" |
| 6 | #include "base/scoped_ptr.h" |
| 7 | #include "chrome/browser/browser_about_handler.h" |
| 8 | #include "chrome/common/url_constants.h" |
| 9 | #include "chrome/renderer/about_handler.h" |
| 10 | #include "googleurl/src/gurl.h" |
| 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | TEST(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { |
| 14 | struct AboutURLTestData { |
| 15 | GURL test_url; |
| 16 | GURL result_url; |
| 17 | bool about_handled; |
| 18 | bool browser_handled; |
| 19 | } test_data[] = { |
| 20 | { |
| 21 | GURL("http://google.com"), |
| 22 | GURL("http://google.com"), |
| 23 | false, |
| 24 | false |
| 25 | }, |
| 26 | { |
| 27 | GURL(chrome::kAboutBlankURL), |
| 28 | GURL(chrome::kAboutBlankURL), |
| 29 | false, |
| 30 | false |
| 31 | }, |
| 32 | { |
| 33 | GURL(std::string(chrome::kAboutCacheURL) + "/mercury"), |
| 34 | GURL(std::string(chrome::kNetworkViewCacheURL) + "mercury"), |
| 35 | false, |
| 36 | true |
| 37 | }, |
| 38 | { |
| 39 | GURL(std::string(chrome::kAboutNetInternalsURL) + "/venus"), |
| 40 | GURL(std::string(chrome::kNetworkViewInternalsURL) + "venus"), |
| 41 | false, |
| 42 | true |
| 43 | }, |
| 44 | { |
| 45 | GURL(std::string(chrome::kAboutAppCacheInternalsURL) + "/earth"), |
| 46 | GURL(std::string(chrome::kAppCacheViewInternalsURL) + "earth"), |
| 47 | false, |
| 48 | true |
| 49 | }, |
| 50 | { |
| 51 | GURL(chrome::kAboutPluginsURL), |
| 52 | GURL(chrome::kChromeUIPluginsURL), |
| 53 | false, |
| 54 | true |
| 55 | }, |
| 56 | { |
| 57 | GURL(chrome::kAboutCrashURL), |
| 58 | GURL(chrome::kAboutCrashURL), |
| 59 | true, |
| 60 | false |
| 61 | }, |
| 62 | { |
| 63 | GURL(chrome::kAboutHangURL), |
| 64 | GURL(chrome::kAboutHangURL), |
| 65 | true, |
| 66 | false |
| 67 | }, |
| 68 | { |
| 69 | GURL(chrome::kAboutShorthangURL), |
| 70 | GURL(chrome::kAboutShorthangURL), |
| 71 | true, |
| 72 | false |
| 73 | }, |
| 74 | { |
| 75 | GURL("about:memory"), |
| 76 | GURL("chrome://about/memory-redirect"), |
| 77 | false, |
| 78 | true |
| 79 | }, |
| 80 | { |
| 81 | GURL("about:mars"), |
| 82 | GURL("chrome://about/mars"), |
| 83 | false, |
| 84 | true |
| 85 | }, |
| 86 | }; |
| 87 | |
| 88 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
| 89 | GURL url(test_data[i].test_url); |
| 90 | EXPECT_EQ(test_data[i].about_handled, AboutHandler::WillHandle(url)); |
| 91 | EXPECT_EQ(test_data[i].browser_handled, |
| 92 | WillHandleBrowserAboutURL(&url, NULL)); |
| 93 | EXPECT_EQ(test_data[i].result_url, url); |
| 94 | } |
| 95 | |
| 96 | // Crash the browser process for about:inducebrowsercrashforrealz. |
| 97 | GURL url(chrome::kAboutBrowserCrash); |
| 98 | EXPECT_DEATH(WillHandleBrowserAboutURL(&url, NULL), ""); |
| 99 | } |