browser/devtools/debugger/test/browser_dbg_variables-view-edit-getset-02.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-edit-getset-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,105 @@
     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 + * Make sure that the variables view is able to override getter properties
     1.9 + * to plain value properties.
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
    1.13 +
    1.14 +let gTab, gDebuggee, gPanel, gDebugger;
    1.15 +let gL10N, gEditor, gVars, gWatch;
    1.16 +
    1.17 +function test() {
    1.18 +  // Debug test slaves are a bit slow at this test.
    1.19 +  requestLongerTimeout(2);
    1.20 +
    1.21 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.22 +    gTab = aTab;
    1.23 +    gDebuggee = aDebuggee;
    1.24 +    gPanel = aPanel;
    1.25 +    gDebugger = gPanel.panelWin;
    1.26 +    gL10N = gDebugger.L10N;
    1.27 +    gEditor = gDebugger.DebuggerView.editor;
    1.28 +    gVars = gDebugger.DebuggerView.Variables;
    1.29 +    gWatch = gDebugger.DebuggerView.WatchExpressions;
    1.30 +
    1.31 +    gVars.switch = function() {};
    1.32 +    gVars.delete = function() {};
    1.33 +
    1.34 +    waitForSourceAndCaretAndScopes(gPanel, ".html", 24)
    1.35 +      .then(() => addWatchExpression())
    1.36 +      .then(() => testEdit("\"xlerb\"", "xlerb"))
    1.37 +      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    1.38 +      .then(null, aError => {
    1.39 +        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.40 +      });
    1.41 +
    1.42 +    EventUtils.sendMouseEvent({ type: "click" },
    1.43 +      gDebuggee.document.querySelector("button"),
    1.44 +      gDebuggee);
    1.45 +  });
    1.46 +}
    1.47 +
    1.48 +function addWatchExpression() {
    1.49 +  let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS);
    1.50 +
    1.51 +  gWatch.addExpression("myVar.prop");
    1.52 +  gEditor.focus();
    1.53 +
    1.54 +  return finished;
    1.55 +}
    1.56 +
    1.57 +function testEdit(aString, aExpected) {
    1.58 +  let localScope = gVars.getScopeAtIndex(1);
    1.59 +  let myVar = localScope.get("myVar");
    1.60 +
    1.61 +  let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES).then(() => {
    1.62 +    let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS).then(() => {
    1.63 +      let exprScope = gVars.getScopeAtIndex(0);
    1.64 +
    1.65 +      ok(exprScope,
    1.66 +        "There should be a wach expressions scope in the variables view.");
    1.67 +      is(exprScope.name, gL10N.getStr("watchExpressionsScopeLabel"),
    1.68 +        "The scope's name should be marked as 'Watch Expressions'.");
    1.69 +      is(exprScope._store.size, 1,
    1.70 +        "There should be one evaluation available.");
    1.71 +
    1.72 +      is(exprScope.get("myVar.prop").value, aExpected,
    1.73 +        "The expression value is correct after the edit.");
    1.74 +    });
    1.75 +
    1.76 +    let editTarget = myVar.get("prop").target;
    1.77 +
    1.78 +    // Allow the target variable to get painted, so that clicking on
    1.79 +    // its value would scroll the new textbox node into view.
    1.80 +    executeSoon(() => {
    1.81 +      let varEdit = editTarget.querySelector(".title > .variables-view-edit");
    1.82 +      EventUtils.sendMouseEvent({ type: "mousedown" }, varEdit, gDebugger);
    1.83 +
    1.84 +      let varInput = editTarget.querySelector(".title > .element-value-input");
    1.85 +      setText(varInput, aString);
    1.86 +      EventUtils.sendKey("RETURN", gDebugger);
    1.87 +    });
    1.88 +
    1.89 +    return finished;
    1.90 +  });
    1.91 +
    1.92 +  myVar.expand();
    1.93 +  gVars.clearHierarchy();
    1.94 +
    1.95 +  return finished;
    1.96 +}
    1.97 +
    1.98 +registerCleanupFunction(function() {
    1.99 +  gTab = null;
   1.100 +  gDebuggee = null;
   1.101 +  gPanel = null;
   1.102 +  gDebugger = null;
   1.103 +  gL10N = null;
   1.104 +  gEditor = null;
   1.105 +  gVars = null;
   1.106 +  gWatch = null;
   1.107 +});
   1.108 +

mercurial