chromium/third_party/blink/renderer/modules/BUILD.gn

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/cast.gni")
import("//build/config/python.gni")
import("//media/media_options.gni")
import("//services/device/public/cpp/compute_pressure/buildflags.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/blink/renderer/bindings/bindings.gni")
import("//third_party/blink/renderer/build/scripts/scripts.gni")
import("//third_party/blink/renderer/modules/modules.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
}

if (is_ios) {
  import("//build/config/ios/bundle_data_from_filelist.gni")
}

visibility = [ "//third_party/blink/renderer/*" ]

config("modules_implementation") {
  defines = [ "BLINK_MODULES_IMPLEMENTATION=1" ]
}

component("modules") {
  output_name = "blink_modules"

  visibility = []  # Allow re-assignment of list.
  visibility = [ "//third_party/blink/*" ]

  sources = [
    "event_modules.h",
    "event_modules_factory.h",
    "event_target_modules.h",
    "modules_export.h",
    "modules_initializer.cc",
    "modules_initializer.h",
  ]

  sources += blink_modules_sources_bindings

  configs += [
    ":modules_implementation",

    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:non_test_config",
    "//third_party/blink/renderer:inside_blink",
    "//third_party/blink/renderer/core:blink_core_pch",
    "//v8:external_startup_data",
  ]

  sub_modules = [
    ":modules_generated",
    "//third_party/blink/renderer/bindings/modules/v8",
    "//third_party/blink/renderer/modules/accessibility",
    "//third_party/blink/renderer/modules/ad_auction",
    "//third_party/blink/renderer/modules/ai",
    "//third_party/blink/renderer/modules/animationworklet",
    "//third_party/blink/renderer/modules/app_banner",
    "//third_party/blink/renderer/modules/audio_output_devices",
    "//third_party/blink/renderer/modules/awc",
    "//third_party/blink/renderer/modules/background_fetch",
    "//third_party/blink/renderer/modules/background_sync",
    "//third_party/blink/renderer/modules/badging",
    "//third_party/blink/renderer/modules/managed_device",
    "//third_party/blink/renderer/modules/battery",
    "//third_party/blink/renderer/modules/beacon",
    "//third_party/blink/renderer/modules/bluetooth",
    "//third_party/blink/renderer/modules/broadcastchannel",
    "//third_party/blink/renderer/modules/browsing_topics",
    "//third_party/blink/renderer/modules/buckets",
    "//third_party/blink/renderer/modules/breakout_box",
    "//third_party/blink/renderer/modules/mojo",
    "//third_party/blink/renderer/modules/cache_storage",
    "//third_party/blink/renderer/modules/canvas",
    "//third_party/blink/renderer/modules/clipboard",
    "//third_party/blink/renderer/modules/contacts_picker",
    "//third_party/blink/renderer/modules/content_extraction",
    "//third_party/blink/renderer/modules/content_index",
    "//third_party/blink/renderer/modules/cookie_store",
    "//third_party/blink/renderer/modules/credentialmanagement",
    "//third_party/blink/renderer/modules/crypto",
    "//third_party/blink/renderer/modules/csspaint",
    "//third_party/blink/renderer/modules/compression",
    "//third_party/blink/renderer/modules/delegated_ink",
    "//third_party/blink/renderer/modules/device_orientation",
    "//third_party/blink/renderer/modules/device_posture",
    "//third_party/blink/renderer/modules/document_metadata",
    "//third_party/blink/renderer/modules/document_picture_in_picture",
    "//third_party/blink/renderer/modules/donottrack",
    "//third_party/blink/renderer/modules/encoding",
    "//third_party/blink/renderer/modules/encryptedmedia",
    "//third_party/blink/renderer/modules/eventsource",
    "//third_party/blink/renderer/modules/exported",
    "//third_party/blink/renderer/modules/eyedropper",
    "//third_party/blink/renderer/modules/filesystem",
    "//third_party/blink/renderer/modules/file_system_access",
    "//third_party/blink/renderer/modules/font_access",
    "//third_party/blink/renderer/modules/gamepad",
    "//third_party/blink/renderer/modules/geolocation",
    "//third_party/blink/renderer/modules/handwriting",
    "//third_party/blink/renderer/modules/hid",
    "//third_party/blink/renderer/modules/idle",
    "//third_party/blink/renderer/modules/imagecapture",
    "//third_party/blink/renderer/modules/cookie_deprecation_label",
    "//third_party/blink/renderer/modules/image_downloader",
    "//third_party/blink/renderer/modules/indexeddb",
    "//third_party/blink/renderer/modules/installation",
    "//third_party/blink/renderer/modules/installedapp",
    "//third_party/blink/renderer/modules/keyboard",
    "//third_party/blink/renderer/modules/launch",
    "//third_party/blink/renderer/modules/locked_mode",
    "//third_party/blink/renderer/modules/locks",
    "//third_party/blink/renderer/modules/lock_screen",
    "//third_party/blink/renderer/modules/manifest",
    "//third_party/blink/renderer/modules/media_capabilities",
    "//third_party/blink/renderer/modules/media_controls",
    "//third_party/blink/renderer/modules/mediacapturefromelement",
    "//third_party/blink/renderer/modules/mediarecorder",
    "//third_party/blink/renderer/modules/mediasession",
    "//third_party/blink/renderer/modules/mediasource",
    "//third_party/blink/renderer/modules/mediastream",
    "//third_party/blink/renderer/modules/media",
    "//third_party/blink/renderer/modules/ml",
    "//third_party/blink/renderer/modules/navigatorcontentutils",
    "//third_party/blink/renderer/modules/netinfo",
    "//third_party/blink/renderer/modules/nfc",
    "//third_party/blink/renderer/modules/notifications",
    "//third_party/blink/renderer/modules/on_device_translation",
    "//third_party/blink/renderer/modules/payments",
    "//third_party/blink/renderer/modules/payments/goods",
    "//third_party/blink/renderer/modules/peerconnection",
    "//third_party/blink/renderer/modules/permissions",
    "//third_party/blink/renderer/modules/picture_in_picture",
    "//third_party/blink/renderer/modules/plugins",
    "//third_party/blink/renderer/modules/presentation",
    "//third_party/blink/renderer/modules/private_attribution",
    "//third_party/blink/renderer/modules/push_messaging",
    "//third_party/blink/renderer/modules/quota",
    "//third_party/blink/renderer/modules/remoteplayback",
    "//third_party/blink/renderer/modules/screen_details",
    "//third_party/blink/renderer/modules/screen_orientation",
    "//third_party/blink/renderer/modules/sensor",
    "//third_party/blink/renderer/modules/service_worker",
    "//third_party/blink/renderer/modules/shapedetection",
    "//third_party/blink/renderer/modules/shared_storage",
    "//third_party/blink/renderer/modules/speech",
    "//third_party/blink/renderer/modules/srcobject",
    "//third_party/blink/renderer/modules/storage",
    "//third_party/blink/renderer/modules/storage_access",
    "//third_party/blink/renderer/modules/subapps",
    "//third_party/blink/renderer/modules/vibration",
    "//third_party/blink/renderer/modules/video_rvfc",
    "//third_party/blink/renderer/modules/virtualkeyboard",
    "//third_party/blink/renderer/modules/wake_lock",
    "//third_party/blink/renderer/modules/web_install",
    "//third_party/blink/renderer/modules/webaudio",
    "//third_party/blink/renderer/modules/webcodecs",
    "//third_party/blink/renderer/modules/webdatabase",
    "//third_party/blink/renderer/modules/webgl",
    "//third_party/blink/renderer/modules/webgpu",
    "//third_party/blink/renderer/modules/webmidi",
    "//third_party/blink/renderer/modules/webrtc",
    "//third_party/blink/renderer/modules/webshare",
    "//third_party/blink/renderer/modules/websockets",
    "//third_party/blink/renderer/modules/webtransport",
    "//third_party/blink/renderer/modules/webusb",
    "//third_party/blink/renderer/modules/worklet",
    "//third_party/blink/renderer/modules/xr",
  ]

  # This uses target_os rather than current_os (which is what is_android is set
  # from) for the case of generating the v8 context snapshot for android. When
  # generating the snapshot for android, blink is compiled with
  # current_os="linux" and target_os="android". Using target_os is necessary as
  # we need to compile in the same way as would happen when current_os="android".
  if (target_os_is_android) {
    sub_modules += [ "//third_party/blink/renderer/modules/remote_objects" ]
  } else {
    sub_modules += [
      "//third_party/blink/renderer/modules/direct_sockets",
      "//third_party/blink/renderer/modules/printing",
      "//third_party/blink/renderer/modules/serial",
      "//third_party/blink/renderer/modules/smart_card",
      "//third_party/blink/renderer/modules/window_controls_overlay",
    ]
  }

  if (enable_compute_pressure) {
    sub_modules += [ "//third_party/blink/renderer/modules/compute_pressure" ]
  }

  deps = [
    ":make_modules_generated",
    "//build:android_buildflags",
    "//cc",
    "//components/webrtc:thread_wrapper",
    "//gin",
    "//net:net",
    "//third_party/blink/renderer/bindings/modules/v8:generated",
    "//third_party/blink/renderer/core",
    "//third_party/icu",
    "//third_party/webrtc_overrides:webrtc_component",
    "//third_party/zlib",
    "//tools/v8_context_snapshot:buildflags",
  ]

  public_deps = sub_modules
  allow_circular_includes_from = sub_modules

  if (is_win) {
    cflags =
        [ "/wd4334" ]  # Result of 32-bit shift implicitly converted to 64 bits.
  }

  configs -= [ "//build/config/compiler:default_symbols" ]
  configs += blink_symbols_config
}

