Chromium Code Reviews| Index: chrome/browser/plugins/flash_permission_browsertest.cc |
| diff --git a/chrome/browser/plugins/flash_permission_browsertest.cc b/chrome/browser/plugins/flash_permission_browsertest.cc |
| index cbcd035629b95e16c8c936642e109becf37a428d..609e6df47ae759cb6ff54a7bd1b5edc113460b21 100644 |
| --- a/chrome/browser/plugins/flash_permission_browsertest.cc |
| +++ b/chrome/browser/plugins/flash_permission_browsertest.cc |
| @@ -2,14 +2,17 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "base/test/scoped_feature_list.h" |
| -#include "chrome/browser/engagement/site_engagement_score.h" |
| +#include "base/base_switches.h" |
| +#include "base/command_line.h" |
| #include "chrome/browser/permissions/permissions_browsertest.h" |
| #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h" |
| -#include "chrome/common/chrome_features.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| #include "content/public/browser/web_contents.h" |
| +#include "content/public/common/content_switches.h" |
| +#include "content/public/test/browser_test_utils.h" |
| #include "content/public/test/ppapi_test_utils.h" |
| +#include "third_party/WebKit/public/web/WebInputEvent.h" |
| class FlashPermissionBrowserTest : public PermissionsBrowserTest { |
| public: |
| @@ -20,27 +23,34 @@ class FlashPermissionBrowserTest : public PermissionsBrowserTest { |
| // PermissionsBrowserTest |
| void SetUpCommandLine(base::CommandLine* command_line) override { |
| PermissionsBrowserTest::SetUpCommandLine(command_line); |
| + |
| ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line)); |
| - feature_list_.InitAndEnableFeature(features::kPreferHtmlOverPlugins); |
| + // Set a high engagement threshhold so it doesn't interfere with testing the |
| + // permission. |
| + command_line->AppendSwitchASCII( |
| + switches::kEnableFeatures, "PreferHtmlOverPlugins<Study1"); |
| + command_line->AppendSwitchASCII( |
| + switches::kForceFieldTrials, "Study1/Enabled/"); |
| + command_line->AppendSwitchASCII( |
| + switches::kForceFieldTrialParams, |
| + "Study1.Enabled:engagement_threshold_for_flash/100"); |
| } |
| - void SetUpOnMainThread() override { |
| - SiteEngagementScore::SetParamValuesForTesting(); |
| - |
| - PermissionsBrowserTest::SetUpOnMainThread(); |
| - } |
| void TriggerPrompt() override { |
| EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();")); |
| } |
| + |
| bool FeatureUsageSucceeds() override { |
| // Flash won't be enabled until the page is refreshed. |
| ui_test_utils::NavigateToURL(browser(), |
| GetWebContents()->GetLastCommittedURL()); |
| - return RunScriptReturnBool("flashIsEnabled();"); |
| + // If either flash with or without fallback content runs successfully it |
| + // indicates the feature is at least partly working, which could imply a |
| + // faulty permission. |
| + return RunScriptReturnBool("flashIsEnabled();") || |
| + RunScriptReturnBool("flashIsEnabledForPluginWithoutFallack();"); |
|
Bernhard Bauer
2016/10/04 09:21:00
Why not combine these expressions in Javascript?
raymes
2016/10/04 23:12:19
It's just a bit simpler to do it here, otherwise c
|
| } |
| - |
| - base::test::ScopedFeatureList feature_list_; |
| }; |
| IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, |
| @@ -65,6 +75,20 @@ IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) { |
| prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();")); |
| + EXPECT_TRUE(FeatureUsageSucceeds()); |
| EXPECT_EQ(1, prompt_factory()->total_request_count()); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, |
| + TriggerPromptViaPluginPlaceholder) { |
| + EXPECT_EQ(0, prompt_factory()->total_request_count()); |
| + EXPECT_FALSE(FeatureUsageSucceeds()); |
| + prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL); |
| + // We need to simulate a mouse click to trigger the placeholder to prompt. |
| + content::SimulateMouseClickAt(GetWebContents(), 0 /* modifiers */, |
| + blink::WebMouseEvent::Button::Left, |
| + gfx::Point(50, 50)); |
| + |
| EXPECT_TRUE(FeatureUsageSucceeds()); |
| + EXPECT_EQ(1, prompt_factory()->total_request_count()); |
| } |