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

Side by Side Diff: chrome/browser/ui/exclusive_access/fullscreen_controller_browsertest.cc

Issue 2004353002: Delete unused code for exclusive access permission prompting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fullscreen-mac-remove-window-controller
Patch Set: Remove changes to content settings UI (spun out to CL 2045163002). Created 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/content_settings/host_content_settings_map_factory.h" 5 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_commands.h" 7 #include "chrome/browser/ui/browser_commands.h"
8 #include "chrome/browser/ui/browser_tabstrip.h" 8 #include "chrome/browser/ui/browser_tabstrip.h"
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" 11 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h"
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
14 #include "components/content_settings/core/browser/host_content_settings_map.h" 14 #include "components/content_settings/core/browser/host_content_settings_map.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 17 #include "net/test/embedded_test_server/embedded_test_server.h"
18 18
19 using content::WebContents; 19 using content::WebContents;
20 using ui::PAGE_TRANSITION_TYPED; 20 using ui::PAGE_TRANSITION_TYPED;
21 21
22 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
23 PendingMouseLockExitsOnTabSwitch) {
24 // This test doesn't make sense in simplified mode, since we never prompt for
25 // mouse lock.
26 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled())
27 return;
28
29 AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
30 AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
31 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents();
32
33 // Request mouse lock. Bubble is displayed.
34 RequestToLockMouse(true, false);
35 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
36
37 // Activate current tab. Mouse lock bubble remains.
38 browser()->tab_strip_model()->ActivateTabAt(0, true);
39 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
40
41 // Activate second tab. Mouse lock bubble clears.
42 {
43 MouseLockNotificationObserver mouse_lock_observer;
44 browser()->tab_strip_model()->ActivateTabAt(1, true);
45 mouse_lock_observer.Wait();
46 }
47 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
48
49 // Now, test that closing an unrelated tab does not disturb a request.
50
51 // Request mouse lock. Bubble is displayed.
52 RequestToLockMouse(true, false);
53 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
54
55 // Close first tab while second active. Mouse lock bubble remains.
56 chrome::CloseWebContents(browser(), tab1, false);
57 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
58 }
59
60 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
61 PendingMouseLockExitsOnTabClose) {
62 // This test doesn't make sense in simplified mode, since we never prompt for
63 // mouse lock.
64 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled())
65 return;
66
67 // Add more tabs.
68 AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
69 AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
70
71 // Request mouse lock. Bubble is displayed.
72 RequestToLockMouse(true, false);
73 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
74
75 // Close tab. Bubble is cleared.
76 {
77 MouseLockNotificationObserver mouse_lock_observer;
78 chrome::CloseTab(browser());
79 mouse_lock_observer.Wait();
80 }
81 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
82 }
83
84 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, MouseLockOnFileURL) { 22 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, MouseLockOnFileURL) {
85 static const base::FilePath::CharType* kEmptyFile = 23 static const base::FilePath::CharType* kEmptyFile =
86 FILE_PATH_LITERAL("empty.html"); 24 FILE_PATH_LITERAL("empty.html");
87 GURL file_url(ui_test_utils::GetTestUrl( 25 GURL file_url(ui_test_utils::GetTestUrl(
88 base::FilePath(base::FilePath::kCurrentDirectory), 26 base::FilePath(base::FilePath::kCurrentDirectory),
89 base::FilePath(kEmptyFile))); 27 base::FilePath(kEmptyFile)));
90 AddTabAtIndex(0, file_url, PAGE_TRANSITION_TYPED); 28 AddTabAtIndex(0, file_url, PAGE_TRANSITION_TYPED);
91 RequestToLockMouse(true, false); 29 RequestToLockMouse(true, false);
92 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); 30 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
93 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled())
94 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
95 else
96 ASSERT_TRUE(IsFullscreenBubbleDisplayingButtons());
97 } 31 }
98 32
99 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenOnFileURL) { 33 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenOnFileURL) {
100 static const base::FilePath::CharType* kEmptyFile = 34 static const base::FilePath::CharType* kEmptyFile =
101 FILE_PATH_LITERAL("empty.html"); 35 FILE_PATH_LITERAL("empty.html");
102 GURL file_url(ui_test_utils::GetTestUrl( 36 GURL file_url(ui_test_utils::GetTestUrl(
103 base::FilePath(base::FilePath::kCurrentDirectory), 37 base::FilePath(base::FilePath::kCurrentDirectory),
104 base::FilePath(kEmptyFile))); 38 base::FilePath(kEmptyFile)));
105 AddTabAtIndex(0, file_url, PAGE_TRANSITION_TYPED); 39 AddTabAtIndex(0, file_url, PAGE_TRANSITION_TYPED);
106 GetFullscreenController()->EnterFullscreenModeForTab( 40 GetFullscreenController()->EnterFullscreenModeForTab(
107 browser()->tab_strip_model()->GetActiveWebContents(), 41 browser()->tab_strip_model()->GetActiveWebContents(),
108 file_url.GetOrigin()); 42 file_url.GetOrigin());
109 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); 43 ASSERT_TRUE(IsFullscreenBubbleDisplayed());
110 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled())
111 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
112 else
113 ASSERT_TRUE(IsFullscreenBubbleDisplayingButtons());
114 } 44 }
115 45
116 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, PermissionContentSettings) { 46 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, PermissionContentSettings) {
117 ASSERT_TRUE(embedded_test_server()->Start()); 47 ASSERT_TRUE(embedded_test_server()->Start());
118 GURL url = embedded_test_server()->GetURL(kFullscreenMouseLockHTML); 48 GURL url = embedded_test_server()->GetURL(kFullscreenMouseLockHTML);
119 ui_test_utils::NavigateToURL(browser(), url); 49 ui_test_utils::NavigateToURL(browser(), url);
120 50
121 EXPECT_FALSE(browser()->window()->IsFullscreen()); 51 EXPECT_FALSE(browser()->window()->IsFullscreen());
122 52
123 // The content's origin is not allowed to go fullscreen. 53 // The content's origin is not allowed to go fullscreen.
(...skipping 11 matching lines...) Expand all
135 65
136 // The content's origin is still not allowed to go fullscreen. 66 // The content's origin is still not allowed to go fullscreen.
137 EXPECT_EQ( 67 EXPECT_EQ(
138 CONTENT_SETTING_ASK, 68 CONTENT_SETTING_ASK,
139 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) 69 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
140 ->GetContentSetting(url.GetOrigin(), 70 ->GetContentSetting(url.GetOrigin(),
141 url.GetOrigin(), 71 url.GetOrigin(),
142 CONTENT_SETTINGS_TYPE_FULLSCREEN, 72 CONTENT_SETTINGS_TYPE_FULLSCREEN,
143 std::string())); 73 std::string()));
144 74
145 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) {
146 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
147 } else {
148 ASSERT_TRUE(IsFullscreenBubbleDisplayingButtons());
149 // It only makes sense to test this on the non-simplified mode. In the
150 // simplified mode, you cannot accept the request (as it is auto-accepted)
151 // so you can't set ALLOW.
152 AcceptCurrentFullscreenOrMouseLockRequest();
153
154 // The content's origin is allowed to go fullscreen.
155 EXPECT_EQ(CONTENT_SETTING_ALLOW,
156 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
157 ->GetContentSetting(url.GetOrigin(), url.GetOrigin(),
158 CONTENT_SETTINGS_TYPE_FULLSCREEN,
159 std::string()));
160 }
161
162 // The primary and secondary patterns have been set when setting the 75 // The primary and secondary patterns have been set when setting the
163 // permission, thus setting another secondary pattern shouldn't work. 76 // permission, thus setting another secondary pattern shouldn't work.
164 EXPECT_EQ( 77 EXPECT_EQ(
165 CONTENT_SETTING_ASK, 78 CONTENT_SETTING_ASK,
166 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) 79 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
167 ->GetContentSetting(url.GetOrigin(), 80 ->GetContentSetting(url.GetOrigin(),
168 GURL("https://test.com"), 81 GURL("https://test.com"),
169 CONTENT_SETTINGS_TYPE_FULLSCREEN, 82 CONTENT_SETTINGS_TYPE_FULLSCREEN,
170 std::string())); 83 std::string()));
171 84
172 HostContentSettingsMapFactory::GetForProfile(browser()->profile()) 85 HostContentSettingsMapFactory::GetForProfile(browser()->profile())
173 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_FULLSCREEN); 86 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_FULLSCREEN);
174 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698