summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/compatibility/test/browser/browser_compatibility_throbber.js
blob: eff0f9ac930a16e36cd0ab64d01136f0f486935c (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
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test whether the throbber is displayed correctly or not.

const TEST_URI = `
  <style>
  body {
    color: blue;
    border-block-color: lime;
    user-modify: read-only;
  }
  div {
    font-variant-alternates: historical-forms;
  }
  </style>
  <body>
    <div>test</div>
  </body>
`;

const {
  COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_START,
} = require("resource://devtools/client/inspector/compatibility/actions/index.js");

add_task(async function () {
  const tab = await addTab(
    "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)
  );

  const { allElementsPane, inspector, selectedElementPane } =
    await openCompatibilityView();

  info("Check the throbber visibility at the beginning");
  assertThrobber(allElementsPane, false);
  assertThrobber(selectedElementPane, false);

  info("Reload the browsing page");
  const onStart = waitForDispatch(
    inspector.store,
    COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_START
  );
  const onComplete = waitForDispatch(
    inspector.store,
    COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_COMPLETE
  );
  gBrowser.reloadTab(tab);

  info("Check the throbber visibility of after starting updating action");
  await onStart;
  assertThrobber(allElementsPane, true);
  assertThrobber(selectedElementPane, false);

  info("Check the throbber visibility of after completing updating action");
  await onComplete;
  assertThrobber(allElementsPane, false);
  assertThrobber(selectedElementPane, false);
});

function assertThrobber(panel, expectedVisibility) {
  const isThrobberVisible = !!panel.querySelector(".devtools-throbber");
  is(
    isThrobberVisible,
    expectedVisibility,
    "Visibility of the throbber is correct"
  );
}