Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct control over online/offline status #245

Closed
magreenblatt opened this issue May 24, 2011 · 9 comments
Closed

Direct control over online/offline status #245

magreenblatt opened this issue May 24, 2011 · 9 comments
Labels
enhancement Enhancement request Framework Related to framework code or APIs

Comments

@magreenblatt
Copy link
Collaborator

Original report by me.


Original issue 245 created by magreenblatt on 2011-05-24T16:45:12.000Z:

Issue comment 23.4 added support for navigator.onLine and online/offline window events. It would be nice if client applications using features like HTML5 app cache could control online/offline mode directly based on application state information instead of just network status.

@magreenblatt
Copy link
Collaborator Author

Comment 1. originally posted by magreenblatt on 2011-12-15T13:21:55.000Z:

@magreenblatt
Copy link
Collaborator Author

  • edited description
  • set component to "Framework"

@magreenblatt
Copy link
Collaborator Author

The DevTools network tab has a “Throttling” option which supports modes such as Offline:


This is implemented for DevTools as follows:

  1. Browser process DevTools code calls NetworkHandler::SetNetworkConditions which calls NetworkContext::SetNetworkConditions (ThrottlingController::SetConditions) in the network process.
  2. ThrottlingController manages the registered state. Only requests that match a frame-specific identifier (devtools_frame_token a.k.a. throttling_profile_id) will be throttled.
  3. ScopedThrottlingToken::MaybeCreate (scoped calls to ThrottlingController::RegisterProfileIDForNetLogSource/UnregisterNetLogSource) maps the throttling_profile_id to url_request_->net_log().source().id in the URLLoader constructor.
  4. ThrottlingNetworkTransaction::Start (ThrottlingController::GetInterceptor) applies the actual throttling. For example, offline mode causes all requests to fail with net::ERR_INTERNET_DISCONNECTED.
  5. Online/offline state needs to be configured separately for ServiceWorkers. See BackgroundSyncRestorer in the DevTools code.
  6. Online/offline state in the renderer process (e.g. for navigator.onLine) is configured via InspectorNetworkAgent::emulateNetworkConditions using NetworkStateNotifier::SetNetworkConnectionInfoOverride/ClearOverride and retrieved via NavigatorOnLine.

CEF should support a mode that throttles all requests for the RequestContext (e.g. not requiring the frame-specific identifier).

@magreenblatt
Copy link
Collaborator Author

It might be less complex to handle this through DevToolsAgentHost like in CefDevToolsFrontend::HandleMessageFromDevToolsFrontend (e.g. DevToolsAgentHost::GetOrCreateFor(inspected_contents)->DispatchProtocolMessage).

The message value for offline:

{"id":92,"method":"Network.emulateNetworkConditions","params":{"offline":true,"latency":0,"downloadThroughput":0,"uploadThroughput":0,"connectionType":"none"}}

The message value for online:

{"id":93,"method":"Network.emulateNetworkConditions","params":{"offline":false,"latency":0,"downloadThroughput":0,"uploadThroughput":0}}

DevTools protocol messages are documented at https://chromedevtools.github.io/devtools-protocol/

@magreenblatt
Copy link
Collaborator Author

Changing the network status via the DevTools protocol does not update the UI in an existing DevTools front-end instance. Consequently the best way to test offline mode is by (1) observing that all network requests fail with ERR_INTERNET_DISCONNECTED, and (2) by running javascript:alert(navigator.onLine) from the address bar in cefclient and seeing that it displays false (meaning offline). This mode is per-browser, so a newly created browser will have the default status (e.g. online unless the --offline command-line flag was specified on startup).

@magreenblatt
Copy link
Collaborator Author

