Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/renderer/content_settings_observer_unittest.cc

Issue 8775005: Content settings: whitelist kExtensionScheme and kChromeInternalScheme on the renderer side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/content_settings_observer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 typedef testing::Test ContentSettingsObserverTest;
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 EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
23 WebSecurityOrigin::create(chrome_ui_url),
24 GURL()));
25
26 GURL chrome_dev_tools_url =
27 GURL(std::string(chrome::kChromeDevToolsScheme).append(end_url));
28 EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
29 WebSecurityOrigin::create(chrome_dev_tools_url),
30 GURL()));
31
32 GURL extension_url =
33 GURL(std::string(chrome::kExtensionScheme).append(end_url));
34 EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
35 WebSecurityOrigin::create(extension_url),
36 GURL()));
37
38 GURL chrome_internal_url =
39 GURL(std::string(chrome::kChromeInternalScheme).append(end_url));
40 EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
41 WebSecurityOrigin::create(chrome_internal_url),
42 GURL()));
43
44 GURL file_url("file:///dir/");
45 EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
46 WebSecurityOrigin::create(file_url),
47 GURL("file:///dir/")));
48 EXPECT_FALSE(ContentSettingsObserver::IsWhitelistedForContentSettings(
49 WebSecurityOrigin::create(file_url),
50 GURL("file:///dir/file")));
51
52 GURL ftp_url("ftp:///dir/");
53 EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
54 WebSecurityOrigin::create(ftp_url),
55 GURL("ftp:///dir/")));
56 EXPECT_FALSE(ContentSettingsObserver::IsWhitelistedForContentSettings(
57 WebSecurityOrigin::create(ftp_url),
58 GURL("ftp:///dir/file")));
59
60 GURL http_url =
61 GURL("http://server.com/path");
62 EXPECT_FALSE(ContentSettingsObserver::IsWhitelistedForContentSettings(
63 WebSecurityOrigin::create(http_url),
64 GURL()));
65 }
OLDNEW
« no previous file with comments | « chrome/renderer/content_settings_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698