Bug: Theme breaks when using autoconfig to set newTabURL
Status: RESOLVED
Priority: --
Resolution: INVALID
Created: 2025-02-25 18:38:25+00:00
Resolved: 2025-03-05 22:37:10+00:00

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0

Steps to reproduce:

I use a barebones html file as a homepage and use the following autoconfig code to set it as the new tab URL.

autoconfig.js
```
// IMPORTANT: first line is a comment
pref("general.config.filename", "autoconfig.cfg");
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false);
```

autoconfig.cfg
```
// IMPORTANT: first line is a comment
var { utils:Cu } = Components;
try {
  Cu.import("resource:///modules/AboutNewTab.jsm");
  var newTabURL = "/home/[user]/Documents/Computer/Firefox config/homepage.html";
} catch(e){Cu.reportError(e);} // report errors in the Browser Console
```


Actual results:

New tabs open the homepage file as expected, but my Firefox theme is broken in new windows (see attached screenshots). The bookmarks toolbar is also visible in new windows despite being set to "Only Show on New Tab".

When the autoconfig file is active, the following errors appears in the browser console upon opening a new window:

```
Uncaught NS_ERROR_MALFORMED_URI: Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIIOService.newURI]
    _newTabURI chrome://browser/content/browser-places.js:1451
    isOnNewTabPage chrome://browser/content/browser-places.js:1444
    isOnNewTabPage chrome://browser/content/browser-places.js:1443
    setToolbarVisibility chrome://browser/content/browser.js:4613
    updateBookmarkToolbarVisibility chrome://browser/content/browser.js:760
    onBeforeInitialXULLayout chrome://browser/content/browser-init.js:72
browser-places.js:1451
NS_ERROR_MALFORMED_URI: Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIIOService.newURI]
    _newTabURI chrome://browser/content/browser-places.js:1451
    isOnNewTabPage chrome://browser/content/browser-places.js:1444
    isOnNewTabPage chrome://browser/content/browser-places.js:1443
    setToolbarVisibility chrome://browser/content/browser.js:4613
    updateBookmarkToolbarVisibility chrome://browser/content/browser.js:760
    onLocationChange chrome://browser/content/browser.js:3364
    callListeners chrome://browser/content/tabbrowser/tabbrowser.js:1009
    _callProgressListeners chrome://browser/content/tabbrowser/tabbrowser.js:1023
    _callProgressListeners chrome://browser/content/tabbrowser/tabbrowser.js:7256
    onLocationChange chrome://browser/content/tabbrowser/tabbrowser.js:7731
tabbrowser.js:1014:23
```

and upon opening a new tab:

```
NS_ERROR_MALFORMED_URI: Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIIOService.newURI]
    _newTabURI chrome://browser/content/browser-places.js:1451
    isOnNewTabPage chrome://browser/content/browser-places.js:1444
    isOnNewTabPage chrome://browser/content/browser-places.js:1443
    setToolbarVisibility chrome://browser/content/browser.js:4613
    updateBookmarkToolbarVisibility chrome://browser/content/browser.js:760
    onLocationChange chrome://browser/content/browser.js:3364
    callListeners chrome://browser/content/tabbrowser/tabbrowser.js:1009
    _callProgressListeners chrome://browser/content/tabbrowser/tabbrowser.js:1023
    updateCurrentBrowser chrome://browser/content/tabbrowser/tabbrowser.js:1266
    _setupEventListeners chrome://browser/content/tabbrowser/tabbrowser.js:6688
    set selectedIndex chrome://global/content/elements/tabbox.js:235
    set selectedPanel chrome://global/content/elements/tabbox.js:245
    set selectedIndex chrome://global/content/elements/tabbox.js:555
    set selectedItem chrome://global/content/elements/tabbox.js:579
    set selectedTab chrome://global/content/elements/tabbox.js:83
    set selectedTab chrome://browser/content/tabbrowser/tabbrowser.js:427
    addTab chrome://browser/content/tabbrowser/tabbrowser.js:2896
    openLinkIn resource:///modules/URILoadingHelper.sys.mjs:569
    openTrustedLinkIn resource:///modules/URILoadingHelper.sys.mjs:729
    openTrustedLinkIn chrome://browser/content/utilityOverlay.js:111
    wrappedJSObject chrome://browser/content/browser-commands.js:347
    openTab chrome://browser/content/browser-commands.js:333
    <anonymous> chrome://browser/content/browser-sets.js:25
tabbrowser.js:1014:23
NS_ERROR_MALFORMED_URI: Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIIOService.newURI]
    _newTabURI chrome://browser/content/browser-places.js:1451
    isOnNewTabPage chrome://browser/content/browser-places.js:1444
    isOnNewTabPage chrome://browser/content/browser-places.js:1443
    setToolbarVisibility chrome://browser/content/browser.js:4613
    updateBookmarkToolbarVisibility chrome://browser/content/browser.js:760
    onLocationChange chrome://browser/content/browser.js:3364
    callListeners chrome://browser/content/tabbrowser/tabbrowser.js:1009
    _callProgressListeners chrome://browser/content/tabbrowser/tabbrowser.js:1023
    _callProgressListeners chrome://browser/content/tabbrowser/tabbrowser.js:7256
    onLocationChange chrome://browser/content/tabbrowser/tabbrowser.js:7731
tabbrowser.js:1014:23
```

I'm able to reproduce this on a new profile.


Expected results:

The autoconfig code should overwrite the new tab URL without affecting the theme or causing errors. The same code behaved without issue as of Firefox 115 esr on my old computer (macOS if that's relevant).