New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 63 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2011
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Feature

Blocking:
issue chromium-os:4558
issue chromium-os:14211
issue 186383
issue 197311

Restricted
  • Only users with EditIssue permission may comment.



Sign in to add a comment

Support for navigator.onLine toggling and online/offline events

Reported by bedn...@gmail.com, Feb 6 2009

Issue description

Chrome Version       : 2.0.160.0
URLs (if applicable) : https://developer.mozilla.org/En/Online_and_offline_events

Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
     Safari 3: FAIL
    Firefox 3: OK
         IE 7: FAIL
         IE 8: OK

What steps will reproduce the problem?
1. Load testpage from Mozilla Developer Center
2. Bring down network interface
3.

What is the expected result?

Page should update, showing support for both the navigator.onLine (note spelling) Boolean property 
and the online/offline events.

What happens instead?

Nothing.

Please provide any additional information below. Attach a screenshot if possible.

I have reported this to the webkit team here:

https://bugs.webkit.org/show_bug.cgi?id=19105

Note that, at one time, this was fixed for Safari/Mac. It has since regressed and I am petitioning to 
have the bug reopened. It has never worked for Safari/Windows.

Cheers,

- Bill
 

Comment 1 by bedn...@gmail.com, Feb 6 2009

Sorry -

Wrong Webkit bug number (its a related bug, but not the exact one):

https://bugs.webkit.org/show_bug.cgi?id=11284

Cheers,

- Bill
Labels: -Type-Bug Type-Feature

Comment 3 by amathad@google.com, Jan 22 2010

I am facing the same issue but it looks like it has been fixed in Webkit.
I am attaching a small test html page that I used to test. I tested it on FF(3.6),
Chrome (dev channel) and Safari (4.0.4) for windows. 

The test:
 - clicking the button shows an alert with the value of navigator.onLine variable
 - I basically tested by clicking the button when connected and when disconnected. FF
and Safari give the desired results but Chrome does not. It looks like the Chromium
codebase has not picked up the fix from the Webkit core -
https://bugs.webkit.org/show_bug.cgi?id=11284
testo.html
258 bytes View Download

Comment 4 by legend...@gmail.com, Mar 31 2010

This will impact Offline Web Apps which will be a feature in HTML5. I found IE 8.0 can 
detect network status and support work offline mode. Firefox just supports work offline 
mode but fails to detect physical network status change. Chrome does not support both 
work offline mode menu and navigator.onLine detection.

Thanks,
-Chengrui 

Comment 5 by mhm@chromium.org, Apr 2 2010

There seems to be another bug in webkit as well:
https://bugs.webkit.org/show_bug.cgi?id=32327
uTest
Repro in dev build: yes
Repro in stable build: yes
Accurate Steps: yes
Configuration used: Chrome 5.0.375.86 + Chrome 6.0.447.0 dev + Windows 7 x64

This is still reproducible.  Test HTML returns 'true' for online and offline.

Comment 7 by darin@chromium.org, Jul 9 2010

Status: WontFix
navigator.onLine and online/offline events are not supported because they are not useful.  they only tell you about the status of your immediate network adapter.  it doesn't say anything about whether or not you can actually connect to a server.  your ISP connection may be down for example, and your local operating system would have no idea.  your OS would just be able to tell you that "yes, you have a connection to your router."  WONTFIX

Comment 8 by darin@chromium.org, Jul 9 2010

the only reliable way to determine if you are online is to actually try to make a connection to a server.  this forces you to write your application in a more robust way.  if you write to navigator.onLine and online/offline events, then your application will not perform well in real network outage/flakiness scenarios.
 Issue 38084  has been merged into this issue.

Comment 10 by timm...@gmail.com, Aug 4 2010

I'd disagree with darin's assessment that online and offline events are not useful. Lets say you are making an ajax call and it fails. Normally at this point, you'd give the user a warning or error message and then add a timeout and retry the call (and keep retrying for a while/forever).

But with functional online/offline events and properties you could handle things differently. So when the ajax call first errors out, check window.navigator.onLine. If it is false, then you can definitively tell the user that the error was due to loss of network (instead of having to guess between server timeout and network being down).  It is much helpful to the user to say, "You won't get any more updates since you have disconnected from the network", than, "You won't get any more updates, check to see if you have disconnected from the network."

Additionally, you can setup a callback for the online event, so that you can _immediately_ retry the ajax call when the browser tells you the network is back. That's much better than the retry scenario because you are probably only retrying the ajax call once every several seconds and the online event would get the application back and running significantly more quickly.

So it seems to me that having real offline properties and events is invaluable, particularly in live/websocket/long polling web applications.
Everybody’s entitled to his own opinion, but opinions on wether this is useful or not shouldn’t make a difference in this case.

At the end of the day the ononline/onoffline events are part of the HTML5 spec, and all other modern browsers support them already. Why not WebKit/Chrome/Safari?

Comment 12 by darin@chromium.org, Aug 27 2010

