Skip to content

Add python client support for webextensions in firefox [rebased upon latest master and with fixed tests] #6463

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

Conversation

motin
Copy link
Contributor

@motin motin commented Sep 30, 2018

This is a rebased and improved upon version of #5069, addressing the concerns raised by the reviewer.

Fixes the python part of #4093

Main contributors of this PR:


This change is Reviewable

@motin motin force-pushed the add-python-client-support-for-webextensions-in-firefox branch 2 times, most recently from c2d888e to aebb2e6 Compare September 30, 2018 11:02
@motin motin force-pushed the add-python-client-support-for-webextensions-in-firefox branch from aebb2e6 to 9bef641 Compare September 30, 2018 11:58
@p0deje p0deje added the C-py Python Bindings label Oct 1, 2018
Copy link
Contributor

@davehunt davehunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left some comments that I'd like to see addressed, but I can confirm that this is installing a web extension when the id is specified. I don't want to block on this, so feel free to merge and release, and perhaps take care of the remaining items as followups.

try:
id = manifest['applications']['gecko']['id']
except KeyError:
id = manifest['name'].replace(" ", "") + "@" + manifest['version']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for picking this up! I've looked into it more and discovered that 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True! Reported as #6471

driver.quit()


def test_add_extension_web_extension_without_id(capabilities, webserver):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is failing for me.

Copy link
Contributor Author

@motin motin Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this due to the reasons you mentioned in https://github.com/SeleniumHQ/selenium/pull/6463/files#r221901851 or some other reason? The test seem to pass in travis

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web extension doesn't appear to be copied to the profile path at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is passing in Travis, let's go ahead and merge. It was the only thing that was making me uncertain about merging. It's failing locally for me, but I'm guessing it's related to the version of Firefox.

@@ -171,3 +171,52 @@ def test_autodetect_proxy_is_set_in_profile():

profile.set_proxy(proxy)
assert profile.default_preferences["network.proxy.type"] == ProxyType.AUTODETECT['ff_value']


def test_add_extension_web_extension_with_id(capabilities, webserver):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are just for legacy Firefox, and we should also add coverage to py/test/selenium/webdriver/marionette

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that many tests for legacy Firefox are missing for marionette. Should this be reported in general as a separate issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see more unit tests for the Selenium client that don't require a driver, for example we should be able to test several aspects of the FirefoxProfile class that aren't affected by the version of Firefox. Where there is a need for a driver test, we should at least make sure we have coverage in modern Firefox (marionette) as we will eventually be looking to drop support for legacy Firefox. If you're interested in contributing more, I'd love to get a coverage report for our unit tests and work on improving it - this will also give us confidence when we come to do larger scale refactoring.

@davehunt
Copy link
Contributor

davehunt commented Oct 4, 2018

Thanks for the contributions @motin and @sangaline. Please feel free to work on any of the follow ups, and to ping me for reviews or if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-py Python Bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants