| 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..ce051cdf285bc0be8f97cf26ee570925a301ac32 100644
|
| --- a/chrome/browser/plugins/flash_permission_browsertest.cc
|
| +++ b/chrome/browser/plugins/flash_permission_browsertest.cc
|
| @@ -2,14 +2,18 @@
|
| // 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"
|
| +#include "url/gurl.h"
|
|
|
| class FlashPermissionBrowserTest : public PermissionsBrowserTest {
|
| public:
|
| @@ -20,27 +24,43 @@ 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();"));
|
| + if (prompt_factory()->response_type() ==
|
| + PermissionRequestManager::ACCEPT_ALL) {
|
| + // If the prompt will be allowed, we need to wait for the page to refresh.
|
| + content::TestNavigationManager observer(GetWebContents(), GetTestUrl());
|
| + EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
|
| + observer.WaitForNavigationFinished();
|
| + } else {
|
| + EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
|
| + }
|
| }
|
| +
|
| bool FeatureUsageSucceeds() override {
|
| - // Flash won't be enabled until the page is refreshed.
|
| + // Wait until the page is refreshed before testing whether flash is enabled
|
| + // or disabled.
|
| 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("flashIsEnabledForPluginWithoutFallback();");
|
| }
|
| -
|
| - base::test::ScopedFeatureList feature_list_;
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest,
|
| @@ -65,6 +85,22 @@ 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::TestNavigationManager observer(GetWebContents(), GetTestUrl());
|
| + content::SimulateMouseClickAt(GetWebContents(), 0 /* modifiers */,
|
| + blink::WebMouseEvent::Button::Left,
|
| + gfx::Point(50, 50));
|
| + observer.WaitForNavigationFinished();
|
| +
|
| EXPECT_TRUE(FeatureUsageSucceeds());
|
| + EXPECT_EQ(1, prompt_factory()->total_request_count());
|
| }
|
|
|