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

// Test that autocomplete doesn't break when trying to reach into objects from
// a different domain. See Bug 989025.

"use strict";

const TEST_URI =
  "https://example.com/browser/devtools/client/webconsole/" +
  "test/browser/test-iframe-parent.html";

add_task(async function () {
  const hud = await openNewTabAndConsole(TEST_URI);

  await executeAndWaitForResultMessage(hud, "document.title", "iframe parent");
  ok(true, "root document's title is accessible");

  // Make sure we don't throw when trying to autocomplete
  const autocompleteUpdated = hud.jsterm.once("autocomplete-updated");
  setInputValue(hud, "window[0].document");
  EventUtils.sendString(".");
  await autocompleteUpdated;

  setInputValue(hud, "window[0].document.title");
  const onPermissionDeniedMessage = waitForMessageByType(
    hud,
    "Permission denied",
    ".error"
  );
  EventUtils.synthesizeKey("KEY_Enter");
  const permissionDenied = await onPermissionDeniedMessage;
  ok(
    permissionDenied.node.classList.contains("error"),
    "A message error is shown when trying to inspect window[0]"
  );

  await executeAndWaitForResultMessage(
    hud,
    "window.location",
    "test-iframe-parent.html"
  );
  ok(true, "root document's location is accessible");
});