1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/compiler_specific.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/test_navigation_observer.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#endif
using content::WebContents;
namespace {
const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
} // namespace
class FullscreenControllerBrowserTest: public FullscreenControllerTest {
protected:
void TestFullscreenMouseLockContentSettings();
};
#if defined(OS_MACOSX)
// http://crbug.com/104265
#define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen
#elif defined(OS_LINUX)
// http://crbug.com/137657
#define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen
#else
#define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen
#endif
// Tests that while in fullscreen creating a new tab will exit fullscreen.
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_TestNewTabExitsFullscreen) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndexAndWait(
0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
{
FullscreenNotificationObserver fullscreen_observer;
AddTabAtIndexAndWait(
1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
fullscreen_observer.Wait();
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
}
#if defined(OS_MACOSX)
// http://crbug.com/100467
#define MAYBE_TestTabExitsItselfFromFullscreen \
FAILS_TestTabExitsItselfFromFullscreen
#elif defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_TestTabExitsItselfFromFullscreen \
DISABLED_TestTabExitsItselfFromFullscreen
#else
#define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen
#endif
// Tests a tab exiting fullscreen will bring the browser out of fullscreen.
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_TestTabExitsItselfFromFullscreen) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndexAndWait(
0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
}
// Tests entering fullscreen and then requesting mouse lock results in
// buttons for the user, and that after confirming the buttons are dismissed.
#if defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_TestFullscreenBubbleMouseLockState \
DISABLED_TestFullscreenBubbleMouseLockState
#else
#define MAYBE_TestFullscreenBubbleMouseLockState \
TestFullscreenBubbleMouseLockState
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_TestFullscreenBubbleMouseLockState) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
AddTabAtIndexAndWait(1, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
// Request mouse lock and verify the bubble is waiting for user confirmation.
RequestToLockMouse(true, false);
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Accept mouse lock and verify bubble no longer shows confirmation buttons.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
}
// Helper method to be called by multiple tests.
// Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
void FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings() {
GURL url = test_server()->GetURL("simple.html");
AddTabAtIndexAndWait(0, url, content::PAGE_TRANSITION_TYPED);
// Validate that going fullscreen for a URL defaults to asking permision.
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
// Add content setting to ALLOW fullscreen.
HostContentSettingsMap* settings_map =
browser()->profile()->GetHostContentSettingsMap();
ContentSettingsPattern pattern =
ContentSettingsPattern::FromURL(url);
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(),
CONTENT_SETTING_ALLOW);
// Now, fullscreen should not prompt for permission.
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_FALSE(IsFullscreenPermissionRequested());
// Leaving tab in fullscreen, now test mouse lock ALLOW:
// Validate that mouse lock defaults to asking permision.
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_TRUE(IsMouseLockPermissionRequested());
LostMouseLock();
// Add content setting to ALLOW mouse lock.
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
CONTENT_SETTING_ALLOW);
// Now, mouse lock should not prompt for permission.
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_FALSE(IsMouseLockPermissionRequested());
LostMouseLock();
// Leaving tab in fullscreen, now test mouse lock BLOCK:
// Add content setting to BLOCK mouse lock.
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
CONTENT_SETTING_BLOCK);
// Now, mouse lock should not be pending.
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
#if defined(OS_MACOSX)
// http://crbug.com/133831
#define MAYBE_FullscreenMouseLockContentSettings \
FLAKY_FullscreenMouseLockContentSettings
#elif defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_FullscreenMouseLockContentSettings \
DISABLED_FullscreenMouseLockContentSettings
#else
#define MAYBE_FullscreenMouseLockContentSettings \
FullscreenMouseLockContentSettings
#endif
// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
IN_PROC_BROWSER_TEST_F(FullscreenControllerBrowserTest,
MAYBE_FullscreenMouseLockContentSettings) {
TestFullscreenMouseLockContentSettings();
}
#if defined(OS_MACOSX) || defined(OS_LINUX)
// http://crbug.com/103912 Mac
// http://crbug.com/143930 Linux
#define MAYBE_BrowserFullscreenMouseLockContentSettings \
DISABLED_BrowserFullscreenMouseLockContentSettings
#else
#define MAYBE_BrowserFullscreenMouseLockContentSettings \
BrowserFullscreenMouseLockContentSettings
#endif
// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK,
// but with the browser initiated in fullscreen mode first.
IN_PROC_BROWSER_TEST_F(FullscreenControllerBrowserTest,
MAYBE_BrowserFullscreenMouseLockContentSettings) {
// Enter browser fullscreen first.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
TestFullscreenMouseLockContentSettings();
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
}
// Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser.
#if defined(OS_MACOSX)
// http://crbug.com/103912
#define MAYBE_BrowserFullscreenExit DISABLED_BrowserFullscreenExit
#else
#define MAYBE_BrowserFullscreenExit BrowserFullscreenExit
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, MAYBE_BrowserFullscreenExit) {
// Enter browser fullscreen.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
// Enter tab fullscreen.
AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
// Exit browser fullscreen.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
// Tests Browser Fullscreen remains active after Tab mode entered and exited.
#if defined(OS_MACOSX)
// http://crbug.com/103912
#define MAYBE_BrowserFullscreenAfterTabFSExit \
DISABLED_BrowserFullscreenAfterTabFSExit
#elif defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_BrowserFullscreenAfterTabFSExit \
DISABLED_BrowserFullscreenAfterTabFSExit
#else
#define MAYBE_BrowserFullscreenAfterTabFSExit BrowserFullscreenAfterTabFSExit
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_BrowserFullscreenAfterTabFSExit) {
// Enter browser fullscreen.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
// Enter and then exit tab fullscreen.
AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
// Verify browser fullscreen still active.
ASSERT_TRUE(IsFullscreenForBrowser());
}
// Tests fullscreen entered without permision prompt for file:// urls.
#if defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_FullscreenFileURL DISABLED_FullscreenFileURL
#else
#define MAYBE_FullscreenFileURL FullscreenFileURL
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, MAYBE_FullscreenFileURL) {
ui_test_utils::NavigateToURL(browser(),
ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kSimpleFile)));
// Validate that going fullscreen for a file does not ask permision.
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
}
// Tests fullscreen is exited on page navigation.
// (Similar to mouse lock version in FullscreenControllerInteractiveTest)
#if defined(OS_MACOSX)
// http://crbug.com/103912
#define MAYBE_TestTabExitsFullscreenOnNavigation \
DISABLED_TestTabExitsFullscreenOnNavigation
#else
#define MAYBE_TestTabExitsFullscreenOnNavigation \
TestTabExitsFullscreenOnNavigation
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_TestTabExitsFullscreenOnNavigation) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
// Tests fullscreen is exited when navigating back.
// (Similar to mouse lock version in FullscreenControllerInteractiveTest)
#if defined(OS_MACOSX)
// http://crbug.com/103912
#define MAYBE_TestTabExitsFullscreenOnGoBack \
DISABLED_TestTabExitsFullscreenOnGoBack
#elif defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_TestTabExitsFullscreenOnGoBack \
DISABLED_TestTabExitsFullscreenOnGoBack
#else
#define MAYBE_TestTabExitsFullscreenOnGoBack TestTabExitsFullscreenOnGoBack
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_TestTabExitsFullscreenOnGoBack) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
GoBack();
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
// Tests fullscreen is not exited on sub frame navigation.
// (Similar to mouse lock version in FullscreenControllerInteractiveTest)
#if defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_TestTabDoesntExitFullscreenOnSubFrameNavigation \
DISABLED_TestTabDoesntExitFullscreenOnSubFrameNavigation
#else
#define MAYBE_TestTabDoesntExitFullscreenOnSubFrameNavigation \
TestTabDoesntExitFullscreenOnSubFrameNavigation
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_TestTabDoesntExitFullscreenOnSubFrameNavigation) {
ASSERT_TRUE(test_server()->Start());
GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
FilePath(kSimpleFile)));
GURL url_with_fragment(url.spec() + "#fragment");
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ui_test_utils::NavigateToURL(browser(), url_with_fragment);
ASSERT_TRUE(IsFullscreenForTabOrPending());
}
// Tests tab fullscreen exits, but browser fullscreen remains, on navigation.
#if defined(OS_MACOSX)
// http://crbug.com/103912
#define MAYBE_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks \
DISABLED_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks
#elif defined(OS_LINUX)
// http://crbug.com/146008
#define MAYBE_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks \
DISABLED_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks
#else
#define MAYBE_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks \
TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
MAYBE_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
GoBack();
ASSERT_TRUE(IsFullscreenForBrowser());
ASSERT_FALSE(IsFullscreenForTabOrPending());
}
#if defined(OS_MACOSX)
// http://crbug.com/100467
IN_PROC_BROWSER_TEST_F(
FullscreenControllerTest, FAILS_TabEntersPresentationModeFromWindowed) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndexAndWait(
0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
WebContents* tab = chrome::GetActiveWebContents(browser());
{
FullscreenNotificationObserver fullscreen_observer;
EXPECT_FALSE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->InPresentationMode());
browser()->ToggleFullscreenModeForTab(tab, true);
fullscreen_observer.Wait();
ASSERT_TRUE(browser()->window()->IsFullscreen());
ASSERT_TRUE(browser()->window()->InPresentationMode());
}
{
FullscreenNotificationObserver fullscreen_observer;
browser()->TogglePresentationMode();
fullscreen_observer.Wait();
ASSERT_FALSE(browser()->window()->IsFullscreen());
ASSERT_FALSE(browser()->window()->InPresentationMode());
}
if (base::mac::IsOSLionOrLater()) {
// Test that tab fullscreen mode doesn't make presentation mode the default
// on Lion.
FullscreenNotificationObserver fullscreen_observer;
chrome::ToggleFullscreenMode(browser());
fullscreen_observer.Wait();
ASSERT_TRUE(browser()->window()->IsFullscreen());
ASSERT_FALSE(browser()->window()->InPresentationMode());
}
}
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
PendingMouseLockExitsOnTabSwitch) {
AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
WebContents* tab1 = chrome::GetActiveWebContents(browser());
// Request mouse lock. Bubble is displayed.
RequestToLockMouse(true, false);
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
// Activate current tab. Mouse lock bubble remains.
chrome::ActivateTabAt(browser(), 0, true);
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
// Activate second tab. Mouse lock bubble clears.
{
MouseLockNotificationObserver mouse_lock_observer;
chrome::ActivateTabAt(browser(), 1, true);
mouse_lock_observer.Wait();
}
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Now, test that closing an unrelated tab does not disturb a request.
// Request mouse lock. Bubble is displayed.
RequestToLockMouse(true, false);
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
// Close first tab while second active. Mouse lock bubble remains.
chrome::CloseWebContents(browser(), tab1);
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerTest,
PendingMouseLockExitsOnTabClose) {
// Add more tabs.
AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_TYPED);
// Request mouse lock. Bubble is displayed.
RequestToLockMouse(true, false);
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
// Close tab. Bubble is cleared.
{
MouseLockNotificationObserver mouse_lock_observer;
chrome::CloseTab(browser());
mouse_lock_observer.Wait();
}
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
}
|