source_set("modules_testing") {
  testonly = true

  sources = [
    "accessibility/testing/internals_accessibility.cc",
    "accessibility/testing/internals_accessibility.h",
    "credentialmanagement/testing/internals_fed_cm.cc",
    "credentialmanagement/testing/internals_fed_cm.h",
    "device_posture/testing/internals_device_posture.cc",
    "device_posture/testing/internals_device_posture.h",
    "fuzzing/internals_fuzzing.cc",
    "fuzzing/internals_fuzzing.h",
    "mediastream/testing/internals_media_stream.cc",
    "mediastream/testing/internals_media_stream.h",
    "netinfo/testing/internals_net_info.cc",
    "netinfo/testing/internals_net_info.h",
    "peerconnection/adapters/test/mock_ice_transport_adapter.h",
    "peerconnection/adapters/test/mock_ice_transport_adapter_cross_thread_factory.h",
    "peerconnection/testing/fake_resource_listener.cc",
    "peerconnection/testing/fake_resource_listener.h",
    "peerconnection/testing/fake_webrtc_data_channel.cc",
    "peerconnection/testing/fake_webrtc_data_channel.h",
    "peerconnection/testing/internals_rtc_certificate.cc",
    "peerconnection/testing/internals_rtc_certificate.h",
    "peerconnection/testing/internals_rtc_peer_connection.cc",
    "peerconnection/testing/internals_rtc_peer_connection.h",
    "peerconnection/testing/mock_peer_connection_interface.h",
    "peerconnection/testing/mock_rtp_receiver.h",
    "peerconnection/testing/mock_rtp_sender.h",
    "permissions/testing/internals_permission.cc",
    "permissions/testing/internals_permission.h",
    "sensor/testing/internals_sensor.cc",
    "sensor/testing/internals_sensor.h",
    "service_worker/testing/internals_service_worker.cc",
    "service_worker/testing/internals_service_worker.h",
    "speech/testing/internals_speech_synthesis.cc",
    "speech/testing/internals_speech_synthesis.h",
    "speech/testing/mojom_speech_synthesis_mock.cc",
    "speech/testing/mojom_speech_synthesis_mock.h",
    "vibration/testing/internals_vibration.cc",
    "vibration/testing/internals_vibration.h",
    "webaudio/testing/internals_web_audio.cc",
    "webaudio/testing/internals_web_audio.h",
  ]

  if (enable_compute_pressure) {
    sources += [
      "compute_pressure/testing/internals_compute_pressure.cc",
      "compute_pressure/testing/internals_compute_pressure.h",
    ]
  }

  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:inside_blink",
    "//third_party/blink/renderer/core:blink_core_pch",
  ]

  public_deps = [
    "//mojo/public/cpp/bindings",
    "//testing/gmock:gmock",
  ]
  deps = [
    "//services/device/public/cpp/generic_sensor",
    "//third_party/blink/renderer/bindings/modules/v8:testing",
    "//third_party/blink/renderer/core",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules",
    "//third_party/blink/renderer/platform:test_support",
  ]
}

