BackgroundService

Defines events for background web platform features.

This CDP domain is experimental.

Types

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class cdp.background_service.ServiceName

The Background Service that will be associated with the commands/events. Every Background Service operates independently, but they share the same API.

BACKGROUND_FETCH = 'backgroundFetch'
BACKGROUND_SYNC = 'backgroundSync'
NOTIFICATIONS = 'notifications'
PAYMENT_HANDLER = 'paymentHandler'
PUSH_MESSAGING = 'pushMessaging'
class cdp.background_service.EventMetadata(key, value)

A key-value pair for additional event information to pass along.

class cdp.background_service.BackgroundServiceEvent(timestamp, origin, service_worker_registration_id, service, event_name, instance_id, event_metadata)
event_metadata = None

A list of event-specific information.

event_name = None

A description of the event.

instance_id = None

An identifier that groups related events together.

origin = None

The origin this event belongs to.

service = None

The Background Service this event belongs to.

service_worker_registration_id = None

The Service Worker ID that initiated the event.

timestamp = None

Timestamp of the event (in seconds).

Commands

Each command is a generator function. The return type Generator[x, y, z] indicates that the generator yields arguments of type x, it must be resumed with an argument of type y, and it returns type z. In this library, types x and y are the same for all commands, and z is the return type you should pay attention to. For more information, see Getting Started: Commands.

cdp.background_service.clear_events(service)

Clears all stored data for the service.

Parameters:service (ServiceName) –
Return type:Generator[Dict[str, Any], Dict[str, Any], None]
cdp.background_service.set_recording(should_record, service)

Set the recording state for the service.

Parameters:
Return type:

Generator[Dict[str, Any], Dict[str, Any], None]

cdp.background_service.start_observing(service)

Enables event updates for the service.

Parameters:service (ServiceName) –
Return type:Generator[Dict[str, Any], Dict[str, Any], None]
cdp.background_service.stop_observing(service)

Disables event updates for the service.

Parameters:service (ServiceName) –
Return type:Generator[Dict[str, Any], Dict[str, Any], None]

Events

Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.

class cdp.background_service.RecordingStateChanged(is_recording, service)

Called when the recording state for the service has been updated.

class cdp.background_service.BackgroundServiceEventReceived(background_service_event)

Called with all existing backgroundServiceEvents when enabled, and all new events afterwards if enabled and recording.