chromium/ios/chrome/browser/web/model/image_fetch/BUILD.gn

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

import("//ios/web/public/js_messaging/optimize_ts.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

source_set("image_fetch") {
  sources = [
    "image_fetch_java_script_feature.h",
    "image_fetch_java_script_feature.mm",
    "image_fetch_tab_helper.h",
    "image_fetch_tab_helper.mm",
  ]
  deps = [
    ":image_fetch_js",
    "//base",
    "//components/image_fetcher/core",
    "//ios/web/common",
    "//ios/web/public/js_messaging",
    "//url",
  ]
  public_deps = [ "//ios/web/public" ]
}

optimize_ts("image_fetch_js") {
  visibility = [
    ":image_fetch",
    ":unit_tests",
  ]

  sources = [ "resources/image_fetch.ts" ]

  deps = [
    "//ios/web/public/js_messaging:gcrweb",
    "//ios/web/public/js_messaging:util_scripts",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "image_fetch_java_script_feature_unittest.mm",
    "image_fetch_tab_helper_unittest.mm",
  ]
  deps = [
    ":image_fetch",
    ":image_fetch_js",
    "//base",
    "//base/test:test_support",
    "//ios/chrome/browser/shared/model/profile/test",
    "//ios/web/js_messaging:java_script_feature",
    "//ios/web/public/js_messaging:js_messaging",
    "//ios/web/public/test",
    "//ios/web/test:js_test_util_internal",
    "//ios/web/web_state/ui:web_controller_header",
    "//net:test_support",
    "//services/network:test_support",
  ]
}

fuzzer_test("image_fetch_java_script_feature_fuzzer") {
  additional_configs = [ "//testing/libfuzzer:build_for_ios_clusterfuzz_job" ]

  sources = [ "image_fetch_java_script_feature_fuzzer.mm" ]
  deps = [
    ":image_fetch",
    "//base",
    "//ios/web/public/js_messaging",
    "//ios/web/public/js_messaging/fuzzer_support",
    "//ios/web/public/js_messaging/fuzzer_support:js_message_proto",
    "//ios/web/public/test:fuzzer_support",
    "//third_party/libprotobuf-mutator",
  ]
  seed_corpus = "fuzzer_corpus"
}