Open Bug 1963823 Opened 2 months ago Updated 2 months ago

URL() returns a URL with pathname that is readonly if the URL is for an Android asset

Categories

(GeckoView :: General, defect)

Firefox 138
All
Android
defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: jw, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Steps to reproduce:

GeckoView uses the URL protocol identifier: "resource://android/assets/" for loading assets from the Android asset folder.

If, in JavaScript running within GeckoView, you create a URL object using this protocol identifier, you get a URL object in which the "pathname" is readonly and cannot be changed. Whereas, if you create a URL object using a protocol identifier of "http" (for example), you can modify the pathname.

var url = new URL("resource://android/assets/a.js");
url.pathname = url.pathname.replace("a.js", "b.js");
console.log(url.toString());
CONSOLE OUTPUT: resource://android/assets/a.js

var url = new URL("http://android/assets/a.js");
url.pathname = url.pathname.replace("a.js", "b.js");
console.log(url.toString());
CONSOLE OUTPUT: http://android/assets/b.js

Note: you can only create a URL object for "resource://" when running from within GeckoView (Firefox itself produces an error if you try it there as it determines it is an unknown protocol. Chrome lets you use any protocol identifier when creating a URL object).

Going back, GeckoView 108 doesn't appear to do this, though, as this older version isn't compatible with the latest Firefox Remote Debugger, it's hard to be sure. It's broken in the latest v138.

Actual results:

The URL created for "resource://android" has properties that a readonly, whereas a URL created for "http://" are not.

Expected results:

The URL object should have a pathname that can be updated.

Severity: -- → S4
You need to log in before you can comment on or make changes to this bug.