browser/devtools/debugger/test/browser_dbg_variables-view-popup-07.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-popup-07.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests the variable inspection popup behaves correctly when switching
     1.9 + * between simple and complex objects.
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
    1.13 +
    1.14 +function test() {
    1.15 +  Task.spawn(function() {
    1.16 +    let [tab, debuggee, panel] = yield initDebugger(TAB_URL);
    1.17 +    let win = panel.panelWin;
    1.18 +    let bubble = win.DebuggerView.VariableBubble;
    1.19 +    let tooltip = bubble._tooltip.panel;
    1.20 +
    1.21 +    function verifySimpleContents(textContent, className) {
    1.22 +      is(tooltip.querySelectorAll(".variables-view-container").length, 0,
    1.23 +        "There should be no variables view container added to the tooltip.");
    1.24 +      is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 1,
    1.25 +        "There should be one simple text node added to the tooltip.");
    1.26 +
    1.27 +      is(tooltip.querySelector(".devtools-tooltip-simple-text").textContent, textContent,
    1.28 +        "The inspected property's value is correct.");
    1.29 +      ok(tooltip.querySelector(".devtools-tooltip-simple-text").className.contains(className),
    1.30 +        "The inspected property's value is colorized correctly.");
    1.31 +    }
    1.32 +
    1.33 +    function verifyComplexContents(propertyCount) {
    1.34 +      is(tooltip.querySelectorAll(".variables-view-container").length, 1,
    1.35 +        "There should be one variables view container added to the tooltip.");
    1.36 +      is(tooltip.querySelectorAll(".devtools-tooltip-simple-text").length, 0,
    1.37 +        "There should be no simple text node added to the tooltip.");
    1.38 +
    1.39 +      is(tooltip.querySelectorAll(".variables-view-scope[untitled]").length, 1,
    1.40 +        "There should be one scope with no header displayed.");
    1.41 +      is(tooltip.querySelectorAll(".variables-view-variable[untitled]").length, 1,
    1.42 +        "There should be one variable with no header displayed.");
    1.43 +
    1.44 +      ok(tooltip.querySelectorAll(".variables-view-property").length >= propertyCount,
    1.45 +        "There should be some properties displayed.");
    1.46 +    }
    1.47 +
    1.48 +    // Allow this generator function to yield first.
    1.49 +    executeSoon(() => debuggee.start());
    1.50 +    yield waitForSourceAndCaretAndScopes(panel, ".html", 24);
    1.51 +
    1.52 +    // Inspect variables.
    1.53 +    yield openVarPopup(panel, { line: 15, ch: 12 });
    1.54 +    verifySimpleContents("1", "token-number");
    1.55 +
    1.56 +    yield reopenVarPopup(panel, { line: 16, ch: 12 }, true);
    1.57 +    verifyComplexContents(2);
    1.58 +
    1.59 +    yield reopenVarPopup(panel, { line: 19, ch: 10 });
    1.60 +    verifySimpleContents("42", "token-number");
    1.61 +
    1.62 +    yield reopenVarPopup(panel, { line: 31, ch: 10 }, true);
    1.63 +    verifyComplexContents(100);
    1.64 +
    1.65 +    yield resumeDebuggerThenCloseAndFinish(panel);
    1.66 +  });
    1.67 +}

mercurial