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

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

Issue 2590363003: [HBD] Intercept Flash navigations in popup windows. (Closed)
Patch Set: fix test Created 4 years 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/browser/plugins/flash_download_interception.cc ('k') | chrome/test/data/permissions/flash.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c1db46dd3fb8ae8cbf9d1f755597e931bf16e81f..57aea02a6014100a87d47b64ba7b20024ab7a6c3 100644
--- a/chrome/browser/plugins/flash_permission_browsertest.cc
+++ b/chrome/browser/plugins/flash_permission_browsertest.cc
@@ -4,6 +4,7 @@
#include "base/base_switches.h"
#include "base/command_line.h"
+#include "base/memory/ptr_util.h"
#include "base/path_service.h"
#include "chrome/browser/permissions/permissions_browsertest.h"
#include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h"
@@ -107,6 +108,37 @@ IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) {
CommonSucceedsIfAllowed();
}
+IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, SucceedsInPopupWindow) {
+ // Spawn the same page in a popup window and wait for it to finish loading.
+ content::WebContents* original_contents = GetWebContents();
+ ASSERT_TRUE(RunScriptReturnBool("spawnPopupAndAwaitLoad();"));
+
+ // Assert that the popup's WebContents is now the active one.
+ ASSERT_NE(original_contents, GetWebContents());
+
+ PermissionRequestManager* manager = PermissionRequestManager::FromWebContents(
+ GetWebContents());
+ auto popup_prompt_factory =
+ base::MakeUnique<MockPermissionPromptFactory>(manager);
+ manager->DisplayPendingRequests();
+
+ EXPECT_EQ(0, popup_prompt_factory->total_request_count());
+ popup_prompt_factory->set_response_type(PermissionRequestManager::ACCEPT_ALL);
+ // FlashPermissionContext::UpdateTabContext will reload the page, we'll have
+ // to wait until it is ready.
+ PageReloadWaiter reload_waiter(GetWebContents());
+ EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
+ EXPECT_TRUE(reload_waiter.Wait());
+
+ EXPECT_TRUE(FeatureUsageSucceeds());
+ EXPECT_EQ(1, popup_prompt_factory->total_request_count());
+
+ // Shut down the popup window tab, as the normal test teardown assumes there
+ // is only one test tab.
+ popup_prompt_factory.reset();
+ GetWebContents()->Close();
+}
+
IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) {
EXPECT_EQ(0, prompt_factory()->total_request_count());
prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL);
« no previous file with comments | « chrome/browser/plugins/flash_download_interception.cc ('k') | chrome/test/data/permissions/flash.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698