Closed Bug 952402 Opened 11 years ago Closed 7 years ago

weird tab.url behaviour

Categories

(Add-on SDK Graveyard :: General, defect, P2)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: dietrich, Unassigned)

References

Details

STR: 1. write a tab.on('open') listener that dumps tab.url 2. open browser with a single tab, then open 4 tabs Expected: *five* URLs output to console (one for each tab), with a URL of either about:blank or about:newtab (not sure what to expect really) Actual: Only *four* URLs output to console, and starts with about:blank, then *changes* to about:newtab Screenshot: https://www.dropbox.com/s/x0fcmc387y814vj/Screenshot%202013-12-19%2022.11.05.png
ni? to Tim for newtab expertise. the sdk code: var tabs = require('sdk/tabs') tabs.on('open', function (tab) { console.log(tab.url) })
Flags: needinfo?(ttaubert)
Ok, I'm not entirely sure I understand what you are doing so here are a few wild guesses: tabs.on("open") is a TabOpen listener so it fires when opening a new tab. One tab was already there when you opened the browser so that's why you get four events only. After 5s of uptime the BrowserNewTabPreloader kicks in (browser.newtab.preload) which means that about:newtab shows immediately and thus the url is about:newtab. For all other cases the page was loaded normally and starts with about:blank.
Flags: needinfo?(ttaubert)
Ah ok the count makes sense. So now this bug is that about:newtab *content* showed in the new tabs, but the first 3 new tabs had about:blank as the value of tab.url in the snippet above.
(In reply to Dietrich Ayala (:dietrich) from comment #3) > So now this bug is that about:newtab *content* showed in the new tabs, but > the first 3 new tabs had about:blank as the value of tab.url in the snippet > above. I don't know how |tab.url| is implemented but if you do gBrowser.addTab("uri") won't that show about:blank as as long as "uri" didn't start loading? Does console.log() off a timeout of say 1s yield something different?
I think this has to do with the first tab not being "opened", but opened as a part of a new window (auto-opened). I believe gozala was trying to get this event exposed on the platform side, pinging him re: that
Flags: needinfo?(rFobic)
This happened with more than just the first tab (but yeah that's a problem). Tim, yes adding 1s wait did result in the correct URL. Very odd that the 1s wait is necessary for the first 5 or so seconds, but not necessary after that. Sounds like the BrowserNewTabPreloader you talk about above.
(In reply to Dietrich Ayala (:dietrich) from comment #6) > Sounds like the BrowserNewTabPreloader you talk about above. Yes, exactly. The BrowserNewTabPreloader swaps in a preloaded docShell before the TabOpen event is fired. The page is thus available and loaded immediately. If you manually open new tabs fast enough you will occasionally see the preloader being a tad too slow.
tabs.on("open", listener) calls listener every time TabOpen event occurs. For new browser window initial tab does not triggers `TabOpen` event so that's why there's only 4 events logged. As of tab.url it's whatever the url is for the tab when `TabOpen` event is fired. Tim I'm not familiar with BrowserNewTabPreloader is there a different event we can listen that is triggered once tab is actually loaded ?
Flags: needinfo?(rFobic) → needinfo?(ttaubert)
(In reply to Irakli Gozalishvili [:irakli] [:gozala] [@gozala] from comment #8) > Tim I'm not familiar with BrowserNewTabPreloader is there a different event > we can listen that is triggered > once tab is actually loaded ? Sorry, I think I don't understand the problem. What exactly are you trying to do and what isn't working? For a preloaded tab the page is loaded immediately (i.e. readyState=complete), a tab that wasn't preloaded will just behave like every other page and send load events.
Flags: needinfo?(ttaubert)
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.