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

Side by Side 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 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"
7 #include "base/path_service.h" 8 #include "base/path_service.h"
8 #include "chrome/browser/permissions/permissions_browsertest.h" 9 #include "chrome/browser/permissions/permissions_browsertest.h"
9 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" 10 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h"
10 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
11 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
12 #include "components/variations/variations_switches.h" 13 #include "components/variations/variations_switches.h"
13 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
15 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
16 #include "content/public/test/ppapi_test_utils.h" 17 #include "content/public/test/ppapi_test_utils.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 101 }
101 102
102 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfBlocked) { 103 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfBlocked) {
103 CommonFailsIfBlocked(); 104 CommonFailsIfBlocked();
104 } 105 }
105 106
106 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) { 107 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) {
107 CommonSucceedsIfAllowed(); 108 CommonSucceedsIfAllowed();
108 } 109 }
109 110
111 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, SucceedsInPopupWindow) {
112 // Spawn the same page in a popup window and wait for it to finish loading.
113 content::WebContents* original_contents = GetWebContents();
114 ASSERT_TRUE(RunScriptReturnBool("spawnPopupAndAwaitLoad();"));
115
116 // Assert that the popup's WebContents is now the active one.
117 ASSERT_NE(original_contents, GetWebContents());
118
119 PermissionRequestManager* manager = PermissionRequestManager::FromWebContents(
120 GetWebContents());
121 auto popup_prompt_factory =
122 base::MakeUnique<MockPermissionPromptFactory>(manager);
123 manager->DisplayPendingRequests();
124
125 EXPECT_EQ(0, popup_prompt_factory->total_request_count());
126 popup_prompt_factory->set_response_type(PermissionRequestManager::ACCEPT_ALL);
127 // FlashPermissionContext::UpdateTabContext will reload the page, we'll have
128 // to wait until it is ready.
129 PageReloadWaiter reload_waiter(GetWebContents());
130 EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
131 EXPECT_TRUE(reload_waiter.Wait());
132
133 EXPECT_TRUE(FeatureUsageSucceeds());
134 EXPECT_EQ(1, popup_prompt_factory->total_request_count());
135
136 // Shut down the popup window tab, as the normal test teardown assumes there
137 // is only one test tab.
138 popup_prompt_factory.reset();
139 GetWebContents()->Close();
140 }
141
110 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) { 142 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) {
111 EXPECT_EQ(0, prompt_factory()->total_request_count()); 143 EXPECT_EQ(0, prompt_factory()->total_request_count());
112 prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL); 144 prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL);
113 // FlashPermissionContext::UpdateTabContext will reload the page, we'll have 145 // FlashPermissionContext::UpdateTabContext will reload the page, we'll have
114 // to wait until it is ready. 146 // to wait until it is ready.
115 PageReloadWaiter reload_waiter(GetWebContents()); 147 PageReloadWaiter reload_waiter(GetWebContents());
116 EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();")); 148 EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();"));
117 EXPECT_TRUE(reload_waiter.Wait()); 149 EXPECT_TRUE(reload_waiter.Wait());
118 150
119 EXPECT_TRUE(FeatureUsageSucceeds()); 151 EXPECT_TRUE(FeatureUsageSucceeds());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url())); 191 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url()));
160 CommonFailsIfBlocked(); 192 CommonFailsIfBlocked();
161 EXPECT_EQ(1, prompt_factory()->total_request_count()); 193 EXPECT_EQ(1, prompt_factory()->total_request_count());
162 194
163 // Navigate to a second URL to verify it's blocked on all file: URLs. 195 // Navigate to a second URL to verify it's blocked on all file: URLs.
164 ui_test_utils::NavigateToURL( 196 ui_test_utils::NavigateToURL(
165 browser(), 197 browser(),
166 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html")); 198 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html"));
167 EXPECT_FALSE(FeatureUsageSucceeds()); 199 EXPECT_FALSE(FeatureUsageSucceeds());
168 } 200 }
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