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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/content_settings_observer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/content_settings_observer_unittest.cc
diff --git a/chrome/renderer/content_settings_observer_unittest.cc b/chrome/renderer/content_settings_observer_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..db587ffc888d61351782b77e90d1b65be62286ef
--- /dev/null
+++ b/chrome/renderer/content_settings_observer_unittest.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/content_settings_observer.h"
+
+#include "chrome/common/url_constants.h"
+#include "content/public/common/url_constants.h"
+#include "googleurl/src/gurl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
+
+using WebKit::WebSecurityOrigin;
+
+typedef testing::Test ContentSettingsObserverTest;
+
+TEST_F(ContentSettingsObserverTest, WhitelistedSchemes) {
+ std::string end_url = ":something";
+
+ GURL chrome_ui_url =
+ GURL(std::string(chrome::kChromeUIScheme).append(end_url));
+ EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(chrome_ui_url),
+ GURL()));
+
+ GURL chrome_dev_tools_url =
+ GURL(std::string(chrome::kChromeDevToolsScheme).append(end_url));
+ EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(chrome_dev_tools_url),
+ GURL()));
+
+ GURL extension_url =
+ GURL(std::string(chrome::kExtensionScheme).append(end_url));
+ EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(extension_url),
+ GURL()));
+
+ GURL chrome_internal_url =
+ GURL(std::string(chrome::kChromeInternalScheme).append(end_url));
+ EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(chrome_internal_url),
+ GURL()));
+
+ GURL file_url("file:///dir/");
+ EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(file_url),
+ GURL("file:///dir/")));
+ EXPECT_FALSE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(file_url),
+ GURL("file:///dir/file")));
+
+ GURL ftp_url("ftp:///dir/");
+ EXPECT_TRUE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(ftp_url),
+ GURL("ftp:///dir/")));
+ EXPECT_FALSE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(ftp_url),
+ GURL("ftp:///dir/file")));
+
+ GURL http_url =
+ GURL("http://server.com/path");
+ EXPECT_FALSE(ContentSettingsObserver::IsWhitelistedForContentSettings(
+ WebSecurityOrigin::create(http_url),
+ GURL()));
+}
« 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