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 | * Tests the variable inspection popup behaves correctly when switching |
michael@0 | 6 | * between simple and complex objects. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; |
michael@0 | 10 | |
michael@0 | 11 | function test() { |
michael@0 | 12 | Task.spawn(function() { |
michael@0 | 13 | let [tab, debuggee, panel] = yield initDebugger(TAB_URL); |
michael@0 | 14 | let win = panel.panelWin; |
michael@0 | 15 | let bubble = win.DebuggerView.VariableBubble; |
michael@0 | 16 | let tooltip = bubble._tooltip.panel; |
michael@0 | 17 | |
michael@0 | 18 | function verifySimpleContents(textContent, className) { |
michael@0 | 19 | is(tooltip.querySelectorAll(".variables-view-container").length, 0, |
michael@0 | 20 | "There should be no variables view container added to the tooltip."); |
michael@0 | 21 | is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1, |
michael@0 | 22 | "There should be one simple text node added to the tooltip."); |
michael@0 | 23 | |
michael@0 | 24 | is(tooltip.querySelector(".devtools-tooltip-simple-text").textContent, textContent, |
michael@0 | 25 | "The inspected property's value is correct."); |
michael@0 | 26 | ok(tooltip.querySelector(".devtools-tooltip-simple-text").className.contains(className), |
michael@0 | 27 | "The inspected property's value is colorized correctly."); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | function verifyComplexContents(propertyCount) { |
michael@0 | 31 | is(tooltip.querySelectorAll(".variables-view-container").length, 1, |
michael@0 | 32 | "There should be one variables view container added to the tooltip."); |
michael@0 | 33 | is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 0, |
michael@0 | 34 | "There should be no simple text node added to the tooltip."); |
michael@0 | 35 | |
michael@0 | 36 | is(tooltip.querySelectorAll(".variables-view-scope[untitled]").length, 1, |
michael@0 | 37 | "There should be one scope with no header displayed."); |
michael@0 | 38 | is(tooltip.querySelectorAll(".variables-view-variable[untitled]").length, 1, |
michael@0 | 39 | "There should be one variable with no header displayed."); |
michael@0 | 40 | |
michael@0 | 41 | ok(tooltip.querySelectorAll(".variables-view-property").length >= propertyCount, |
michael@0 | 42 | "There should be some properties displayed."); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | // Allow this generator function to yield first. |
michael@0 | 46 | executeSoon(() => debuggee.start()); |
michael@0 | 47 | yield waitForSourceAndCaretAndScopes(panel, ".html", 24); |
michael@0 | 48 | |
michael@0 | 49 | // Inspect variables. |
michael@0 | 50 | yield openVarPopup(panel, { line: 15, ch: 12 }); |
michael@0 | 51 | verifySimpleContents("1", "token-number"); |
michael@0 | 52 | |
michael@0 | 53 | yield reopenVarPopup(panel, { line: 16, ch: 12 }, true); |
michael@0 | 54 | verifyComplexContents(2); |
michael@0 | 55 | |
michael@0 | 56 | yield reopenVarPopup(panel, { line: 19, ch: 10 }); |
michael@0 | 57 | verifySimpleContents("42", "token-number"); |
michael@0 | 58 | |
michael@0 | 59 | yield reopenVarPopup(panel, { line: 31, ch: 10 }, true); |
michael@0 | 60 | verifyComplexContents(100); |
michael@0 | 61 | |
michael@0 | 62 | yield resumeDebuggerThenCloseAndFinish(panel); |
michael@0 | 63 | }); |
michael@0 | 64 | } |