URL "about:newtab" still shows default and not custom new tab

Hi everyone,

currently i write my first extension to create a new tab page, its finished and working great. But i want that my homepage is my new tab page as well, not only for new tabs.

My first idea was to set “about:newtab” as homepage, but why the url still shows the default one and not my new custom tab, i thought its “overwritten”?

My next idea was to open the preferences, my custom new tab page and clicking “Use Current Pages”. Firefox adds automatically a url like “moz-extension:///tab.html”. Is this the only way? Does the “” changes, e.g. on next update of the addon? Is there any other way?

In Chrome i just tick the radio button “New Tab page” for homepage. Does someone has any hint that i can add to the FAQ?

Thx + BR Thomas

Found “chrome_settings_overrides” to set homepage to new tab page, but cannot be changed after installation of add-on by user. Any hint to make it optional for users?

I am also interested by this :slight_smile:
I think one way could be to modify the browser.startup.homepage settings in about:config, but webextension doesn’t allow such settings modification.

There is several options:

  1. you generate “homepage link” for the user using browser.extension.getURL('newTab.html') and then tell them to use it in Firefox Options page.
  2. you override homepage in chrome_settings_overrides - but this cannot be changed afterwards by user so not a good idea.
  3. you can detect opening homepage by listening to events like tabs.onUpdated (or tabs.onCreated) and when you detect about:newtab, you change that to your add-on. However to make this work properly it may require some complex logic (sometimes tab opens as about:blank and then changes to something else). Also it may introduce new set of issues like wrong focus on page instead of address bar.

I’m using the first option with short text about how to do that and a button to copy that URL to clipboard.

1 Like

Thx for your answer, but for me it looks more than workarounds/hacks. In Chrome its much easier, no “chrome_settings_overrides.homepage” needed, chrome://newtab shows the default or custom new tab page and the user has the option “New Tab as Homepage” or just enter “chrome://newtab” (commonly knows) as homepage url.

Thats why i decided to use “chrome_settings_overrides.homepage” in hope that it works without adding complex code like checking url to make an redirect to custom new tab page which could cause trouble, or offering any strange url which the user has to copy etc… not very user friendly.

I would give it a try, but does it show only the custom page or tries to load default new tab page for under a second and then it redirects… would be not nice and a ugly workaround, but i will see. But what happens if Firefox changes this, because for me “about:newtab” behaviour is a bug.

My next problem is that “chrome_settings_overrides.homepage” seems to be not stable. It works most of the time, but sometimes after starting Firefox it shows default “about:newtab” or nothing, and not the page defined in “chrome_settings_overrides.homepage”. Verified, because it does not contain any code of my “newtab.html”, thats why i think its not an issue with the extension, because same code works great in Chrome.

But i will try and keep you posted. Thx again… BR

Regarding opening very first Firefox window - I’m pretty sure this is a Firefox bug. Because add-ons are loaded asynchronously there is a chance that Firefox will open first tab faster than load add-ons overriding it and so it display the default page.

I agree the chrome_settings_overrides.homepage way suppose to be the right one, but Firefox needs to fix this as well (allow users to change it without disabling whole add-on).

But next problem, on browser start i get nothing, a blank page with title “New Tab” but with not any html code, that i can assume that my extension is not loaded. For me it makes such new tab extension useless and no idea howto answer such support questions.

I tried already everything, deleting profile folder, not logging in for Firefox sync etc. But i get always a blank page on start.

Please does anyone has an idea how i can handle it? Maybe just remove the following?

“chrome_settings_overrides”: {
“homepage”: “tab.html”
},

But no idea if this help when users do it by hand, maybe i have the same issue on start. I know only i cannot check with debugging extensions because its lost after restart and i do not want submit something to AMO just for testing. Another thing which i do not understand why developing is only “temporarily”… anyway.

Or what have to do that tab.html is shown on start?

Thanks a million again for help, Thomas

This is most probably the problem I mentioned before and it’s part of this bug (I hope):

