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

// Check that cached messages from nested iframes are displayed in the
// Web/Browser Console.

"use strict";

const TEST_URI =
  "http://example.com/browser/devtools/client/webconsole/" +
  "test/browser/test-console-iframes.html";

const expectedMessages = [
  ["main file", ".console-api"],
  ["blah", ".error"],
  ["iframe 2", ".console-api"],
  ["iframe 3", ".console-api"],
];

// This log comes from test-iframe1.html, which is included from test-console-iframes.html
// __and__ from test-iframe3.html as well, so we should see it twice.
const expectedDupedMessage = "iframe 1";

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

  let hud = await openNewTabAndConsole(TEST_URI);

  await testMessages(hud);
  await closeConsole();
  info("web console closed");

  // Show the content messages
  await pushPref("devtools.browsertoolbox.scope", "everything");
  hud = await BrowserConsoleManager.toggleBrowserConsole();
  ok(hud, "browser console opened");
  await testMessages(hud);

  // clear the browser console.
  await clearOutput(hud);
  await waitForTick();
  await safeCloseBrowserConsole();
});

async function testMessages(hud) {
  for (const [message, selector] of expectedMessages) {
    info(`checking that the message "${message}" exists`);
    await waitFor(() => findMessageByType(hud, message, selector));
  }

  ok(true, "Found expected unique messages");

  await waitFor(
    () => findConsoleAPIMessages(hud, expectedDupedMessage).length == 2
  );
  ok(true, `${expectedDupedMessage} is present twice`);
}