port.onDisconnect isn't fired when extension is disabled/uninstalled

NEW
Assigned to

Status

()

Toolkit
WebExtensions: General
P3
normal
2 years ago
8 months ago

People

(Reporter: Maciej Ćwiek, Assigned: robwu)

Tracking

44 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [runtime] triaged)

(Reporter)

Description

2 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36

Steps to reproduce:

// background script
chrome.runtime.onConnect.addListener(function (port) {}); // just accept connection

// content script
var port = chrome.runtime.connect({name: "foo"});
port.onDisconnect.addListener(function () {
    console.log('disconnected');
});


Actual results:

The listener is not fired when either disabling or uninstalling the extension.
It only works when port.disconnect() is called explicitly.


Expected results:

The listener is should be fired when either disabling or uninstalling the extension, so the behaviour is aligned with Google Chrome API.
Whiteboard: [runtime][berlin]
Whiteboard: [runtime][berlin] → [runtime][berlin][good first bug]
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [runtime][berlin][good first bug] → [runtime]

Updated

a year ago
Assignee: nobody → aswan

Updated

a year ago
Whiteboard: [runtime] → [runtime] triaged
(Assignee)

Comment 1

11 months ago
This is not an uncommon pattern in Chrome extensions: Open a port to the background script in the content script, and if onDisconnect is triggered, assume that the extension has unloaded.

Updated

10 months ago
Assignee: aswan → rob

Updated

8 months ago
Component: WebExtensions: Untriaged → WebExtensions: General
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.