mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1153128 - Add sendSyncMessage to SpecialPowers.loadChromeScript. r=jmaher
MozReview-Commit-ID: AsbBiOkhhLo
This commit is contained in:
parent
edfa4cdbaa
commit
fa0d17026f
@ -9,3 +9,7 @@ addMessageListener("valid-assert", function (message) {
|
||||
assert.equal(1, 1, "another valid assertion");
|
||||
sendAsyncMessage("valid-assert-done");
|
||||
});
|
||||
|
||||
addMessageListener("sync-message", () => {
|
||||
return "Received a synchronous message.";
|
||||
});
|
||||
|
@ -33,6 +33,16 @@ function endOfTest() {
|
||||
}
|
||||
|
||||
script.sendAsyncMessage("foo", MESSAGE);
|
||||
|
||||
/*
|
||||
* [0][0] is because we're using one real message listener in SpecialPowersObserverAPI.js
|
||||
* and dispatching that to multiple _chromeScriptListeners. The outer array comes
|
||||
* from the message manager since there can be multiple real listeners. The inner
|
||||
* array is for the return values of _chromeScriptListeners.
|
||||
*/
|
||||
is(script.sendSyncMessage("sync-message")[0][0], "Received a synchronous message.",
|
||||
"Check sync return value");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -483,10 +483,9 @@ SpecialPowersObserverAPI.prototype = {
|
||||
let id = aMessage.json.id;
|
||||
let name = aMessage.json.name;
|
||||
let message = aMessage.json.message;
|
||||
this._chromeScriptListeners
|
||||
.filter(o => (o.name == name && o.id == id))
|
||||
.forEach(o => o.listener(message));
|
||||
return undefined; // See comment at the beginning of this function.
|
||||
return this._chromeScriptListeners
|
||||
.filter(o => (o.name == name && o.id == id))
|
||||
.map(o => o.listener(message));
|
||||
}
|
||||
|
||||
case "SPImportInMainProcess": {
|
||||
|
@ -482,6 +482,11 @@ SpecialPowersAPI.prototype = {
|
||||
{ id: id, name: name, message: message });
|
||||
},
|
||||
|
||||
sendSyncMessage: (name, message) => {
|
||||
return this._sendSyncMessage("SPChromeScriptMessage",
|
||||
{ id, name, message });
|
||||
},
|
||||
|
||||
destroy: () => {
|
||||
listeners = [];
|
||||
this._removeMessageListener("SPChromeScriptMessage", chromeScript);
|
||||
|
Loading…
Reference in New Issue
Block a user