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

Unified Diff: chrome/browser/plugins/flash_permission_browsertest.cc

Issue 2391743005: Make the flash permission prompt work properly on file: URLs (Closed)
Patch Set: test prompt Created 4 years, 2 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/browser/plugins/flash_permission_browsertest.cc
diff --git a/chrome/browser/plugins/flash_permission_browsertest.cc b/chrome/browser/plugins/flash_permission_browsertest.cc
index ce051cdf285bc0be8f97cf26ee570925a301ac32..565fb099b572c24c4371ea6bbeea6c92614d5f06 100644
--- a/chrome/browser/plugins/flash_permission_browsertest.cc
+++ b/chrome/browser/plugins/flash_permission_browsertest.cc
@@ -4,8 +4,10 @@
#include "base/base_switches.h"
#include "base/command_line.h"
+#include "base/path_service.h"
#include "chrome/browser/permissions/permissions_browsertest.h"
#include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
@@ -42,7 +44,8 @@ class FlashPermissionBrowserTest : public PermissionsBrowserTest {
if (prompt_factory()->response_type() ==
PermissionRequestManager::ACCEPT_ALL) {
// If the prompt will be allowed, we need to wait for the page to refresh.
- content::TestNavigationManager observer(GetWebContents(), GetTestUrl());
+ content::TestNavigationManager observer(
+ GetWebContents(), GetWebContents()->GetLastCommittedURL());
EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
observer.WaitForNavigationFinished();
} else {
@@ -95,7 +98,8 @@ IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest,
EXPECT_FALSE(FeatureUsageSucceeds());
prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL);
// We need to simulate a mouse click to trigger the placeholder to prompt.
- content::TestNavigationManager observer(GetWebContents(), GetTestUrl());
+ content::TestNavigationManager observer(
+ GetWebContents(), GetWebContents()->GetLastCommittedURL());
content::SimulateMouseClickAt(GetWebContents(), 0 /* modifiers */,
blink::WebMouseEvent::Button::Left,
gfx::Point(50, 50));
@@ -104,3 +108,33 @@ IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest,
EXPECT_TRUE(FeatureUsageSucceeds());
EXPECT_EQ(1, prompt_factory()->total_request_count());
}
+
+IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, AllowFileURL) {
+ base::FilePath test_path;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_path);
+ ui_test_utils::NavigateToURL(
+ browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url()));
+ CommonSucceedsIfAllowed();
+ EXPECT_EQ(1, prompt_factory()->total_request_count());
+
+ // Navigate to a second URL to verify it's allowed on all file: URLs.
+ ui_test_utils::NavigateToURL(
+ browser(),
+ GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html"));
+ EXPECT_TRUE(FeatureUsageSucceeds());
+}
+
+IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, BlockFileURL) {
+ base::FilePath test_path;
+ PathService::Get(chrome::DIR_TEST_DATA, &test_path);
+ ui_test_utils::NavigateToURL(
+ browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url()));
+ CommonFailsIfBlocked();
+ EXPECT_EQ(1, prompt_factory()->total_request_count());
+
+ // Navigate to a second URL to verify it's blocked on all file: URLs.
+ ui_test_utils::NavigateToURL(
+ browser(),
+ GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html"));
+ EXPECT_FALSE(FeatureUsageSucceeds());
+}
« no previous file with comments | « chrome/browser/permissions/permissions_browsertest.cc ('k') | chrome/browser/plugins/flash_permission_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698