| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/frame/FrameOwner.h" | 35 #include "core/frame/FrameOwner.h" |
| 36 #include "core/frame/FrameView.h" | 36 #include "core/frame/FrameView.h" |
| 37 #include "core/frame/Settings.h" | 37 #include "core/frame/Settings.h" |
| 38 #include "core/html/HTMLDocument.h" | 38 #include "core/html/HTMLDocument.h" |
| 39 #include "core/loader/DocumentLoader.h" | 39 #include "core/loader/DocumentLoader.h" |
| 40 #include "core/loader/EmptyClients.h" | 40 #include "core/loader/EmptyClients.h" |
| 41 #include "core/page/Page.h" | 41 #include "core/page/Page.h" |
| 42 #include "core/testing/DummyPageHolder.h" | 42 #include "core/testing/DummyPageHolder.h" |
| 43 #include "platform/network/ResourceRequest.h" | 43 #include "platform/network/ResourceRequest.h" |
| 44 #include "platform/weborigin/KURL.h" | 44 #include "platform/weborigin/KURL.h" |
| 45 #include "public/platform/WebAddressSpace.h" |
| 45 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h" | 46 #include "testing/gmock/include/gmock/gmock-generated-function-mockers.h" |
| 46 #include "testing/gtest/include/gtest/gtest.h" | 47 #include "testing/gtest/include/gtest/gtest.h" |
| 47 | 48 |
| 48 namespace blink { | 49 namespace blink { |
| 49 | 50 |
| 50 class StubFrameLoaderClientWithParent final : public EmptyFrameLoaderClient { | 51 class StubFrameLoaderClientWithParent final : public EmptyFrameLoaderClient { |
| 51 public: | 52 public: |
| 52 static PassOwnPtrWillBeRawPtr<StubFrameLoaderClientWithParent> create(Frame*
parent) | 53 static PassOwnPtrWillBeRawPtr<StubFrameLoaderClientWithParent> create(Frame*
parent) |
| 53 { | 54 { |
| 54 return adoptPtrWillBeNoop(new StubFrameLoaderClientWithParent(parent)); | 55 return adoptPtrWillBeNoop(new StubFrameLoaderClientWithParent(parent)); |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 response.setURL(url); | 576 response.setURL(url); |
| 576 response.setSecurityInfo(securityInfo); | 577 response.setSecurityInfo(securityInfo); |
| 577 response.setHasMajorCertificateErrors(true); | 578 response.setHasMajorCertificateErrors(true); |
| 578 RefPtrWillBeRawPtr<Resource> resource = Resource::create(resourceRequest, Re
source::Image); | 579 RefPtrWillBeRawPtr<Resource> resource = Resource::create(resourceRequest, Re
source::Image); |
| 579 resource->setResponse(response); | 580 resource->setResponse(response); |
| 580 fetchContext->dispatchDidLoadResourceFromMemoryCache(resource.get(), WebURLR
equest::FrameTypeNone, WebURLRequest::RequestContextImage); | 581 fetchContext->dispatchDidLoadResourceFromMemoryCache(resource.get(), WebURLR
equest::FrameTypeNone, WebURLRequest::RequestContextImage); |
| 581 } | 582 } |
| 582 | 583 |
| 583 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPublicDocument) | 584 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPublicDocument) |
| 584 { | 585 { |
| 585 EXPECT_EQ(WebURLRequest::AddressSpacePublic, document->addressSpace()); | 586 EXPECT_EQ(WebAddressSpacePublic, document->addressSpace()); |
| 586 | 587 |
| 587 struct TestCase { | 588 struct TestCase { |
| 588 const char* url; | 589 const char* url; |
| 589 bool isExternalExpectation; | 590 bool isExternalExpectation; |
| 590 } cases[] = { | 591 } cases[] = { |
| 591 { "data:text/html,whatever", false }, | 592 { "data:text/html,whatever", false }, |
| 592 { "file:///etc/passwd", false }, | 593 { "file:///etc/passwd", false }, |
| 593 { "blob:http://example.com/", false }, | 594 { "blob:http://example.com/", false }, |
| 594 | 595 |
| 595 { "http://example.com/", false }, | 596 { "http://example.com/", false }, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 622 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); | 623 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); |
| 623 | 624 |
| 624 ResourceRequest subRequest(test.url); | 625 ResourceRequest subRequest(test.url); |
| 625 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 626 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
| 626 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); | 627 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); |
| 627 } | 628 } |
| 628 } | 629 } |
| 629 | 630 |
| 630 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPrivateDocument) | 631 TEST_F(FrameFetchContextTest, SetIsExternalRequestForPrivateDocument) |
| 631 { | 632 { |
| 632 document->setAddressSpace(WebURLRequest::AddressSpacePrivate); | 633 document->setAddressSpace(WebAddressSpacePrivate); |
| 633 EXPECT_EQ(WebURLRequest::AddressSpacePrivate, document->addressSpace()); | 634 EXPECT_EQ(WebAddressSpacePrivate, document->addressSpace()); |
| 634 | 635 |
| 635 struct TestCase { | 636 struct TestCase { |
| 636 const char* url; | 637 const char* url; |
| 637 bool isExternalExpectation; | 638 bool isExternalExpectation; |
| 638 } cases[] = { | 639 } cases[] = { |
| 639 { "data:text/html,whatever", false }, | 640 { "data:text/html,whatever", false }, |
| 640 { "file:///etc/passwd", false }, | 641 { "file:///etc/passwd", false }, |
| 641 { "blob:http://example.com/", false }, | 642 { "blob:http://example.com/", false }, |
| 642 | 643 |
| 643 { "http://example.com/", false }, | 644 { "http://example.com/", false }, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 670 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); | 671 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); |
| 671 | 672 |
| 672 ResourceRequest subRequest(test.url); | 673 ResourceRequest subRequest(test.url); |
| 673 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 674 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
| 674 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); | 675 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); |
| 675 } | 676 } |
| 676 } | 677 } |
| 677 | 678 |
| 678 TEST_F(FrameFetchContextTest, SetIsExternalRequestForLocalDocument) | 679 TEST_F(FrameFetchContextTest, SetIsExternalRequestForLocalDocument) |
| 679 { | 680 { |
| 680 document->setAddressSpace(WebURLRequest::AddressSpaceLocal); | 681 document->setAddressSpace(WebAddressSpaceLocal); |
| 681 EXPECT_EQ(WebURLRequest::AddressSpaceLocal, document->addressSpace()); | 682 EXPECT_EQ(WebAddressSpaceLocal, document->addressSpace()); |
| 682 | 683 |
| 683 struct TestCase { | 684 struct TestCase { |
| 684 const char* url; | 685 const char* url; |
| 685 bool isExternalExpectation; | 686 bool isExternalExpectation; |
| 686 } cases[] = { | 687 } cases[] = { |
| 687 { "data:text/html,whatever", false }, | 688 { "data:text/html,whatever", false }, |
| 688 { "file:///etc/passwd", false }, | 689 { "file:///etc/passwd", false }, |
| 689 { "blob:http://example.com/", false }, | 690 { "blob:http://example.com/", false }, |
| 690 | 691 |
| 691 { "http://example.com/", false }, | 692 { "http://example.com/", false }, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 716 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); | 717 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); |
| 717 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); | 718 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); |
| 718 | 719 |
| 719 ResourceRequest subRequest(test.url); | 720 ResourceRequest subRequest(test.url); |
| 720 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 721 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
| 721 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); | 722 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); |
| 722 } | 723 } |
| 723 } | 724 } |
| 724 | 725 |
| 725 } // namespace blink | 726 } // namespace blink |
| OLD | NEW |