| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stringprintf.h" | 5 #include "base/stringprintf.h" |
| 6 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 6 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
| 7 #include "chrome/renderer/safe_browsing/malware_dom_details.h" | 7 #include "chrome/renderer/safe_browsing/malware_dom_details.h" |
| 8 #include "chrome/test/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
| 9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 EXPECT_EQ(GURL(), params[3].parent); | 90 EXPECT_EQ(GURL(), params[3].parent); |
| 91 EXPECT_EQ(1u, params[3].children.size()); | 91 EXPECT_EQ(1u, params[3].children.size()); |
| 92 EXPECT_EQ(iframe2_url, params[3].children[0]); | 92 EXPECT_EQ(iframe2_url, params[3].children[0]); |
| 93 | 93 |
| 94 EXPECT_EQ(iframe2_url, params[4].url); | 94 EXPECT_EQ(iframe2_url, params[4].url); |
| 95 EXPECT_EQ(GURL(), params[4].parent); | 95 EXPECT_EQ(GURL(), params[4].parent); |
| 96 EXPECT_EQ(0u, params[4].children.size()); | 96 EXPECT_EQ(0u, params[4].children.size()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 { // >50 subframes, to verify kMaxNodes. | 99 { // >50 subframes, to verify kMaxNodes. |
| 100 std::string html = ""; | 100 std::string html; |
| 101 for (int i = 0; i < 55; ++i) { | 101 for (int i = 0; i < 55; ++i) { |
| 102 // The iframe contents is just a number. | 102 // The iframe contents is just a number. |
| 103 GURL iframe_url(base::StringPrintf("%s%d", urlprefix, i)); | 103 GURL iframe_url(base::StringPrintf("%s%d", urlprefix, i)); |
| 104 html += "<iframe src=\"" + net::EscapeForHTML(iframe_url.spec()) + | 104 html += "<iframe src=\"" + net::EscapeForHTML(iframe_url.spec()) + |
| 105 "\"></iframe>"; | 105 "\"></iframe>"; |
| 106 } | 106 } |
| 107 GURL url(urlprefix + html); | 107 GURL url(urlprefix + html); |
| 108 | 108 |
| 109 LoadHTML(html.c_str()); | 109 LoadHTML(html.c_str()); |
| 110 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; | 110 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; |
| 111 details->ExtractResources(¶ms); | 111 details->ExtractResources(¶ms); |
| 112 ASSERT_EQ(51u, params.size()); | 112 ASSERT_EQ(51u, params.size()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 { // A page with >50 scripts, to verify kMaxNodes. | 115 { // A page with >50 scripts, to verify kMaxNodes. |
| 116 std::string html = ""; | 116 std::string html; |
| 117 for (int i = 0; i < 55; ++i) { | 117 for (int i = 0; i < 55; ++i) { |
| 118 // The iframe contents is just a number. | 118 // The iframe contents is just a number. |
| 119 GURL script_url(base::StringPrintf("%s%d", urlprefix, i)); | 119 GURL script_url(base::StringPrintf("%s%d", urlprefix, i)); |
| 120 html += "<script src=\"" + net::EscapeForHTML(script_url.spec()) + | 120 html += "<script src=\"" + net::EscapeForHTML(script_url.spec()) + |
| 121 "\"></script>"; | 121 "\"></script>"; |
| 122 } | 122 } |
| 123 GURL url(urlprefix + html); | 123 GURL url(urlprefix + html); |
| 124 | 124 |
| 125 LoadHTML(html.c_str()); | 125 LoadHTML(html.c_str()); |
| 126 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; | 126 std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node> params; |
| 127 details->ExtractResources(¶ms); | 127 details->ExtractResources(¶ms); |
| 128 ASSERT_EQ(51u, params.size()); | 128 ASSERT_EQ(51u, params.size()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } | 131 } |
| OLD | NEW |