Wed, 31 Dec 2014 06:09:35 +0100
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 | * Test that non-enumerable variables and properties can be hidden |
michael@0 | 6 | * in the variables view. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 15 | gTab = aTab; |
michael@0 | 16 | gDebuggee = aDebuggee; |
michael@0 | 17 | gPanel = aPanel; |
michael@0 | 18 | gDebugger = gPanel.panelWin; |
michael@0 | 19 | |
michael@0 | 20 | waitForSourceAndCaretAndScopes(gPanel, ".html", 14).then(performTest); |
michael@0 | 21 | gDebuggee.simpleCall(); |
michael@0 | 22 | }); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function performTest() { |
michael@0 | 26 | let testScope = gDebugger.DebuggerView.Variables.addScope("test-scope"); |
michael@0 | 27 | let testVar = testScope.addItem("foo"); |
michael@0 | 28 | |
michael@0 | 29 | testVar.addItems({ |
michael@0 | 30 | foo: { |
michael@0 | 31 | value: "bar", |
michael@0 | 32 | enumerable: true |
michael@0 | 33 | }, |
michael@0 | 34 | bar: { |
michael@0 | 35 | value: "foo", |
michael@0 | 36 | enumerable: false |
michael@0 | 37 | } |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | // Expand the scope and variable. |
michael@0 | 41 | testScope.expand(); |
michael@0 | 42 | testVar.expand(); |
michael@0 | 43 | |
michael@0 | 44 | // Expanding the non-enumerable container is synchronously dispatched |
michael@0 | 45 | // on the main thread, so wait for the next tick. |
michael@0 | 46 | executeSoon(() => { |
michael@0 | 47 | let details = testVar._enum; |
michael@0 | 48 | let nonenum = testVar._nonenum; |
michael@0 | 49 | |
michael@0 | 50 | is(details.childNodes.length, 1, |
michael@0 | 51 | "There should be just one property in the .details container."); |
michael@0 | 52 | ok(details.hasAttribute("open"), |
michael@0 | 53 | ".details container should be visible."); |
michael@0 | 54 | ok(nonenum.hasAttribute("open"), |
michael@0 | 55 | ".nonenum container should be visible."); |
michael@0 | 56 | is(nonenum.childNodes.length, 1, |
michael@0 | 57 | "There should be just one property in the .nonenum container."); |
michael@0 | 58 | |
michael@0 | 59 | // Uncheck 'show hidden properties'. |
michael@0 | 60 | gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); |
michael@0 | 61 | gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
michael@0 | 62 | |
michael@0 | 63 | ok(details.hasAttribute("open"), |
michael@0 | 64 | ".details container should stay visible."); |
michael@0 | 65 | ok(!nonenum.hasAttribute("open"), |
michael@0 | 66 | ".nonenum container should become hidden."); |
michael@0 | 67 | |
michael@0 | 68 | // Check 'show hidden properties'. |
michael@0 | 69 | gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); |
michael@0 | 70 | gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
michael@0 | 71 | |
michael@0 | 72 | ok(details.hasAttribute("open"), |
michael@0 | 73 | ".details container should stay visible."); |
michael@0 | 74 | ok(nonenum.hasAttribute("open"), |
michael@0 | 75 | ".nonenum container should become visible."); |
michael@0 | 76 | |
michael@0 | 77 | // Collapse the variable. This is done on the current tick. |
michael@0 | 78 | testVar.collapse(); |
michael@0 | 79 | |
michael@0 | 80 | ok(!details.hasAttribute("open"), |
michael@0 | 81 | ".details container should be hidden."); |
michael@0 | 82 | ok(!nonenum.hasAttribute("open"), |
michael@0 | 83 | ".nonenum container should be hidden."); |
michael@0 | 84 | |
michael@0 | 85 | // Uncheck 'show hidden properties'. |
michael@0 | 86 | gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); |
michael@0 | 87 | gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
michael@0 | 88 | |
michael@0 | 89 | ok(!details.hasAttribute("open"), |
michael@0 | 90 | ".details container should stay hidden."); |
michael@0 | 91 | ok(!nonenum.hasAttribute("open"), |
michael@0 | 92 | ".nonenum container should stay hidden."); |
michael@0 | 93 | |
michael@0 | 94 | // Check 'show hidden properties'. |
michael@0 | 95 | gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); |
michael@0 | 96 | gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
michael@0 | 97 | |
michael@0 | 98 | resumeDebuggerThenCloseAndFinish(gPanel); |
michael@0 | 99 | }); |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | registerCleanupFunction(function() { |
michael@0 | 103 | gTab = null; |
michael@0 | 104 | gDebuggee = null; |
michael@0 | 105 | gPanel = null; |
michael@0 | 106 | gDebugger = null; |
michael@0 | 107 | }); |