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.

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

mercurial