Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015, Google Inc. All rights reserved. | 2 * Copyright (c) 2015, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "core/loader/BaseFetchContext.h" | 31 #include "core/loader/BaseFetchContext.h" |
| 32 | 32 |
| 33 #include "core/testing/NullExecutionContext.h" | 33 #include "core/testing/NullExecutionContext.h" |
| 34 #include "platform/RuntimeEnabledFeatures.h" | 34 #include "platform/RuntimeEnabledFeatures.h" |
| 35 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class MockBaseFetchContext final : public BaseFetchContext { | |
| 41 public: | |
| 42 explicit MockBaseFetchContext(ExecutionContext* execution_context) | |
| 43 : BaseFetchContext(execution_context) {} | |
| 44 | |
|
horo
2017/04/20 06:00:48
nit: destructor.
kinuko
2017/04/21 09:45:27
Done.
| |
| 45 // BaseFetchContext overrides: | |
| 46 ContentSettingsClient* GetContentSettingsClient() const override { | |
| 47 return nullptr; | |
| 48 } | |
| 49 Settings* GetSettings() const override { return nullptr; } | |
| 50 SubresourceFilter* GetSubresourceFilter() const override { return nullptr; } | |
| 51 SecurityContext* GetMainResourceSecurityContext() const override { | |
| 52 return nullptr; | |
| 53 } | |
| 54 bool ShouldBlockRequestByInspector(const ResourceRequest&) const override { | |
| 55 return false; | |
| 56 } | |
| 57 void DispatchDidBlockRequest(const ResourceRequest&, | |
| 58 const FetchInitiatorInfo&, | |
| 59 ResourceRequestBlockedReason) const override {} | |
| 60 void ReportLocalLoadFailed(const KURL&) const override {} | |
| 61 bool ShouldBypassMainWorldCSP() const override { return false; } | |
| 62 bool IsSVGImageChromeClient() const override { return false; } | |
| 63 void CountUsage(UseCounter::Feature) const override {} | |
| 64 void CountDeprecation(UseCounter::Feature) const override {} | |
| 65 bool ShouldBlockFetchByMixedContentCheck( | |
| 66 const ResourceRequest&, | |
| 67 const KURL&, | |
| 68 SecurityViolationReportingPolicy) const override { | |
| 69 return false; | |
| 70 } | |
| 71 }; | |
| 72 | |
| 40 class BaseFetchContextTest : public ::testing::Test { | 73 class BaseFetchContextTest : public ::testing::Test { |
| 41 protected: | 74 protected: |
| 42 void SetUp() override { | 75 void SetUp() override { |
| 43 execution_context_ = new NullExecutionContext(); | 76 execution_context_ = new NullExecutionContext(); |
| 44 fetch_context_ = new BaseFetchContext(execution_context_); | 77 fetch_context_ = new MockBaseFetchContext(execution_context_); |
| 45 } | 78 } |
| 46 | 79 |
| 47 Persistent<ExecutionContext> execution_context_; | 80 Persistent<ExecutionContext> execution_context_; |
| 48 Persistent<BaseFetchContext> fetch_context_; | 81 Persistent<BaseFetchContext> fetch_context_; |
| 49 }; | 82 }; |
| 50 | 83 |
| 51 TEST_F(BaseFetchContextTest, SetIsExternalRequestForPublicContext) { | 84 TEST_F(BaseFetchContextTest, SetIsExternalRequestForPublicContext) { |
| 52 EXPECT_EQ(kWebAddressSpacePublic, | 85 EXPECT_EQ(kWebAddressSpacePublic, |
| 53 execution_context_->GetSecurityContext().AddressSpace()); | 86 execution_context_->GetSecurityContext().AddressSpace()); |
| 54 | 87 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 kFetchMainResource); | 210 kFetchMainResource); |
| 178 EXPECT_EQ(test.is_external_expectation, main_request.IsExternalRequest()); | 211 EXPECT_EQ(test.is_external_expectation, main_request.IsExternalRequest()); |
| 179 | 212 |
| 180 ResourceRequest sub_request(test.url); | 213 ResourceRequest sub_request(test.url); |
| 181 fetch_context_->AddAdditionalRequestHeaders(sub_request, kFetchSubresource); | 214 fetch_context_->AddAdditionalRequestHeaders(sub_request, kFetchSubresource); |
| 182 EXPECT_EQ(test.is_external_expectation, sub_request.IsExternalRequest()); | 215 EXPECT_EQ(test.is_external_expectation, sub_request.IsExternalRequest()); |
| 183 } | 216 } |
| 184 } | 217 } |
| 185 | 218 |
| 186 } // namespace blink | 219 } // namespace blink |
| OLD | NEW |