summaryrefslogtreecommitdiffstats
path: root/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_urlbarfocus.js
blob: cc4c0585de1714fff8cfe4bbc4f50b1d11edc4b5 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// This test makes sure that the URL bar is focused when entering the private window.

"use strict";

function checkUrlbarFocus(win) {
  let urlbar = win.gURLBar;
  is(
    win.document.activeElement,
    urlbar.inputField,
    "URL Bar should be focused"
  );
  is(urlbar.value, "", "URL Bar should be empty");
}

function openNewPrivateWindow() {
  return new Promise(resolve => {
    whenNewWindowLoaded({ private: true }, win => {
      executeSoon(() => resolve(win));
    });
  });
}

add_task(async function () {
  let win = await openNewPrivateWindow();
  checkUrlbarFocus(win);
  win.close();
});

add_task(async function () {
  AboutNewTab.newTabURL = "about:blank";
  registerCleanupFunction(() => {
    AboutNewTab.resetNewTabURL();
  });

  let win = await openNewPrivateWindow();
  checkUrlbarFocus(win);
  win.close();

  AboutNewTab.resetNewTabURL();
});