Labels: -Area-Misc Area-WebKit WebKit-Core
Status: Untriaged
Putting this back on the radar.  I agree with the argument in comment #10.  Thanks for your input.
Labels: Mstone-8
putting into m8 since that's the next mstone.
Labels: -Mstone-8 Mstone-X
The link state is really all we know anything about.  I.e. we only know how the physical layer (WiFi/Ethernet) is doing.  We don't know any thing about whether the internets are working.  Are other implementations only looking at the link state?

Anyway, this clearly isn't making m8.  Setting to X until we have some clear plan and/or owner.

Comment 15 by jdmob...@gmail.com, Oct 15 2010

In response to Comment 14, Fx3 and IE8 do both use link state for navigator.onLine and the associated events. That's according to testing I've done, but their respective docs seem to say the same:

https://developer.mozilla.org/En/Online_and_offline_events
http://msdn.microsoft.com/en-us/library/cc304129(VS.85).aspx#status_improvements

Comment 16 by Deleted ...@, Dec 7 2010

Hi, I tested with Safari 5.0.2, Firefox 4.0b7, Chrome Dev build and Opera 10.6. All on Mac OSX 10.6.4

Here's how each of the browser behaves when I turnoff network connection. 

- gives the navigator.onLine status as false for Safari and FF. 
- gives the status as true for Opera till I explicitly enable Work Offline which again dont make much sense. Why a user needs to manually enable work offline.
- always gives true for Chrome.

IMO, this is an extremely important feature for offline web app development. I totally agree with comment #10 and #11

It will be great to see Chromium team putting this on a priority as almost all of the latest browser versions (including webkit based Safari) behaves as expected (except for Opera).

Thanks for your effort in advance.
 Issue 62052  has been merged into this issue.
I tested this with Firefox 4b10 and it works very nicely there:
If I unplug the cable and disable WIFI it immediately throws the "offline" event. When I put the cable back in, it throws an "online" event. I understand the argument that this is not a 100% precise way to determine if there is a connection to a server or just to a network but it works as a pretty sweet indicator.
I hope this will make it's way into Chromium soon, because as far as offline applications go, Chrome has always been on the leading edge!

Comment 19 by nfh...@gmail.com, Feb 2 2011

As per  issue 38084  also see http://hacks.mozilla.org/2010/01/offline-web-applications/

This shows a working demo as to why you might need this.
Labels: -Mstone-X Mstone-11
Status: Assigned

Comment 21 by adamk@chromium.org, Feb 11 2011

Blockedon: 53473

Comment 22 by polo...@gmail.com, Feb 12 2011

am creating chrome web app that can work offline. would like to receive the events. at least let navigator.onLine work!
Labels: -Mstone-11 Mstone-12
Project Member

Comment 24 by bugdroid1@chromium.org, Mar 4 2011

The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=76985

------------------------------------------------------------------------
r76985 | adamk@chromium.org | Fri Mar 04 14:42:08 PST 2011

Changed paths:
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/socket/client_socket_pool_base.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/network_change_notifier.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/network_change_notifier_win.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/network_change_notifier_win.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/render_messages_internal.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/socket/client_socket_pool_base.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/network_change_notifier.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/jingle/notifier/communicator/login.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/intranet_redirect_detector.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/google/google_url_tracker.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/renderer/render_view.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/dnsrr_resolver.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/sync/engine/syncapi.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/content/browser/tab_contents/tab_contents.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/io_thread.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/proxy/proxy_service.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/spdy/spdy_session_pool.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/host_resolver_impl.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/host_resolver_impl.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/spdy/spdy_session_pool.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/io_thread.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/proxy/proxy_service.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/content/browser/tab_contents/tab_contents.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/renderer/render_view.h?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/google/google_url_tracker.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/intranet_redirect_detector.cc?r1=76985&r2=76984&pathrev=76985
 M http://src.chromium.org/viewvc/chrome/trunk/src/jingle/notifier/communicator/login.cc?r1=76985&r2=76984&pathrev=76985

Plumb through NetworkChangeNotifier::IsOffline() to WebKit, enabling
navigator.onLine and online/offline events.  Only works on Windows at the moment, as IsCurrentlyOffline() is supported only by NetworkChangeNotifierWin.

Most of the changes are due to the need to support two different kinds of NetworkChangeNotifier observers. Both observers currently happen to trigger on the same event, but that could change, e.g., if we store the previous online state and only notify on a change. Thus the need for two different observer interfaces, and associated Add/Remove methods.

BUG= 7469 
TEST=Load https://bug336359.bugzilla.mozilla.org/attachment.cgi?id=220609, unplug network cable, reload, see that page changes to note offline status

Review URL: http://codereview.chromium.org/6526059
------------------------------------------------------------------------
Cc: osh...@chromium.org
Blocking: chromium-os:14211
Blocking: chromium-os:4558
 Issue 79295  has been merged into this issue.

