Closed Bug 1409540 Opened 4 years ago Closed 4 years ago

chrome.tabs.onRemove does not remove tab before calling the callback function

Categories

(WebExtensions :: General, defect, P2)

57 Branch
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1396758

People

(Reporter: zepeuj, Unassigned, Mentored)

Details

(Whiteboard: [tab])

+++ This bug was initially created as a clone of Bug #1291830 +++

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0
Build ID: 20160727004019

Steps to reproduce:

subscribe to the tabs.onRemoved event and supplied a callback function that queries the chrome.tabs.query() method to get a list of all tabs.


Actual results:

The tabs included the removed tab.


Expected results:

I expect the tab to not be in the list of tabs at this point in the tab's lifecycle.

********************************************************************************

A sample if needed:

const onRemovedTab = (removedTabId, removeInfo) => {

	console.log("Tab removed: " + removedTabId);

	const queryOpenedTabs = windowId => {

		chrome.tabs.query({ windowType: "normal", windowId: windowId }, openedTabs => {

			let tabIndex = null;

			for (const openedTab of openedTabs) {
				if (openedTab.id === removedTabId) {
					console.error("removed tab still there!!");
					tabIndex = openedTab.index;
					break;
				}
			}

			//Removed tab is still there, check in session with index
			if (tabIndex) {
				const gettingSessions = browser.sessions.getRecentlyClosed({ maxResults: 1 });
				gettingSessions.then(session => {
					if (session[0].tab) {
						if (session[0].tab.index === tabIndex) {
							console.log("As expected, removed tab is in the object session.");
						}
					}

				});
			}
			else {
				console.log("removed tab is gone.");
			}

		});
	};

	// the setTimeout is used for test to increase the timeout and see how many time to wait...
	setTimeout(() => queryOpenedTabs(removeInfo.windowId), 50);
};

chrome.tabs.onRemoved.addListener(onRemovedTab);
Changing version to 57 as it will most probably not be fixed in 56.
The problem also appears in the Nigthly version.
Version: 56 Branch → 57 Branch
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
Whiteboard: [tab]
Duplicate of bug: 1396758
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.