browser/devtools/debugger/test/browser_dbg_variables-view-01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Tests that creating, collpasing and expanding scopes in the
     6  * variables view works as expected.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
    11 function test() {
    12   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    13     let variables = aPanel.panelWin.DebuggerView.Variables;
    14     let testScope = variables.addScope("test");
    16     ok(testScope,
    17       "Should have created a scope.");
    18     ok(testScope.id.contains("test"),
    19       "The newly created scope should have the default id set.");
    20     is(testScope.name, "test",
    21       "The newly created scope should have the desired name set.");
    23     ok(!testScope.displayValue,
    24       "The newly created scope should not have a displayed value (1).");
    25     ok(!testScope.displayValueClassName,
    26       "The newly created scope should not have a displayed value (2).");
    28     ok(testScope.target,
    29       "The newly created scope should point to a target node.");
    30     ok(testScope.target.id.contains("test"),
    31       "Should have the correct scope id on the element.");
    33     is(testScope.target.querySelector(".name").getAttribute("value"), "test",
    34       "Any new scope should have the designated name.");
    35     is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
    36       "Any new scope should have a container with no enumerable child nodes.");
    37     is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
    38       "Any new scope should have a container with no non-enumerable child nodes.");
    40     ok(!testScope.expanded,
    41       "Any new created scope should be initially collapsed.");
    42     ok(testScope.visible,
    43       "Any new created scope should be initially visible.");
    45     let expandCallbackArg = null;
    46     let collapseCallbackArg = null;
    47     let toggleCallbackArg = null;
    48     let hideCallbackArg = null;
    49     let showCallbackArg = null;
    51     testScope.onexpand = aScope => expandCallbackArg = aScope;
    52     testScope.oncollapse = aScope => collapseCallbackArg = aScope;
    53     testScope.ontoggle = aScope => toggleCallbackArg = aScope;
    54     testScope.onhide = aScope => hideCallbackArg = aScope;
    55     testScope.onshow = aScope => showCallbackArg = aScope;
    57     testScope.expand();
    58     ok(testScope.expanded,
    59       "The testScope shouldn't be collapsed anymore.");
    60     is(expandCallbackArg, testScope,
    61       "The expandCallback wasn't called as it should.");
    63     testScope.collapse();
    64     ok(!testScope.expanded,
    65       "The testScope should be collapsed again.");
    66     is(collapseCallbackArg, testScope,
    67       "The collapseCallback wasn't called as it should.");
    69     testScope.expanded = true;
    70     ok(testScope.expanded,
    71       "The testScope shouldn't be collapsed anymore.");
    73     testScope.toggle();
    74     ok(!testScope.expanded,
    75       "The testScope should be collapsed again.");
    76     is(toggleCallbackArg, testScope,
    77       "The toggleCallback wasn't called as it should.");
    79     testScope.hide();
    80     ok(!testScope.visible,
    81       "The testScope should be invisible after hiding.");
    82     is(hideCallbackArg, testScope,
    83       "The hideCallback wasn't called as it should.");
    85     testScope.show();
    86     ok(testScope.visible,
    87       "The testScope should be visible again.");
    88     is(showCallbackArg, testScope,
    89       "The showCallback wasn't called as it should.");
    91     testScope.visible = false;
    92     ok(!testScope.visible,
    93       "The testScope should be invisible after hiding.");
    94     ok(!testScope.expanded,
    95       "The testScope should remember it is collapsed even if it is hidden.");
    97     testScope.visible = true;
    98     ok(testScope.visible,
    99       "The testScope should be visible after reshowing.");
   100     ok(!testScope.expanded,
   101       "The testScope should remember it is collapsed after it is reshown.");
   103     EventUtils.sendMouseEvent({ type: "mousedown", button: 1 },
   104       testScope.target.querySelector(".title"),
   105       aPanel.panelWin);
   107     ok(!testScope.expanded,
   108       "Clicking the testScope title with the right mouse button should't expand it.");
   110     EventUtils.sendMouseEvent({ type: "mousedown" },
   111       testScope.target.querySelector(".title"),
   112       aPanel.panelWin);
   114     ok(testScope.expanded,
   115       "Clicking the testScope title should expand it.");
   117     EventUtils.sendMouseEvent({ type: "mousedown" },
   118       testScope.target.querySelector(".title"),
   119       aPanel.panelWin);
   121     ok(!testScope.expanded,
   122       "Clicking again the testScope title should collapse it.");
   124     closeDebuggerAndFinish(aPanel);
   125   });
   126 }

mercurial