Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 "chrome/renderer/content_settings_observer.h" | |
| 6 | |
| 7 #include "chrome/common/url_constants.h" | |
| 8 #include "content/public/common/url_constants.h" | |
| 9 #include "googleurl/src/gurl.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | |
| 12 | |
| 13 using WebKit::WebSecurityOrigin; | |
| 14 | |
| 15 class ContentSettingsObserverTest : public testing::Test {}; | |
|
jochen (gone - plz use gerrit)
2011/12/01 15:23:31
typedef testing::Test ContentSettingsObserverTest
marja
2011/12/01 15:41:35
Done.
| |
| 16 | |
| 17 TEST_F(ContentSettingsObserverTest, WhitelistedSchemes) { | |
| 18 std::string end_url = ":something"; | |
| 19 | |
| 20 GURL chrome_ui_url = | |
| 21 GURL(std::string(chrome::kChromeUIScheme).append(end_url)); | |
| 22 ASSERT_TRUE( | |
| 23 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
|
jochen (gone - plz use gerrit)
2011/12/01 15:23:31
fits on previous line?
marja
2011/12/01 15:41:35
Done.
| |
| 24 WebSecurityOrigin::create(chrome_ui_url), | |
| 25 GURL())); | |
| 26 | |
| 27 GURL chrome_dev_tools_url = | |
| 28 GURL(std::string(chrome::kChromeDevToolsScheme).append(end_url)); | |
| 29 EXPECT_TRUE( | |
| 30 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 31 WebSecurityOrigin::create(chrome_dev_tools_url), | |
| 32 GURL())); | |
| 33 | |
| 34 GURL extension_url = | |
| 35 GURL(std::string(chrome::kExtensionScheme).append(end_url)); | |
| 36 EXPECT_TRUE( | |
| 37 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 38 WebSecurityOrigin::create(extension_url), | |
| 39 GURL())); | |
| 40 | |
| 41 GURL chrome_internal_url = | |
| 42 GURL(std::string(chrome::kChromeInternalScheme).append(end_url)); | |
| 43 EXPECT_TRUE( | |
| 44 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 45 WebSecurityOrigin::create(chrome_internal_url), | |
| 46 GURL())); | |
| 47 | |
| 48 GURL file_url("file:///dir/"); | |
| 49 EXPECT_TRUE( | |
| 50 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 51 WebSecurityOrigin::create(file_url), | |
| 52 GURL("file:///dir/"))); | |
| 53 EXPECT_FALSE( | |
| 54 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 55 WebSecurityOrigin::create(file_url), | |
| 56 GURL("file:///dir/file"))); | |
| 57 | |
| 58 GURL ftp_url("ftp:///dir/"); | |
| 59 EXPECT_TRUE( | |
| 60 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 61 WebSecurityOrigin::create(ftp_url), | |
| 62 GURL("ftp:///dir/"))); | |
| 63 EXPECT_FALSE( | |
| 64 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 65 WebSecurityOrigin::create(ftp_url), | |
| 66 GURL("ftp:///dir/file"))); | |
| 67 | |
| 68 GURL http_url = | |
| 69 GURL("http://server.com/path"); | |
| 70 EXPECT_FALSE( | |
| 71 ContentSettingsObserver::IsWhitelistedForContentSettings( | |
| 72 WebSecurityOrigin::create(http_url), | |
| 73 GURL())); | |
| 74 } | |
| OLD | NEW |