diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/testing')
20 files changed, 223 insertions, 70 deletions
diff --git a/chromium/third_party/blink/renderer/platform/testing/OWNERS b/chromium/third_party/blink/renderer/platform/testing/OWNERS index 81fbf4e9384..ef21f5ed508 100644 --- a/chromium/third_party/blink/renderer/platform/testing/OWNERS +++ b/chromium/third_party/blink/renderer/platform/testing/OWNERS @@ -1,4 +1,2 @@ danakj@chromium.org dcheng@chromium.org - -per-file testing_platform_support_with_web_rtc.*=hbos@chromium.org diff --git a/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.cc b/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.cc index dd55c90a14c..70cdf2a9e61 100644 --- a/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.cc +++ b/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.cc @@ -6,19 +6,27 @@ namespace blink { -void CodeCacheLoaderMock::FetchFromCodeCacheSynchronously( - const WebURL& url, - base::Time* response_time_out, - mojo_base::BigBuffer* buffer_out) { - *response_time_out = base::Time(); - *buffer_out = mojo_base::BigBuffer(); -} - void CodeCacheLoaderMock::FetchFromCodeCache( blink::mojom::CodeCacheType cache_type, const WebURL& url, WebCodeCacheLoader::FetchCodeCacheCallback callback) { - std::move(callback).Run(base::Time(), mojo_base::BigBuffer()); + if (controller_ && controller_->delayed_) { + // This simple mock doesn't support multiple in-flight loads. + CHECK(!controller_->callback_); + + controller_->callback_ = std::move(callback); + } else { + std::move(callback).Run(base::Time(), mojo_base::BigBuffer()); + } +} + +void CodeCacheLoaderMock::Controller::DelayResponse() { + delayed_ = true; +} +void CodeCacheLoaderMock::Controller::Respond(base::Time time, + mojo_base::BigBuffer data) { + CHECK(callback_); + std::move(callback_).Run(time, std::move(data)); } } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.h b/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.h index 7878081a5d1..fb06db03e65 100644 --- a/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.h +++ b/chromium/third_party/blink/renderer/platform/testing/code_cache_loader_mock.h @@ -14,25 +14,41 @@ namespace blink { // A simple class for mocking WebCodeCacheLoader. class CodeCacheLoaderMock : public WebCodeCacheLoader { public: - CodeCacheLoaderMock() {} + // A class which can be owned by both this mock loader and the creator of this + // mock loader, which lets the creator control the behavior of the mock loader + // without having to retain a reference to the mock loader itself. + class Controller : public base::RefCounted<Controller> { + public: + void DelayResponse(); + void Respond(base::Time time, mojo_base::BigBuffer data); + + private: + friend class CodeCacheLoaderMock; + friend class base::RefCounted<Controller>; + ~Controller() = default; + + // Whether to delay responses until Respond is called. + // Otherwise responses are immediate and empty. + bool delayed_ = false; + + // Callback saved by fetch call, if delayed_ was true. + WebCodeCacheLoader::FetchCodeCacheCallback callback_; + }; + + explicit CodeCacheLoaderMock(scoped_refptr<Controller> controller = nullptr) + : controller_(std::move(controller)) {} + CodeCacheLoaderMock(const CodeCacheLoaderMock&) = delete; + CodeCacheLoaderMock& operator=(const CodeCacheLoaderMock&) = delete; ~CodeCacheLoaderMock() override = default; // CodeCacheLoader methods: - void FetchFromCodeCacheSynchronously( - const WebURL& url, - base::Time* response_time_out, - mojo_base::BigBuffer* buffer_out) override; void FetchFromCodeCache( blink::mojom::CodeCacheType cache_type, const WebURL& url, WebCodeCacheLoader::FetchCodeCacheCallback callback) override; - base::WeakPtr<CodeCacheLoaderMock> GetWeakPtr(); - private: - base::WeakPtrFactory<CodeCacheLoaderMock> weak_ptr_factory_{this}; - - DISALLOW_COPY_AND_ASSIGN(CodeCacheLoaderMock); + scoped_refptr<Controller> controller_; }; } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/testing/compositor_test.h b/chromium/third_party/blink/renderer/platform/testing/compositor_test.h index 5d07c0e5a65..e6eb1e72591 100644 --- a/chromium/third_party/blink/renderer/platform/testing/compositor_test.h +++ b/chromium/third_party/blink/renderer/platform/testing/compositor_test.h @@ -5,7 +5,6 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_COMPOSITOR_TEST_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_COMPOSITOR_TEST_H_ -#include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "base/test/test_mock_time_task_runner.h" #include "base/threading/thread_task_runner_handle.h" @@ -16,6 +15,8 @@ namespace blink { class CompositorTest : public testing::Test { public: CompositorTest(); + CompositorTest(const CompositorTest&) = delete; + CompositorTest& operator=(const CompositorTest&) = delete; ~CompositorTest() override; protected: @@ -23,9 +24,6 @@ class CompositorTest : public testing::Test { // and bind it as the current ThreadTaskRunnerHandle for this thread. scoped_refptr<base::TestMockTimeTaskRunner> runner_; base::ThreadTaskRunnerHandle runner_handle_; - - private: - DISALLOW_COPY_AND_ASSIGN(CompositorTest); }; } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/testing/fuzzed_data_provider.h b/chromium/third_party/blink/renderer/platform/testing/fuzzed_data_provider.h index 1a28925c4bb..3629df14a9b 100644 --- a/chromium/third_party/blink/renderer/platform/testing/fuzzed_data_provider.h +++ b/chromium/third_party/blink/renderer/platform/testing/fuzzed_data_provider.h @@ -7,7 +7,6 @@ #include <fuzzer/FuzzedDataProvider.h> -#include "base/macros.h" #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" @@ -19,6 +18,8 @@ class FuzzedDataProvider { public: FuzzedDataProvider(const uint8_t* bytes, size_t num_bytes); + FuzzedDataProvider(const FuzzedDataProvider&) = delete; + FuzzedDataProvider& operator=(const FuzzedDataProvider&) = delete; // Returns a string with length between 0 and max_length. String ConsumeRandomLengthString(size_t max_length); @@ -58,8 +59,6 @@ class FuzzedDataProvider { private: ::FuzzedDataProvider provider_; - - DISALLOW_COPY_AND_ASSIGN(FuzzedDataProvider); }; } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/testing/image_decode_bench.cc b/chromium/third_party/blink/renderer/platform/testing/image_decode_bench.cc index b3426cd9215..f20aa2d282c 100644 --- a/chromium/third_party/blink/renderer/platform/testing/image_decode_bench.cc +++ b/chromium/third_party/blink/renderer/platform/testing/image_decode_bench.cc @@ -28,11 +28,11 @@ namespace { scoped_refptr<SharedBuffer> ReadFile(const char* name) { std::string file; - if (base::ReadFileToString(base::FilePath::FromUTF8Unsafe(name), &file)) - return SharedBuffer::Create(file.data(), file.size()); - perror(name); - exit(2); - return SharedBuffer::Create(); + if (!base::ReadFileToString(base::FilePath::FromUTF8Unsafe(name), &file)) { + perror(name); + exit(2); + } + return SharedBuffer::Create(file.data(), file.size()); } struct ImageMeta { diff --git a/chromium/third_party/blink/renderer/platform/testing/noop_web_url_loader.cc b/chromium/third_party/blink/renderer/platform/testing/noop_web_url_loader.cc new file mode 100644 index 00000000000..a744186fff2 --- /dev/null +++ b/chromium/third_party/blink/renderer/platform/testing/noop_web_url_loader.cc @@ -0,0 +1,39 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// 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/platform/testing/noop_web_url_loader.h" + +#include "services/network/public/cpp/resource_request.h" +#include "third_party/blink/public/platform/resource_load_info_notifier_wrapper.h" +#include "third_party/blink/public/platform/web_url_request_extra_data.h" + +namespace blink { + +void NoopWebURLLoader::LoadSynchronously( + std::unique_ptr<network::ResourceRequest> request, + scoped_refptr<WebURLRequestExtraData> url_request_extra_data, + bool pass_response_pipe_to_client, + bool no_mime_sniffing, + base::TimeDelta timeout_interval, + WebURLLoaderClient*, + WebURLResponse&, + absl::optional<WebURLError>&, + WebData&, + int64_t& encoded_data_length, + int64_t& encoded_body_length, + WebBlobInfo& downloaded_blob, + std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper> + resource_load_info_notifier_wrapper) { + NOTREACHED(); +} + +void NoopWebURLLoader::LoadAsynchronously( + std::unique_ptr<network::ResourceRequest> request, + scoped_refptr<WebURLRequestExtraData> url_request_extra_data, + bool no_mime_sniffing, + std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper> + resource_load_info_notifier_wrapper, + WebURLLoaderClient*) {} + +} // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/testing/noop_web_url_loader.h b/chromium/third_party/blink/renderer/platform/testing/noop_web_url_loader.h new file mode 100644 index 00000000000..7283c5e60e3 --- /dev/null +++ b/chromium/third_party/blink/renderer/platform/testing/noop_web_url_loader.h @@ -0,0 +1,56 @@ +// Copyright 2021 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_NOOP_WEB_URL_LOADER_H_ +#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_NOOP_WEB_URL_LOADER_H_ + +#include "third_party/blink/public/platform/web_url_loader.h" + +namespace blink { + +class NoopWebURLLoader final : public WebURLLoader { + public: + explicit NoopWebURLLoader( + scoped_refptr<base::SingleThreadTaskRunner> task_runner) + : task_runner_(task_runner) {} + ~NoopWebURLLoader() override = default; + void LoadSynchronously( + std::unique_ptr<network::ResourceRequest> request, + scoped_refptr<WebURLRequestExtraData> url_request_extra_data, + bool pass_response_pipe_to_client, + bool no_mime_sniffing, + base::TimeDelta timeout_interval, + WebURLLoaderClient*, + WebURLResponse&, + absl::optional<WebURLError>&, + WebData&, + int64_t& encoded_data_length, + int64_t& encoded_body_length, + WebBlobInfo& downloaded_blob, + std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper> + resource_load_info_notifier_wrapper) override; + void LoadAsynchronously( + std::unique_ptr<network::ResourceRequest> request, + scoped_refptr<WebURLRequestExtraData> url_request_extra_data, + bool no_mime_sniffing, + std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper> + resource_load_info_notifier_wrapper, + WebURLLoaderClient*) override; + + void Freeze(WebLoaderFreezeMode) override {} + void DidChangePriority(WebURLRequest::Priority, int) override { + NOTREACHED(); + } + scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunnerForBodyLoader() + override { + return task_runner_; + } + + private: + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_NOOP_WEB_URL_LOADER_H_ diff --git a/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.cc b/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.cc index 90397bd97a1..7ad3c6fcfee 100644 --- a/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.cc +++ b/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.cc @@ -69,7 +69,8 @@ TestPaintArtifact& TestPaintArtifact::ForeignLayer( DEFINE_STATIC_LOCAL(LiteralDebugNameClient, client, ("ForeignLayer")); paint_artifact_->GetDisplayItemList() .AllocateAndConstruct<ForeignLayerDisplayItem>( - client, DisplayItem::kForeignLayerFirst, std::move(layer), offset); + client, DisplayItem::kForeignLayerFirst, std::move(layer), offset, + client.GetPaintInvalidationReason()); DidAddDisplayItem(); return *this; } @@ -87,7 +88,8 @@ TestPaintArtifact& TestPaintArtifact::RectDrawing(DisplayItemClient& client, paint_artifact_->GetDisplayItemList() .AllocateAndConstruct<DrawingDisplayItem>( client, DisplayItem::kDrawingFirst, bounds, - recorder.finishRecordingAsPicture()); + recorder.finishRecordingAsPicture(), + client.GetPaintInvalidationReason()); DidAddDisplayItem(); return *this; } @@ -109,8 +111,30 @@ TestPaintArtifact& TestPaintArtifact::SetRasterEffectOutset( return *this; } -TestPaintArtifact& TestPaintArtifact::KnownToBeOpaque() { - paint_artifact_->PaintChunks().back().known_to_be_opaque = true; +TestPaintArtifact& TestPaintArtifact::RectKnownToBeOpaque(const IntRect& r) { + auto& chunk = paint_artifact_->PaintChunks().back(); + chunk.rect_known_to_be_opaque = r; + DCHECK(chunk.bounds.Contains(r)); + return *this; +} + +TestPaintArtifact& TestPaintArtifact::TextKnownToBeOnOpaqueBackground() { + auto& chunk = paint_artifact_->PaintChunks().back(); + DCHECK(chunk.has_text); + paint_artifact_->PaintChunks().back().text_known_to_be_on_opaque_background = + true; + return *this; +} + +TestPaintArtifact& TestPaintArtifact::HasText() { + auto& chunk = paint_artifact_->PaintChunks().back(); + chunk.has_text = true; + chunk.text_known_to_be_on_opaque_background = false; + return *this; +} + +TestPaintArtifact& TestPaintArtifact::EffectivelyInvisible() { + paint_artifact_->PaintChunks().back().effectively_invisible = true; return *this; } @@ -134,6 +158,11 @@ TestPaintArtifact& TestPaintArtifact::Uncacheable() { return *this; } +TestPaintArtifact& TestPaintArtifact::IsMovedFromCachedSubsequence() { + paint_artifact_->PaintChunks().back().is_moved_from_cached_subsequence = true; + return *this; +} + scoped_refptr<PaintArtifact> TestPaintArtifact::Build() { return std::move(paint_artifact_); } diff --git a/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.h b/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.h index 4c9044ca2fc..d11d6514769 100644 --- a/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.h +++ b/chromium/third_party/blink/renderer/platform/testing/test_paint_artifact.h @@ -117,8 +117,12 @@ class TestPaintArtifact { TestPaintArtifact& DrawableBounds(const IntRect&); TestPaintArtifact& SetRasterEffectOutset(RasterEffectOutset); - TestPaintArtifact& KnownToBeOpaque(); + TestPaintArtifact& RectKnownToBeOpaque(const IntRect&); + TestPaintArtifact& TextKnownToBeOnOpaqueBackground(); + TestPaintArtifact& HasText(); + TestPaintArtifact& EffectivelyInvisible(); TestPaintArtifact& Uncacheable(); + TestPaintArtifact& IsMovedFromCachedSubsequence(); // Build the paint artifact. After that, if this object has automatically // created any display item client, the caller must retain this object when diff --git a/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.cc b/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.cc index 12ed1318c4a..0b6ebef8352 100644 --- a/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.cc +++ b/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.cc @@ -109,8 +109,9 @@ WebString TestingPlatformSupport::DefaultLocale() { return WebString::FromUTF8("en-US"); } -WebData TestingPlatformSupport::GetDataResource(int resource_id, - ui::ScaleFactor scale_factor) { +WebData TestingPlatformSupport::GetDataResource( + int resource_id, + ui::ResourceScaleFactor scale_factor) { return old_platform_ ? old_platform_->GetDataResource(resource_id, scale_factor) : WebData(); diff --git a/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.h b/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.h index debac8d0477..cf6ed4f932b 100644 --- a/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.h +++ b/chromium/third_party/blink/renderer/platform/testing/testing_platform_support.h @@ -36,7 +36,6 @@ #include "base/auto_reset.h" #include "base/callback.h" -#include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/renderer/platform/platform_export.h" @@ -56,16 +55,15 @@ namespace blink { class TestingPlatformSupport : public Platform { public: TestingPlatformSupport(); + TestingPlatformSupport(const TestingPlatformSupport&) = delete; + TestingPlatformSupport& operator=(const TestingPlatformSupport&) = delete; ~TestingPlatformSupport() override; // Platform: WebString DefaultLocale() override; - std::unique_ptr<WebCodeCacheLoader> CreateCodeCacheLoader() override { - return std::make_unique<CodeCacheLoaderMock>(); - } WebData GetDataResource(int resource_id, - ui::ScaleFactor scale_factor) override; + ui::ResourceScaleFactor scale_factor) override; WebData UncompressDataResource(int resource_id) override; ThreadSafeBrowserInterfaceBrokerProxy* GetBrowserInterfaceBroker() override; bool IsThreadedAnimationEnabled() override; @@ -74,7 +72,7 @@ class TestingPlatformSupport : public Platform { virtual void RunUntilIdle(); void SetThreadedAnimationEnabled(bool enabled); - void SetUseZoomForDSF(bool enabeld); + void SetUseZoomForDSF(bool enabled); // Overrides the handling of GetInterface on the platform's associated // interface provider. @@ -98,9 +96,7 @@ class TestingPlatformSupport : public Platform { private: bool is_threaded_animation_enabled_ = false; - bool is_zoom_for_dsf_enabled_ = false; - - DISALLOW_COPY_AND_ASSIGN(TestingPlatformSupport); + bool is_zoom_for_dsf_enabled_ = true; }; // ScopedTestingPlatformSupport<MyTestingPlatformSupport> can be used to @@ -128,8 +124,6 @@ class TestingPlatformSupport : public Platform { // } template <class T, typename... Args> class ScopedTestingPlatformSupport final { - DISALLOW_COPY_AND_ASSIGN(ScopedTestingPlatformSupport); - public: explicit ScopedTestingPlatformSupport(Args&&... args) { testing_platform_support_ = @@ -138,6 +132,9 @@ class ScopedTestingPlatformSupport final { DCHECK(original_platform_); Platform::SetCurrentPlatformForTesting(testing_platform_support_.get()); } + ScopedTestingPlatformSupport(const ScopedTestingPlatformSupport&) = delete; + ScopedTestingPlatformSupport& operator=(const ScopedTestingPlatformSupport&) = + delete; ~ScopedTestingPlatformSupport() { DCHECK_EQ(testing_platform_support_.get(), Platform::Current()); testing_platform_support_.reset(); @@ -158,10 +155,12 @@ class ScopedTestingPlatformSupport final { }; class ScopedUnittestsEnvironmentSetup final { - DISALLOW_COPY_AND_ASSIGN(ScopedUnittestsEnvironmentSetup); - public: ScopedUnittestsEnvironmentSetup(int argc, char** argv); + ScopedUnittestsEnvironmentSetup(const ScopedUnittestsEnvironmentSetup&) = + delete; + ScopedUnittestsEnvironmentSetup& operator=( + const ScopedUnittestsEnvironmentSetup&) = delete; ~ScopedUnittestsEnvironmentSetup(); private: diff --git a/chromium/third_party/blink/renderer/platform/testing/testing_platform_support_with_mock_scheduler.h b/chromium/third_party/blink/renderer/platform/testing/testing_platform_support_with_mock_scheduler.h index 6aa650b9560..0e513ee8d78 100644 --- a/chromium/third_party/blink/renderer/platform/testing/testing_platform_support_with_mock_scheduler.h +++ b/chromium/third_party/blink/renderer/platform/testing/testing_platform_support_with_mock_scheduler.h @@ -7,7 +7,6 @@ #include <memory> -#include "base/macros.h" #include "base/test/test_mock_time_task_runner.h" #include "third_party/blink/renderer/platform/scheduler/public/thread.h" #include "third_party/blink/renderer/platform/testing/scoped_main_thread_overrider.h" @@ -34,6 +33,10 @@ class MainThreadSchedulerImpl; class TestingPlatformSupportWithMockScheduler : public TestingPlatformSupport { public: TestingPlatformSupportWithMockScheduler(); + TestingPlatformSupportWithMockScheduler( + const TestingPlatformSupportWithMockScheduler&) = delete; + TestingPlatformSupportWithMockScheduler& operator=( + const TestingPlatformSupportWithMockScheduler&) = delete; ~TestingPlatformSupportWithMockScheduler() override; scoped_refptr<base::TestMockTimeTaskRunner> test_task_runner() { @@ -79,9 +82,6 @@ class TestingPlatformSupportWithMockScheduler : public TestingPlatformSupport { base::sequence_manager::SequenceManager* sequence_manager_; // Owned by scheduler_. std::unique_ptr<ScopedMainThreadOverrider> main_thread_overrider_; - - private: - DISALLOW_COPY_AND_ASSIGN(TestingPlatformSupportWithMockScheduler); }; } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/testing/unit_test_helpers.h b/chromium/third_party/blink/renderer/platform/testing/unit_test_helpers.h index 6ed243a25b7..bf166a0b550 100644 --- a/chromium/third_party/blink/renderer/platform/testing/unit_test_helpers.h +++ b/chromium/third_party/blink/renderer/platform/testing/unit_test_helpers.h @@ -95,7 +95,7 @@ class LineReader { private: String text_; - size_t index_; + wtf_size_t index_; }; } // namespace test diff --git a/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.cc b/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.cc index 15da0476d4b..8f1bf358540 100644 --- a/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.cc +++ b/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.cc @@ -64,7 +64,8 @@ WebURL RegisterMockedURLLoadFromBase(const WebString& base_url, void RegisterMockedURLLoad(const WebURL& full_url, const WebString& file_path, const WebString& mime_type, - WebURLLoaderMockFactory* mock_factory) { + WebURLLoaderMockFactory* mock_factory, + network::mojom::IPAddressSpace address_space) { network::mojom::LoadTimingInfoPtr timing = network::mojom::LoadTimingInfo::New(); @@ -73,6 +74,7 @@ void RegisterMockedURLLoad(const WebURL& full_url, response.SetHttpHeaderField(http_names::kContentType, mime_type); response.SetHttpStatusCode(200); response.SetLoadTiming(*timing); + response.SetAddressSpace(address_space); mock_factory->RegisterURL(full_url, response, file_path); } diff --git a/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.h b/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.h index 12c6f6c2f54..e6e1cea1523 100644 --- a/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.h +++ b/chromium/third_party/blink/renderer/platform/testing/url_test_helpers.h @@ -31,6 +31,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_URL_TEST_HELPERS_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_URL_TEST_HELPERS_H_ +#include "services/network/public/mojom/ip_address_space.mojom-shared.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/platform/web_url_loader_mock_factory.h" @@ -74,7 +75,9 @@ void RegisterMockedURLLoad( const WebString& file_path, const WebString& mime_type = WebString::FromUTF8("text/html"), WebURLLoaderMockFactory* mock_factory = - WebURLLoaderMockFactory::GetSingletonInstance()); + WebURLLoaderMockFactory::GetSingletonInstance(), + network::mojom::IPAddressSpace address_space = + network::mojom::IPAddressSpace::kPublic); // Unregisters a URL that has been registered, so that the same URL can be // registered again from the another test. diff --git a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.cc b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.cc index 3624ea4f6b8..ac44a4b0412 100644 --- a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.cc +++ b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.cc @@ -60,7 +60,8 @@ void WebURLLoaderMock::ServeAsynchronousRequest( data.ForEachSegment([this, &delegate, &self](const char* segment, size_t segment_size, size_t segment_offset) { - delegate->DidReceiveData(client_, segment, segment_size); + delegate->DidReceiveData(client_, segment, + base::checked_cast<int>(segment_size)); // DidReceiveData() may clear the |self| weak ptr. We stop iterating // when that happens. return self; @@ -133,8 +134,8 @@ void WebURLLoaderMock::Cancel() { factory_->CancelLoad(this); } -void WebURLLoaderMock::SetDefersLoading(DeferType deferred) { - is_deferred_ = (deferred != DeferType::kNotDeferred); +void WebURLLoaderMock::Freeze(WebLoaderFreezeMode mode) { + is_deferred_ = (mode != WebLoaderFreezeMode::kNone); // Ignores setDefersLoading(false) safely. if (!is_deferred_) return; diff --git a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.h b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.h index 8cb21ae9c09..5613710ab9a 100644 --- a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.h +++ b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock.h @@ -6,7 +6,6 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_WEBURL_LOADER_MOCK_H_ #include <memory> -#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/platform/web_url_error.h" @@ -31,6 +30,8 @@ const uint32_t kRedirectResponseOverheadBytes = 300; class WebURLLoaderMock : public WebURLLoader { public: explicit WebURLLoaderMock(WebURLLoaderMockFactoryImpl* factory); + WebURLLoaderMock(const WebURLLoaderMock&) = delete; + WebURLLoaderMock& operator=(const WebURLLoaderMock&) = delete; ~WebURLLoaderMock() override; // Simulates the asynchronous request being served. @@ -66,7 +67,7 @@ class WebURLLoaderMock : public WebURLLoader { std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper> resource_load_info_notifier_wrapper, WebURLLoaderClient* client) override; - void SetDefersLoading(DeferType defer) override; + void Freeze(WebLoaderFreezeMode mode) override; void DidChangePriority(WebURLRequest::Priority new_priority, int intra_priority_value) override; scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunnerForBodyLoader() @@ -85,8 +86,6 @@ class WebURLLoaderMock : public WebURLLoader { bool is_deferred_ = false; base::WeakPtrFactory<WebURLLoaderMock> weak_factory_{this}; - - DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMock); }; } // namespace blink diff --git a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.cc b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.cc index cd79a8d3856..2ca34773005 100644 --- a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.cc +++ b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.cc @@ -12,6 +12,7 @@ #include "base/files/file_util.h" #include "base/memory/ptr_util.h" #include "base/run_loop.h" +#include "services/network/public/cpp/resource_request.h" #include "third_party/blink/public/platform/file_path_conversion.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/web_string.h" diff --git a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.h b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.h index 57f855118d1..a0a395567e2 100644 --- a/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.h +++ b/chromium/third_party/blink/renderer/platform/testing/weburl_loader_mock_factory_impl.h @@ -6,7 +6,6 @@ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_WEBURL_LOADER_MOCK_FACTORY_IMPL_H_ #include "base/files/file_path.h" -#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/platform/web_url.h" @@ -36,6 +35,9 @@ class WebURLLoaderTestDelegate; class WebURLLoaderMockFactoryImpl : public WebURLLoaderMockFactory { public: WebURLLoaderMockFactoryImpl(TestingPlatformSupport*); + WebURLLoaderMockFactoryImpl(const WebURLLoaderMockFactoryImpl&) = delete; + WebURLLoaderMockFactoryImpl& operator=(const WebURLLoaderMockFactoryImpl&) = + delete; ~WebURLLoaderMockFactoryImpl() override; // WebURLLoaderMockFactory: @@ -124,8 +126,6 @@ class WebURLLoaderMockFactoryImpl : public WebURLLoaderMockFactory { ProtocolToResponseMap protocol_to_response_info_; TestingPlatformSupport* platform_; - - DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactoryImpl); }; } // namespace blink |