mozilla / web-ext

A command line tool to help build, run, and test web extensions
Mozilla Public License 2.0
2.69k stars 338 forks source link

Can't run Firefox Webextension from an existing profile #1811

Closed ealashwali closed 4 years ago

ealashwali commented 4 years ago

Is this a feature request or a bug?

Bug.

What is the current behavior?

1) I want to test my own extension. If I run it with options to maintain profile data using this command: jpm run -b "C:\Program Files (x86)\Firefox Developer Edition\firefox.exe" --binary-args -jsconsole -p C:\Users\e\Documents\dev\myExt--no-copy --debug

The extension produces unexpected behavior. At first, the extension icon did not show up. Then in a second attempt, the extension icon showed up, but if I click on it, I see the form I expect, but it does not work. I should be able to input data, press a button, and the data appears a table below the text-box, in the same form, immediately. Now, if I input data in the form, click the button, I see no effect at all.

But, if I run the extension using a fresh profile using this command: jpm run -b "C:\Program Files (x86)\Firefox Developer Edition\firefox.exe" The extension works as expected.

2) FYI, the extension uses storage and contains data. If the user input data, then in the next run, if I run it from the existing profile, I should see the data as the extension programmed to retrieve the data from storage.

3) I use an embedded extension. i.e. it contains legacy code from SDK. However, the extension was working perfectly few years ago.

My problem seem relevant to this: https://github.com/mozilla/web-ext/issues/1363 But I do not know what is the solution. I do not want to update Firefox version because I faced loads of others problems.

What is the expected or desired behavior?

I expect to see the extension icon which if I click it opens a tab which retrieves data from the storage if exist. Unfortunately it does not retrieve the data, and does not input new data, and the button click does not have effect. It shows an error at this stage (see next comment).

Version information (for bug reports)

node --version && npm --version && web-ext --version

v8.11.1 5.6.0 'web-ext' is not recognized as an internal or external command, operable program or batch file.

ealashwali commented 4 years ago

Further info: Those are the errors that appear in the debug window just after the code line that retrieves the data from the storage:

Attempt to create privileged extension parent from incorrect child process  ExtensionParent.jsm:646
Error: WebExtension context not found!  ExtensionParent.jsm:778:13

This is the function that retrieves the existing data from storage:

function init()
{
  var retrieveAllStorageItems = browser.storage.local.get(null);
  retrieveAllStorageItems.then(function (results) {
    Object.keys(results).forEach(function(t) {
            var storedObj= results[t];
            var level = storedObj.levelValue;
            var error = storedObj.errorValue;
            displayRow(t, level, error) //another function to display the retrieve items
        });
    }, onError);
} 

Can you please point to me what is the problem here?

Rob--W commented 4 years ago

You're using jpm and an ancient version of Firefox (56.0b8). Neither of those are supported any more.

Nevertheless, I just gave it a try:

... and was able to load the WebExtension with web-ext run -f path/to/old/firefox.

Could you provide the relevant details that allows us to reproduce the bug with web-ext?

ealashwali commented 4 years ago

@Rob--W Thanks for your response. I am aware about the legacy tools I am using. It is an embedded extension (in an SDK add on legacy extension). The Firefox version is also old due to the legacy part of SDK as Firefox 57+ do not support embedded extensions. I used jpm to run the legacy SDK add on which has webextension embedded on it. My question, does web-ext allow me to run an embedded extension (i.e. SDK extension that embeds webextension)?

Rob--W commented 4 years ago

(I'll close this issue since it is not related to web-ext; but I'll continue to reply)

web-ext run requires a non-legacy extension in order to start up.

Are you using any internal APIs that have been removed from Firefox? If not, then you can convert your extension to a WebExtension experiment and run it with Firefox Nightly / DevEd.

For more info, see https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/basics.html#webextensions-experiments

ealashwali commented 4 years ago

Ok. I will try to check if the issue also appear in a non legacy extension with Firfox 56. I tried web-ext. I installed it using: npm install --global web-ext Then I go inside the webextension folder and run the command: C:\Users\me\Documents\dev\testStorageWebExtV2>web-ext run -f C:\Program Files (x86)\Firefox Developer Edition This is the output I get:

\Firefox was unexpected at this time.

C:\Users\me\Documents\dev\testStorageWebExtV2>  "C:\Users\me\AppData\Roaming\npm\\node.exe"  "C:\Users\me\AppData\Roaming\npm\\node_modules\web-ext\bin\web-ext" run -f C:\Program Files (x86)\Firefox Developer Edition

Can you help solving this issue plz.?

Rob--W commented 4 years ago

You need to quote the parameter or change the file path so that it doesn't contain spaces.

ealashwali commented 4 years ago

Thanks. My original problem has been solved by running the extension on an older version of Firefox. It seems 56 does not accept legacy extensions but I can not migrate at the moment.