If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Add-on SDK based addon don't launch contentScript until panel is open by user

RESOLVED INCOMPLETE

Status

Add-on SDK
General
RESOLVED INCOMPLETE
3 months ago
10 days ago

People

(Reporter: Alexander Grimalovsky, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 months ago
Created attachment 8881221 [details]
Example minimal add-on to demonstrate problem

Starting from Firefox 55 alpha 1 there is a change into behavior of how content scripts of Add-on SDK based addons are running. 

Into all versions prior to Firefox 55 content script is running immediately after Panel object, it is attached to is instantiated. Into Firefox 55 it is not launched until panel itself will be opened by user. This behavior change breaks addons that are running its main code within content scripts.

I've prepared minimal add-on to demonstrate the problem (attached to the issue). Whole purpose of this add-on is to display 2 log messages:
 - "Add-on code is launched" upon start of add-on itseld
 - "Panel code is launched" when content script is launched into addon's panel

Steps to reproduce:

1. Open about:config and add new preference to be able to see log messages from add-on: extensions.@test-auto-restart.sdk.console.logLevel => all
2. Load provided add-on as temporary add-on (about:debugging#addons -> Load Temporary Add-on)
3. Start debugger for this add-on and observe its console
4. Reload add-on

Expected results into addon's console (can be observed in Firefox 54):   
test:Add-on code is launched
test:Panel code is launched

Actual results (as seen in Firefox 55, tested into Firefox Developer Edition that is 55.a3 at a time of filling this bug):
test:Add-on code is launched

When addon's button on toolbar is being clicked and panel will open - second message will appear in console, indicating that panel code is launched.

Updated

3 months ago
Component: General → General
Product: Toolkit → Add-on SDK
Version: 55 Branch → unspecified
(Reporter)

Comment 1

3 months ago
Just for reference and to notify authors of other add-ons that may face similar issue:

There is a workaround against this issue. You can simply show / hide panel programmatically to let content script to start. Something like this:

import {Panel} from "sdk/panel";

const panel = Panel({ /* Panel options*/ });
panel.show();
panel.hide();

This code produces no visible results, but allows content script code to start.
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: NEW → RESOLVED
Last Resolved: 10 days ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.