summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_jsterm_focus_reload.js
blob: 5bafa3943df2a976f75a83030a52cb474ed4f665 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Check that the console does not steal the focus when reloading a page, if the focus
// is on the content page.

"use strict";

const TEST_URI = `data:text/html,<!DOCTYPE html><meta charset=utf8>Focus test`;

add_task(async function () {
  info("Testing that messages disappear on a refresh if logs aren't persisted");
  const hud = await openNewTabAndConsole(TEST_URI);
  is(isInputFocused(hud), true, "JsTerm is focused when opening the console");

  info("Put the focus on the content page");
  SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => content.focus());
  await waitFor(() => isInputFocused(hud) === false);

  info(
    "Reload the page to check that JsTerm does not steal the content page focus"
  );
  await reloadBrowser();
  is(
    isInputFocused(hud),
    false,
    "JsTerm is still unfocused after reloading the page"
  );
});