michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that creating, collpasing and expanding scopes in the michael@0: * variables view works as expected. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: let variables = aPanel.panelWin.DebuggerView.Variables; michael@0: let testScope = variables.addScope("test"); michael@0: michael@0: ok(testScope, michael@0: "Should have created a scope."); michael@0: ok(testScope.id.contains("test"), michael@0: "The newly created scope should have the default id set."); michael@0: is(testScope.name, "test", michael@0: "The newly created scope should have the desired name set."); michael@0: michael@0: ok(!testScope.displayValue, michael@0: "The newly created scope should not have a displayed value (1)."); michael@0: ok(!testScope.displayValueClassName, michael@0: "The newly created scope should not have a displayed value (2)."); michael@0: michael@0: ok(testScope.target, michael@0: "The newly created scope should point to a target node."); michael@0: ok(testScope.target.id.contains("test"), michael@0: "Should have the correct scope id on the element."); michael@0: michael@0: is(testScope.target.querySelector(".name").getAttribute("value"), "test", michael@0: "Any new scope should have the designated name."); michael@0: is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, michael@0: "Any new scope should have a container with no enumerable child nodes."); michael@0: is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "Any new scope should have a container with no non-enumerable child nodes."); michael@0: michael@0: ok(!testScope.expanded, michael@0: "Any new created scope should be initially collapsed."); michael@0: ok(testScope.visible, michael@0: "Any new created scope should be initially visible."); michael@0: michael@0: let expandCallbackArg = null; michael@0: let collapseCallbackArg = null; michael@0: let toggleCallbackArg = null; michael@0: let hideCallbackArg = null; michael@0: let showCallbackArg = null; michael@0: michael@0: testScope.onexpand = aScope => expandCallbackArg = aScope; michael@0: testScope.oncollapse = aScope => collapseCallbackArg = aScope; michael@0: testScope.ontoggle = aScope => toggleCallbackArg = aScope; michael@0: testScope.onhide = aScope => hideCallbackArg = aScope; michael@0: testScope.onshow = aScope => showCallbackArg = aScope; michael@0: michael@0: testScope.expand(); michael@0: ok(testScope.expanded, michael@0: "The testScope shouldn't be collapsed anymore."); michael@0: is(expandCallbackArg, testScope, michael@0: "The expandCallback wasn't called as it should."); michael@0: michael@0: testScope.collapse(); michael@0: ok(!testScope.expanded, michael@0: "The testScope should be collapsed again."); michael@0: is(collapseCallbackArg, testScope, michael@0: "The collapseCallback wasn't called as it should."); michael@0: michael@0: testScope.expanded = true; michael@0: ok(testScope.expanded, michael@0: "The testScope shouldn't be collapsed anymore."); michael@0: michael@0: testScope.toggle(); michael@0: ok(!testScope.expanded, michael@0: "The testScope should be collapsed again."); michael@0: is(toggleCallbackArg, testScope, michael@0: "The toggleCallback wasn't called as it should."); michael@0: michael@0: testScope.hide(); michael@0: ok(!testScope.visible, michael@0: "The testScope should be invisible after hiding."); michael@0: is(hideCallbackArg, testScope, michael@0: "The hideCallback wasn't called as it should."); michael@0: michael@0: testScope.show(); michael@0: ok(testScope.visible, michael@0: "The testScope should be visible again."); michael@0: is(showCallbackArg, testScope, michael@0: "The showCallback wasn't called as it should."); michael@0: michael@0: testScope.visible = false; michael@0: ok(!testScope.visible, michael@0: "The testScope should be invisible after hiding."); michael@0: ok(!testScope.expanded, michael@0: "The testScope should remember it is collapsed even if it is hidden."); michael@0: michael@0: testScope.visible = true; michael@0: ok(testScope.visible, michael@0: "The testScope should be visible after reshowing."); michael@0: ok(!testScope.expanded, michael@0: "The testScope should remember it is collapsed after it is reshown."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown", button: 1 }, michael@0: testScope.target.querySelector(".title"), michael@0: aPanel.panelWin); michael@0: michael@0: ok(!testScope.expanded, michael@0: "Clicking the testScope title with the right mouse button should't expand it."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: testScope.target.querySelector(".title"), michael@0: aPanel.panelWin); michael@0: michael@0: ok(testScope.expanded, michael@0: "Clicking the testScope title should expand it."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: testScope.target.querySelector(".title"), michael@0: aPanel.panelWin); michael@0: michael@0: ok(!testScope.expanded, michael@0: "Clicking again the testScope title should collapse it."); michael@0: michael@0: closeDebuggerAndFinish(aPanel); michael@0: }); michael@0: }