group("make_modules_generated") {
  public_deps = [
    ":make_modules_generated_event_factory",
    ":make_modules_generated_event_names",
    ":make_modules_generated_event_target_names",
    ":make_modules_generated_indexed_db_names",
    ":make_modules_generated_media_capabilities_names",
    "//components/payments/mojom:mojom_blink_headers",
    "//components/schema_org/common:mojom_blink_headers",
    "//components/services/filesystem/public/mojom:mojom_blink_headers",
    "//device/bluetooth/public/mojom:mojom_blink_headers",
    "//device/gamepad/public/mojom:mojom_blink_headers",
    "//device/vr/public/mojom:vr_service_blink_headers",
    "//media/capture/mojom:image_capture_blink_headers",
    "//media/midi:mojo_blink_headers",
    "//services/device/public/mojom:generic_sensor_headers",
    "//services/device/public/mojom:geoposition_blink_headers",
    "//services/device/public/mojom:mojom_blink_headers",
    "//services/device/public/mojom:usb_blink_headers",
    "//services/shape_detection/public/mojom:mojom_blink_headers",
    "//services/webnn/public/mojom:mojom_blink_headers",
    "//third_party/blink/public/mojom:mojom_modules_blink_headers",
    "//third_party/blink/renderer/bindings/modules/v8:generated",
    "//third_party/blink/renderer/core:core_event_interfaces",
    "//ui/accessibility:ax_enums_mojo_blink_headers",
    "//ui/display/mojom:mojom_blink_headers",
  ]
}

# generate_event_interfaces ----------------------------------------------------

action_with_pydeps("modules_event_interfaces") {
  script = "//third_party/blink/renderer/bindings/scripts/generate_event_interface_names.py"

  inputs = [ web_idl_database_filepath ]
  outputs =
      [ get_path_info(".", "gen_dir") + "/event_interface_modules_names.json5" ]

  args = [
    "--web_idl_database",
    rebase_path(web_idl_database_filepath, root_build_dir),
    "--component",
    "modules",
    "--export-macro",
    "MODULES_EXPORT",
    "--suffix",
    "Modules",
    "--output",
    rebase_path(outputs[0], root_build_dir),
  ]

  deps = [ "//third_party/blink/renderer/bindings:web_idl_database" ]
}

# make_event_factory -----------------------------------------------------------

make_event_factory("make_modules_generated_event_factory") {
  in_files = [ "$blink_modules_output_dir/event_interface_modules_names.json5" ]
  outputs = [ "$blink_modules_output_dir/event_modules_factory.cc" ]
  deps = make_core_generated_deps + [ ":modules_event_interfaces" ]
}

