tab onUpdated event with status == complete firing multiple times in a single page load

1,689 views
Skip to first unread message

doubleTap

unread,
Dec 3, 2011, 8:45:51 PM12/3/11
to Chromium-extensions
At least 1 out of 10 page loads I find that the onUpdated event for a
tab is fired more than once with the status of "complete." This also
means that onUpdated is firing multiple times with the status of
"loading" for a single page load in a single tab. I do not remember
seeing this in the past but maybe I missed it. Is this the intended
functionality? It makes using programmatic injection impossible
without periodically duplicating scripts. I have found it commonly
reproduced on facebook.com.

doubleTap

unread,
Dec 3, 2011, 9:19:22 PM12/3/11
to Chromium-extensions
I created a proof of concept extension with the following. If you run
it at facebook, you will see the multiple completes as recorded in the
background page console.
Manifest:
{ "name":"multiComplete",
"version":"0.1",
"description":"tab onUpdated event with status == complete firing
multiple times in a single page load",
"permissions":["http://*/*","https://*/*","tabs"],
"background_page":"background.html"
}

Background.html:
<script type="text/javascript">
chrome.tabs.onUpdated.addListener(function(id,info,tab)
{console.log(tab.status,tab.url);});
</script>

Mihai Parparita

unread,
Dec 5, 2011, 11:52:38 AM12/5/11
to doubleTap, Chromium-extensions
This is probably because Facebook uses the HTML5 history API (http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#dom-history-pushstate) which means that additional navigations are simulated without the page really reloading.

If this behavior is confusing (and/or you would find it useful to be able to differentiate between these synthetic loads and actual page loads), can you file an enhancement request at http://new.crbug.com/?

Mihai

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


doubleTap

unread,
Dec 5, 2011, 2:01:36 PM12/5/11
to Chromium-extensions
Hi Mihai,

I filed the enhancement here: http://goo.gl/69aui
You were correct about pushState being the cause.

Thank you,

-doubletap

On Dec 5, 8:52 am, Mihai Parparita <mih...@chromium.org> wrote:
> This is probably because Facebook uses the HTML5 history API (http://www.whatwg.org/specs/web-apps/current-work/multipage/history.h...)


> which means that additional navigations are simulated without the page
> really reloading.
>
> If this behavior is confusing (and/or you would find it useful to be able
> to differentiate between these synthetic loads and actual page loads), can

> you file an enhancement request athttp://new.crbug.com/?

> > To post to this group, send email to chromium-extensi...@chromium.org.


> > To unsubscribe from this group, send email to

> > chromium-extensions+unsubscr...@chromium.org.

Reply all
Reply to author
Forward
0 new messages