browser/devtools/debugger/test/browser_dbg_variables-view-02.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 variables 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");
    15     let testVar = testScope.addItem("something");
    16     let duplVar = testScope.addItem("something");
    18     info("Scope id: " + testScope.id);
    19     info("Scope name: " + testScope.name);
    20     info("Variable id: " + testVar.id);
    21     info("Variable name: " + testVar.name);
    23     ok(testScope,
    24       "Should have created a scope.");
    25     is(duplVar, null,
    26       "Shouldn't be able to duplicate variables in the same scope.");
    28     ok(testVar,
    29       "Should have created a variable.");
    30     ok(testVar.id.contains("something"),
    31       "The newly created variable should have the default id set.");
    32     is(testVar.name, "something",
    33       "The newly created variable should have the desired name set.");
    35     ok(!testVar.displayValue,
    36       "The newly created variable should not have a displayed value yet (1).");
    37     ok(!testVar.displayValueClassName,
    38       "The newly created variable should not have a displayed value yet (2).");
    40     ok(testVar.target,
    41       "The newly created scope should point to a target node.");
    42     ok(testVar.target.id.contains("something"),
    43       "Should have the correct variable id on the element.");
    45     is(testVar.target.querySelector(".name").getAttribute("value"), "something",
    46       "Any new variable should have the designated name.");
    47     is(testVar.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
    48       "Any new variable should have a container with no enumerable child nodes.");
    49     is(testVar.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
    50       "Any new variable should have a container with no non-enumerable child nodes.");
    52     ok(!testVar.expanded,
    53       "Any new created scope should be initially collapsed.");
    54     ok(testVar.visible,
    55       "Any new created scope should be initially visible.");
    57     let expandCallbackArg = null;
    58     let collapseCallbackArg = null;
    59     let toggleCallbackArg = null;
    60     let hideCallbackArg = null;
    61     let showCallbackArg = null;
    63     testVar.onexpand = aScope => expandCallbackArg = aScope;
    64     testVar.oncollapse = aScope => collapseCallbackArg = aScope;
    65     testVar.ontoggle = aScope => toggleCallbackArg = aScope;
    66     testVar.onhide = aScope => hideCallbackArg = aScope;
    67     testVar.onshow = aScope => showCallbackArg = aScope;
    69     testVar.expand();
    70     ok(testVar.expanded,
    71       "The testVar shouldn't be collapsed anymore.");
    72     is(expandCallbackArg, testVar,
    73       "The expandCallback wasn't called as it should.");
    75     testVar.collapse();
    76     ok(!testVar.expanded,
    77       "The testVar should be collapsed again.");
    78     is(collapseCallbackArg, testVar,
    79       "The collapseCallback wasn't called as it should.");
    81     testVar.expanded = true;
    82     ok(testVar.expanded,
    83       "The testVar shouldn't be collapsed anymore.");
    85     testVar.toggle();
    86     ok(!testVar.expanded,
    87       "The testVar should be collapsed again.");
    88     is(toggleCallbackArg, testVar,
    89       "The toggleCallback wasn't called as it should.");
    91     testVar.hide();
    92     ok(!testVar.visible,
    93       "The testVar should be invisible after hiding.");
    94     is(hideCallbackArg, testVar,
    95       "The hideCallback wasn't called as it should.");
    97     testVar.show();
    98     ok(testVar.visible,
    99       "The testVar should be visible again.");
   100     is(showCallbackArg, testVar,
   101       "The showCallback wasn't called as it should.");
   103     testVar.visible = false;
   104     ok(!testVar.visible,
   105       "The testVar should be invisible after hiding.");
   106     ok(!testVar.expanded,
   107       "The testVar should remember it is collapsed even if it is hidden.");
   109     testVar.visible = true;
   110     ok(testVar.visible,
   111       "The testVar should be visible after reshowing.");
   112     ok(!testVar.expanded,
   113       "The testVar should remember it is collapsed after it is reshown.");
   115     EventUtils.sendMouseEvent({ type: "mousedown" },
   116       testVar.target.querySelector(".name"),
   117       aPanel.panelWin);
   119     ok(testVar.expanded,
   120       "Clicking the testVar name should expand it.");
   122     EventUtils.sendMouseEvent({ type: "mousedown" },
   123       testVar.target.querySelector(".name"),
   124       aPanel.panelWin);
   126     ok(!testVar.expanded,
   127       "Clicking again the testVar name should collapse it.");
   129     EventUtils.sendMouseEvent({ type: "mousedown" },
   130       testVar.target.querySelector(".arrow"),
   131       aPanel.panelWin);
   133     ok(testVar.expanded,
   134       "Clicking the testVar arrow should expand it.");
   136     EventUtils.sendMouseEvent({ type: "mousedown" },
   137       testVar.target.querySelector(".arrow"),
   138       aPanel.panelWin);
   140     ok(!testVar.expanded,
   141       "Clicking again the testVar arrow should collapse it.");
   143     EventUtils.sendMouseEvent({ type: "mousedown" },
   144       testVar.target.querySelector(".title"),
   145       aPanel.panelWin);
   147     ok(testVar.expanded,
   148       "Clicking the testVar title should expand it again.");
   150     testVar.addItem("child", {
   151       value: {
   152         type: "object",
   153         class: "Object"
   154       }
   155     });
   157     let testChild = testVar.get("child");
   158     ok(testChild,
   159       "Should have created a child property.");
   160     ok(testChild.id.contains("child"),
   161       "The newly created property should have the default id set.");
   162     is(testChild.name, "child",
   163       "The newly created property should have the desired name set.");
   165     is(testChild.displayValue, "Object",
   166       "The newly created property should not have a displayed value yet (1).");
   167     is(testChild.displayValueClassName, "token-other",
   168       "The newly created property should not have a displayed value yet (2).");
   170     ok(testChild.target,
   171       "The newly created scope should point to a target node.");
   172     ok(testChild.target.id.contains("child"),
   173       "Should have the correct property id on the element.");
   175     is(testChild.target.querySelector(".name").getAttribute("value"), "child",
   176       "Any new property should have the designated name.");
   177     is(testChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
   178       "Any new property should have a container with no enumerable child nodes.");
   179     is(testChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
   180       "Any new property should have a container with no non-enumerable child nodes.");
   182     ok(!testChild.expanded,
   183       "Any new created scope should be initially collapsed.");
   184     ok(testChild.visible,
   185       "Any new created scope should be initially visible.");
   187     EventUtils.sendMouseEvent({ type: "mousedown" },
   188       testChild.target.querySelector(".name"),
   189       aPanel.panelWin);
   191     ok(testChild.expanded,
   192       "Clicking the testChild name should expand it.");
   194     EventUtils.sendMouseEvent({ type: "mousedown" },
   195       testChild.target.querySelector(".name"),
   196       aPanel.panelWin);
   198     ok(!testChild.expanded,
   199       "Clicking again the testChild name should collapse it.");
   201     EventUtils.sendMouseEvent({ type: "mousedown" },
   202       testChild.target.querySelector(".arrow"),
   203       aPanel.panelWin);
   205     ok(testChild.expanded,
   206       "Clicking the testChild arrow should expand it.");
   208     EventUtils.sendMouseEvent({ type: "mousedown" },
   209       testChild.target.querySelector(".arrow"),
   210       aPanel.panelWin);
   212     ok(!testChild.expanded,
   213       "Clicking again the testChild arrow should collapse it.");
   215     EventUtils.sendMouseEvent({ type: "mousedown" },
   216       testChild.target.querySelector(".title"),
   217       aPanel.panelWin);
   219     closeDebuggerAndFinish(aPanel);
   220   });
   221 }

mercurial