OLD | NEW |
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 18 matching lines...) Expand all Loading... |
40 }; | 42 }; |
41 | 43 |
42 } // namespace | 44 } // namespace |
43 | 45 |
44 class FlashPermissionBrowserTest : public PermissionsBrowserTest { | 46 class FlashPermissionBrowserTest : public PermissionsBrowserTest { |
45 public: | 47 public: |
46 FlashPermissionBrowserTest() | 48 FlashPermissionBrowserTest() |
47 : PermissionsBrowserTest("/permissions/flash.html") {} | 49 : PermissionsBrowserTest("/permissions/flash.html") {} |
48 ~FlashPermissionBrowserTest() override {} | 50 ~FlashPermissionBrowserTest() override {} |
49 | 51 |
| 52 void SetUpOnMainThread() override { |
| 53 PermissionsBrowserTest::SetUpOnMainThread(); |
| 54 scoped_feature_list_.InitFromCommandLine("PreferHtmlOverPlugins<Study1", |
| 55 std::string()); |
| 56 } |
| 57 |
50 // PermissionsBrowserTest | 58 // PermissionsBrowserTest |
51 void SetUpCommandLine(base::CommandLine* command_line) override { | 59 void SetUpCommandLine(base::CommandLine* command_line) override { |
52 PermissionsBrowserTest::SetUpCommandLine(command_line); | 60 PermissionsBrowserTest::SetUpCommandLine(command_line); |
53 | 61 |
54 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line)); | 62 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line)); |
55 | 63 |
56 // Set a high engagement threshhold so it doesn't interfere with testing the | 64 // Set a high engagement threshhold so it doesn't interfere with testing the |
57 // permission. | 65 // permission. |
58 command_line->AppendSwitchASCII(switches::kEnableFeatures, | |
59 "PreferHtmlOverPlugins<Study1"); | |
60 command_line->AppendSwitchASCII(switches::kForceFieldTrials, | 66 command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
61 "Study1/Enabled/"); | 67 "Study1/Enabled/"); |
62 command_line->AppendSwitchASCII( | 68 command_line->AppendSwitchASCII( |
63 variations::switches::kForceFieldTrialParams, | 69 variations::switches::kForceFieldTrialParams, |
64 "Study1.Enabled:engagement_threshold_for_flash/100"); | 70 "Study1.Enabled:engagement_threshold_for_flash/100"); |
65 } | 71 } |
66 | 72 |
67 void TriggerPrompt() override { | 73 void TriggerPrompt() override { |
68 if (prompt_factory()->response_type() == | 74 if (prompt_factory()->response_type() == |
69 PermissionRequestManager::ACCEPT_ALL) { | 75 PermissionRequestManager::ACCEPT_ALL) { |
(...skipping 18 matching lines...) Expand all Loading... |
88 // and tests should always wait for that reload to finish before calling | 94 // and tests should always wait for that reload to finish before calling |
89 // this method. | 95 // this method. |
90 ui_test_utils::NavigateToURL(browser(), | 96 ui_test_utils::NavigateToURL(browser(), |
91 GetWebContents()->GetLastCommittedURL()); | 97 GetWebContents()->GetLastCommittedURL()); |
92 // If either flash with or without fallback content runs successfully it | 98 // If either flash with or without fallback content runs successfully it |
93 // indicates the feature is at least partly working, which could imply a | 99 // indicates the feature is at least partly working, which could imply a |
94 // faulty permission. | 100 // faulty permission. |
95 return RunScriptReturnBool("flashIsEnabled();") || | 101 return RunScriptReturnBool("flashIsEnabled();") || |
96 RunScriptReturnBool("flashIsEnabledForPluginWithoutFallback();"); | 102 RunScriptReturnBool("flashIsEnabledForPluginWithoutFallback();"); |
97 } | 103 } |
| 104 |
| 105 private: |
| 106 base::test::ScopedFeatureList scoped_feature_list_; |
98 }; | 107 }; |
99 | 108 |
100 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, | 109 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, |
101 CommonFailsBeforeRequesting) { | 110 CommonFailsBeforeRequesting) { |
102 CommonFailsBeforeRequesting(); | 111 CommonFailsBeforeRequesting(); |
103 } | 112 } |
104 | 113 |
105 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfDismissed) { | 114 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfDismissed) { |
106 CommonFailsIfDismissed(); | 115 CommonFailsIfDismissed(); |
107 } | 116 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url())); | 224 browser(), GURL("file://" + test_path.AsUTF8Unsafe() + test_url())); |
216 CommonFailsIfBlocked(); | 225 CommonFailsIfBlocked(); |
217 EXPECT_EQ(1, prompt_factory()->TotalRequestCount()); | 226 EXPECT_EQ(1, prompt_factory()->TotalRequestCount()); |
218 | 227 |
219 // Navigate to a second URL to verify it's blocked on all file: URLs. | 228 // Navigate to a second URL to verify it's blocked on all file: URLs. |
220 ui_test_utils::NavigateToURL( | 229 ui_test_utils::NavigateToURL( |
221 browser(), | 230 browser(), |
222 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html")); | 231 GURL("file://" + test_path.AsUTF8Unsafe() + "/permissions/flash2.html")); |
223 EXPECT_FALSE(FeatureUsageSucceeds()); | 232 EXPECT_FALSE(FeatureUsageSucceeds()); |
224 } | 233 } |
OLD | NEW |