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

// This test makes sure that when the user presses enter in the urlbar in full
// screen, the toolbars are hidden.  This should not be run on macOS because we
// don't hide the toolbars there.

"use strict";

ChromeUtils.defineESModuleGetters(this, {
  UrlbarTestUtils: "resource://testing-common/UrlbarTestUtils.sys.mjs",
});

add_task(async function test() {
  await BrowserTestUtils.withNewTab("about:blank", async () => {
    // Do the View:FullScreen command and wait for the transition.
    let onFullscreen = BrowserTestUtils.waitForEvent(window, "fullscreen");
    document.getElementById("View:FullScreen").doCommand();
    await onFullscreen;

    // Do the Browser:OpenLocation command to show the nav toolbox and focus
    // the urlbar.
    let onToolboxShown = TestUtils.topicObserved(
      "fullscreen-nav-toolbox",
      (subject, data) => data == "shown"
    );
    document.getElementById("Browser:OpenLocation").doCommand();
    info("Waiting for the nav toolbox to be shown");
    await onToolboxShown;

    // Enter a URL.
    await UrlbarTestUtils.promiseAutocompleteResultPopup({
      window,
      // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      value: "http://example.com/",
      waitForFocus: SimpleTest.waitForFocus,
      fireInputEvent: true,
    });

    // Press enter and wait for the nav toolbox to be hidden.
    let onToolboxHidden = TestUtils.topicObserved(
      "fullscreen-nav-toolbox",
      (subject, data) => data == "hidden"
    );
    EventUtils.synthesizeKey("KEY_Enter");
    info("Waiting for the nav toolbox to be hidden");
    await onToolboxHidden;

    Assert.ok(true, "Nav toolbox hidden");

    info("Waiting for exiting from the fullscreen mode...");
    onFullscreen = BrowserTestUtils.waitForEvent(window, "fullscreen");
    document.getElementById("View:FullScreen").doCommand();
    await onFullscreen;
  });
});