Closed Bug 1562844 Opened 5 years ago Closed 5 years ago

[geckoview] WebExtension tabs and webNavigation event listeners support

Categories

(GeckoView :: Extensions, defect, P3)

Unspecified
All
defect

Tracking

(firefox-esr68 wontfix, firefox68 wontfix, firefox69 wontfix, firefox70 fixed)

RESOLVED FIXED
mozilla70
Tracking Status
firefox-esr68 --- wontfix
firefox68 --- wontfix
firefox69 --- wontfix
firefox70 --- fixed

People

(Reporter: chrmod, Assigned: chrmod)

References

(Depends on 1 open bug, Blocks 2 open bugs)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0

Steps to reproduce:

In GeckoView WebExtension APIs are not working correctly as their implementation comes from Fennec and it relies on it's internals.

Specifically tab.onCreated, tabs.onRemoved, tabs.onUpdated, webNavigation.onCommited throw errors when listeners are assigned.

This changes provide basic support for webextenion tabs and webNavigation listeners by implementing missing objects on which Fennec implementation was relying.

Blocks: 1555094
Assignee: nobody → krzysztof.modras
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Keywords: checkin-needed
Keywords: checkin-needed
Blocks: 1563277
Blocks: 1551378
Depends on: 1539144
Attachment #9075323 - Attachment description: GeckoView webextensions tabs and webnavigation listeners support → Bug 1562844 - GeckoView webextensions tabs and webnavigation listeners support
Blocks: 1569884
No longer blocks: 1569884
Depends on: 1569884

I have repeatedly run the tests, and they often failed on TV. These failures are unrelated to this patch, because the patch only affects GeckoView code, while TV only runs on Fennec due to bug 1566423.

Keywords: checkin-needed

Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2a9a7371947a
GeckoView webextensions tabs and webnavigation listeners support r=robwu,rpl,snorp

Keywords: checkin-needed

Push with failures: https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=2a9a7371947a9557fe4fd32641bd8fd555b11968&searchStr=android%2C7.0%2Cx86-64%2Cdebug%2Cmochitests%2Ctest-android-em-7.0-x86_64%2Fdebug-geckoview-mochitest-e10s-3%2Cm%283%29&selectedJob=261128372

Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=261128372&repo=autoland&lineNumber=6903

Backout link: https://hg.mozilla.org/integration/autoland/rev/3bd2aca8271901b2318b02a1a435e61a7764e770

[task 2019-08-12T16:05:35.083Z] 16:05:35 INFO - 3146 INFO TEST-START | mobile/android/components/extensions/test/mochitest/test_ext_tabs_onUpdated.html
[task 2019-08-12T16:05:35.083Z] 16:05:35 INFO - Buffered messages logged at 16:05:25
[task 2019-08-12T16:05:35.083Z] 16:05:35 INFO - 3147 INFO add_task | Entering test test_onUpdated
[task 2019-08-12T16:05:35.083Z] 16:05:35 INFO - 3148 INFO Extension loaded
[task 2019-08-12T16:05:35.084Z] 16:05:35 INFO - Buffered messages finished
[task 2019-08-12T16:05:35.084Z] 16:05:35 INFO - 3149 INFO TEST-UNEXPECTED-FAIL | mobile/android/components/extensions/test/mochitest/test_ext_tabs_onUpdated.html | got unexpected number of updateInfo data - Expected: [{"status":"complete","url":"about:blank"},{"status":"loading"},{"status":"loading","url":"http://mochi.test:8888/tests/mobile/android/components/extensions/test/mochitest/context_tabs_onUpdated_page.html"},{"status":"complete"}], Actual: [{"status":"loading"},{"status":"loading","url":"http://mochi.test:8888/tests/mobile/android/components/extensions/test/mochitest/context_tabs_onUpdated_page.html"},{"status":"complete"}]
[task 2019-08-12T16:05:35.084Z] 16:05:35 INFO - SimpleTest.ok@SimpleTest/SimpleTest.js:275:18
[task 2019-08-12T16:05:35.084Z] 16:05:35 INFO - testHandler@SimpleTest/ExtensionTestUtils.js:59:18
[task 2019-08-12T16:05:35.084Z] 16:05:35 INFO - testResult@SimpleTest/ExtensionTestUtils.js:73:18
[task 2019-08-12T16:05:35.084Z] 16:05:35 INFO - 3150 INFO TEST-PASS | mobile/android/components/extensions/test/mochitest/test_ext_tabs_onUpdated.html | tabs.onUpdated

Flags: needinfo?(krzysztof.modras)

There was a change on central that homogenized the behavior around about:blank loading between Fennec and GeckoView.
After rebase with central I've fixed the failing test.

Not sure if Raptor failures are related. Can I do something to verify it locally?

Flags: needinfo?(nbeleuzu)
Flags: needinfo?(csabou)
Keywords: checkin-needed

Cancelling the checkin-needed. As Raptor failures are caused by this patch.

Flags: needinfo?(nbeleuzu)
Flags: needinfo?(csabou)
Keywords: checkin-needed

The raptor test failure is because this patch fixed the WebExtension API implementation on GeckoView.
Previously, tabs.update(tabId, {url}) changed the URL of the foreground tab (regardless of the value of tabId). The patch for this bug fixed the implementation, and now tabs.update(tabId, ...) will look up the right tab before trying to navigate it.
Raptor uses tabId 0 by default, which is an invalid tabId.

If the objective is to update (and remove) the active foreground tab, then testTabId = null should be used instead of 0.
If you aren't sure, then null is the right value to use for tabs.update, since it results in the equivalent behavior before this patch.