Add support for direct DevTools protocol messaging (fixes issue #2961).

This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:

  • Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
    callback (see issue Add callback for document element creation #1454).
  • Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
  • Add a --devtools-protocol-log-file=<path> command-line flag for
    logging protocol messages sent to/from the DevTools front-end
    while it is displayed. This is useful for understanding existing
    DevTools protocol usage.
  • Add a new "libcef_static_unittests" executable target to support
    light-weight unit tests of libcef_static internals (e.g. without
    requiring exposure via the CEF API). Files to be unittested are
    placed in the new "libcef_static_unittested" source_set which is
    then included by both the existing libcef_static library and the
    new unittests executable target.
  • Linux: Remove use_bundled_fontconfig=false, which is no longer
    required and causes unittest build errors (see issue Linux Ubuntu 16.04: Hang during startup in FT_Load_Glyph #2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue #245). This is controlled
by the "Offline mode" context menu option and the --offline
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.

→ <<cset 39aed35644dc (bb)>>

@magreenblatt
Copy link
Collaborator Author

  • changed state from "new" to "resolved"

@magreenblatt
Copy link
Collaborator Author

Add support for direct DevTools protocol messaging (fixes issue #2961).

This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:

  • Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
    callback (see issue Add callback for document element creation #1454).
  • Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
  • Add a --devtools-protocol-log-file=<path> command-line flag for
    logging protocol messages sent to/from the DevTools front-end
    while it is displayed. This is useful for understanding existing
    DevTools protocol usage.
  • Add a new "libcef_static_unittests" executable target to support
    light-weight unit tests of libcef_static internals (e.g. without
    requiring exposure via the CEF API). Files to be unittested are
    placed in the new "libcef_static_unittested" source_set which is
    then included by both the existing libcef_static library and the
    new unittests executable target.
  • Linux: Remove use_bundled_fontconfig=false, which is no longer
    required and causes unittest build errors (see issue Linux Ubuntu 16.04: Hang during startup in FT_Load_Glyph #2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue #245). This is controlled
by the "Offline mode" context menu option and the --offline
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.

→ <<cset 0fb8a5f1eada (bb)>>

@magreenblatt
Copy link
Collaborator Author

Add support for direct DevTools protocol messaging (fixes issue #2961).

This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:

  • Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
    callback (see issue Add callback for document element creation #1454).
  • Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
  • Add a --devtools-protocol-log-file=<path> command-line flag for
    logging protocol messages sent to/from the DevTools front-end
    while it is displayed. This is useful for understanding existing
    DevTools protocol usage.
  • Add a new "libcef_static_unittests" executable target to support
    light-weight unit tests of libcef_static internals (e.g. without
    requiring exposure via the CEF API). Files to be unittested are
    placed in the new "libcef_static_unittested" source_set which is
    then included by both the existing libcef_static library and the
    new unittests executable target.
  • Linux: Remove use_bundled_fontconfig=false, which is no longer
    required and causes unittest build errors (see issue Linux Ubuntu 16.04: Hang during startup in FT_Load_Glyph #2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue #245). This is controlled
by the "Offline mode" context menu option and the --offline
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.

→ <<cset fd6631bd1812 (bb)>>

S1artie pushed a commit to GEBIT/cef that referenced this issue Aug 10, 2023
…iumembedded#2961).

This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:
- Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
  callback (see issue chromiumembedded#1454).
- Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
- Add a `--devtools-protocol-log-file=<path>` command-line flag for
  logging protocol messages sent to/from the DevTools front-end
  while it is displayed. This is useful for understanding existing
  DevTools protocol usage.
- Add a new "libcef_static_unittests" executable target to support
  light-weight unit tests of libcef_static internals (e.g. without
  requiring exposure via the CEF API). Files to be unittested are
  placed in the new "libcef_static_unittested" source_set which is
  then included by both the existing libcef_static library and the
  new unittests executable target.
- Linux: Remove use_bundled_fontconfig=false, which is no longer
  required and causes unittest build errors (see issue chromiumembedded#2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue chromiumembedded#245). This is controlled
by the "Offline mode" context menu option and the `--offline`
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.
filipnavara pushed a commit to emclient/cef that referenced this issue Dec 26, 2023
…iumembedded#2961).

This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:
- Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
  callback (see issue chromiumembedded#1454).
- Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
- Add a `--devtools-protocol-log-file=<path>` command-line flag for
  logging protocol messages sent to/from the DevTools front-end
  while it is displayed. This is useful for understanding existing
  DevTools protocol usage.
- Add a new "libcef_static_unittests" executable target to support
  light-weight unit tests of libcef_static internals (e.g. without
  requiring exposure via the CEF API). Files to be unittested are
  placed in the new "libcef_static_unittested" source_set which is
  then included by both the existing libcef_static library and the
  new unittests executable target.
- Linux: Remove use_bundled_fontconfig=false, which is no longer
  required and causes unittest build errors (see issue chromiumembedded#2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue chromiumembedded#245). This is controlled
by the "Offline mode" context menu option and the `--offline`
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.
filipnavara pushed a commit to emclient/cef that referenced this issue Dec 26, 2023
…iumembedded#2961).

This change allows the client to directly send and receive DevTools
protocol messages (send method calls, and receive method results and
events) without requiring a DevTools front-end or remote-debugging
session.

This change includes additional supporting changes:
- Add a new CefRequestHandler::OnDocumentAvailableInMainFrame
  callback (see issue chromiumembedded#1454).
- Add a CefParseJSON variant that accepts a UTF8-encoded buffer.
- Add a `--devtools-protocol-log-file=<path>` command-line flag for
  logging protocol messages sent to/from the DevTools front-end
  while it is displayed. This is useful for understanding existing
  DevTools protocol usage.
- Add a new "libcef_static_unittests" executable target to support
  light-weight unit tests of libcef_static internals (e.g. without
  requiring exposure via the CEF API). Files to be unittested are
  placed in the new "libcef_static_unittested" source_set which is
  then included by both the existing libcef_static library and the
  new unittests executable target.
- Linux: Remove use_bundled_fontconfig=false, which is no longer
  required and causes unittest build errors (see issue chromiumembedded#2424).

This change also adds a cefclient demo for configuring offline mode
using the DevTools protocol (fixes issue chromiumembedded#245). This is controlled
by the "Offline mode" context menu option and the `--offline`
command-line switch which will launch cefclient in offline mode. When
cefclient is offline all network requests will fail with
ERR_INTERNET_DISCONNECTED and navigator.onLine will return false when
called from JavaScript in any frame. This mode is per-browser so
newly created browser windows will have the default mode. Note that
configuring offline mode in this way will not update the Network tab
UI ("Throtting" option) in a displayed DevTools front-end instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement request Framework Related to framework code or APIs
Projects
None yet
Development

No branches or pull requests

1 participant