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

"use strict";

// See Bug 597756. Check that errors are still displayed in the console after
// reloading a page.

const TEST_URI =
  "http://example.com/browser/devtools/client/webconsole/" +
  "test/browser/test-reopen-closed-tab.html";

add_task(async function () {
  // If we persist log, the test might be successful even if only the first
  // error log is shown.
  pushPref("devtools.webconsole.persistlog", false);

  info("Open console and refresh tab.");

  expectUncaughtExceptionNoE10s();
  let hud = await openNewTabAndConsole(TEST_URI);
  await clearOutput(hud);

  expectUncaughtExceptionNoE10s();
  await reloadBrowser();
  await waitForError(hud);

  // Close and reopen
  await closeConsole();

  expectUncaughtExceptionNoE10s();
  gBrowser.removeCurrentTab();
  hud = await openNewTabAndConsole(TEST_URI);

  expectUncaughtExceptionNoE10s();
  await reloadBrowser();
  await waitForError(hud);
});

async function waitForError(hud) {
  info("Wait for error message");
  await waitFor(() => findErrorMessage(hud, "fooBug597756_error"));
  ok(true, "error message displayed");
}

function expectUncaughtExceptionNoE10s() {
  // On e10s, the exception is triggered in child process
  // and is ignored by test harness
  if (!Services.appinfo.browserTabsRemoteAutostart) {
    expectUncaughtException();
  }
}