Comment 29 by k...@google.com, Apr 25 2011

Labels: Mstone13 MovedFrom12
Moving out of M12.

Comment 30 by k...@google.com, Apr 25 2011

Labels: -Mstone-12 Mstone-13
Moving out of M12.

Comment 31 by krisr@chromium.org, Apr 28 2011

Cc: krisr@chromium.org a deleted user nirnimes...@gtempaccount.com
Labels: -Pri-2 Pri-1
This is blocking chromium-os:4558 which is breaking a large number of pyauto tests on ChromeOS.  Can we get this fixed soon?

Comment 32 by adamk@chromium.org, Apr 28 2011

To be clear, r76985 already enabled this support on Windows, but I'm leaving the issue open to track progress on Mac & Linux implementations.
Hi, I tried it in on Windows 7 with Chrome Dev Build 12.0.742.12, canary build 13.0.752.0 and 11.0.696.0 but not able to get it working on any.

What i am doing is:
Load https://bug336359.bugzilla.mozilla.org/attachment.cgi?id=220609, unplug network cable, wait and see that page changes to note offline status

Can some tell me in which build this fix is available?

Thanks a lot in advance
Attached a version of the test case that I've tested on Chrome.
onlineTest.html
918 bytes View Download
With which Chrome build you tested? I tested this test just on 12.0.742.12 and see that navigator.onLine always returns true and ononline/onoffline events don't fire.
I tested this on 12.0.742.12 on Windows 7.
Got it. My machine had Virtual Ethernet Adapters installed. I get onoffline event only if i disable all the network adapters (doesn't matter if they can provide network access or not).

Is this behavior fine? When this event should get fired? Virtual Ethernet adapters are not providing you any internet/outside access so you are ideally offline at that time. Network and sharing center shows "No network access" in this situation so onoffline event should fire here.

What do you say?

Comment 38 by adamk@google.com, May 3 2011

It's a known issue that this detection isn't perfect: the definition of "online" is a bit fuzzy (what if you could connect to the local network but not any site on the internet?), and as you see, things like virtual interfaces can confuse our detection code.  For reasons like this, the "offline" state is, in my opinion, much more valuable to web applications (since it has no false positives) than the "online" state.

But thanks for the report, and I'll log this as a feature request for our detection code.
Labels: -Mstone-13 Mstone-14 MovedFrom13
Moving !type=meta|regression and !releaseblocker to next mstone
Project Member

Comment 40 by bugdroid1@chromium.org, Jun 2 2011

The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=87699

------------------------------------------------------------------------
r87699 | adamk@google.com | Thu Jun 02 14:56:44 PDT 2011

Changed paths:
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/network_change_notifier_mac.cc?r1=87699&r2=87698&pathrev=87699
 M http://src.chromium.org/viewvc/chrome/trunk/src/net/base/network_change_notifier_mac.h?r1=87699&r2=87698&pathrev=87699

Implement NetworkChangeNotifier::IsCurrentlyOffline() for Mac.

R=willchan@chromium.org
BUG= 7469 , 53473 
TEST=load onlineTest.html attachment on  bug 7469 ; disconnect/connect network cable

Review URL: http://codereview.chromium.org/7006015
------------------------------------------------------------------------
Labels: -MovedFrom12 MovedFrom-12
fix it

Comment 43 by Deleted ...@, Sep 14 2011

What is the status of support of this property in safari [webkit]. I can see that bill opened this bug for them but was it resolved. in webkit, i could also see a new bug opened  Bug 32555  - [Qt] support navigator.onLine and ononline/onoffline events which was resolved too but the latest safari does not seem to support it.

Comment 44 by adamk@chromium.org, Oct 11 2011

Blockedon: -53473
Status: Fixed
This is supported in M14 (current stable) on Windows, Mac, and Chromium OS, so I'm closing this bug to better indicate the state of the world.   Issue 53473  will stay open until Linux support is landed.
Labels: Hotlist-GoogleApps
Project Member

Comment 47 by bugdroid1@chromium.org, Nov 16 2011

Project Member

Comment 48 by bugdroid1@chromium.org, Oct 13 2012

Blocking: -chromium-os:14211 -chromium-os:4558 chromium-os:14211 chromium-os:4558
Labels: Restrict-AddIssueComment-Commit
This issue has been closed for some time. No one will pay attention to new comments.
If you are seeing this bug or have new data, please click New Issue to start a new bug.
Project Member

Comment 49 by bugdroid1@chromium.org, Mar 10 2013

Labels: -Area-WebKit -WebKit-Core -Mstone-14 Cr-Content M-14 Cr-Content-Core
Project Member

Comment 50 by bugdroid1@chromium.org, Mar 13 2013

Labels: -Restrict-AddIssueComment-Commit Restrict-AddIssueComment-EditIssue
Project Member

Comment 51 by bugdroid1@chromium.org, Apr 6 2013

Labels: -Cr-Content Cr-Blink

Sign in to add a comment