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

Unified Diff: chrome/browser/extensions/extension_browsertests_misc.cc

Issue 2808051: Refactored extension privilege enumeration and implemented URLPattern compari... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months 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 | « no previous file | chrome/browser/extensions/extension_install_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_browsertests_misc.cc
===================================================================
--- chrome/browser/extensions/extension_browsertests_misc.cc (revision 54542)
+++ chrome/browser/extensions/extension_browsertests_misc.cc (working copy)
@@ -7,6 +7,7 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/extensions/autoupdate_interceptor.h"
+#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_error_reporter.h"
#include "chrome/browser/extensions/extension_host.h"
@@ -26,6 +27,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/ui_test_utils.h"
+#include "net/base/mock_host_resolver.h"
#include "net/base/net_util.h"
#include "net/test/test_server.h"
@@ -174,6 +176,32 @@
}
#endif // defined(TOOLKIT_VIEWS)
+// Tests that extension resources can be loaded from origins which the
+// extension specifies in permissions but not from others.
+IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, OriginPrivileges) {
+ host_resolver()->AddRule("*", "127.0.0.1");
+ ASSERT_TRUE(StartHTTPServer());
+ ASSERT_TRUE(LoadExtension(test_data_dir_
+ .AppendASCII("origin_privileges").AppendASCII("extension")));
+
+ ui_test_utils::NavigateToURL(browser(),
+ GURL("http://a.com:1337/files/extensions/origin_privileges/index.html"));
+ std::string result;
+ ui_test_utils::ExecuteJavaScriptAndExtractString(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(document.title)",
+ &result);
+ EXPECT_EQ(result, "Loaded");
+
+ ui_test_utils::NavigateToURL(browser(),
+ GURL("http://b.com:1337/files/extensions/origin_privileges/index.html"));
+ ui_test_utils::ExecuteJavaScriptAndExtractString(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"window.domAutomationController.send(document.title)",
+ &result);
+ EXPECT_EQ(result, "Image failed to load");
+}
+
// Tests that we can load extension pages into the tab area and they can call
// extension APIs.
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TabContents) {
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_install_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698