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

"use strict";

function clickReload(devtoolsDocument) {
  devtoolsDocument.querySelector(".qa-reload-button").click();
}

// Test that ensures the remote page is reloaded when the button is clicked
add_task(async function () {
  const debug_tab = await addTab("about:home");

  const { document, tab, window } = await openAboutDebugging();

  // go to This Firefox and inspect the new tab
  info("Inspecting a new tab in This Firefox");
  await selectThisFirefoxPage(document, window.AboutDebugging.store);
  const { devtoolsDocument, devtoolsTab, devtoolsWindow } =
    await openAboutDevtoolsToolbox(document, tab, window, "about:home");

  info("Clicking reload button and waiting for requests to complete");
  const toolbox = getToolbox(devtoolsWindow);
  const { onDomCompleteResource } =
    await waitForNextTopLevelDomCompleteResource(toolbox.commands);

  // Watch for navigation promises.
  const refreshes = Promise.all([
    onDomCompleteResource,
    toolbox.commands.client.waitForRequestsToSettle(),
    waitForAboutDebuggingRequests(window.AboutDebugging.store),
  ]);

  // We cannot include this one in the Promise.all array, as it needs to be
  // explicitly called after navigation started.
  const waitForLoadedPanelsReload = await watchForLoadedPanelsReload(toolbox);

  clickReload(devtoolsDocument);
  await refreshes;
  await waitForLoadedPanelsReload();

  ok(true, "Clicked refresh; both page and devtools reloaded");

  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);

  info("Remove the debugged tab");
  await removeTab(debug_tab);
  await waitUntil(() => !findDebugTargetByText("about:home", document));
  await waitForAboutDebuggingRequests(window.AboutDebugging.store);

  info("Remove the about:debugging tab.");
  await removeTab(tab);
});