| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 52         shell()->web_contents()->GetMainFrame()->GetRoutingID())); | 52         shell()->web_contents()->GetMainFrame()->GetRoutingID())); | 
| 53   } | 53   } | 
| 54 | 54 | 
| 55   void CheckResources(const base::FilePath& page_file_path, | 55   void CheckResources(const base::FilePath& page_file_path, | 
| 56                       const UrlVectorMatcher& expected_resources_matcher, | 56                       const UrlVectorMatcher& expected_resources_matcher, | 
| 57                       const UrlVectorMatcher& expected_subframe_urls_matcher, | 57                       const UrlVectorMatcher& expected_subframe_urls_matcher, | 
| 58                       const GURL& file_url, | 58                       const GURL& file_url, | 
| 59                       int render_frame_routing_id) { | 59                       int render_frame_routing_id) { | 
| 60     // Get all savable resource links for the page. | 60     // Get all savable resource links for the page. | 
| 61     std::vector<GURL> resources_list; | 61     std::vector<GURL> resources_list; | 
| 62     std::vector<GURL> subframe_original_urls; | 62     std::vector<SavableSubframe> subframes; | 
| 63     std::vector<blink::WebFrame*> subframes; | 63     SavableResourcesResult result(&resources_list, &subframes); | 
| 64     SavableResourcesResult result(&resources_list, |  | 
| 65                                   &subframe_original_urls, &subframes); |  | 
| 66 | 64 | 
| 67     const char* savable_schemes[] = { | 65     const char* savable_schemes[] = { | 
| 68       "http", | 66       "http", | 
| 69       "https", | 67       "https", | 
| 70       "file", | 68       "file", | 
| 71       NULL | 69       NULL | 
| 72     }; | 70     }; | 
| 73 | 71 | 
| 74     RenderFrame* render_frame = | 72     RenderFrame* render_frame = | 
| 75         RenderFrame::FromRoutingID(render_frame_routing_id); | 73         RenderFrame::FromRoutingID(render_frame_routing_id); | 
| 76 | 74 | 
| 77     ASSERT_TRUE(GetSavableResourceLinksForFrame( | 75     ASSERT_TRUE(GetSavableResourceLinksForFrame( | 
| 78         render_frame->GetWebFrame(), | 76         render_frame->GetWebFrame(), | 
| 79         &result, savable_schemes)); | 77         &result, savable_schemes)); | 
| 80 | 78 | 
| 81     EXPECT_THAT(resources_list, expected_resources_matcher); | 79     EXPECT_THAT(resources_list, expected_resources_matcher); | 
| 82 | 80 | 
| 83     EXPECT_EQ(subframe_original_urls.size(), subframes.size()); | 81     std::vector<GURL> subframe_original_urls; | 
|  | 82     for (const SavableSubframe& subframe : subframes) { | 
|  | 83       subframe_original_urls.push_back(subframe.original_url); | 
|  | 84     } | 
| 84     EXPECT_THAT(subframe_original_urls, expected_subframe_urls_matcher); | 85     EXPECT_THAT(subframe_original_urls, expected_subframe_urls_matcher); | 
| 85     EXPECT_THAT(subframes, testing::Each(testing::NotNull())); |  | 
| 86   } | 86   } | 
| 87 }; | 87 }; | 
| 88 | 88 | 
| 89 IN_PROC_BROWSER_TEST_F(SavableResourcesTest, | 89 IN_PROC_BROWSER_TEST_F(SavableResourcesTest, | 
| 90                        GetSavableResourceLinksWithPageHasValidStyleLink) { | 90                        GetSavableResourceLinksWithPageHasValidStyleLink) { | 
| 91   base::FilePath page_file_path = | 91   base::FilePath page_file_path = | 
| 92       GetTestFilePath("dom_serializer", "simple_linked_stylesheet.html"); | 92       GetTestFilePath("dom_serializer", "simple_linked_stylesheet.html"); | 
| 93 | 93 | 
| 94   auto expected_subresources_matcher = testing::UnorderedElementsAre( | 94   auto expected_subresources_matcher = testing::UnorderedElementsAre( | 
| 95       net::FilePathToFileURL(GetTestFilePath("dom_serializer", "style.css"))); | 95       net::FilePathToFileURL(GetTestFilePath("dom_serializer", "style.css"))); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 129 | 129 | 
| 130   auto expected_subresources_matcher = testing::IsEmpty(); | 130   auto expected_subresources_matcher = testing::IsEmpty(); | 
| 131 | 131 | 
| 132   auto expected_subframe_urls_matcher = testing::IsEmpty(); | 132   auto expected_subframe_urls_matcher = testing::IsEmpty(); | 
| 133 | 133 | 
| 134   GetSavableResourceLinksForPage(page_file_path, expected_subresources_matcher, | 134   GetSavableResourceLinksForPage(page_file_path, expected_subresources_matcher, | 
| 135                                  expected_subframe_urls_matcher); | 135                                  expected_subframe_urls_matcher); | 
| 136 } | 136 } | 
| 137 | 137 | 
| 138 }  // namespace content | 138 }  // namespace content | 
| OLD | NEW | 
|---|