Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require an id to be set in Firefox web extension manifests #6471

Closed
motin opened this issue Oct 2, 2018 · 5 comments
Closed

Require an id to be set in Firefox web extension manifests #6471

motin opened this issue Oct 2, 2018 · 5 comments
Labels
C-nodejs I-stale Applied to issues that become stale, and eventually closed.

Comments

@motin
Copy link
Contributor

motin commented Oct 2, 2018

As mentioned in #6463 (comment):

Whilst web extensions don't mandate an id, it appears that when installing extensions from the profile Firefox will verify that the name of the file/directory containing the extension matches the id of the add-on. This means that we effectively do require an id to be set in the manifest, and that we use it when writing to the profile directory. It may work by coincidence when the id matches the name@version format used here. It's worth testing with the other clients, but if this is the case then I believe we should require the id and raise an exception when it's not provided to avoid harder to debug issues with Firefox launching without the addon installed. Sorry for my earlier comment suggesting that we needed id to be optional, which was based on this documentation.

Current client implementations

Here is how the ruby bindings handle web extensions without an id (it doesn't even look for applications.gecko.id):

def read_id_from_manifest_json(directory)
manifest_path = File.join(directory, 'manifest.json')
return unless File.exist?(manifest_path)
manifest = JSON.parse(File.read(manifest_path))
[manifest['name'].delete(' '), manifest['version']].join('@')
end

The Java bindings looks for applications.gecko.id but does the same as the Ruby bindings in case it isn't set:

Map<String, Object> manifestObject = json.read(MAP_TYPE);
if (manifestObject.get("applications") instanceof Map) {
Map<?, ?> applicationObj = (Map<?, ?>) manifestObject.get("applications");
if (applicationObj.get("gecko") instanceof Map) {
Map<?, ?> geckoObj = (Map<?, ?>) applicationObj.get("gecko");
if (geckoObj.get("id") instanceof String) {
addOnId = ((String) geckoObj.get("id")).trim();
}
}
}
if (addOnId == null || addOnId.isEmpty()) {
addOnId = ((String) manifestObject.get("name")).replaceAll(" ", "") +
"@" + manifestObject.get("version");
}

The JavaScript bindings throw an error if applications.gecko.id is not defined:

if (!(applications && applications.gecko && applications.gecko.id)) {
throw new AddonFormatError(`Could not find add-on ID for ${extension}`);
}

The Python bindings, as proposed in #6463, exhibit the same behavior as the Java bindings:
https://github.com/motin/selenium/blob/add-python-client-support-for-webextensions-in-firefox/py/selenium/webdriver/firefox/firefox_profile.py#L333-L339

@p0deje
Copy link
Member

p0deje commented May 3, 2019

Ruby support landed in a25638d

@p0deje
Copy link
Member

p0deje commented May 3, 2019

I guess now all the bindings except JavaScript work similarly.

@github-actions
Copy link

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the I-stale Applied to issues that become stale, and eventually closed. label Oct 20, 2021
@github-actions
Copy link

github-actions bot commented Nov 3, 2021

This issue was closed because it has been stalled for 14 days with no activity.

@github-actions github-actions bot closed this as completed Nov 3, 2021
@github-actions
Copy link

github-actions bot commented Dec 4, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-nodejs I-stale Applied to issues that become stale, and eventually closed.
Projects
None yet
Development

No branches or pull requests

2 participants