зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1644151, remove now unused PromiseMessage.jsm module, actors can use sendQuery to wait for messages instead, r=marcosc
Differential Revision: https://phabricator.services.mozilla.com/D79574
This commit is contained in:
Родитель
f1cd439a13
Коммит
65cad80635
|
@ -1,33 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["PromiseMessage"];
|
||||
|
||||
var msgId = 0;
|
||||
|
||||
var PromiseMessage = {
|
||||
send(messageManager, name, data = {}) {
|
||||
const id = `${name}_${msgId++}`;
|
||||
|
||||
// Make a copy of data so that the caller doesn't see us setting 'id':
|
||||
// To a new object, assign data's props, and then override the id.
|
||||
const dataCopy = Object.assign({}, data, { id });
|
||||
|
||||
// Send the message.
|
||||
messageManager.sendAsyncMessage(name, dataCopy);
|
||||
|
||||
// Return a promise that resolves when we get a reply (a message of the same name).
|
||||
return new Promise(resolve => {
|
||||
messageManager.addMessageListener(name, function listener(reply) {
|
||||
if (reply.data.id !== id) {
|
||||
return;
|
||||
}
|
||||
messageManager.removeMessageListener(name, listener);
|
||||
resolve(reply);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
|
@ -202,7 +202,6 @@ EXTRA_JS_MODULES += [
|
|||
'ProfileAge.jsm',
|
||||
'Promise-backend.js',
|
||||
'Promise.jsm',
|
||||
'PromiseMessage.jsm',
|
||||
'PromiseUtils.jsm',
|
||||
'Region.jsm',
|
||||
'RemotePageAccessManager.jsm',
|
||||
|
|
|
@ -25,7 +25,6 @@ skip-if = debug || os = "linux"
|
|||
skip-if = debug || os = "linux"
|
||||
[browser_Geometry.js]
|
||||
[browser_InlineSpellChecker.js]
|
||||
[browser_PromiseMessage.js]
|
||||
[browser_Troubleshoot.js]
|
||||
[browser_web_channel.js]
|
||||
support-files =
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* global Cu, BrowserTestUtils, is, ok, add_task, gBrowser */
|
||||
"use strict";
|
||||
ChromeUtils.import("resource://gre/modules/PromiseMessage.jsm", this);
|
||||
|
||||
const url = "http://example.org/tests/dom/manifest/test/resource.sjs";
|
||||
|
||||
/**
|
||||
* Test basic API error conditions
|
||||
*/
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url }, testPromiseMessageAPI);
|
||||
});
|
||||
|
||||
async function testPromiseMessageAPI(aBrowser) {
|
||||
// Reusing an existing message.
|
||||
const msgKey = "DOM:WebManifest:hasManifestLink";
|
||||
const mm = aBrowser.messageManager;
|
||||
const id = "this should not change";
|
||||
const foo = "neitherShouldThis";
|
||||
const data = { id, foo };
|
||||
|
||||
// This just returns false, and it doesn't matter for this test.
|
||||
await PromiseMessage.send(mm, msgKey, data);
|
||||
|
||||
// Check that no new props were added
|
||||
const props = Object.getOwnPropertyNames(data);
|
||||
ok(props.length === 2, "There should only be 2 props");
|
||||
ok(props.includes("id"), "Has the id property");
|
||||
ok(props.includes("foo"), "Has the foo property");
|
||||
|
||||
// Check that the props didn't change.
|
||||
is(data.id, id, "The id prop must not change.");
|
||||
is(data.foo, foo, "The foo prop must not change.");
|
||||
}
|
Загрузка…
Ссылка в новой задаче