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 <deque> | 5 #include <deque> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 "window.domAutomationController.send(" | 1291 "window.domAutomationController.send(" |
1292 "receivedPrerenderLoadEvents[%d] || 0)", index); | 1292 "receivedPrerenderLoadEvents[%d] || 0)", index); |
1293 | 1293 |
1294 CHECK(content::ExecuteScriptAndExtractInt( | 1294 CHECK(content::ExecuteScriptAndExtractInt( |
1295 GetActiveWebContents(), | 1295 GetActiveWebContents(), |
1296 expression, | 1296 expression, |
1297 &load_event_count)); | 1297 &load_event_count)); |
1298 return load_event_count; | 1298 return load_event_count; |
1299 } | 1299 } |
1300 | 1300 |
| 1301 int GetPrerenderDomContentLoadedEventCountForLinkNumber(int index) const { |
| 1302 int dom_content_loaded_event_count; |
| 1303 std::string expression = base::StringPrintf( |
| 1304 "window.domAutomationController.send(" |
| 1305 "receivedPrerenderDomContentLoadedEvents[%d] || 0)", index); |
| 1306 |
| 1307 CHECK(content::ExecuteScriptAndExtractInt( |
| 1308 GetActiveWebContents(), |
| 1309 expression, |
| 1310 &dom_content_loaded_event_count)); |
| 1311 return dom_content_loaded_event_count; |
| 1312 } |
| 1313 |
1301 bool DidReceivePrerenderStopEventForLinkNumber(int index) const { | 1314 bool DidReceivePrerenderStopEventForLinkNumber(int index) const { |
1302 bool received_prerender_stopped; | 1315 bool received_prerender_stopped; |
1303 std::string expression = base::StringPrintf( | 1316 std::string expression = base::StringPrintf( |
1304 "window.domAutomationController.send(Boolean(" | 1317 "window.domAutomationController.send(Boolean(" |
1305 "receivedPrerenderStopEvents[%d]))", index); | 1318 "receivedPrerenderStopEvents[%d]))", index); |
1306 | 1319 |
1307 CHECK(content::ExecuteScriptAndExtractBool( | 1320 CHECK(content::ExecuteScriptAndExtractBool( |
1308 GetActiveWebContents(), | 1321 GetActiveWebContents(), |
1309 expression, | 1322 expression, |
1310 &received_prerender_stopped)); | 1323 &received_prerender_stopped)); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1516 // Check if page behaves as expected while in prerendered state. | 1529 // Check if page behaves as expected while in prerendered state. |
1517 EXPECT_TRUE(DidPrerenderPass(prerender_contents->prerender_contents())); | 1530 EXPECT_TRUE(DidPrerenderPass(prerender_contents->prerender_contents())); |
1518 } | 1531 } |
1519 } | 1532 } |
1520 | 1533 |
1521 // Test that the referring page received the right start and load events. | 1534 // Test that the referring page received the right start and load events. |
1522 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); | 1535 EXPECT_TRUE(DidReceivePrerenderStartEventForLinkNumber(0)); |
1523 if (check_load_events_) { | 1536 if (check_load_events_) { |
1524 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads()); | 1537 EXPECT_EQ(expected_number_of_loads, prerenders[0]->number_of_loads()); |
1525 EXPECT_EQ(expected_number_of_loads, | 1538 EXPECT_EQ(expected_number_of_loads, |
| 1539 GetPrerenderDomContentLoadedEventCountForLinkNumber(0)); |
| 1540 EXPECT_EQ(expected_number_of_loads, |
1526 GetPrerenderLoadEventCountForLinkNumber(0)); | 1541 GetPrerenderLoadEventCountForLinkNumber(0)); |
1527 } | 1542 } |
1528 EXPECT_FALSE(HadPrerenderEventErrors()); | 1543 EXPECT_FALSE(HadPrerenderEventErrors()); |
1529 | 1544 |
1530 return prerenders.Pass(); | 1545 return prerenders.Pass(); |
1531 } | 1546 } |
1532 | 1547 |
1533 void NavigateToURLImpl(const content::OpenURLParams& params, | 1548 void NavigateToURLImpl(const content::OpenURLParams& params, |
1534 bool expect_swap_to_succeed) const { | 1549 bool expect_swap_to_succeed) const { |
1535 ASSERT_NE(static_cast<PrerenderManager*>(NULL), GetPrerenderManager()); | 1550 ASSERT_NE(static_cast<PrerenderManager*>(NULL), GetPrerenderManager()); |
(...skipping 2505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4041 } | 4056 } |
4042 }; | 4057 }; |
4043 | 4058 |
4044 // Checks that prerendering works in incognito mode. | 4059 // Checks that prerendering works in incognito mode. |
4045 IN_PROC_BROWSER_TEST_F(PrerenderIncognitoBrowserTest, PrerenderIncognito) { | 4060 IN_PROC_BROWSER_TEST_F(PrerenderIncognitoBrowserTest, PrerenderIncognito) { |
4046 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 4061 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
4047 NavigateToDestURL(); | 4062 NavigateToDestURL(); |
4048 } | 4063 } |
4049 | 4064 |
4050 } // namespace prerender | 4065 } // namespace prerender |
OLD | NEW |