# make_names -------------------------------------------------------------------

make_names("make_modules_generated_event_names") {
  in_files = [ "$blink_modules_output_dir/event_interface_modules_names.json5" ]
  output_dir = blink_modules_output_dir
  deps = make_core_generated_deps + [ ":modules_event_interfaces" ]
}

make_names("make_modules_generated_event_target_names") {
  in_files = [ "event_target_modules_names.json5" ]
  output_dir = blink_modules_output_dir
}

make_names("make_modules_generated_indexed_db_names") {
  in_files = [ "indexeddb/indexed_db_names.json5" ]
  output_dir = blink_modules_output_dir
  deps = []  # Don't use default deps (otherwise it will be circular).
}

make_names("make_modules_generated_media_capabilities_names") {
  in_files = [ "media_capabilities/media_capabilities_names.json5" ]
  output_dir = blink_modules_output_dir
  deps = []  # Don't use default deps (otherwise it will be circular).
}

blink_modules_sources("modules_generated") {
  # Targets from above that generate outputs that need to be compiled.
  # All sources declared as outputs from these targets will be compiled
  # into one target.
  targets_generating_sources = [
    ":make_modules_generated_event_factory",
    ":make_modules_generated_event_names",
    ":make_modules_generated_event_target_names",
    ":make_modules_generated_indexed_db_names",
    ":make_modules_generated_media_capabilities_names",
  ]

  sources = []
  foreach(current, targets_generating_sources) {
    sources += get_target_outputs(current)
  }
}

