chromium/content/browser/service_worker/service_worker_updated_script_loader_unittest.cc

// 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/browser/service_worker/service_worker_updated_script_loader.h"

#include <map>
#include <memory>
#include <string>
#include <utility>

#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/service_worker_consts.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/public/test/browser_task_environment.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
#include "net/base/load_flags.h"
#include "net/base/test_completion_callback.h"
#include "net/http/http_util.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/redirect_info.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/test/test_url_loader_client.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration_options.mojom.h"
#include "url/origin.h"

namespace content {
namespace service_worker_updated_script_loader_unittest {

const char kNormalScriptURL[] =;

// MockHTTPServer is a utility to provide mocked responses for
// ServiceWorkerUpdatedScriptLoader.
class MockHTTPServer {};

// ServiceWorkerUpdatedScriptLoaderTest is for testing the handling of requests
// for installing service worker scripts via ServiceWorkerUpdatedScriptLoader.
class ServiceWorkerUpdatedScriptLoaderTest
    : public testing::TestWithParam<blink::mojom::ScriptType> {};

// Tests the loader when the first script data block is different.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, FirstBlockDifferent) {}

// Tests the loader when the script data block in the middle is different.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, MiddleBlockDifferent) {}

// Tests the loader when the last script data block is different.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, LastBlockDifferent) {}

// Tests the loader when the last script data block is different and
// OnCompleted() has been called during update check.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, LastBlockDifferentCompleted) {}

// Tests the loader when the new script has more data appended.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, NewScriptLargerThanOld) {}

// Tests the loader when the script changed to have no body.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, NewScriptEmptyBody) {}

// Tests the loader could report error when the resumed network
// download completed with error.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, CompleteFailed) {}

// Regression test for https://crbug.com/1312995.
TEST_P(ServiceWorkerUpdatedScriptLoaderTest, ClientConsumeNetworkLater) {}

INSTANTIATE_TEST_SUITE_P();
}  // namespace service_worker_updated_script_loader_unittest
}  // namespace content