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