зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1273941 - replace uses of promise.defer in devtools/client/framework; r=jryans
MozReview-Commit-ID: GwgbcXOmvtK --HG-- extra : transplant_source : %21MF%10yF%AC%01%D3%3C%A3%95fF%CA%7Ct%A6%92w
This commit is contained in:
Родитель
16d4051c4f
Коммит
abf6180c9f
|
@ -6,7 +6,7 @@
|
|||
|
||||
const {Cc, Ci, Cu} = require("chrome");
|
||||
const Services = require("Services");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
|
||||
function l10n(name) {
|
||||
const bundle = Services.strings.createBundle("chrome://devtools/locale/toolbox.properties");
|
||||
|
@ -42,7 +42,7 @@ function handleThreadState(toolbox, event, packet) {
|
|||
}
|
||||
|
||||
function attachThread(toolbox) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
let target = toolbox.target;
|
||||
let { form: { chromeDebugger, actor } } = target;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
const {Cc, Ci, Cu} = require("chrome");
|
||||
const Services = require("Services");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
const Telemetry = require("devtools/client/shared/telemetry");
|
||||
const { gDevTools } = require("./devtools");
|
||||
const { when: unload } = require("sdk/system/unload");
|
||||
|
@ -237,7 +238,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
|
|||
let transport = DebuggerServer.connectPipe();
|
||||
let client = new DebuggerClient(transport);
|
||||
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
client.connect().then(() => {
|
||||
client.mainRoot.listProcesses(response => {
|
||||
// Do nothing if there is only one process, the parent process.
|
||||
|
@ -374,7 +375,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
|
|||
/**
|
||||
* The deferred promise will be resolved by WebIDE's UI.init()
|
||||
*/
|
||||
isWebIDEInitialized: promise.defer(),
|
||||
isWebIDEInitialized: defer(),
|
||||
|
||||
/**
|
||||
* Uninstall WebIDE widget
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
const Services = require("Services");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
|
||||
// Load gDevToolsBrowser toolbox lazily as they need gDevTools to be fully initialized
|
||||
loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true);
|
||||
|
@ -393,7 +394,7 @@ DevTools.prototype = {
|
|||
* The toolbox that was opened
|
||||
*/
|
||||
showToolbox: function (target, toolId, hostType, hostOptions) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
let toolbox = this._toolboxes.get(target);
|
||||
if (toolbox) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
const { Ci } = require("chrome");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const Services = require("Services");
|
||||
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
@ -187,7 +188,7 @@ TabTarget.prototype = {
|
|||
"remote tabs.");
|
||||
}
|
||||
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
if (this._protocolDescription &&
|
||||
this._protocolDescription.types[actorName]) {
|
||||
|
@ -369,7 +370,7 @@ TabTarget.prototype = {
|
|||
return this._remote.promise;
|
||||
}
|
||||
|
||||
this._remote = promise.defer();
|
||||
this._remote = defer();
|
||||
|
||||
if (this.isLocalTab) {
|
||||
// Since a remote protocol connection will be made, let's start the
|
||||
|
@ -553,7 +554,7 @@ TabTarget.prototype = {
|
|||
return this._destroyer.promise;
|
||||
}
|
||||
|
||||
this._destroyer = promise.defer();
|
||||
this._destroyer = defer();
|
||||
|
||||
// Before taking any action, notify listeners that destruction is imminent.
|
||||
this.emit("close");
|
||||
|
@ -622,7 +623,7 @@ TabTarget.prototype = {
|
|||
* @see TabActor.prototype.onResolveLocation
|
||||
*/
|
||||
resolveLocation(loc) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
this.client.request(Object.assign({
|
||||
to: this._form.actor,
|
||||
|
|
|
@ -237,7 +237,7 @@ function DevToolPanel(iframeWindow, toolbox) {
|
|||
|
||||
DevToolPanel.prototype = {
|
||||
open: function () {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
executeSoon(() => {
|
||||
this._isReady = true;
|
||||
|
@ -263,6 +263,6 @@ DevToolPanel.prototype = {
|
|||
_isReady: false,
|
||||
|
||||
destroy: function DTI_destroy() {
|
||||
return promise.defer(null);
|
||||
return defer(null);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ function runTests(aTab) {
|
|||
url: "about:blank",
|
||||
label: "someLabel",
|
||||
build: function (iframeWindow, toolbox) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
executeSoon(() => {
|
||||
deferred.resolve({
|
||||
target: toolbox.target,
|
||||
|
|
|
@ -90,7 +90,7 @@ function createScript(url) {
|
|||
|
||||
function waitForSourceShown(debuggerPanel, url) {
|
||||
let { panelWin } = debuggerPanel;
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
info(`Waiting for source ${url} to be shown in the debugger...`);
|
||||
panelWin.on(panelWin.EVENTS.SOURCE_SHOWN, function onSourceShown(_, source) {
|
||||
|
|
|
@ -116,7 +116,7 @@ function* testSelect(select) {
|
|||
continue;
|
||||
}
|
||||
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
gDevTools.once("pref-changed", (event, data) => {
|
||||
if (data.pref == pref) {
|
||||
ok(true, "Correct pref was changed");
|
||||
|
@ -136,7 +136,7 @@ function* testSelect(select) {
|
|||
}
|
||||
|
||||
function* testMouseClick(node, prefValue) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
let pref = node.getAttribute("data-pref");
|
||||
gDevTools.once("pref-changed", (event, data) => {
|
||||
|
@ -218,7 +218,7 @@ function* testToggleTools() {
|
|||
}
|
||||
|
||||
function* toggleTool(node) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
let toolId = node.getAttribute("id");
|
||||
if (node.checked) {
|
||||
|
|
|
@ -26,7 +26,7 @@ function test() {
|
|||
}
|
||||
|
||||
function testPrefsAreRespectedWhenReopeningToolbox() {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||
|
||||
info("Closing toolbox to test after reopening");
|
||||
|
@ -45,7 +45,7 @@ function testPrefsAreRespectedWhenReopeningToolbox() {
|
|||
}
|
||||
|
||||
function testSelectTool(devtoolsToolbox) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
info("Selecting the options panel");
|
||||
|
||||
toolbox = devtoolsToolbox;
|
||||
|
|
|
@ -87,7 +87,7 @@ function toggleServiceWorkersTestingCheckbox() {
|
|||
}
|
||||
|
||||
function reload() {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
|
||||
gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
|
||||
|
|
|
@ -30,7 +30,7 @@ function test() {
|
|||
label: "FAKE TOOL!!!",
|
||||
isTargetSupported: () => true,
|
||||
build: function (iframeWindow, toolbox) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
executeSoon(() => {
|
||||
deferred.resolve({
|
||||
target: toolbox.target,
|
||||
|
|
|
@ -25,7 +25,7 @@ function test() {
|
|||
label: "Test tool",
|
||||
isTargetSupported: () => true,
|
||||
build: function (iframeWindow, toolbox) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
executeSoon(() => {
|
||||
deferred.resolve({
|
||||
target: toolbox.target,
|
||||
|
|
|
@ -65,7 +65,7 @@ function runTools(target) {
|
|||
}
|
||||
|
||||
function getClient() {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
|
@ -79,7 +79,7 @@ function getClient() {
|
|||
}
|
||||
|
||||
function getTarget(client) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
client.listTabs(tabList => {
|
||||
let target = TargetFactory.forRemoteTab({
|
||||
|
|
|
@ -37,7 +37,7 @@ function test() {
|
|||
|
||||
// navigate to different local url and check title
|
||||
.then(function () {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
target.once("navigate", () => deferred.resolve());
|
||||
gBrowser.loadURI(URL_2);
|
||||
return deferred.promise;
|
||||
|
@ -46,7 +46,7 @@ function test() {
|
|||
|
||||
// navigate to a real url and check title
|
||||
.then(() => {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
target.once("navigate", () => deferred.resolve());
|
||||
gBrowser.loadURI(URL_3);
|
||||
return deferred.promise;
|
||||
|
|
|
@ -56,7 +56,7 @@ function getSourceActor(aSources, aURL) {
|
|||
* The new window object that holds Scratchpad.
|
||||
*/
|
||||
function* openScratchpadWindow() {
|
||||
let { promise: p, resolve } = promise.defer();
|
||||
let { promise: p, resolve } = defer();
|
||||
let win = ScratchpadManager.openScratchpad();
|
||||
|
||||
yield once(win, "load");
|
||||
|
@ -82,7 +82,7 @@ function waitForContentMessage(name) {
|
|||
|
||||
let mm = gBrowser.selectedBrowser.messageManager;
|
||||
|
||||
let def = promise.defer();
|
||||
let def = defer();
|
||||
mm.addMessageListener(name, function onMessage(msg) {
|
||||
mm.removeMessageListener(name, onMessage);
|
||||
def.resolve(msg.data);
|
||||
|
|
|
@ -88,7 +88,7 @@ function* setDisableCacheCheckboxChecked(tabX, state) {
|
|||
}
|
||||
|
||||
function reloadTab(tabX) {
|
||||
let def = promise.defer();
|
||||
let def = defer();
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
|
||||
// once() doesn't work here so we use a standard handler instead.
|
||||
|
|
|
@ -203,7 +203,7 @@ function synthesizeKeyShortcut(key, target) {
|
|||
function waitForNEvents(target, eventName, numTimes, useCapture = false) {
|
||||
info("Waiting for event: '" + eventName + "' on " + target + ".");
|
||||
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
let count = 0;
|
||||
|
||||
for (let [add, remove] of [
|
||||
|
@ -262,7 +262,7 @@ function loadHelperScript(filePath) {
|
|||
* @return {Promise}
|
||||
*/
|
||||
function waitForTick() {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
executeSoon(deferred.resolve);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ function waitForTick() {
|
|||
* @return A promise that resolves when the time is passed
|
||||
*/
|
||||
function wait(ms) {
|
||||
let def = promise.defer();
|
||||
let def = defer();
|
||||
content.setTimeout(def.resolve, ms);
|
||||
return def.promise;
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ function evalInDebuggee(mm, script) {
|
|||
* callback is invoked.
|
||||
*/
|
||||
function waitForContextMenu(popup, button, onShown, onHidden) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
function onPopupShown() {
|
||||
info("onPopupShown");
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
/* eslint no-unused-vars: [2, {"vars": "local"}] */
|
||||
/* import-globals-from ./shared-head.js */
|
||||
// Currently this file expects "promise" to be imported into scope.
|
||||
// Currently this file expects "defer" to be imported into scope.
|
||||
|
||||
// Common utility functions for working with Redux stores. The file is meant
|
||||
// to be safe to load in both mochitest and xpcshell environments.
|
||||
|
@ -38,7 +38,7 @@ function commonLog(message) {
|
|||
* Resolved once the store reaches the expected state.
|
||||
*/
|
||||
function waitUntilState(store, predicate) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
let unsubscribe = store.subscribe(check);
|
||||
|
||||
commonLog(`Waiting for state predicate "${predicate}"`);
|
||||
|
@ -66,7 +66,7 @@ function waitUntilState(store, predicate) {
|
|||
* Resolved once the expected action is emitted by the store.
|
||||
*/
|
||||
function waitUntilAction(store, actionType) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
let unsubscribe = store.subscribe(check);
|
||||
let history = store.history;
|
||||
let index = history.length;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
const EventEmitter = require("devtools/shared/event-emitter");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
const Services = require("Services");
|
||||
const {DOMHelpers} = require("resource://devtools/client/shared/DOMHelpers.jsm");
|
||||
|
||||
|
@ -53,7 +54,7 @@ BottomHost.prototype = {
|
|||
* Create a box at the bottom of the host tab.
|
||||
*/
|
||||
create: function () {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
let gBrowser = this.hostTab.ownerDocument.defaultView.gBrowser;
|
||||
let ownerDocument = gBrowser.ownerDocument;
|
||||
|
@ -194,7 +195,7 @@ SidebarHost.prototype = {
|
|||
* Create a box in the sidebar of the host tab.
|
||||
*/
|
||||
create: function () {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
let gBrowser = this.hostTab.ownerDocument.defaultView.gBrowser;
|
||||
let ownerDocument = gBrowser.ownerDocument;
|
||||
|
@ -277,7 +278,7 @@ WindowHost.prototype = {
|
|||
* Create a new xul window to contain the toolbox.
|
||||
*/
|
||||
create: function () {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
|
||||
let flags = "chrome,centerscreen,resizable,dialog=no";
|
||||
let win = Services.ww.openWindow(null, this.WINDOW_URL, "_blank",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"use strict";
|
||||
|
||||
const Services = require("Services");
|
||||
const promise = require("promise");
|
||||
const defer = require("devtools/shared/defer");
|
||||
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const {Task} = require("devtools/shared/task");
|
||||
const {gDevTools} = require("devtools/client/framework/devtools");
|
||||
|
@ -396,7 +396,7 @@ OptionsPanel.prototype = {
|
|||
return this.destroyPromise;
|
||||
}
|
||||
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
this.destroyPromise = deferred.promise;
|
||||
|
||||
this._removeListeners();
|
||||
|
|
|
@ -14,6 +14,7 @@ const HTML_NS = "http://www.w3.org/1999/xhtml";
|
|||
|
||||
var {Cc, Ci, Cu} = require("chrome");
|
||||
var promise = require("promise");
|
||||
var defer = require("devtools/shared/defer");
|
||||
var Services = require("Services");
|
||||
var {Task} = require("devtools/shared/task");
|
||||
var {gDevTools} = require("devtools/client/framework/devtools");
|
||||
|
@ -234,7 +235,7 @@ Toolbox.prototype = {
|
|||
* A promise that resolves once the panel is ready.
|
||||
*/
|
||||
getPanelWhenReady: function (id) {
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
let panel = this.getPanel(id);
|
||||
if (panel) {
|
||||
deferred.resolve(panel);
|
||||
|
@ -364,7 +365,7 @@ Toolbox.prototype = {
|
|||
open: function () {
|
||||
return Task.spawn(function* () {
|
||||
let iframe = yield this._host.create();
|
||||
let domReady = promise.defer();
|
||||
let domReady = defer();
|
||||
|
||||
// Prevent reloading the document when the toolbox is opened in a tab
|
||||
let location = iframe.contentWindow.location.href;
|
||||
|
@ -1189,7 +1190,7 @@ Toolbox.prototype = {
|
|||
});
|
||||
}
|
||||
|
||||
let deferred = promise.defer();
|
||||
let deferred = defer();
|
||||
let iframe = this.doc.getElementById("toolbox-panel-iframe-" + id);
|
||||
|
||||
if (iframe) {
|
||||
|
@ -1257,7 +1258,7 @@ Toolbox.prototype = {
|
|||
if (typeof panel.open == "function") {
|
||||
built = panel.open();
|
||||
} else {
|
||||
let buildDeferred = promise.defer();
|
||||
let buildDeferred = defer();
|
||||
buildDeferred.resolve(panel);
|
||||
built = buildDeferred.promise;
|
||||
}
|
||||
|
@ -2188,7 +2189,7 @@ Toolbox.prototype = {
|
|||
return this._performanceFrontConnection.promise;
|
||||
}
|
||||
|
||||
this._performanceFrontConnection = promise.defer();
|
||||
this._performanceFrontConnection = defer();
|
||||
this._performance = createPerformanceFront(this._target);
|
||||
yield this.performance.connect();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ var { OS } = require("resource://gre/modules/osfile.jsm");
|
|||
var { FileUtils } = require("resource://gre/modules/FileUtils.jsm");
|
||||
var { TargetFactory } = require("devtools/client/framework/target");
|
||||
var promise = require("promise");
|
||||
var defer = require("devtools/shared/defer");
|
||||
var { Task } = require("devtools/shared/task");
|
||||
var { expectState } = require("devtools/server/actors/common");
|
||||
var HeapSnapshotFileUtils = require("devtools/shared/heapsnapshot/HeapSnapshotFileUtils");
|
||||
|
|
Загрузка…
Ссылка в новой задаче