OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 TEST_F(ResourceFetcherTest, ContentTypeDataURL) { | 728 TEST_F(ResourceFetcherTest, ContentTypeDataURL) { |
729 ResourceFetcher* fetcher = ResourceFetcher::Create(Context()); | 729 ResourceFetcher* fetcher = ResourceFetcher::Create(Context()); |
730 FetchParameters fetch_params{ResourceRequest("data:text/testmimetype,foo")}; | 730 FetchParameters fetch_params{ResourceRequest("data:text/testmimetype,foo")}; |
731 Resource* resource = MockResource::Fetch(fetch_params, fetcher); | 731 Resource* resource = MockResource::Fetch(fetch_params, fetcher); |
732 ASSERT_TRUE(resource); | 732 ASSERT_TRUE(resource); |
733 EXPECT_EQ(ResourceStatus::kCached, resource->GetStatus()); | 733 EXPECT_EQ(ResourceStatus::kCached, resource->GetStatus()); |
734 EXPECT_EQ("text/testmimetype", resource->GetResponse().MimeType()); | 734 EXPECT_EQ("text/testmimetype", resource->GetResponse().MimeType()); |
735 EXPECT_EQ("text/testmimetype", resource->GetResponse().HttpContentType()); | 735 EXPECT_EQ("text/testmimetype", resource->GetResponse().HttpContentType()); |
736 } | 736 } |
737 | 737 |
| 738 TEST_F(ResourceFetcherTest, ContentIdURL) { |
| 739 KURL url(kParsedURLString, "cid:0123456789@example.com"); |
| 740 ResourceResponse response; |
| 741 response.SetURL(url); |
| 742 response.SetHTTPStatusCode(200); |
| 743 RegisterMockedURLLoadWithCustomResponse(url, response); |
| 744 |
| 745 ResourceFetcher* fetcher = ResourceFetcher::Create(Context()); |
| 746 |
| 747 // Fetching a main resource with the Content-ID scheme must be canceled if |
| 748 // there is no MHTMLArchive. |
| 749 { |
| 750 ResourceRequest resource_request(url); |
| 751 resource_request.SetRequestContext(WebURLRequest::kRequestContextIframe); |
| 752 resource_request.SetFrameType(WebURLRequest::kFrameTypeNested); |
| 753 FetchParameters fetch_params(resource_request); |
| 754 RawResource* resource = |
| 755 RawResource::FetchMainResource(fetch_params, fetcher, SubstituteData()); |
| 756 EXPECT_EQ(nullptr, resource); |
| 757 } |
| 758 |
| 759 // For all the other resource type, it must not be canceled. |
| 760 // Note: It is important not to cancel them because there are some embedders |
| 761 // of WebView that are using Content-ID URLs for sub-resources, even without |
| 762 // any MHTMLArchive. Please see https://crbug.com/739658. |
| 763 { |
| 764 ResourceRequest resource_request(url); |
| 765 resource_request.SetRequestContext(WebURLRequest::kRequestContextVideo); |
| 766 FetchParameters fetch_params(resource_request); |
| 767 RawResource* resource = RawResource::FetchMedia(fetch_params, fetcher); |
| 768 EXPECT_NE(nullptr, resource); |
| 769 } |
| 770 } |
| 771 |
738 } // namespace blink | 772 } // namespace blink |
OLD | NEW |