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

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

Issue 2910843002: [Cleanup] Move all browsertests to use ScopedFeatureList to modify features
Patch Set: rebase update Created 3 years, 6 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" 7 #include "base/memory/ptr_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/scoped_feature_list.h"
10 #include "chrome/browser/permissions/permissions_browsertest.h" 11 #include "chrome/browser/permissions/permissions_browsertest.h"
11 #include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h" 12 #include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h"
13 #include "chrome/common/chrome_features.h"
12 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
13 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
14 #include "components/variations/variations_switches.h" 16 #include "components/variations/variations_switches.h"
15 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
18 #include "content/public/test/browser_test_utils.h" 20 #include "content/public/test/browser_test_utils.h"
19 #include "content/public/test/ppapi_test_utils.h" 21 #include "content/public/test/ppapi_test_utils.h"
20 #include "third_party/WebKit/public/platform/WebInputEvent.h" 22 #include "third_party/WebKit/public/platform/WebInputEvent.h"
21 #include "url/gurl.h" 23 #include "url/gurl.h"
(...skipping 24 matching lines...) Expand all
46 FlashPermissionBrowserTest() 48 FlashPermissionBrowserTest()
47 : PermissionsBrowserTest("/permissions/flash.html") {} 49 : PermissionsBrowserTest("/permissions/flash.html") {}
48 ~FlashPermissionBrowserTest() override {} 50 ~FlashPermissionBrowserTest() override {}
49 51
50 // PermissionsBrowserTest 52 // PermissionsBrowserTest
51 void SetUpCommandLine(base::CommandLine* command_line) override { 53 void SetUpCommandLine(base::CommandLine* command_line) override {
52 PermissionsBrowserTest::SetUpCommandLine(command_line); 54 PermissionsBrowserTest::SetUpCommandLine(command_line);
53 55
54 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line)); 56 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line));
55 57
58 #if BUILDFLAG(ENABLE_PLUGINS)
Ilya Sherman 2017/06/12 21:50:29 Why did you add this #if wrapper?
chaopeng 2017/06/28 19:21:24 This feature only define when enable plugins. http
56 // Set a high engagement threshhold so it doesn't interfere with testing the 59 // Set a high engagement threshhold so it doesn't interfere with testing the
57 // permission. 60 // permission.
Ilya Sherman 2017/06/12 21:50:29 Why did you drop the setting of the param?
chaopeng 2017/06/28 19:21:24 Done.
58 command_line->AppendSwitchASCII(switches::kEnableFeatures, 61 scoped_feature_list_.InitAndEnableFeature(features::kPreferHtmlOverPlugins);
59 "PreferHtmlOverPlugins<Study1"); 62 #endif
60 command_line->AppendSwitchASCII(switches::kForceFieldTrials,
61 "Study1/Enabled/");
62 command_line->AppendSwitchASCII(
63 variations::switches::kForceFieldTrialParams,
64 "Study1.Enabled:engagement_threshold_for_flash/100");
65 } 63 }
66 64
67 void TriggerPrompt() override { 65 void TriggerPrompt() override {
68 if (prompt_factory()->response_type() == 66 if (prompt_factory()->response_type() ==
69 PermissionRequestManager::ACCEPT_ALL) { 67 PermissionRequestManager::ACCEPT_ALL) {
70 // If the prompt will be allowed, we need to wait for the page to refresh. 68 // If the prompt will be allowed, we need to wait for the page to refresh.
71 PageReloadWaiter reload_waiter(GetWebContents()); 69 PageReloadWaiter reload_waiter(GetWebContents());
72 EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();")); 70 EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
73 EXPECT_TRUE(reload_waiter.Wait()); 71 EXPECT_TRUE(reload_waiter.Wait());
74 } else { 72 } else {
(...skipping 13 matching lines...) Expand all
88 // and tests should always wait for that reload to finish before calling 86 // and tests should always wait for that reload to finish before calling
89 // this method. 87 // this method.
90 ui_test_utils::NavigateToURL(browser(), 88 ui_test_utils::NavigateToURL(browser(),
91 GetWebContents()->GetLastCommittedURL()); 89 GetWebContents()->GetLastCommittedURL());
92 // If either flash with or without fallback content runs successfully it 90 // If either flash with or without fallback content runs successfully it
93 // indicates the feature is at least partly working, which could imply a 91 // indicates the feature is at least partly working, which could imply a
94 // faulty permission. 92 // faulty permission.
95 return RunScriptReturnBool("flashIsEnabled();") || 93 return RunScriptReturnBool("flashIsEnabled();") ||
96 RunScriptReturnBool("flashIsEnabledForPluginWithoutFallback();"); 94 RunScriptReturnBool("flashIsEnabledForPluginWithoutFallback();");
97 } 95 }
96
97 private:
98 base::test::ScopedFeatureList scoped_feature_list_;
98 }; 99 };
99 100
100 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, 101 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest,
101 CommonFailsBeforeRequesting) { 102 CommonFailsBeforeRequesting) {
102 CommonFailsBeforeRequesting(); 103 CommonFailsBeforeRequesting();
103 } 104 }
104 105
105 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfDismissed) { 106 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfDismissed) {
106 CommonFailsIfDismissed(); 107 CommonFailsIfDismissed();
107 } 108 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url())); 216 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url()));
216 CommonFailsIfBlocked(); 217 CommonFailsIfBlocked();
217 EXPECT_EQ(1, prompt_factory()->TotalRequestCount()); 218 EXPECT_EQ(1, prompt_factory()->TotalRequestCount());
218 219
219 // Navigate to a second URL to verify it's blocked on all file: URLs. 220 // Navigate to a second URL to verify it's blocked on all file: URLs.
220 ui_test_utils::NavigateToURL( 221 ui_test_utils::NavigateToURL(
221 browser(), 222 browser(),
222 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html")); 223 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html"));
223 EXPECT_FALSE(FeatureUsageSucceeds()); 224 EXPECT_FALSE(FeatureUsageSucceeds());
224 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698