browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-02.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 variables view is able to override getter properties
     6  * to plain value properties.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    12 let gL10N, gEditor, gVars, gWatch;
    14 function test() {
    15   // Debug test slaves are a bit slow at this test.
    16   requestLongerTimeout(2);
    18   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    19     gTab = aTab;
    20     gDebuggee = aDebuggee;
    21     gPanel = aPanel;
    22     gDebugger = gPanel.panelWin;
    23     gL10N = gDebugger.L10N;
    24     gEditor = gDebugger.DebuggerView.editor;
    25     gVars = gDebugger.DebuggerView.Variables;
    26     gWatch = gDebugger.DebuggerView.WatchExpressions;
    28     gVars.switch = function() {};
    29     gVars.delete = function() {};
    31     waitForSourceAndCaretAndScopes(gPanel, ".html", 24)
    32       .then(() => addWatchExpression())
    33       .then(() => testEdit("\"xlerb\"", "xlerb"))
    34       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    35       .then(null, aError => {
    36         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    37       });
    39     EventUtils.sendMouseEvent({ type: "click" },
    40       gDebuggee.document.querySelector("button"),
    41       gDebuggee);
    42   });
    43 }
    45 function addWatchExpression() {
    46   let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS);
    48   gWatch.addExpression("myVar.prop");
    49   gEditor.focus();
    51   return finished;
    52 }
    54 function testEdit(aString, aExpected) {
    55   let localScope = gVars.getScopeAtIndex(1);
    56   let myVar = localScope.get("myVar");
    58   let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES).then(() => {
    59     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS).then(() => {
    60       let exprScope = gVars.getScopeAtIndex(0);
    62       ok(exprScope,
    63         "There should be a wach expressions scope in the variables view.");
    64       is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    65         "The scope's name should be marked as 'Watch Expressions'.");
    66       is(exprScope._store.size, 1,
    67         "There should be one evaluation available.");
    69       is(exprScope.get("myVar.prop").value, aExpected,
    70         "The expression value is correct after the edit.");
    71     });
    73     let editTarget = myVar.get("prop").target;
    75     // Allow the target variable to get painted, so that clicking on
    76     // its value would scroll the new textbox node into view.
    77     executeSoon(() => {
    78       let varEdit = editTarget.querySelector(".title > .variables-view-edit");
    79       EventUtils.sendMouseEvent({ type: "mousedown" }, varEdit, gDebugger);
    81       let varInput = editTarget.querySelector(".title > .element-value-input");
    82       setText(varInput, aString);
    83       EventUtils.sendKey("RETURN", gDebugger);
    84     });
    86     return finished;
    87   });
    89   myVar.expand();
    90   gVars.clearHierarchy();
    92   return finished;
    93 }
    95 registerCleanupFunction(function() {
    96   gTab = null;
    97   gDebuggee = null;
    98   gPanel = null;
    99   gDebugger = null;
   100   gL10N = null;
   101   gEditor = null;
   102   gVars = null;
   103   gWatch = null;
   104 });

mercurial