summaryrefslogtreecommitdiffstats
path: root/devtools/client/jsonview/test/browser_jsonview_initial_focus.js
blob: 71b0623ce5be23160bc284a88399bae5373f0691 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const VALID_JSON_URL = URL_ROOT + "valid_json.json";

add_task(async function () {
  info("Test focus JSON view started");
  await addJsonViewTab(VALID_JSON_URL);

  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async () => {
    const scroller = content.document.getElementById("json-scrolling-panel");
    ok(scroller, "Found the scrollable area");
    is(
      content.document.activeElement,
      scroller,
      "Scrollable area initially focused"
    );
  });
  await reloadBrowser();
  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async () => {
    const scroller = await ContentTaskUtils.waitForCondition(
      () => content.document.getElementById("json-scrolling-panel"),
      "Wait for the panel to be loaded"
    );
    is(
      content.document.activeElement,
      scroller,
      "Scrollable area focused after reload"
    );
  });
});