source_set("unit_tests") {
  testonly = true

  sources = [
    "accessibility/accessibility_object_model_test.cc",
    "accessibility/ax_layout_object_test.cc",
    "accessibility/ax_node_object_test.cc",
    "accessibility/ax_object_cache_test.cc",
    "accessibility/ax_object_test.cc",
    "accessibility/ax_position_test.cc",
    "accessibility/ax_range_test.cc",
    "accessibility/ax_selection_test.cc",
    "accessibility/testing/accessibility_selection_test.cc",
    "accessibility/testing/accessibility_selection_test.h",
    "accessibility/testing/accessibility_test.cc",
    "accessibility/testing/accessibility_test.h",
    "ai/model_execution_responder_test.cc",
    "animationworklet/animation_worklet_global_scope_test.cc",
    "animationworklet/animation_worklet_proxy_client_test.cc",
    "animationworklet/worklet_animation_test.cc",
    "background_fetch/background_fetch_icon_loader_test.cc",
    "background_fetch/background_fetch_manager_test.cc",
    "bluetooth/bluetooth_uuid_unittest.cc",
    "broadcastchannel/broadcast_channel_unittest.cc",
    "cache_storage/cache_test.cc",
    "canvas/canvas2d/base_rendering_context_2d_test.cc",
    "canvas/canvas2d/canvas_filter_operation_resolver_test.cc",
    "canvas/canvas2d/canvas_filter_test.cc",
    "canvas/canvas2d/canvas_filter_test_utils.cc",
    "canvas/canvas2d/canvas_filter_test_utils.h",
    "canvas/canvas2d/canvas_path_test.cc",
    "canvas/canvas2d/canvas_rendering_context_2d_api_test.cc",
    "canvas/canvas2d/canvas_rendering_context_2d_test.cc",
    "canvas/canvas2d/canvas_style_test_utils.cc",
    "canvas/canvas2d/canvas_style_test_utils.h",
    "canvas/canvas2d/identifiability_study_helper_test.cc",
    "canvas/htmlcanvas/html_canvas_element_module_test.cc",
    "canvas/offscreencanvas/offscreen_canvas_rendering_api_ukm_metrics_test.cc",
    "canvas/offscreencanvas/offscreen_canvas_test.cc",
    "canvas/offscreencanvas2d/offscreen_canvas_rendering_context_2d_test.cc",
    "content_extraction/inner_html_builder_unittest.cc",
    "content_extraction/inner_text_builder_unittest.cc",
    "content_index/content_description_type_converter_test.cc",
    "credentialmanagement/authentication_credentials_container_test.cc",
    "credentialmanagement/credential_manager_type_converters_unittest.cc",
    "credentialmanagement/digital_identity_credential_test.cc",
    "credentialmanagement/password_credential_test.cc",
    "credentialmanagement/public_key_credential_unittest.cc",
    "csspaint/document_paint_definition_test.cc",
    "csspaint/nativepaint/background_color_paint_definition_test.cc",
    "csspaint/nativepaint/clip_path_paint_definition_test.cc",
    "csspaint/paint_rendering_context_2d_test.cc",
    "csspaint/paint_worklet_global_scope_test.cc",
    "csspaint/paint_worklet_proxy_client_test.cc",
    "csspaint/paint_worklet_test.cc",
    "delegated_ink/delegated_ink_trail_presenter_unittest.cc",
    "device_orientation/device_motion_event_pump_unittest.cc",
    "device_orientation/device_orientation_event_pump_unittest.cc",
    "document_metadata/document_metadata_extractor_test.cc",
    "document_picture_in_picture/picture_in_picture_controller_test.cc",
    "eventsource/event_source_parser_test.cc",
    "filesystem/dom_file_system_base_test.cc",
    "filesystem/file_writer_test.cc",
    "handwriting/handwriting_type_converters_unittest.cc",
    "imagecapture/image_capture_test.cc",
    "installedapp/installed_app_controller_test.cc",
    "manifest/image_resource_type_converters_test.cc",
    "manifest/manifest_manager_unittest.cc",
    "manifest/manifest_parser_unittest.cc",
    "media/audio/audio_output_ipc_factory_test.cc",
    "media/audio/audio_renderer_mixer_input_test.cc",
    "media/audio/audio_renderer_mixer_manager_test.cc",
    "media/audio/audio_renderer_mixer_test.cc",
    "media/audio/audio_renderer_sink_cache_test.cc",
    "media/audio/mojo_audio_input_ipc_test.cc",
    "media/audio/mojo_audio_output_ipc_test.cc",
    "media/web_media_player_util_unittest.cc",
    "media_capabilities/media_capabilities_test.cc",
    "media_controls/elements/media_control_animated_arrow_container_element_test.cc",
    "media_controls/elements/media_control_display_cutout_fullscreen_button_element_test.cc",
    "media_controls/elements/media_control_elements_helper_test.cc",
    "media_controls/elements/media_control_input_element_test.cc",
    "media_controls/elements/media_control_loading_panel_element_test.cc",
    "media_controls/elements/media_control_panel_element_test.cc",
    "media_controls/elements/media_control_popup_menu_element_test.cc",
    "media_controls/elements/media_control_scrubbing_message_element_test.cc",
    "media_controls/elements/media_control_timeline_element_test.cc",
    "media_controls/elements/media_control_toggle_closed_captions_button_element_test.cc",
    "media_controls/media_controls_display_cutout_delegate_test.cc",
    "media_controls/media_controls_impl_test.cc",
    "media_controls/media_controls_orientation_lock_delegate_test.cc",
    "media_controls/media_controls_rotate_to_fullscreen_delegate_test.cc",
    "mediacapturefromelement/canvas_capture_handler_unittest.cc",
    "mediacapturefromelement/html_audio_element_capturer_source_unittest.cc",
    "mediacapturefromelement/html_video_element_capturer_source_unittest.cc",
    "mediarecorder/audio_track_mojo_encoder_unittest.cc",
    "mediarecorder/audio_track_recorder_unittest.cc",
    "mediarecorder/fake_encoded_video_frame.h",
    "mediarecorder/key_frame_request_processor_unittest.cc",
    "mediarecorder/media_recorder_encoder_wrapper_unittest.cc",
    "mediarecorder/media_recorder_handler_unittest.cc",
    "mediarecorder/media_recorder_unittest.cc",
    "mediarecorder/track_recorder_unittest.cc",
    "mediarecorder/video_track_recorder_unittest.cc",
    "mediasession/media_session_test.cc",
    "mediastream/browser_capture_media_stream_track_test.cc",
    "mediastream/local_media_stream_audio_source_test.cc",
    "mediastream/low_latency_video_renderer_algorithm_unittest.cc",
    "mediastream/media_constraints_test.cc",
    "mediastream/media_devices_test.cc",
    "mediastream/media_stream_audio_processor_test.cc",
    "mediastream/media_stream_constraints_util_audio_test.cc",
    "mediastream/media_stream_constraints_util_sets_test.cc",
    "mediastream/media_stream_constraints_util_test.cc",
    "mediastream/media_stream_constraints_util_video_content_test.cc",
    "mediastream/media_stream_constraints_util_video_device_test.cc",
    "mediastream/media_stream_device_observer_test.cc",
    "mediastream/media_stream_set_test.cc",
    "mediastream/media_stream_track_impl_test.cc",
    "mediastream/media_stream_track_transfer_test.cc",
    "mediastream/media_stream_utils_test.cc",
    "mediastream/media_stream_video_capturer_source_test.cc",
    "mediastream/media_stream_video_renderer_sink_test.cc",
    "mediastream/media_stream_video_source_test.cc",
    "mediastream/media_stream_video_track_test.cc",
    "mediastream/mock_mojo_media_stream_dispatcher_host.cc",
    "mediastream/mock_mojo_media_stream_dispatcher_host.h",
    "mediastream/processed_local_audio_source_test.cc",
    "mediastream/track_audio_renderer_test.cc",
    "mediastream/transferred_media_stream_track_test.cc",
    "mediastream/user_media_client_test.cc",
    "mediastream/video_track_adapter_unittest.cc",
    "mediastream/web_media_player_ms_test.cc",
    "mediastream/webaudio_media_stream_audio_sink_test.cc",
    "nfc/nfc_proxy_test.cc",
    "notifications/notification_data_test.cc",
    "notifications/notification_resources_loader_test.cc",
    "payments/abort_test.cc",
    "payments/can_make_payment_test.cc",
    "payments/complete_test.cc",
    "payments/goods/digital_goods_type_converters_unittest.cc",
    "payments/on_payment_response_test.cc",
    "payments/payment_address_test.cc",
    "payments/payment_event_data_conversion_test.cc",
    "payments/payment_request_details_test.cc",
    "payments/payment_request_for_invalid_origin_or_ssl_test.cc",
    "payments/payment_request_optional_total_test.cc",
    "payments/payment_request_test.cc",
    "payments/payment_request_update_event_test.cc",
    "payments/payment_response_test.cc",
    "payments/payment_test_helper.cc",
    "payments/payment_test_helper.h",
    "payments/payments_validators_test.cc",
    "payments/secure_payment_confirmation_helper_test.cc",
    "peerconnection/byte_buffer_queue_test.cc",
    "peerconnection/media_stream_remote_video_source_test.cc",
    "peerconnection/media_stream_track_metrics_test.cc",
    "peerconnection/media_stream_video_webrtc_sink_test.cc",
    "peerconnection/peer_connection_dependency_factory_test.cc",
    "peerconnection/peer_connection_tracker_test.cc",
    "peerconnection/rtc_data_channel_test.cc",
    "peerconnection/rtc_encoded_audio_frame_test.cc",
    "peerconnection/rtc_encoded_audio_underlying_sink_test.cc",
    "peerconnection/rtc_encoded_audio_underlying_source_test.cc",
    "peerconnection/rtc_encoded_underlying_sink_wrapper_test.cc",
    "peerconnection/rtc_encoded_underlying_source_wrapper_test.cc",
    "peerconnection/rtc_encoded_video_frame_test.cc",
    "peerconnection/rtc_encoded_video_underlying_sink_test.cc",
    "peerconnection/rtc_encoded_video_underlying_source_test.cc",
    "peerconnection/rtc_ice_candidate_test.cc",
    "peerconnection/rtc_peer_connection_handler_test.cc",
    "peerconnection/rtc_peer_connection_test.cc",
    "peerconnection/rtc_rtp_receiver_impl_test.cc",
    "peerconnection/rtc_rtp_script_transformer_test.cc",
    "peerconnection/rtc_rtp_sender_impl_test.cc",
    "peerconnection/rtc_rtp_transceiver_impl_test.cc",
    "peerconnection/rtc_rtp_transport_processor_test.cc",
    "peerconnection/rtc_rtp_transport_test.cc",
    "peerconnection/rtc_sctp_transport_test.cc",
    "peerconnection/speed_limit_uma_listener_test.cc",
    "peerconnection/thermal_resource_test.cc",
    "peerconnection/thermal_uma_listener_test.cc",
    "peerconnection/transceiver_state_surfacer_test.cc",
    "peerconnection/webrtc_audio_renderer_test.cc",
    "peerconnection/webrtc_media_stream_track_adapter_map_test.cc",
    "peerconnection/webrtc_media_stream_track_adapter_test.cc",
    "peerconnection/webrtc_set_description_observer_test.cc",
    "peerconnection/webrtc_video_perf_reporter_test.cc",
    "presentation/mock_presentation_service.h",
    "presentation/presentation_availability_state_test.cc",
    "presentation/presentation_availability_test.cc",
    "presentation/presentation_connection_callbacks_test.cc",
    "presentation/presentation_receiver_test.cc",
    "presentation/presentation_request_test.cc",
    "push_messaging/push_manager_test.cc",
    "push_messaging/push_message_data_test.cc",
    "push_messaging/push_subscription_test.cc",
    "remoteplayback/remote_playback_test.cc",
    "screen_orientation/screen_orientation_controller_test.cc",
    "sensor/sensor_test_utils.cc",
    "sensor/sensor_test_utils.h",
    "service_worker/service_worker_container_test.cc",
    "service_worker/service_worker_event_queue_test.cc",
    "service_worker/service_worker_installed_scripts_manager_test.cc",
    "service_worker/service_worker_router_type_converter_test.cc",
    "service_worker/thread_safe_script_container_test.cc",
    "service_worker/web_embedded_worker_impl_test.cc",
    "service_worker/web_service_worker_fetch_context_impl_test.cc",
    "shared_storage/shared_storage_worklet_unittest.cc",
    "video_rvfc/video_frame_callback_requester_impl_test.cc",
    "video_rvfc/video_frame_request_callback_collection_test.cc",
    "wake_lock/wake_lock_manager_test.cc",
    "wake_lock/wake_lock_sentinel_test.cc",
    "wake_lock/wake_lock_test.cc",
    "wake_lock/wake_lock_test_utils.cc",
    "wake_lock/wake_lock_test_utils.h",
    "webaudio/audio_basic_processor_handler_test.cc",
    "webaudio/audio_context_autoplay_test.cc",
    "webaudio/audio_context_test.cc",
    "webaudio/audio_node_input_test.cc",
    "webaudio/audio_worklet_global_scope_test.cc",
    "webaudio/audio_worklet_thread_test.cc",
    "webaudio/biquad_dsp_kernel_test.cc",
    "webaudio/convolver_node_test.cc",
    "webaudio/dynamics_compressor_node_test.cc",
    "webaudio/script_processor_node_test.cc",
    "webaudio/stereo_panner_node_test.cc",
    "webdatabase/dom_window_web_database_test.cc",
    "webdatabase/quota_tracker_test.cc",
    "webrtc/webrtc_audio_device_impl_test.cc",
    "webshare/navigator_share_test.cc",
    "websockets/dom_websocket_test.cc",
    "websockets/mock_websocket_channel.cc",
    "websockets/mock_websocket_channel.h",
    "websockets/websocket_channel_impl_test.cc",
    "websockets/websocket_common_test.cc",
    "websockets/websocket_error_test.cc",
    "websockets/websocket_message_chunk_accumulator_test.cc",
    "websockets/websocket_stream_test.cc",
    "worklet/animation_and_paint_worklet_thread_test.cc",
    "worklet/worklet_thread_test_common.cc",
    "worklet/worklet_thread_test_common.h",
    "xr/xr_rigid_transform_test.cc",
    "xr/xr_test_utils.cc",
    "xr/xr_view_test.cc",
  ]

  if (enable_compute_pressure) {
    sources += [
      "compute_pressure/pressure_observer_test.cc",
      "compute_pressure/pressure_observer_test_utils.cc",
      "compute_pressure/pressure_observer_test_utils.h",
    ]
  }

  if (!is_android) {
    sources += [
      # Inline text box tests do not apply to Android, which only loads
      # AXInlineTextBox tests for the focused node.
      "accessibility/ax_inline_text_box_test.cc",
    ]
  }

  if (!is_android && !is_ios) {
    sources += [
      # CaptureController is not Web-exposed on Android and iOS,
      # so most of the logic is compile-guarded away on Android and iOS,
      # preventing meaningful testing.
      "mediastream/capture_controller_test.cc",
    ]
  }

  if (media_use_openh264) {
    sources += [ "mediarecorder/h264_encoder_unittest.cc" ]
  }

  configs += [
    "//third_party/blink/renderer:config",
    "//third_party/blink/renderer:inside_blink",
    "//third_party/blink/renderer/core:blink_core_pch",
  ]

  deps = [
    ":modules",
    ":modules_testing",
    "//base",
    "//base/test:test_support",
    "//build:chromecast_buildflags",
    "//components/schema_org/common:mojom_blink",
    "//components/ukm:test_support",
    "//media:test_support",
    "//media/capture/mojom:image_capture_blink",
    "//media/gpu:gpu",
    "//media/mojo:buildflags",
    "//media/mojo:test_support",
    "//media/mojo/mojom",
    "//media/mojo/services:services",
    "//media/webrtc:webrtc",
    "//mojo/public/cpp/bindings",
    "//net:test_support",
    "//services/device/public/cpp:test_support",
    "//services/metrics/public/cpp:ukm_builders",
    "//services/network:test_support",
    "//skia",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/blink/public:blink_headers",
    "//third_party/blink/public:test_headers",
    "//third_party/blink/public/strings:strings_grit",
    "//third_party/blink/renderer/controller:blink_bindings_test_sources",
    "//third_party/blink/renderer/core",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/core:unit_test_support",
    "//third_party/blink/renderer/core:unit_tests",
    "//third_party/blink/renderer/modules/ad_auction:unit_tests",
    "//third_party/blink/renderer/modules/breakout_box:unit_tests",
    "//third_party/blink/renderer/modules/file_system_access:unit_tests",
    "//third_party/blink/renderer/modules/gamepad:unit_tests",
    "//third_party/blink/renderer/modules/hid:unit_tests",
    "//third_party/blink/renderer/modules/idle:unit_tests",
    "//third_party/blink/renderer/modules/indexeddb:unit_tests",
    "//third_party/blink/renderer/modules/mediastream:test_support",
    "//third_party/blink/renderer/modules/ml:unit_tests",
    "//third_party/blink/renderer/modules/peerconnection:test_support",
    "//third_party/blink/renderer/modules/storage:unit_tests",
    "//third_party/blink/renderer/modules/storage_access:unit_tests",
    "//third_party/blink/renderer/modules/webcodecs:unit_tests",
    "//third_party/blink/renderer/modules/webgpu:unit_tests",
    "//third_party/blink/renderer/modules/webtransport:unit_tests",
    "//third_party/blink/renderer/platform",
    "//third_party/blink/renderer/platform:test_support",
    "//third_party/blink/renderer/platform/wtf",
    "//third_party/googletest:gmock",
    "//third_party/opus",
    "//third_party/webrtc_overrides:webrtc_component",
    "//ui/strings:ax_strings_grit",
    "//v8",
  ]

  # This uses target_os rather than current_os (which is what is_android is set
  # from) for the case of generating the v8 context snapshot for android. When
  # generating the snapshot for android, blink is compiled with
  # current_os="linux" and target_os="android". Using target_os is necessary as
  # we need to compile in the same way as would happen when current_os="android".
  if (!target_os_is_android) {
    deps += [
      "//third_party/blink/renderer/modules/direct_sockets:unit_tests",
      "//third_party/blink/renderer/modules/serial:unit_tests",
      "//third_party/blink/renderer/modules/smart_card:unit_tests",
    ]
  }

  data_deps = [
    ":accessibility_unittests_data",
    ":mediastream_unittests_data",
  ]
}