But maybe you should create new bug for that.
I’m pretty sure this is due to the asynchronous nature of add-ons loading - where Firefox can load homepage before the add-on overriding it.

For me it’s like 50% chance that when I start Firefox, it will show my add-on page :frowning: .
But what I’m gonna try is make a dirty workaround - on start of my add-on (start of background script) check whether there is one empty tab opened and if yes, then I redirect it.

Done :slight_smile:

Thx for the quick answer, i just wait for first reply like “Duplicate”, “GoogleIsYourFriend”, “Its me” etc. :wink:

I hope they accept it, otherwise i try to implement the workaround you described.

Btw. how do you check for empty page? Events like tabs.onCreted does not help because its already open before extension start, a setIntervall thing?

BR Thomas

1 Like

Great!
The empty page detection may not need any trigger - when you add-on background script starts it’s the right time (or maybe with some 100ms sleep, or maybe something else… I’m not sure now…).
But something like this:

browser.tabs.query({}).then(tabs => 
  tabs.length === 1 &&
  tabs[0].url === 'about:blank' && 
  tabs[0].status === browser.tabs.TabStatus.COMPLETE && 
  browser.tabs.update(tabs[0].id, {url: browser.runtime.getURL('dial.html')})
);

I think I will try it with my next release now when it’s already written :smiley: .

Also note that your background script starts also when your add-on is updated or reloaded (but it should be an issue here).

I have now multiple users reporting this bug after upgrading to Firefox 62.
But now when I’m trying to reproduce it, it’s kind of rare - it seems like it happens to me only when I reboot whole PC and start Firefox 62 for very first time.

But the work-around is much more complicated if you want to fix all cases.

You see, you can get “nice” empty “about:blank” tab:

{
  "id": 1,
  "index": 0,
  "windowId": 1,
  "highlighted": false,
  "active": false,
  "pinned": false,
  "status": "complete",
  "hidden": false,
  "discarded": false,
  "incognito": false,
  "width": 1536,
  "height": 846,
  "lastAccessed": 1537255202548,
  "audible": false,
  "mutedInfo": {
    "muted": false
  },
  "isInReaderMode": false,
  "sharingState": {
    "camera": false,
    "microphone": false
  },
  "url": "about:blank",
  "title": "New Tab"
}

But if you have “Restore previous session” enabled you can get your add-on page that has no HTML:** <html><head></head><body></body></html> but the tab info looks fine:

{
  "id": 2,
  "index": 0,
  "windowId": 1,
  "highlighted": false,
  "active": false,
  "attention": false,
  "pinned": false,
  "status": "complete",
  "hidden": false,
  "discarded": false,
  "incognito": false,
  "width": 1719,
  "height": 945,
  "lastAccessed": 1537255579257,
  "audible": false,
  "mutedInfo": {
    "muted": false
  },
  "isInReaderMode": false,
  "sharingState": {
    "camera": false,
    "microphone": false
  },
  "url": "moz-extension://78dfa00e-5ed2-465e-8e61-6259d76eb8dc/dial.html",
  "title": "GroupSpeedDial",
  "favIconUrl": "data:image/png;base64,iVBORw0K..."
}

And the third case:
Multiple-pages-homepage feature - If one of them is add-on page, it won’t get loaded - this is easy to reproduce as it occurs 100% times:

The tab looks like this:

{
  "id": 3,
  "index": 1,
  "windowId": 1,
  "highlighted": false,
  "active": false,
  "attention": false,
  "pinned": false,
  "status": "complete",
  "hidden": false,
  "discarded": false,
  "incognito": false,
  "width": 1719,
  "height": 945,
  "lastAccessed": 1537256252074,
  "audible": false,
  "mutedInfo": {
    "muted": false
  },
  "isInReaderMode": false,
  "sharingState": {
    "camera": false,
    "microphone": false
  },
  "url": "about:blank",
  "title": "78dfa00e-5ed2-465e-8e61-6259d76eb8dc/dial.html"
}

it is about:blank but the “title” looks different