зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1287229 - port.disconnect should not throw r=billm
MozReview-Commit-ID: 7d8Zmb4OAd0 --HG-- extra : rebase_source : 6766832c0081679eadf1bdbc1576f8b554c68e3c
This commit is contained in:
Родитель
28a234ae47
Коммит
fcbcffffd6
|
@ -1048,7 +1048,9 @@ Port.prototype = {
|
|||
|
||||
disconnect() {
|
||||
if (this.disconnected) {
|
||||
throw new this.context.contentWindow.Error("Attempt to disconnect() a disconnected port");
|
||||
// disconnect() may be called without side effects even after the port is
|
||||
// closed - https://developer.chrome.com/extensions/runtime#type-Port
|
||||
return;
|
||||
}
|
||||
this.handleDisconnection();
|
||||
this.messageManager.sendAsyncMessage(this.disconnectName);
|
||||
|
|
|
@ -17,6 +17,9 @@ function backgroundScript() {
|
|||
browser.runtime.onConnect.addListener(port => {
|
||||
browser.test.assertEq(port.name, "ernie", "port name correct");
|
||||
port.onDisconnect.addListener(() => {
|
||||
// Closing an already-disconnected port is a no-op.
|
||||
port.disconnect();
|
||||
port.disconnect();
|
||||
browser.test.sendMessage("disconnected");
|
||||
});
|
||||
browser.test.sendMessage("connected");
|
||||
|
|
Загрузка…
Ссылка в новой задаче