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

Unified Diff: chrome/test/ppapi/ppapi_browsertest.cc

Issue 10826164: Add infobar for PPAPI broker usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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
Index: chrome/test/ppapi/ppapi_browsertest.cc
diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc
index dcf5b1275ef49506049318faaca0f2524fe529e0..158b0b98a2763dbf0d3e2316e37916a917126bd6 100644
--- a/chrome/test/ppapi/ppapi_browsertest.cc
+++ b/chrome/test/ppapi/ppapi_browsertest.cc
@@ -6,6 +6,8 @@
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
+#include "chrome/browser/content_settings/host_content_settings_map.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_tabstrip.h"
@@ -15,6 +17,9 @@
#include "content/public/test/test_renderer_host.h"
using content::RenderViewHost;
+using ::testing::Return;
+using ::testing::StrictMock;
+using ::testing::_;
// This macro finesses macro expansion to do what we want.
#define STRIP_PREFIXES(test_name) StripPrefixes(#test_name)
@@ -122,6 +127,7 @@ using content::RenderViewHost;
#endif
markusheintz_ 2012/08/13 06:09:06 nit: pls remove empty line.
Bernhard Bauer 2012/08/13 10:51:46 Done.
+
//
// Interface tests.
//
@@ -135,6 +141,60 @@ TEST_PPAPI_IN_PROCESS(Broker)
// Flaky, http://crbug.com/111355
TEST_PPAPI_OUT_OF_PROCESS(DISABLED_Broker)
+IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Accept) {
+ // Accepting the infobar should grant permission to access the PPAPI broker.
+ StrictMock<InfoBarObserver> observer;
+ EXPECT_CALL(observer, ShouldAcceptInfoBar(_)).WillOnce(Return(true));
+
+ GURL url = GetTestFileUrl("Broker_ConnectPermissionGranted");
+ RunTestURL(url);
+
+ // It should also set a content settings exception for the site.
+ HostContentSettingsMap* content_settings =
+ browser()->profile()->GetHostContentSettingsMap();
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
+ content_settings->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string()));
+}
+
+IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Deny) {
+ // Canceling the infobar should deny permission to access the PPAPI broker.
+ StrictMock<InfoBarObserver> observer;
+ EXPECT_CALL(observer, ShouldAcceptInfoBar(_)).WillOnce(Return(false));
+
+ GURL url = GetTestFileUrl("Broker_ConnectPermissionDenied");
+ RunTestURL(url);
+
+ // It should *not* set a content settings exception for the site.
+ HostContentSettingsMap* content_settings =
+ browser()->profile()->GetHostContentSettingsMap();
+ EXPECT_EQ(CONTENT_SETTING_ASK,
+ content_settings->GetContentSetting(
+ url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string()));
+}
+
+IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Blocked) {
+ // Block access to the PPAPI broker.
+ browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_BLOCK);
+
+ // We shouldn't see an infobar.
+ StrictMock<InfoBarObserver> observer;
+
+ RunTest("Broker_ConnectPermissionDenied");
+}
+
+IN_PROC_BROWSER_TEST_F(PPAPIBrokerInfoBarTest, Allowed) {
+ // Always allow access to the PPAPI broker.
+ browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
+ CONTENT_SETTINGS_TYPE_PPAPI_BROKER, CONTENT_SETTING_ALLOW);
+
+ // We shouldn't see an infobar.
+ StrictMock<InfoBarObserver> observer;
+
+ RunTest("Broker_ConnectPermissionGranted");
+}
+
TEST_PPAPI_IN_PROCESS(Core)
TEST_PPAPI_OUT_OF_PROCESS(Core)
TEST_PPAPI_NACL_VIA_HTTP(Core)

Powered by Google App Engine
This is Rietveld 408576698