if (is_ios) {
  bundle_data_from_filelist("accessibility_selection_test_bundle_data") {
    testonly = true
    filelist_name = "accessibility/testing/data/selection/accessibility_selection_test_bundle_data.filelist"
  }
}

group("accessibility_unittests_data") {
  data = [ "accessibility/testing/data/" ]
}

group("mediastream_unittests_data") {
  data = [ "//media/test/data/" ]
}

fuzzer_test("web_app_manifest_fuzzer") {
  sources = [ "manifest/manifest_fuzzer.cc" ]

  dict = "manifest/manifest_fuzzer.dict"
  seed_corpus = "manifest/fuzzer_seed_corpus"

  deps = [
    ":modules",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
  ]
}

fuzzer_test("media_capabilities_fuzzer") {
  sources = [ "media_capabilities/media_capabilities_fuzzer.cc" ]

  seed_corpus = "media_capabilities/fuzzer_seed_corpus"

  deps = [
    ":modules",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/media_capabilities:fuzzer_media_configuration_proto",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}

fuzzer_test("webcodecs_video_frame_copy_to_fuzzer") {
  sources = [
    "webcodecs/fuzzer_utils.cc",
    "webcodecs/fuzzer_utils.h",
    "webcodecs/video_frame_copy_to_fuzzer.cc",
  ]

  seed_corpus = "webcodecs/fuzzer_seed_corpus/video_frame_copy_to"

  deps = [
    ":modules",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}

fuzzer_test("webcodecs_audio_data_copy_to_fuzzer") {
  sources = [
    "webcodecs/audio_data_copy_to_fuzzer.cc",
    "webcodecs/fuzzer_utils.cc",
    "webcodecs/fuzzer_utils.h",
  ]

  seed_corpus = "webcodecs/fuzzer_seed_corpus/audio_data_copy_to"

  deps = [
    ":modules",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}

fuzzer_test("webcodecs_video_decoder_fuzzer") {
  sources = [
    "webcodecs/fuzzer_utils.cc",
    "webcodecs/fuzzer_utils.h",
    "webcodecs/video_decoder_fuzzer.cc",
  ]

  seed_corpus = "webcodecs/fuzzer_seed_corpus/video_decoder"

  deps = [
    ":modules",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}

image_decoder_fuzzer_seed_corpus_dir =
    "$target_gen_dir/webcodecs/image_fuzzer_seed_corpus"

action("generate_image_decoder_fuzzer_corpus") {
  script = "webcodecs/fuzzer_seed_corpus/generate_image_corpus.py"
  sources = [ "webcodecs/image_decoder_base.textproto" ]

  data = [ "//third_party/blink/web_tests/images/resources/" ]

  deps = [
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/protobuf:py_proto",
  ]

  pyproto_path = "$root_out_dir/pyproto"

  args = [ "-i" ]
  args += rebase_path(sources, root_build_dir)
  args += [
    "-o",
    "ignored",
    "-d",
    rebase_path(image_decoder_fuzzer_seed_corpus_dir, root_build_dir),
    "-p",
    rebase_path(pyproto_path, root_build_dir),
    "-p",
    rebase_path("$pyproto_path/third_party/blink/renderer/modules/webcodecs/",
                root_build_dir),
  ]

  outputs = [ image_decoder_fuzzer_seed_corpus_dir ]
}

fuzzer_test("webcodecs_image_decoder_fuzzer") {
  sources = [
    "webcodecs/fuzzer_utils.cc",
    "webcodecs/fuzzer_utils.h",
    "webcodecs/image_decoder_fuzzer.cc",
  ]

  seed_corpus = image_decoder_fuzzer_seed_corpus_dir
  seed_corpus_deps = [ ":generate_image_decoder_fuzzer_corpus" ]

  deps = [
    ":modules",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}

fuzzer_test("webcodecs_audio_decoder_fuzzer") {
  sources = [
    "webcodecs/audio_decoder_fuzzer.cc",
    "webcodecs/fuzzer_utils.cc",
    "webcodecs/fuzzer_utils.h",
  ]

  seed_corpus = "webcodecs/fuzzer_seed_corpus/audio_decoder"

  deps = [
    ":modules",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}

fuzzer_test("webcodecs_video_encoder_fuzzer") {
  sources = [
    "webcodecs/fuzzer_utils.cc",
    "webcodecs/fuzzer_utils.h",
    "webcodecs/video_encoder_fuzzer.cc",
  ]

  seed_corpus = "webcodecs/fuzzer_seed_corpus/video_encoder"

  deps = [
    ":modules",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}

fuzzer_test("webcodecs_audio_encoder_fuzzer") {
  sources = [
    "webcodecs/audio_encoder_fuzzer.cc",
    "webcodecs/fuzzer_utils.cc",
    "webcodecs/fuzzer_utils.h",
  ]

  seed_corpus = "webcodecs/fuzzer_seed_corpus/audio_encoder"

  deps = [
    ":modules",
    "//media/mojo/services:services",
    "//third_party/blink/renderer/core:testing",
    "//third_party/blink/renderer/modules/webcodecs:fuzzer_protos",
    "//third_party/blink/renderer/platform:blink_fuzzer_test_support",
    "//third_party/libprotobuf-mutator",
    "//third_party/protobuf:protobuf_lite",
  ]
}