1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33

content / common / fetch / fetch_api_request_proto_unittest.cc [blame]

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

#include "content/common/fetch/fetch_api_request_proto.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace content {

TEST(FetchAPIRequestProtoTest, SerialiazeDeserializeRoundTrip) {
  auto request = blink::mojom::FetchAPIRequest::New();
  request->mode = network::mojom::RequestMode::kSameOrigin;
  request->is_main_resource_load = true;
  request->url = GURL("foo.com");
  request->method = "GET";
  request->headers = {{"User-Agent", "Chrome"}};
  request->referrer = blink::mojom::Referrer::New(
      GURL("bar.com"),
      network::mojom::ReferrerPolicy::kNoReferrerWhenDowngrade);
  request->credentials_mode = network::mojom::CredentialsMode::kSameOrigin;
  request->cache_mode = blink::mojom::FetchCacheMode::kForceCache;
  request->redirect_mode = network::mojom::RedirectMode::kManual;
  request->integrity = "integrity";
  request->keepalive = true;
  request->is_reload = true;

  EXPECT_EQ(SerializeFetchRequestToString(*request),
            SerializeFetchRequestToString(*DeserializeFetchRequestFromString(
                SerializeFetchRequestToString(*request))));
}

}  // namespace content