Closed Bug 1489227 Opened 8 years ago Closed 8 years ago

onInstalled behavior inconsistent with Chrome

Categories

(WebExtensions :: Compatibility, defect)

61 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: tom_xyz, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36 Steps to reproduce: I recently ported my Chrome extension to Firefox Quantum. However, I noticed that the onInstalled event in the background page behaves differently in Firefox and Chrome. In Firefox, the onInstalled event is fired only once after you install the extension. In Chrome, the onInstalled event is fired every time the browser is started. This can break extensions ported from Chrome because, for example, context menus are usually created from the onInstalled event handler, e.g.: https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/context-menu/main.js In the example above, the context menu would disappear when you restart Firefox, which is an issue. Even though the behavior in Firefox is truer to the meaning of "onInstalled", to be consistent with Chrome's behavior to make porting Chrome extensions more straight forward, this event should be changed to fire every time Firefox is restarted. Actual results: The onInstalled event is fired only once after you install the extension the first time. Expected results: The onInstalled event should fire every time Firefox starts up to be consistent with Chrome extensions.
UPDATE: Even after adding browser.contextMenus.create() to the onStartup event handler, the context menu is still not displayed after restarting Firefox. This suggests there is some other issue at play here pertaining to extension context menus disappearing after Firefox is restarted.
Component: Untriaged → Compatibility
Product: Firefox → WebExtensions
If Chrome does call onInstalled listeners at every startup, that certainly does not match their documented behavior: https://developer.chrome.com/apps/runtime#event-onInstalled I would consider that a bug in Chrome that we would not want to duplicate in Firefox.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
@Kris I believe this issue relates to creating the context menu only. Here's what I observed: - In Chrome an extension's context menu is created once inside the onInstalled event handler (see Google's sample code from the link above). I can verify that this works because this is where I create my extension's context menu, and it's preserved across Chrome sessions (i.e., after a restart). - In Firefox no matter where I create the context menu -- inside onInstalled or onStartup event handler -- the context menu is only created once after the initial extension installation. When you restart Firefox the context menu for the extension disappears.
Since the issue I'm seeing is technically not the same as the title of this issue, I will create a separate issue for the context menu disappearing after restarting Firefox.
You need to log in before you can comment on or make changes to this bug.