Investigate loading of "moz-extension://" pages in Marionette and WebDriver BiDi
Categories
(Remote Protocol :: Agent, task, P3)
Tracking
(Not tracked)
People
(Reporter: whimboo, Unassigned)
References
()
Details
(Whiteboard: [webdriver:backlog])
(In reply to Julian Descottes [:jdescottes] from bug 1903272 comment #9)
We should file a bug to see if it's possible to test extension pages by loading moz-extension URLs in a tab as well, as this seems to be a recommended solution to test extensions until we have support.
It seems to be possible as I just tried to check (see the logs below) but the UUID
as used within the URL isn't the actual extension id that we get returned from the webExtension.install
command:
1744193529538 RemoteAgent DEBUG WebDriverBiDiConnection 9139d051-c42c-432c-962c-e25955c0a54b -> {"method":"webExtension.install","params":{"extensionData":{"type":"archivePath","path":"/Users/henrik/code/gecko/cookie_manager.xpi"}},"id":8}
1744193529539 RemoteAgent TRACE Received command webExtension.install for destination ROOT
1744193529605 RemoteAgent DEBUG WebDriverBiDiConnection 9139d051-c42c-432c-962c-e25955c0a54b <- {"type":"success","id":8,"result":{"extension":"{60f82f00-9ad5-4de5-b31c-b16a47c51558}"}}
1744193712118 RemoteAgent DEBUG WebDriverBiDiConnection 9139d051-c42c-432c-962c-e25955c0a54b -> {"method":"browsingContext.navigate","params":{"context":"6ad1c1f9-9846-43d2-92dd-da4917585352","url":"moz-extension://60f82f00-9ad5-4de5-b31c-b16a47c51558/options.html"},"id":10}
1744193712118 RemoteAgent TRACE Received command browsingContext.navigate for destination ROOT
1744193712119 RemoteAgent TRACE Received command browsingContext._getBaseURL for destination WINDOW_GLOBAL
1744193712131 RemoteAgent TRACE Created MessageHandler WINDOW_GLOBAL for session b0e33eba-6fb1-4400-b3bc-636fe23c2cf2
1744193712132 RemoteAgent TRACE Received command browsingContext._getBaseURL for destination WINDOW_GLOBAL
1744193712135 RemoteAgent TRACE [12] ProgressListener Start: expectNavigation=true resolveWhenStarted=true unloadTimeout=200 waitForExplicitStart=true
1744193712135 RemoteAgent TRACE [12] ProgressListener Skip setting the unload timer
This navigation never finishes because the page doesn't exist. We probably should fail instead.
Opening the Add-ons Manager and manually opening the preferences page for the web extension gives me moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html
as URL. Using this location for the navigation command we succeed:
1744193919877 RemoteAgent DEBUG WebDriverBiDiConnection 9139d051-c42c-432c-962c-e25955c0a54b -> {"method":"browsingContext.navigate","params":{"context":"6ad1c1f9-9846-43d2-92dd-da4917585352","url":"moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html","wait":"complete"},"id":12}
1744193919878 RemoteAgent TRACE Received command browsingContext.navigate for destination ROOT
1744193919878 RemoteAgent TRACE Received command browsingContext._getBaseURL for destination WINDOW_GLOBAL
1744193919884 RemoteAgent TRACE Created MessageHandler WINDOW_GLOBAL for session b0e33eba-6fb1-4400-b3bc-636fe23c2cf2
1744193919885 RemoteAgent TRACE Received command browsingContext._getBaseURL for destination WINDOW_GLOBAL
1744193919889 RemoteAgent TRACE [15] ProgressListener Start: expectNavigation=true resolveWhenStarted=false unloadTimeout=200 waitForExplicitStart=true
1744193919889 RemoteAgent TRACE [15] ProgressListener Skip setting the unload timer
1744193919890 RemoteAgent TRACE [15] NavigationListenerChild Loading state: flags: 983041, status: 0, isStart: true, isStop: false, isNetwork: true, isBindingAborted: false, targetURI: moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html
1744193919891 RemoteAgent TRACE [6ad1c1f9-9846-43d2-92dd-da4917585352] Navigation started for url: moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html (a1a63ca6-936d-4312-874b-659c0cd76fce)
1744193919892 RemoteAgent TRACE [15] ProgressListener Loading state: isStart=true isStop=false status=0x0, loadType=0x200001
1744193919892 RemoteAgent TRACE [15] ProgressListener Started loading moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html
1744193919899 RemoteAgent TRACE [15] NavigationListenerChild Loading state: flags: 196610, status: 0, isStart: false, isStop: false, isNetwork: false, isBindingAborted: false, targetURI: moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html
1744193919906 RemoteAgent TRACE MessageHandler WINDOW_GLOBAL for session b0e33eba-6fb1-4400-b3bc-636fe23c2cf2 is being destroyed
1744193919906 RemoteAgent TRACE Unregistered MessageHandler WINDOW_GLOBAL for session b0e33eba-6fb1-4400-b3bc-636fe23c2cf2
1744193919913 RemoteAgent TRACE [15] NavigationListenerChild Loading state: flags: 196612, status: 0, isStart: false, isStop: false, isNetwork: false, isBindingAborted: false, targetURI: moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html
console.error: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFaviconService.setFaviconForPage]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource:///actors/LinkHandlerParent.sys.mjs :: setIconFromLink :: line 142" data: no]
1744193919928 RemoteAgent TRACE [15] NavigationListenerChild Loading state: flags: 131088, status: 0, isStart: false, isStop: true, isNetwork: false, isBindingAborted: false, targetURI: moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html
1744193919928 RemoteAgent TRACE [6ad1c1f9-9846-43d2-92dd-da4917585352] Navigation finished for url: moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html (a1a63ca6-936d-4312-874b-659c0cd76fce)
1744193919929 RemoteAgent TRACE [15] ProgressListener Loading state: isStart=false isStop=true status=0x0, loadType=0x800001
1744193919929 RemoteAgent TRACE [15] ProgressListener Stop: has error=false url=moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html
1744193919929 RemoteAgent DEBUG WebDriverBiDiConnection 9139d051-c42c-432c-962c-e25955c0a54b <- {"type":"success","id":12,"result":{"navigation":"a1a63ca6-936d-4312-874b-659c0cd76fce","url":"moz-extension://cb314a3e-0803-4074-9952-5dc11a84d366/options.html"}}
Luca, is there actually a way to know / retrieve such a random UUID
for extension pages?
Comment 1•4 months ago
|
||
Luca, is there actually a way to know / retrieve such a random UUID for extension pages?
If the extension isn't completely shutdown yet and there is still an active WebExtensionPolicy
instance, then:
- something like the following snippet would give the moz-extension url from the addon id:
WebExtensionPolicy.getByID("formautofill@mozilla.org").getURL("")
- something like the following snippet would give the addon id from the moz-extension url:
WebExtensionPolicy.getByURI(Services.io.newURI("moz-extension://UUID/")).id
Tomislav is working with the WECG (The WebExtensions W3C community group) to get to WPT tests for extensions in agreement with the other browser vendors, and so he may have some more context about what they have been discussing with other vendors in the WECG meetings about the WPT topic that may be relevant for what was mentioned in Bug 1903272 comment 9 and that seems to be what this bugzilla issue is now tracking and so I'm also forwarding the needinfo to Tomislav to double-check if he may be more thoughts about that specifically.
Reporter | ||
Comment 2•4 months ago
|
||
Thanks Luca! So the following works in Marionette:
def test(self):
result = self.marionette.open(type="tab", focus=False)
addons = Addons(self.marionette)
id = addons.install(
"/Users/henrik/code/gecko/cookie_manager.xpi", temp=True)
with self.marionette.using_context("chrome"):
url = self.marionette.execute_script(
f"return WebExtensionPolicy.getByID('{id}').getURL("")")
self.marionette.navigate(f"{url}/options.html")
Nevertheless executing chrome scope scripts shouldn't be needed for clients so we may need some kind of API that returns details of an installed addon including this url. But lets wait for Tomislav in case he has more information.
Reporter | ||
Comment 3•4 months ago
|
||
The best way to retrieve the web extension's URL would be to have a command that lists all the user installed web extensions. I've created https://github.com/w3c/webdriver-bidi/issues/898 to get this added to the spec.
Comment 4•3 months ago
|
||
Apologies for the delay, agreed with Luca's suggestion, and supporting a BiDi command to get installed extensions is also a good next step.
Additionally, I think it would make sense to add the base URI (host) for extension pages to the result object of webExtension.install
WebDriver method, since all implementations already have a notion of that, and it will be required for running more advanced kinds of tests in wpt.
Reporter | ||
Comment 5•3 months ago
|
||
(In reply to Tomislav Jovanovic :zombie from comment #4)
Additionally, I think it would make sense to add the base URI (host) for extension pages to the result object of
webExtension.install
WebDriver method, since all implementations already have a notion of that, and it will be required for running more advanced kinds of tests in wpt.
Is the base URI (host) for extension pages a feature that is part of the WebExtension spec and supported by all browsers? When I look into the spec I can only find an empty section for https://w3c.github.io/webextensions/specification/index.html#extension-pages.
Comment 6•3 months ago
|
||
We don't have (In reply to Henrik Skupin [:whimboo][⌚️UTC+2] from comment #5)
Is the base URI (host) for extension pages a feature that is part of the WebExtension spec and supported by all browsers? When I look into the spec I can only find an empty section for https://w3c.github.io/webextensions/specification/index.html#extension-pages.
We're working on the spec (as you can notice it's not complete), and while how it's generated is different for each engine, extension host is a shared concept, and available to extensions using the runtime.getURL() api.
Reporter | ||
Comment 7•3 months ago
|
||
Do you have an estimated timeline for when the concept of the host will be included in the specification? If it's going to take a while, we could consider introducing a vendor-prefixed field as a temporary solution. The info type we would return for the installation could be shared with a getAddons
command as well, which would just return a list of this info type one entry for each installed addon.
Description
•