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

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

Issue 2590363003: [HBD] Intercept Flash navigations in popup windows. (Closed)
Patch Set: Ad dtest 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 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/path_service.h" 7 #include "base/path_service.h"
8 #include "chrome/browser/permissions/permissions_browsertest.h" 8 #include "chrome/browser/permissions/permissions_browsertest.h"
9 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" 9 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfBlocked) { 102 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfBlocked) {
103 CommonFailsIfBlocked(); 103 CommonFailsIfBlocked();
104 } 104 }
105 105
106 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) { 106 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) {
107 CommonSucceedsIfAllowed(); 107 CommonSucceedsIfAllowed();
108 } 108 }
109 109
110 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, SucceedsInPopupWindow) {
111 // Spawn the same page in a popup window and wait for it to finish loading.
112 content::WebContents* original_contents = GetWebContents();
113 ASSERT_TRUE(RunScriptReturnBool("spawnPopupAndAwaitLoad();"));
114
115 // Assert that the popup's WebContents is now the active one.
116 ASSERT_NE(original_contents, GetWebContents());
117
118 PermissionRequestManager* manager = PermissionRequestManager::FromWebContents(
119 GetWebContents());
120 MockPermissionPromptFactory popup_prompt_factory(manager);
121 manager->DisplayPendingRequests();
122
123 EXPECT_EQ(0, popup_prompt_factory.total_request_count());
124 popup_prompt_factory.set_response_type(PermissionRequestManager::ACCEPT_ALL);
125 // FlashPermissionContext::UpdateTabContext will reload the page, we'll have
126 // to wait until it is ready.
127 PageReloadWaiter reload_waiter(GetWebContents());
128 EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
129 EXPECT_TRUE(reload_waiter.Wait());
130
131 EXPECT_TRUE(FeatureUsageSucceeds());
132 EXPECT_EQ(1, popup_prompt_factory.total_request_count());
133 }
134
110 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) { 135 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) {
111 EXPECT_EQ(0, prompt_factory()->total_request_count()); 136 EXPECT_EQ(0, prompt_factory()->total_request_count());
112 prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL); 137 prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL);
113 // FlashPermissionContext::UpdateTabContext will reload the page, we'll have 138 // FlashPermissionContext::UpdateTabContext will reload the page, we'll have
114 // to wait until it is ready. 139 // to wait until it is ready.
115 PageReloadWaiter reload_waiter(GetWebContents()); 140 PageReloadWaiter reload_waiter(GetWebContents());
116 EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();")); 141 EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();"));
117 EXPECT_TRUE(reload_waiter.Wait()); 142 EXPECT_TRUE(reload_waiter.Wait());
118 143
119 EXPECT_TRUE(FeatureUsageSucceeds()); 144 EXPECT_TRUE(FeatureUsageSucceeds());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url())); 184 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url()));
160 CommonFailsIfBlocked(); 185 CommonFailsIfBlocked();
161 EXPECT_EQ(1, prompt_factory()->total_request_count()); 186 EXPECT_EQ(1, prompt_factory()->total_request_count());
162 187
163 // Navigate to a second URL to verify it's blocked on all file: URLs. 188 // Navigate to a second URL to verify it's blocked on all file: URLs.
164 ui_test_utils::NavigateToURL( 189 ui_test_utils::NavigateToURL(
165 browser(), 190 browser(),
166 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html")); 191 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html"));
167 EXPECT_FALSE(FeatureUsageSucceeds()); 192 EXPECT_FALSE(FeatureUsageSucceeds());
168 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698