Raptor on GeckoView used to not close the tab, because tabs.remove(0) has never closed any tab on GeckoView. Should we continue to not close the active tab (and get "Error: Invalid tab ID 0" (examlple)?

Flags: needinfo?(krzysztof.modras) → needinfo?(hskupin)
Attachment #9085106 - Attachment description: [GeckoView] Bug 1562844 - Use correct tabId in Raptor → Bug 1562844 - Use correct tabId in Raptor

Not sure why I was set as needinfo in comment 9. All questions regarding Raptor should actually go to Rob.

Flags: needinfo?(hskupin) → needinfo?(rwood)

(In reply to Rob Wu [:robwu] from comment #9)

The raptor test failure is because this patch fixed the WebExtension API implementation on GeckoView.
Previously, tabs.update(tabId, {url}) changed the URL of the foreground tab (regardless of the value of tabId). The patch for this bug fixed the implementation, and now tabs.update(tabId, ...) will look up the right tab before trying to navigate it.
Hi, comments inline thanks :)

Raptor uses tabId 0 by default, which is an invalid tabId.

If the objective is to update (and remove) the active foreground tab, then testTabId = null should be used instead of 0.
If you aren't sure, then null is the right value to use for tabs.update, since it results in the equivalent behavior before this patch.

Right so on geckoview browsers (GVE, refbrow, fenix) we needed to default because tabs.create wasn't supported at the time (and the callback to that receives a valid tabId for the newly created tab). So my understanding now is we should change that default to 'null' instead of 0 (I see in the patch, cool). Will that work on non-geckoview also (i.e. fennec, and Firefox desktop)? Is tabs.create supported now on geckoview? In which case instead of using a default (i.e. null) then we can grab the actual tabID at creation time.

Raptor runs on Firefox (and Chrome/ium) desktop as well as all the Firefox android platforms so any changes here we must ensure work on all the platforms, or change the runner.js to handle appropriately. So try runs will need to run at least one Raptor tp6 job on Firefox deskop, Chromium, fennec, refbrow, fenix, and GVE. Thanks!

Raptor on GeckoView used to not close the tab, because tabs.remove(0) has never closed any tab on GeckoView. Should we continue to not close the active tab (and get "Error: Invalid tab ID 0" (examlple)?

Is tabs.remove supported on geckoview now? Can we provide 'null' here also for the tabID so it defaults to closing the current / foreground tab?

Thanks! :)

Flags: needinfo?(rwood)
Flags: needinfo?(rob)
Flags: needinfo?(krzysztof.modras)

(In reply to Robert Wood [:rwood] from comment #12)

Right so on geckoview browsers (GVE, refbrow, fenix) we needed to default because tabs.create wasn't supported at the time (and the callback to that receives a valid tabId for the newly created tab). So my understanding now is we should change that default to 'null' instead of 0 (I see in the patch, cool). Will that work on non-geckoview also (i.e. fennec, and Firefox desktop)?

Yes. The documented behavior is that if tabId is not set (=null), that the active tab is used.
Any correct WebExtension / Chrome extension API implementation will reject a value of "0".

Is tabs.create supported now on geckoview? In which case instead of using a default (i.e. null) then we can grab the actual tabID at creation time.

Creating new tabs with tabs.create is supported, provided that a WebExtensionController.TabDelegate, e.g. as done in TestRunnerActivity.java. To not block these patches any further, I suggest to open a new bug about using tabs.create on GeckoView in Raptor.

Raptor on GeckoView used to not close the tab, because tabs.remove(0) has never closed any tab on GeckoView. Should we continue to not close the active tab (and get "Error: Invalid tab ID 0" (examlple)?

Is tabs.remove supported on geckoview now? Can we provide 'null' here also for the tabID so it defaults to closing the current / foreground tab?

tabs.remove is supported now, but as Raptor doesn't seem to open tabs on GeckoView now, I think that not closing anything is the right behavior, for now.

Flags: needinfo?(rob)

(In reply to Rob Wu [:robwu] from comment #13)

Yes. The documented behavior is that if tabId is not set (=null), that the active tab is used.
Any correct WebExtension / Chrome extension API implementation will reject a value of "0".

Ok. On the non-geckoview platforms Raptor is using the tabID from tabs.create and not zero so that's why it's working there.

Is tabs.create supported now on geckoview? In which case instead of using a default (i.e. null) then we can grab the actual tabID at creation time.

Creating new tabs with tabs.create is supported, provided that a WebExtensionController.TabDelegate, e.g. as done in TestRunnerActivity.java. To not block these patches any further, I suggest to open a new bug about using tabs.create on GeckoView in Raptor.

No it's ok - we are soon moving away from the Raptor web extension anyway, in favour of browsertime.

Raptor on GeckoView used to not close the tab, because tabs.remove(0) has never closed any tab on GeckoView. Should we continue to not close the active tab (and get "Error: Invalid tab ID 0" (examlple)?

Is tabs.remove supported on geckoview now? Can we provide 'null' here also for the tabID so it defaults to closing the current / foreground tab?

tabs.remove is supported now, but as Raptor doesn't seem to open tabs on GeckoView now, I think that not closing anything is the right behavior, for now.

Ah, makes sense, yes we can just leave it as/is.

Flags: needinfo?(krzysztof.modras)
Keywords: checkin-needed

Pushed by archaeopteryx@coole-files.de:
https://hg.mozilla.org/integration/autoland/rev/d74231becedc
GeckoView webextensions tabs and webnavigation listeners support r=robwu,rpl,snorp
https://hg.mozilla.org/integration/autoland/rev/5448f3aaa09a
Use correct tabId in Raptor r=robwu,rwood

Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
Regressions: 1574917

Moving some WebExtension bugs to the GeckoView::Extensions component.

Component: General → Extensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: