Closed Bug 1287229 Opened 3 years ago Closed 3 years ago

port.disconnect() should not throw an error if the port is already disconnected

Categories

(WebExtensions :: Untriaged, defect)

defect
Not set

Tracking

(firefox50 fixed)

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: robwu, Assigned: robwu)

Details

Attachments

(1 file)

https://developer.chrome.com/extensions/runtime#type-Port

> Calling disconnect() on an already-disconnected port has no effect.

I.e. disconnect() ought to be no-op if the port is already disconnected. In contrast, Firefox throws an error: http://searchfox.org/mozilla-central/rev/bfcc10319e4e3ce78367fa9bba9316f7eb5248b6/toolkit/components/extensions/ExtensionUtils.jsm#1051
Comment on attachment 8771628 [details]
Bug 1287229 - port.disconnect should not throw

https://reviewboard.mozilla.org/r/64734/#review62068

::: toolkit/components/extensions/ExtensionUtils.jsm:1049
(Diff revision 1)
>      }
>    },
>  
>    disconnect() {
>      if (this.disconnected) {
> -      throw new this.context.contentWindow.Error("Attempt to disconnect() a disconnected port");
> +      return;

Please add a comment with a link to the Chrome docs.
Attachment #8771628 - Flags: review?(wmccloskey) → review+
Comment on attachment 8771628 [details]
Bug 1287229 - port.disconnect should not throw

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/64734/diff/1-2/
Pushed by wmccloskey@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e8e2132fa883
port.disconnect should not throw r=billm
https://hg.mozilla.org/mozilla-central/rev/e8e2132fa883
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.