browser/devtools/debugger/test/browser_dbg_variables-view-edit-value.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Make sure that the editing variables or properties values works properly.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gVars;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gVars = gDebugger.DebuggerView.Variables;
    21     waitForSourceAndCaretAndScopes(gPanel, ".html", 24)
    22       .then(() => initialChecks())
    23       .then(() => testModification("a", "1"))
    24       .then(() => testModification("{ a: 1 }", "Object"))
    25       .then(() => testModification("[a]", "Array[1]"))
    26       .then(() => testModification("b", "Object"))
    27       .then(() => testModification("b.a", "1"))
    28       .then(() => testModification("c.a", "1"))
    29       .then(() => testModification("Infinity", "Infinity"))
    30       .then(() => testModification("NaN", "NaN"))
    31       .then(() => testModification("new Function", "anonymous()"))
    32       .then(() => testModification("+0", "0"))
    33       .then(() => testModification("-0", "-0"))
    34       .then(() => testModification("Object.keys({})", "Array[0]"))
    35       .then(() => testModification("document.title", '"Debugger test page"'))
    36       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    37       .then(null, aError => {
    38         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    39       });
    41     EventUtils.sendMouseEvent({ type: "click" },
    42       gDebuggee.document.querySelector("button"),
    43       gDebuggee);
    44   });
    45 }
    47 function initialChecks() {
    48   let localScope = gVars.getScopeAtIndex(0);
    49   let aVar = localScope.get("a");
    51   is(aVar.target.querySelector(".name").getAttribute("value"), "a",
    52     "Should have the right name for 'a'.");
    53   is(aVar.target.querySelector(".value").getAttribute("value"), "1",
    54     "Should have the right initial value for 'a'.");
    55 }
    57 function testModification(aNewValue, aNewResult) {
    58   let localScope = gVars.getScopeAtIndex(0);
    59   let aVar = localScope.get("a");
    61   // Allow the target variable to get painted, so that clicking on
    62   // its value would scroll the new textbox node into view.
    63   executeSoon(() => {
    64     let varValue = aVar.target.querySelector(".title > .value");
    65     EventUtils.sendMouseEvent({ type: "mousedown" }, varValue, gDebugger);
    67     let varInput = aVar.target.querySelector(".title > .element-value-input");
    68     setText(varInput, aNewValue);
    69     EventUtils.sendKey("RETURN", gDebugger);
    70   });
    72   return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
    73     let localScope = gVars.getScopeAtIndex(0);
    74     let aVar = localScope.get("a");
    76     is(aVar.target.querySelector(".name").getAttribute("value"), "a",
    77       "Should have the right name for 'a'.");
    78     is(aVar.target.querySelector(".value").getAttribute("value"), aNewResult,
    79       "Should have the right new value for 'a'.");
    80   });
    81 }
    83 registerCleanupFunction(function() {
    84   gTab = null;
    85   gDebuggee = null;
    86   gPanel = null;
    87   gDebugger = null;
    88   gVars = null;
    89 });

mercurial