summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser_console_variables_view_dom_nodes.js
blob: 522fe47546d443259d03c3e78e4fb24fe25781ec (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
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Test that ensures DOM nodes are rendered correctly in VariablesView.

"use strict";

function test() {
  const TEST_URI = `
    data:text/html;charset=utf-8,
    <html>
      <head>
        <title>Test for DOM nodes in variables view</title>
      </head>
      <body>
        <div></div>
        <div id="testID"></div>
        <div class="single-class"></div>
        <div class="multiple-classes another-class"></div>
        <div class="class-and-id" id="class-and-id"></div>
        <div class="multiple-classes-and-id another-class"
          id="multiple-classes-and-id"></div>
        <div class="   whitespace-start"></div>
        <div class="whitespace-end     "></div>
        <div class="multiple    spaces"></div>
      </body>
    </html>
`;

  Task.spawn(runner).then(finishTest);

  function* runner() {
    const {tab} = yield loadTab(TEST_URI);
    const hud = yield openConsole(tab);
    const jsterm = hud.jsterm;

    let deferred = promise.defer();
    jsterm.once("variablesview-fetched", (_, val) => deferred.resolve(val));
    jsterm.execute("inspect(document.querySelectorAll('div'))");

    let variableScope = yield deferred.promise;
    ok(variableScope, "Variables view opened");

    yield findVariableViewProperties(variableScope, [
      { name: "0", value: "<div>"},
      { name: "1", value: "<div#testID>"},
      { name: "2", value: "<div.single-class>"},
      { name: "3", value: "<div.multiple-classes.another-class>"},
      { name: "4", value: "<div#class-and-id.class-and-id>"},
      { name: "5", value: "<div#multiple-classes-and-id." +
                          "multiple-classes-and-id.another-class>"},
      { name: "6", value: "<div.whitespace-start>"},
      { name: "7", value: "<div.whitespace-end>"},
      { name: "8", value: "<div.multiple.spaces>"},
    ], { webconsole: hud});
  }
}