mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1368204 - convert uses of 'defer' to 'new Promise' in client/responsive.html; r=tromey
MozReview-Commit-ID: HnjT6j9yjW3 --HG-- extra : rebase_source : 7c1eedaaec2b5f9ac05517a3a0e2210cdbd80002
This commit is contained in:
parent
dede65c36c
commit
1f9d9f8cb7
@ -5,7 +5,6 @@
|
||||
"use strict";
|
||||
|
||||
const { Ci } = require("chrome");
|
||||
const promise = require("promise");
|
||||
const { Task } = require("devtools/shared/task");
|
||||
const { tunnelToInnerBrowser } = require("./tunnel");
|
||||
|
||||
@ -329,19 +328,18 @@ function addXULBrowserDecorations(browser) {
|
||||
}
|
||||
|
||||
function tabLoaded(tab) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
return new Promise(resolve => {
|
||||
function handle(event) {
|
||||
if (event.originalTarget != tab.linkedBrowser.contentDocument ||
|
||||
event.target.location.href == "about:blank") {
|
||||
return;
|
||||
}
|
||||
tab.linkedBrowser.removeEventListener("load", handle, true);
|
||||
deferred.resolve(event);
|
||||
resolve(event);
|
||||
}
|
||||
|
||||
tab.linkedBrowser.addEventListener("load", handle, true);
|
||||
return deferred.promise;
|
||||
});
|
||||
}
|
||||
|
||||
exports.swapToInnerBrowser = swapToInnerBrowser;
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { defer } = require("promise");
|
||||
|
||||
// The prefix used for RDM messages in content.
|
||||
// see: devtools/client/responsivedesign/responsivedesign-child.js
|
||||
const MESSAGE_PREFIX = "ResponsiveMode:";
|
||||
@ -52,14 +50,12 @@ exports.off = off;
|
||||
* A promise that is resolved when the given message is emitted.
|
||||
*/
|
||||
function once(mm, message) {
|
||||
let { resolve, promise } = defer();
|
||||
|
||||
return new Promise(resolve => {
|
||||
on(mm, message, function onMessage({data}) {
|
||||
off(mm, message, onMessage);
|
||||
resolve(data);
|
||||
});
|
||||
|
||||
return promise;
|
||||
});
|
||||
}
|
||||
exports.once = once;
|
||||
|
||||
|
@ -4,23 +4,19 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const promise = require("promise");
|
||||
|
||||
const REQUEST_DONE_SUFFIX = ":done";
|
||||
|
||||
function wait(win, type) {
|
||||
let deferred = promise.defer();
|
||||
|
||||
return new Promise(resolve => {
|
||||
let onMessage = event => {
|
||||
if (event.data.type !== type) {
|
||||
return;
|
||||
}
|
||||
win.removeEventListener("message", onMessage);
|
||||
deferred.resolve();
|
||||
resolve();
|
||||
};
|
||||
win.addEventListener("message", onMessage);
|
||||
|
||||
return deferred.promise;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user