summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/fullscreen/browser_fullscreen_newtab.js
blob: d5a74a0aa370119517ee3db14f596ec10b112aeb (plain)
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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// This test verifies that when in fullscreen mode, and a new tab is opened,
// fullscreen mode is exited and the url bar is focused.
add_task(async function test_fullscreen_display_none() {
  await SpecialPowers.pushPrefEnv({
    set: [
      ["full-screen-api.enabled", true],
      ["full-screen-api.allow-trusted-requests-only", false],
    ],
  });

  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "https://example.org/browser/browser/base/content/test/fullscreen/fullscreen.html"
  );

  let fullScreenEntered = BrowserTestUtils.waitForEvent(
    document,
    "fullscreenchange",
    false,
    () => document.fullscreenElement
  );

  await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
    content.document.getElementById("request").click();
  });

  await fullScreenEntered;

  let fullScreenExited = BrowserTestUtils.waitForEvent(
    document,
    "fullscreenchange",
    false,
    () => !document.fullscreenElement
  );

  let focusPromise = BrowserTestUtils.waitForEvent(window, "focus");
  EventUtils.synthesizeKey("T", { accelKey: true });
  await focusPromise;

  is(
    document.activeElement,
    gURLBar.inputField,
    "url bar is focused after new tab opened"
  );

  await fullScreenExited;

  BrowserTestUtils.removeTab(gBrowser.selectedTab);
  BrowserTestUtils.removeTab(tab);
});