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

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

Issue 8659009: Consider the origin when computing extension permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 | « no previous file | chrome/common/extensions/extension_set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_info_map_unittest.cc
===================================================================
--- chrome/browser/extensions/extension_info_map_unittest.cc (revision 112565)
+++ chrome/browser/extensions/extension_info_map_unittest.cc (working copy)
@@ -10,8 +10,12 @@
#include "chrome/common/extensions/extension.h"
#include "content/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
using content::BrowserThread;
+using WebKit::WebSecurityOrigin;
+using WebKit::WebString;
namespace keys = extension_manifest_keys;
@@ -130,6 +134,8 @@
"tabs_extension.json"));
GURL app_url("http://www.google.com/mail/foo.html");
+ WebSecurityOrigin app_origin = WebSecurityOrigin::create(
+ GURL("http://www.google.com/mail/foo.html"));
ASSERT_TRUE(app->is_app());
ASSERT_TRUE(app->web_extent().MatchesURL(app_url));
@@ -139,25 +145,35 @@
// The app should have the notifications permission, either from a
// chrome-extension URL or from its web extent.
const Extension* match = info_map->extensions().GetByURL(
- app->GetResourceURL("a.html"));
+ ExtensionURLInfo(app_origin, app->GetResourceURL("a.html")));
EXPECT_TRUE(match &&
match->HasAPIPermission(ExtensionAPIPermission::kNotification));
- match = info_map->extensions().GetByURL(app_url);
+ match = info_map->extensions().GetByURL(
+ ExtensionURLInfo(app_origin, app_url));
EXPECT_TRUE(match &&
match->HasAPIPermission(ExtensionAPIPermission::kNotification));
EXPECT_FALSE(match &&
match->HasAPIPermission(ExtensionAPIPermission::kTab));
// The extension should have the tabs permission.
- match = info_map->extensions().GetByURL(extension->GetResourceURL("a.html"));
+ match = info_map->extensions().GetByURL(
+ ExtensionURLInfo(app_origin, extension->GetResourceURL("a.html")));
EXPECT_TRUE(match &&
match->HasAPIPermission(ExtensionAPIPermission::kTab));
EXPECT_FALSE(match &&
match->HasAPIPermission(ExtensionAPIPermission::kNotification));
// Random URL should not have any permissions.
- match = info_map->extensions().GetByURL(GURL("http://evil.com/a.html"));
+ GURL evil_url("http://evil.com/a.html");
+ match = info_map->extensions().GetByURL(
+ ExtensionURLInfo(WebSecurityOrigin::create(evil_url), evil_url));
EXPECT_FALSE(match);
+
+ // Sandboxed origins should not have any permissions.
+ match = info_map->extensions().GetByURL(ExtensionURLInfo(
+ WebSecurityOrigin::createFromString(WebString::fromUTF8("null")),
+ app_url));
+ EXPECT_FALSE(match);
}
} // namespace
« no previous file with comments | « no previous file | chrome/common/extensions/extension_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698