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

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

Issue 2361453004: Add browsertest for Flash permission prompt (Closed)
Patch Set: Test Created 4 years, 2 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
« no previous file with comments | « chrome/browser/permissions/permissions_browsertest.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/test/scoped_feature_list.h"
6 #include "chrome/browser/engagement/site_engagement_score.h"
7 #include "chrome/browser/permissions/permissions_browsertest.h"
8 #include "chrome/browser/ui/website_settings/mock_permission_prompt_factory.h"
9 #include "chrome/common/chrome_features.h"
10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/test/ppapi_test_utils.h"
13
14 class FlashPermissionBrowserTest : public PermissionsBrowserTest {
15 public:
16 FlashPermissionBrowserTest()
17 : PermissionsBrowserTest("/permissions/flash.html") {}
18 ~FlashPermissionBrowserTest() override {}
19
20 // PermissionsBrowserTest
21 void SetUpCommandLine(base::CommandLine* command_line) override {
22 PermissionsBrowserTest::SetUpCommandLine(command_line);
23 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line));
24
25 feature_list_.InitAndEnableFeature(features::kPreferHtmlOverPlugins);
26 }
27
28 void SetUpOnMainThread() override {
29 SiteEngagementScore::SetParamValuesForTesting();
30
31 PermissionsBrowserTest::SetUpOnMainThread();
32 }
33 void TriggerPrompt() override {
34 EXPECT_TRUE(RunScriptReturnBool("triggerPrompt();"));
35 }
36 bool FeatureUsageSucceeds() override {
37 // Flash won't be enabled until the page is refreshed.
38 ui_test_utils::NavigateToURL(browser(),
39 GetWebContents()->GetLastCommittedURL());
40 return RunScriptReturnBool("flashIsEnabled();");
41 }
42
43 base::test::ScopedFeatureList feature_list_;
44 };
45
46 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest,
47 CommonFailsBeforeRequesting) {
48 CommonFailsBeforeRequesting();
49 }
50
51 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfDismissed) {
52 CommonFailsIfDismissed();
53 }
54
55 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonFailsIfBlocked) {
56 CommonFailsIfBlocked();
57 }
58
59 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, CommonSucceedsIfAllowed) {
60 CommonSucceedsIfAllowed();
61 }
62
63 IN_PROC_BROWSER_TEST_F(FlashPermissionBrowserTest, TriggerPromptViaNewWindow) {
64 EXPECT_EQ(0, prompt_factory()->total_request_count());
65 prompt_factory()->set_response_type(PermissionRequestManager::ACCEPT_ALL);
66 EXPECT_TRUE(RunScriptReturnBool("triggerPromptViaNewWindow();"));
67
68 EXPECT_EQ(1, prompt_factory()->total_request_count());
69 EXPECT_TRUE(FeatureUsageSucceeds());
70 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permissions_browsertest.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698