OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "content/public/browser/render_frame_host.h" | 8 #include "content/public/browser/render_frame_host.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 page_file_path, expected_resources_matcher, file_url, | 48 page_file_path, expected_resources_matcher, file_url, |
49 shell()->web_contents()->GetMainFrame()->GetRoutingID())); | 49 shell()->web_contents()->GetMainFrame()->GetRoutingID())); |
50 } | 50 } |
51 | 51 |
52 void CheckResources(const base::FilePath& page_file_path, | 52 void CheckResources(const base::FilePath& page_file_path, |
53 const UrlVectorMatcher& expected_resources_matcher, | 53 const UrlVectorMatcher& expected_resources_matcher, |
54 const GURL& file_url, | 54 const GURL& file_url, |
55 int render_frame_routing_id) { | 55 int render_frame_routing_id) { |
56 // Get all savable resource links for the page. | 56 // Get all savable resource links for the page. |
57 std::vector<GURL> resources_list; | 57 std::vector<GURL> resources_list; |
58 std::vector<GURL> referrer_urls_list; | 58 SavableResourcesResult result(&resources_list); |
59 std::vector<blink::WebReferrerPolicy> referrer_policies_list; | |
60 SavableResourcesResult result(&resources_list, &referrer_urls_list, | |
61 &referrer_policies_list); | |
62 | 59 |
63 const char* savable_schemes[] = { | 60 const char* savable_schemes[] = { |
64 "http", | 61 "http", |
65 "https", | 62 "https", |
66 "file", | 63 "file", |
67 NULL | 64 NULL |
68 }; | 65 }; |
69 | 66 |
70 RenderFrame* render_frame = | 67 RenderFrame* render_frame = |
71 RenderFrame::FromRoutingID(render_frame_routing_id); | 68 RenderFrame::FromRoutingID(render_frame_routing_id); |
72 | 69 |
73 ASSERT_TRUE(GetSavableResourceLinksForFrame( | 70 ASSERT_TRUE(GetSavableResourceLinksForFrame( |
74 render_frame->GetWebFrame(), | 71 render_frame->GetWebFrame(), |
75 &result, savable_schemes)); | 72 &result, savable_schemes)); |
76 | 73 |
77 EXPECT_EQ(resources_list.size(), referrer_urls_list.size()); | |
78 EXPECT_EQ(resources_list.size(), referrer_policies_list.size()); | |
79 EXPECT_THAT(resources_list, expected_resources_matcher); | 74 EXPECT_THAT(resources_list, expected_resources_matcher); |
80 } | 75 } |
81 }; | 76 }; |
82 | 77 |
83 IN_PROC_BROWSER_TEST_F(SavableResourcesTest, | 78 IN_PROC_BROWSER_TEST_F(SavableResourcesTest, |
84 GetSavableResourceLinksWithPageHasValidStyleLink) { | 79 GetSavableResourceLinksWithPageHasValidStyleLink) { |
85 base::FilePath page_file_path = | 80 base::FilePath page_file_path = |
86 GetTestFilePath("dom_serializer", "simple_linked_stylesheet.html"); | 81 GetTestFilePath("dom_serializer", "simple_linked_stylesheet.html"); |
87 | 82 |
88 auto expected_subresources_matcher = testing::UnorderedElementsAre( | 83 auto expected_subresources_matcher = testing::UnorderedElementsAre( |
(...skipping 22 matching lines...) Expand all Loading... |
111 IN_PROC_BROWSER_TEST_F(SavableResourcesTest, | 106 IN_PROC_BROWSER_TEST_F(SavableResourcesTest, |
112 GetSavableResourceLinksWithPageHasInvalidLinks) { | 107 GetSavableResourceLinksWithPageHasInvalidLinks) { |
113 base::FilePath page_file_path = | 108 base::FilePath page_file_path = |
114 GetTestFilePath("dom_serializer", "youtube_2.htm"); | 109 GetTestFilePath("dom_serializer", "youtube_2.htm"); |
115 | 110 |
116 auto expected_subresources_matcher = testing::IsEmpty(); | 111 auto expected_subresources_matcher = testing::IsEmpty(); |
117 GetSavableResourceLinksForPage(page_file_path, expected_subresources_matcher); | 112 GetSavableResourceLinksForPage(page_file_path, expected_subresources_matcher); |
118 } | 113 } |
119 | 114 |
120 } // namespace content | 115 } // namespace content |
OLD | NEW |