File: browser_dbg_variables-view-01.js

package info (click to toggle)
iceweasel 31.6.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,368,576 kB
  • sloc: cpp: 3,692,968; ansic: 1,797,194; python: 193,401; java: 180,622; asm: 133,557; xml: 89,288; sh: 71,748; perl: 22,087; makefile: 21,687; objc: 4,014; yacc: 1,995; pascal: 1,292; lex: 950; exp: 449; lisp: 228; awk: 211; php: 113; sed: 43; csh: 31; ada: 16; ruby: 3
file content (126 lines) | stat: -rw-r--r-- 4,582 bytes parent folder | download | duplicates (5)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Tests that creating, collpasing and expanding scopes in the
 * variables view works as expected.
 */

const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";

function test() {
  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    let variables = aPanel.panelWin.DebuggerView.Variables;
    let testScope = variables.addScope("test");

    ok(testScope,
      "Should have created a scope.");
    ok(testScope.id.contains("test"),
      "The newly created scope should have the default id set.");
    is(testScope.name, "test",
      "The newly created scope should have the desired name set.");

    ok(!testScope.displayValue,
      "The newly created scope should not have a displayed value (1).");
    ok(!testScope.displayValueClassName,
      "The newly created scope should not have a displayed value (2).");

    ok(testScope.target,
      "The newly created scope should point to a target node.");
    ok(testScope.target.id.contains("test"),
      "Should have the correct scope id on the element.");

    is(testScope.target.querySelector(".name").getAttribute("value"), "test",
      "Any new scope should have the designated name.");
    is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
      "Any new scope should have a container with no enumerable child nodes.");
    is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
      "Any new scope should have a container with no non-enumerable child nodes.");

    ok(!testScope.expanded,
      "Any new created scope should be initially collapsed.");
    ok(testScope.visible,
      "Any new created scope should be initially visible.");

    let expandCallbackArg = null;
    let collapseCallbackArg = null;
    let toggleCallbackArg = null;
    let hideCallbackArg = null;
    let showCallbackArg = null;

    testScope.onexpand = aScope => expandCallbackArg = aScope;
    testScope.oncollapse = aScope => collapseCallbackArg = aScope;
    testScope.ontoggle = aScope => toggleCallbackArg = aScope;
    testScope.onhide = aScope => hideCallbackArg = aScope;
    testScope.onshow = aScope => showCallbackArg = aScope;

    testScope.expand();
    ok(testScope.expanded,
      "The testScope shouldn't be collapsed anymore.");
    is(expandCallbackArg, testScope,
      "The expandCallback wasn't called as it should.");

    testScope.collapse();
    ok(!testScope.expanded,
      "The testScope should be collapsed again.");
    is(collapseCallbackArg, testScope,
      "The collapseCallback wasn't called as it should.");

    testScope.expanded = true;
    ok(testScope.expanded,
      "The testScope shouldn't be collapsed anymore.");

    testScope.toggle();
    ok(!testScope.expanded,
      "The testScope should be collapsed again.");
    is(toggleCallbackArg, testScope,
      "The toggleCallback wasn't called as it should.");

    testScope.hide();
    ok(!testScope.visible,
      "The testScope should be invisible after hiding.");
    is(hideCallbackArg, testScope,
      "The hideCallback wasn't called as it should.");

    testScope.show();
    ok(testScope.visible,
      "The testScope should be visible again.");
    is(showCallbackArg, testScope,
      "The showCallback wasn't called as it should.");

    testScope.visible = false;
    ok(!testScope.visible,
      "The testScope should be invisible after hiding.");
    ok(!testScope.expanded,
      "The testScope should remember it is collapsed even if it is hidden.");

    testScope.visible = true;
    ok(testScope.visible,
      "The testScope should be visible after reshowing.");
    ok(!testScope.expanded,
      "The testScope should remember it is collapsed after it is reshown.");

    EventUtils.sendMouseEvent({ type: "mousedown", button: 1 },
      testScope.target.querySelector(".title"),
      aPanel.panelWin);

    ok(!testScope.expanded,
      "Clicking the testScope title with the right mouse button should't expand it.");

    EventUtils.sendMouseEvent({ type: "mousedown" },
      testScope.target.querySelector(".title"),
      aPanel.panelWin);

    ok(testScope.expanded,
      "Clicking the testScope title should expand it.");

    EventUtils.sendMouseEvent({ type: "mousedown" },
      testScope.target.querySelector(".title"),
      aPanel.panelWin);

    ok(!testScope.expanded,
      "Clicking again the testScope title should collapse it.");

    closeDebuggerAndFinish(aPanel);
  });
}