mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-28 13:40:17 -10:00
In prevision of Promise.jsm removal, use defer helper module instead of Promise.jsm as that's the only one feature that DOM Promise don't support. PART2: Substitutes promise.defer usages with defer $ sed -i 's/promise.defer/defer/gI' $(egrep -lir "promise.defer\(\)" devtools) Reset modification to the following files as they are using deprecated syncable promises as we don't want to touch them. http://searchfox.org/mozilla-central/search?q=deprecated-sync-thenables&case=true®exp=false&path= $ git checkout devtools/client/debugger/test/mochitest/ $ git checkout devtools/shared/client/main.js $ git checkout devtools/client/debugger/ $ git checkout devtools/server/main.js MozReview-Commit-ID: DGN5ae68wtn
92 lines
2.8 KiB
JavaScript
92 lines
2.8 KiB
JavaScript
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
// Check that inspecting an optimized out variable works when execution is
|
|
// paused.
|
|
|
|
"use strict";
|
|
|
|
// Force the old debugger UI since it's directly used (see Bug 1301705)
|
|
Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
|
|
registerCleanupFunction(function* () {
|
|
Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
|
|
});
|
|
|
|
function test() {
|
|
Task.spawn(function* () {
|
|
const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
|
|
"test/test-closure-optimized-out.html";
|
|
let {tab} = yield loadTab(TEST_URI);
|
|
let hud = yield openConsole(tab);
|
|
let { toolbox, panel, panelWin } = yield openDebugger();
|
|
|
|
let sources = panelWin.DebuggerView.Sources;
|
|
yield panel.addBreakpoint({ actor: sources.values[0], line: 18 });
|
|
yield ensureThreadClientState(panel, "resumed");
|
|
|
|
let fetchedScopes = panelWin.once(panelWin.EVENTS.FETCHED_SCOPES);
|
|
|
|
// Cause the debuggee to pause
|
|
ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
|
|
let button = content.document.querySelector("button");
|
|
button.click();
|
|
});
|
|
|
|
yield fetchedScopes;
|
|
ok(true, "Scopes were fetched");
|
|
|
|
yield toolbox.selectTool("webconsole");
|
|
|
|
// This is the meat of the test: evaluate the optimized out variable.
|
|
hud.jsterm.execute("upvar");
|
|
yield waitForMessages({
|
|
webconsole: hud,
|
|
messages: [{
|
|
text: "optimized out",
|
|
category: CATEGORY_OUTPUT,
|
|
}]
|
|
});
|
|
|
|
finishTest();
|
|
}).catch(aError => {
|
|
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
|
});
|
|
}
|
|
|
|
// Debugger helper functions stolen from devtools/client/debugger/test/head.js.
|
|
|
|
function ensureThreadClientState(aPanel, aState) {
|
|
let thread = aPanel.panelWin.gThreadClient;
|
|
let state = thread.state;
|
|
|
|
info("Thread is: '" + state + "'.");
|
|
|
|
if (state == aState) {
|
|
return promise.resolve(null);
|
|
}
|
|
return waitForThreadEvents(aPanel, aState);
|
|
}
|
|
|
|
function waitForThreadEvents(aPanel, aEventName, aEventRepeat = 1) {
|
|
info("Waiting for thread event: '" + aEventName + "' to fire: " +
|
|
aEventRepeat + " time(s).");
|
|
|
|
let deferred = defer();
|
|
let thread = aPanel.panelWin.gThreadClient;
|
|
let count = 0;
|
|
|
|
thread.addListener(aEventName, function onEvent(eventName, ...args) {
|
|
info("Thread event '" + eventName + "' fired: " + (++count) + " time(s).");
|
|
|
|
if (count == aEventRepeat) {
|
|
ok(true, "Enough '" + eventName + "' thread events have been fired.");
|
|
thread.removeListener(eventName, onEvent);
|
|
deferred.resolve.apply(deferred, args);
|
|
}
|
|
});
|
|
|
|
return deferred.promise;
|
|
}
|