chromium/third_party/blink/renderer/core/speculation_rules/speculation_rules_header_test.cc

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

#include "third_party/blink/renderer/core/speculation_rules/speculation_rules_header.h"

#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/speculation_rules/document_speculation_rules.h"
#include "third_party/blink/renderer/core/speculation_rules/speculation_rules_metrics.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/exported/wrapped_resource_response.h"
#include "third_party/blink/renderer/platform/network/http_names.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"

namespace blink {
namespace {

Contains;
HasSubstr;
Not;
ResultOf;

class ScopedRegisterMockedURLLoads {};

class ConsoleCapturingChromeClient : public EmptyChromeClient {};

TEST(SpeculationRulesHeaderTest, NoMetricsWithoutHeader) {}

TEST(SpeculationRulesHeaderTest, UnparseableHeader) {}

TEST(SpeculationRulesHeaderTest, EmptyHeader) {}

TEST(SpeculationRulesHeaderTest, InvalidItem) {}

TEST(SpeculationRulesHeaderTest, ValidURL) {}

TEST(SpeculationRulesHeaderTest, InvalidNvsHintError) {}

TEST(SpeculationRulesHeaderTest, InvalidNvsHintWarning) {}

TEST(SpeculationRulesHeaderTest, UsesResponseURLAsBaseURL) {}

TEST(SpeculationRulesHeaderTest, InvalidStatusCode) {}

TEST(SpeculationRulesHeaderTest, NetError) {}

// Regression test for crbug.com/356767669.
// Order of events:
// 1) The load of the speculation rules header completes
// 2) The document detaches
// 3) SpeculationRuleLoader::NotifyFinished is called
TEST(SpeculationRulesHeaderTest, DocumentDetached) {}

}  // namespace
}  // namespace blink