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

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: sync Created 8 years, 3 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 | « chrome/common/content_settings_types.h ('k') | chrome/test/ppapi/ppapi_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ppapi/ppapi_browsertest.cc
diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc
index 977359cbc96468cc7329ebbb337ef19fc3f73961..e7e7f9c9eb63d688dee342e6a713261297967c69 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"
@@ -136,6 +138,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.
+ InfoBarObserver observer;
+ observer.ExpectInfoBarAndAccept(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.
+ InfoBarObserver observer;
+ observer.ExpectInfoBarAndAccept(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.
+ 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.
+ InfoBarObserver observer;
+
+ RunTest("Broker_ConnectPermissionGranted");
+}
+
TEST_PPAPI_IN_PROCESS(Core)
TEST_PPAPI_OUT_OF_PROCESS(Core)
TEST_PPAPI_NACL_VIA_HTTP(Core)
« no previous file with comments | « chrome/common/content_settings_types.h ('k') | chrome/test/ppapi/ppapi_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698