lib/selenium/devtools/v137/service_worker.rb



# frozen_string_literal: true

# Licensed to the Software Freedom Conservancy (SFC) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The SFC licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

# This file is automatically generated. Any changes will be lost!
module Selenium
  module DevTools
    module V137
      class ServiceWorker
        EVENTS = {
          worker_error_reported: 'workerErrorReported',
          worker_registration_updated: 'workerRegistrationUpdated',
          worker_version_updated: 'workerVersionUpdated',
        }.freeze

        def initialize(devtools)
          @devtools = devtools
        end

        def on(event, &block)
          event = EVENTS[event] if event.is_a?(Symbol)
          @devtools.callbacks["ServiceWorker.#{event}"] << block
        end

        def deliver_push_message(origin:, registration_id:, data:)
          @devtools.send_cmd('ServiceWorker.deliverPushMessage',
                             origin: origin,
                             registrationId: registration_id,
                             data: data)
        end

        def disable
          @devtools.send_cmd('ServiceWorker.disable')
        end

        def dispatch_sync_event(origin:, registration_id:, tag:, last_chance:)
          @devtools.send_cmd('ServiceWorker.dispatchSyncEvent',
                             origin: origin,
                             registrationId: registration_id,
                             tag: tag,
                             lastChance: last_chance)
        end

        def dispatch_periodic_sync_event(origin:, registration_id:, tag:)
          @devtools.send_cmd('ServiceWorker.dispatchPeriodicSyncEvent',
                             origin: origin,
                             registrationId: registration_id,
                             tag: tag)
        end

        def enable
          @devtools.send_cmd('ServiceWorker.enable')
        end

        def inspect_worker(version_id:)
          @devtools.send_cmd('ServiceWorker.inspectWorker',
                             versionId: version_id)
        end

        def set_force_update_on_page_load(force_update_on_page_load:)
          @devtools.send_cmd('ServiceWorker.setForceUpdateOnPageLoad',
                             forceUpdateOnPageLoad: force_update_on_page_load)
        end

        def skip_waiting(scope_url:)
          @devtools.send_cmd('ServiceWorker.skipWaiting',
                             scopeURL: scope_url)
        end

        def start_worker(scope_url:)
          @devtools.send_cmd('ServiceWorker.startWorker',
                             scopeURL: scope_url)
        end

        def stop_all_workers
          @devtools.send_cmd('ServiceWorker.stopAllWorkers')
        end

        def stop_worker(version_id:)
          @devtools.send_cmd('ServiceWorker.stopWorker',
                             versionId: version_id)
        end

        def unregister(scope_url:)
          @devtools.send_cmd('ServiceWorker.unregister',
                             scopeURL: scope_url)
        end

        def update_registration(scope_url:)
          @devtools.send_cmd('ServiceWorker.updateRegistration',
                             scopeURL: scope_url)
        end

      end # ServiceWorker
    end # V137
  end # DevTools
end # Selenium