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

Side by Side Diff: chrome/browser/plugins/flash_permission_browsertest.cc

Issue 2622643004: Revert of [HBD] Intercept Flash navigations in popup windows. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/ptr_util.h"
8 #include "base/path_service.h" 7 #include "base/path_service.h"
9 #include "chrome/browser/permissions/permissions_browsertest.h" 8 #include "chrome/browser/permissions/permissions_browsertest.h"
10 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" 9 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h"
11 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
12 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
13 #include "components/variations/variations_switches.h" 12 #include "components/variations/variations_switches.h"
14 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
16 #include "content/public/test/browser_test_utils.h" 15 #include "content/public/test/browser_test_utils.h"
17 #include "content/public/test/ppapi_test_utils.h" 16 #include "content/public/test/ppapi_test_utils.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 76 }
78 77
79 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfBlocked) { 78 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfBlocked) {
80 CommonFailsIfBlocked(); 79 CommonFailsIfBlocked();
81 } 80 }
82 81
83 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) { 82 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) {
84 CommonSucceedsIfAllowed(); 83 CommonSucceedsIfAllowed();
85 } 84 }
86 85
87 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, SucceedsInPopupWindow) {
88 // Spawn the same page in a popup window and wait for it to finish loading.
89 content::WebContents* original_contents = GetWebContents();
90 ASSERT_TRUE(RunScriptReturnBool("spawnPopupAndAwaitLoad();"));
91
92 // Assert that the popup's WebContents is now the active one.
93 ASSERT_NE(original_contents, GetWebContents());
94
95 PermissionRequestManager* manager = PermissionRequestManager::FromWebContents(
96 GetWebContents());
97 auto popup_prompt_factory =
98 base::MakeUnique<MockPermissionPromptFactory>(manager);
99 manager->DisplayPendingRequests();
100
101 EXPECT_EQ(0, popup_prompt_factory->total_request_count());
102 popup_prompt_factory->set_response_type(PermissionRequestManager::ACCEPT_ALL);
103 // FlashPermissionContext::UpdateTabContext will reload the page, we'll have
104 // to wait until it is ready.
105 PageReloadWaiter reload_waiter(GetWebContents());
106 EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
107 EXPECT_TRUE(reload_waiter.Wait());
108
109 EXPECT_TRUE(FeatureUsageSucceeds());
110 EXPECT_EQ(1, popup_prompt_factory->total_request_count());
111
112 // Shut down the popup window tab, as the normal test teardown assumes there
113 // is only one test tab.
114 popup_prompt_factory.reset();
115 GetWebContents()->Close();
116 }
117
118 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) { 86 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) {
119 EXPECT_EQ(0, prompt_factory()->total_request_count()); 87 EXPECT_EQ(0, prompt_factory()->total_request_count());
120 prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL); 88 prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL);
121 EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();")); 89 EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();"));
122 90
123 EXPECT_TRUE(FeatureUsageSucceeds()); 91 EXPECT_TRUE(FeatureUsageSucceeds());
124 EXPECT_EQ(1, prompt_factory()->total_request_count()); 92 EXPECT_EQ(1, prompt_factory()->total_request_count());
125 } 93 }
126 94
127 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, 95 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url())); 131 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url()));
164 CommonFailsIfBlocked(); 132 CommonFailsIfBlocked();
165 EXPECT_EQ(1, prompt_factory()->total_request_count()); 133 EXPECT_EQ(1, prompt_factory()->total_request_count());
166 134
167 // Navigate to a second URL to verify it's blocked on all file: URLs. 135 // Navigate to a second URL to verify it's blocked on all file: URLs.
168 ui_test_utils::NavigateToURL( 136 ui_test_utils::NavigateToURL(
169 browser(), 137 browser(),
170 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html")); 138 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html"));
171 EXPECT_FALSE(FeatureUsageSucceeds()); 139 EXPECT_FALSE(FeatureUsageSucceeds());
172 } 140 }
OLDNEW
« 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