Unwind the URL-based experiment IDs.
[chromium-blink-merge.git] / chrome / browser / prerender / prerender_unittest.cc
blobb0e37e182de8431554911cabb55cf3eb587d80b6
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
3 // found in the LICENSE file.
5 #include <map>
6 #include <utility>
8 #include "base/command_line.h"
9 #include "base/format_macros.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/metrics/field_trial.h"
13 #include "base/prefs/pref_service.h"
14 #include "base/strings/stringprintf.h"
15 #include "base/time/time.h"
16 #include "chrome/browser/net/prediction_options.h"
17 #include "chrome/browser/prerender/prerender_contents.h"
18 #include "chrome/browser/prerender/prerender_field_trial.h"
19 #include "chrome/browser/prerender/prerender_handle.h"
20 #include "chrome/browser/prerender/prerender_link_manager.h"
21 #include "chrome/browser/prerender/prerender_manager.h"
22 #include "chrome/browser/prerender/prerender_origin.h"
23 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/pref_names.h"
25 #include "chrome/common/prerender_types.h"
26 #include "chrome/test/base/testing_browser_process.h"
27 #include "chrome/test/base/testing_profile.h"
28 #include "content/public/browser/render_view_host.h"
29 #include "content/public/test/test_browser_thread.h"
30 #include "testing/gtest/include/gtest/gtest.h"
31 #include "ui/gfx/geometry/size.h"
32 #include "url/gurl.h"
34 using base::Time;
35 using base::TimeDelta;
36 using base::TimeTicks;
37 using content::BrowserThread;
38 using content::Referrer;
40 namespace prerender {
42 class UnitTestPrerenderManager;
44 namespace {
46 class DummyPrerenderContents : public PrerenderContents {
47 public:
48 DummyPrerenderContents(UnitTestPrerenderManager* test_prerender_manager,
49 const GURL& url,
50 Origin origin,
51 FinalStatus expected_final_status);
53 ~DummyPrerenderContents() override;
55 void StartPrerendering(
56 const gfx::Size& size,
57 content::SessionStorageNamespace* session_storage_namespace) override;
59 bool GetChildId(int* child_id) const override {
60 // Having a default child_id of -1 forces pending prerenders not to fail
61 // on session storage and cross domain checking.
62 *child_id = -1;
63 return true;
66 bool GetRouteId(int* route_id) const override {
67 *route_id = route_id_;
68 return true;
71 FinalStatus expected_final_status() const { return expected_final_status_; }
73 bool prerendering_has_been_cancelled() const {
74 return PrerenderContents::prerendering_has_been_cancelled();
77 private:
78 static int g_next_route_id_;
79 int route_id_;
81 UnitTestPrerenderManager* test_prerender_manager_;
82 FinalStatus expected_final_status_;
85 int DummyPrerenderContents::g_next_route_id_ = 0;
87 const gfx::Size kSize(640, 480);
89 const uint32 kDefaultRelTypes = PrerenderRelTypePrerender;
91 } // namespace
93 class UnitTestPrerenderManager : public PrerenderManager {
94 public:
95 using PrerenderManager::kMinTimeBetweenPrerendersMs;
96 using PrerenderManager::kNavigationRecordWindowMs;
98 explicit UnitTestPrerenderManager(Profile* profile)
99 : PrerenderManager(profile),
100 time_(Time::Now()),
101 time_ticks_(TimeTicks::Now()) {
102 set_rate_limit_enabled(false);
105 ~UnitTestPrerenderManager() override {}
107 // From KeyedService, via PrererenderManager:
108 void Shutdown() override {
109 if (next_prerender_contents())
110 next_prerender_contents_->Destroy(FINAL_STATUS_MANAGER_SHUTDOWN);
111 PrerenderManager::Shutdown();
114 // From PrerenderManager:
115 void MoveEntryToPendingDelete(PrerenderContents* entry,
116 FinalStatus final_status) override {
117 if (entry == next_prerender_contents_.get())
118 return;
119 PrerenderManager::MoveEntryToPendingDelete(entry, final_status);
122 PrerenderContents* FindEntry(const GURL& url) {
123 DeleteOldEntries();
124 to_delete_prerenders_.clear();
125 if (PrerenderData* data = FindPrerenderData(url, NULL))
126 return data->contents();
127 return NULL;
130 PrerenderContents* FindAndUseEntry(const GURL& url) {
131 PrerenderData* prerender_data = FindPrerenderData(url, NULL);
132 if (!prerender_data)
133 return NULL;
134 ScopedVector<PrerenderData>::iterator to_erase =
135 FindIteratorForPrerenderContents(prerender_data->contents());
136 CHECK(to_erase != active_prerenders_.end());
137 PrerenderContents* prerender_contents = prerender_data->ReleaseContents();
138 active_prerenders_.erase(to_erase);
140 prerender_contents->PrepareForUse();
141 return prerender_contents;
144 void AdvanceTime(TimeDelta delta) {
145 time_ += delta;
148 void AdvanceTimeTicks(TimeDelta delta) {
149 time_ticks_ += delta;
152 DummyPrerenderContents* CreateNextPrerenderContents(
153 const GURL& url,
154 FinalStatus expected_final_status) {
155 DummyPrerenderContents* prerender_contents =
156 new DummyPrerenderContents(this, url,
157 ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN,
158 expected_final_status);
159 SetNextPrerenderContents(prerender_contents);
160 return prerender_contents;
163 DummyPrerenderContents* CreateNextPrerenderContents(
164 const GURL& url,
165 Origin origin,
166 FinalStatus expected_final_status) {
167 DummyPrerenderContents* prerender_contents =
168 new DummyPrerenderContents(this, url, origin, expected_final_status);
169 SetNextPrerenderContents(prerender_contents);
170 return prerender_contents;
173 DummyPrerenderContents* CreateNextPrerenderContents(
174 const GURL& url,
175 const std::vector<GURL>& alias_urls,
176 FinalStatus expected_final_status) {
177 DummyPrerenderContents* prerender_contents =
178 new DummyPrerenderContents(this, url,
179 ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN,
180 expected_final_status);
181 for (std::vector<GURL>::const_iterator it = alias_urls.begin();
182 it != alias_urls.end();
183 ++it) {
184 EXPECT_TRUE(prerender_contents->AddAliasURL(*it));
186 SetNextPrerenderContents(prerender_contents);
187 return prerender_contents;
190 void set_rate_limit_enabled(bool enabled) {
191 mutable_config().rate_limit_enabled = enabled;
194 PrerenderContents* next_prerender_contents() {
195 return next_prerender_contents_.get();
198 // from PrerenderManager
199 Time GetCurrentTime() const override { return time_; }
201 TimeTicks GetCurrentTimeTicks() const override { return time_ticks_; }
203 PrerenderContents* GetPrerenderContentsForRoute(int child_id,
204 int route_id) const override {
205 // Overridden for the PrerenderLinkManager's pending prerender logic.
206 PrerenderContentsMap::const_iterator iter = prerender_contents_map_.find(
207 std::make_pair(child_id, route_id));
208 if (iter == prerender_contents_map_.end())
209 return NULL;
210 return iter->second;
213 void DummyPrerenderContentsStarted(int child_id,
214 int route_id,
215 PrerenderContents* prerender_contents) {
216 prerender_contents_map_[std::make_pair(child_id, route_id)] =
217 prerender_contents;
220 void DummyPrerenderContentsDestroyed(int child_id,
221 int route_id) {
222 prerender_contents_map_.erase(std::make_pair(child_id, route_id));
225 private:
226 void SetNextPrerenderContents(DummyPrerenderContents* prerender_contents) {
227 CHECK(!next_prerender_contents_.get());
228 next_prerender_contents_.reset(prerender_contents);
229 if (prerender_contents->expected_final_status() == FINAL_STATUS_USED)
230 used_prerender_contents_.push_back(prerender_contents);
233 PrerenderContents* CreatePrerenderContents(const GURL& url,
234 const Referrer& referrer,
235 Origin origin) override {
236 CHECK(next_prerender_contents_.get());
237 EXPECT_EQ(url, next_prerender_contents_->prerender_url());
238 EXPECT_EQ(origin, next_prerender_contents_->origin());
239 return next_prerender_contents_.release();
242 // Maintain a map from route pairs to PrerenderContents for
243 // GetPrerenderContentsForRoute.
244 typedef std::map<std::pair<int,int>, PrerenderContents*> PrerenderContentsMap;
245 PrerenderContentsMap prerender_contents_map_;
247 Time time_;
248 TimeTicks time_ticks_;
249 scoped_ptr<PrerenderContents> next_prerender_contents_;
250 // PrerenderContents with an |expected_final_status| of FINAL_STATUS_USED,
251 // tracked so they will be automatically deleted.
252 ScopedVector<PrerenderContents> used_prerender_contents_;
255 class RestorePrerenderMode {
256 public:
257 RestorePrerenderMode() : prev_mode_(PrerenderManager::GetMode()) {
260 ~RestorePrerenderMode() { PrerenderManager::SetMode(prev_mode_); }
261 private:
262 PrerenderManager::PrerenderManagerMode prev_mode_;
265 DummyPrerenderContents::DummyPrerenderContents(
266 UnitTestPrerenderManager* test_prerender_manager,
267 const GURL& url,
268 Origin origin,
269 FinalStatus expected_final_status)
270 : PrerenderContents(test_prerender_manager,
271 NULL, url, Referrer(), origin),
272 route_id_(g_next_route_id_++),
273 test_prerender_manager_(test_prerender_manager),
274 expected_final_status_(expected_final_status) {
277 DummyPrerenderContents::~DummyPrerenderContents() {
278 EXPECT_EQ(expected_final_status_, final_status());
279 test_prerender_manager_->DummyPrerenderContentsDestroyed(-1, route_id_);
282 void DummyPrerenderContents::StartPrerendering(
283 const gfx::Size& size,
284 content::SessionStorageNamespace* session_storage_namespace) {
285 // In the base PrerenderContents implementation, StartPrerendering will
286 // be called even when the PrerenderManager is part of the control group,
287 // but it will early exit before actually creating a new RenderView if
288 // |is_control_group| is true;
289 load_start_time_ = test_prerender_manager_->GetCurrentTimeTicks();
290 if (!test_prerender_manager_->IsControlGroup()) {
291 prerendering_has_started_ = true;
292 test_prerender_manager_->DummyPrerenderContentsStarted(-1, route_id_, this);
293 NotifyPrerenderStart();
297 class PrerenderTest : public testing::Test {
298 public:
299 static const int kDefaultChildId = -1;
300 static const int kDefaultRenderViewRouteId = -1;
302 PrerenderTest() : ui_thread_(BrowserThread::UI, &message_loop_),
303 prerender_manager_(new UnitTestPrerenderManager(&profile_)),
304 prerender_link_manager_(
305 new PrerenderLinkManager(prerender_manager_.get())),
306 last_prerender_id_(0),
307 field_trial_list_(NULL) {
308 // Enable omnibox prerendering.
309 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
310 switches::kPrerenderFromOmnibox,
311 switches::kPrerenderFromOmniboxSwitchValueEnabled);
314 ~PrerenderTest() override {
315 prerender_link_manager_->OnChannelClosing(kDefaultChildId);
316 prerender_link_manager_->Shutdown();
317 prerender_manager_->Shutdown();
320 UnitTestPrerenderManager* prerender_manager() {
321 return prerender_manager_.get();
324 PrerenderLinkManager* prerender_link_manager() {
325 return prerender_link_manager_.get();
328 void SetConcurrency(size_t concurrency) {
329 prerender_manager()->mutable_config().max_link_concurrency_per_launcher =
330 concurrency;
331 prerender_manager()->mutable_config().max_link_concurrency =
332 std::max(prerender_manager()->mutable_config().max_link_concurrency,
333 concurrency);
336 bool IsEmptyPrerenderLinkManager() const {
337 return prerender_link_manager_->IsEmpty();
340 int last_prerender_id() const {
341 return last_prerender_id_;
344 int GetNextPrerenderID() {
345 return ++last_prerender_id_;
348 bool LauncherHasRunningPrerender(int child_id, int prerender_id) {
349 PrerenderLinkManager::LinkPrerender* prerender =
350 prerender_link_manager()->FindByLauncherChildIdAndPrerenderId(
351 child_id, prerender_id);
352 return prerender && prerender->handle;
355 bool LauncherHasScheduledPrerender(int child_id, int prerender_id) {
356 PrerenderLinkManager::LinkPrerender* prerender =
357 prerender_link_manager()->FindByLauncherChildIdAndPrerenderId(
358 child_id, prerender_id);
359 return prerender != NULL;
362 // Shorthand to add a simple prerender with a reasonable source. Returns
363 // true iff the prerender has been added to the PrerenderManager by the
364 // PrerenderLinkManager and the PrerenderManager returned a handle.
365 bool AddSimplePrerender(const GURL& url) {
366 prerender_link_manager()->OnAddPrerender(
367 kDefaultChildId, GetNextPrerenderID(), url, kDefaultRelTypes,
368 content::Referrer(), kSize, kDefaultRenderViewRouteId);
369 return LauncherHasRunningPrerender(kDefaultChildId, last_prerender_id());
372 void DisablePrerender() {
373 profile_.GetPrefs()->SetInteger(
374 prefs::kNetworkPredictionOptions,
375 chrome_browser_net::NETWORK_PREDICTION_NEVER);
378 private:
379 // Needed to pass PrerenderManager's DCHECKs.
380 TestingProfile profile_;
381 base::MessageLoop message_loop_;
382 content::TestBrowserThread ui_thread_;
383 scoped_ptr<UnitTestPrerenderManager> prerender_manager_;
384 scoped_ptr<PrerenderLinkManager> prerender_link_manager_;
385 int last_prerender_id_;
386 base::FieldTrialList field_trial_list_;
389 TEST_F(PrerenderTest, PrerenderRespectsDisableFlag) {
390 RestorePrerenderMode restore_prerender_mode;
391 ASSERT_TRUE(PrerenderManager::IsPrerenderingPossible());
392 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
393 command_line->AppendSwitchASCII(
394 switches::kPrerenderMode,
395 switches::kPrerenderModeSwitchValueDisabled);
396 prerender::ConfigurePrerender(*command_line);
397 ASSERT_FALSE(PrerenderManager::IsPrerenderingPossible());
400 TEST_F(PrerenderTest, FoundTest) {
401 GURL url("http://www.google.com/");
402 DummyPrerenderContents* prerender_contents =
403 prerender_manager()->CreateNextPrerenderContents(
404 url,
405 FINAL_STATUS_USED);
406 EXPECT_TRUE(AddSimplePrerender(url));
407 EXPECT_TRUE(prerender_contents->prerendering_has_started());
408 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
411 // Make sure that if queue a request, and a second prerender request for the
412 // same URL comes in, that the second request attaches to the first prerender,
413 // and we don't use the second prerender contents.
414 TEST_F(PrerenderTest, DuplicateTest) {
415 SetConcurrency(2);
416 GURL url("http://www.google.com/");
417 DummyPrerenderContents* prerender_contents =
418 prerender_manager()->CreateNextPrerenderContents(
419 url,
420 FINAL_STATUS_USED);
421 DummyPrerenderContents* null = NULL;
422 EXPECT_TRUE(AddSimplePrerender(url));
423 EXPECT_EQ(null, prerender_manager()->next_prerender_contents());
424 EXPECT_TRUE(prerender_contents->prerendering_has_started());
426 DummyPrerenderContents* prerender_contents1 =
427 prerender_manager()->CreateNextPrerenderContents(
428 url,
429 FINAL_STATUS_MANAGER_SHUTDOWN);
430 EXPECT_TRUE(AddSimplePrerender(url));
431 EXPECT_EQ(prerender_contents1,
432 prerender_manager()->next_prerender_contents());
433 EXPECT_FALSE(prerender_contents1->prerendering_has_started());
435 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
438 // Ensure that we expire a prerendered page after the max. permitted time.
439 TEST_F(PrerenderTest, ExpireTest) {
440 GURL url("http://www.google.com/");
441 DummyPrerenderContents* prerender_contents =
442 prerender_manager()->CreateNextPrerenderContents(
443 url,
444 FINAL_STATUS_TIMED_OUT);
445 DummyPrerenderContents* null = NULL;
446 EXPECT_TRUE(AddSimplePrerender(url));
447 EXPECT_EQ(null, prerender_manager()->next_prerender_contents());
448 EXPECT_TRUE(prerender_contents->prerendering_has_started());
449 prerender_manager()->AdvanceTimeTicks(
450 prerender_manager()->config().time_to_live + TimeDelta::FromSeconds(1));
451 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
454 // Ensure that we don't launch prerenders of bad urls (in this case, a mailto:
455 // url)
456 TEST_F(PrerenderTest, BadURLTest) {
457 GURL url("mailto:test@gmail.com");
458 DummyPrerenderContents* prerender_contents =
459 prerender_manager()->CreateNextPrerenderContents(
460 url,
461 FINAL_STATUS_UNSUPPORTED_SCHEME);
462 EXPECT_FALSE(AddSimplePrerender(url));
463 EXPECT_FALSE(prerender_contents->prerendering_has_started());
464 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
465 DummyPrerenderContents* null = NULL;
466 EXPECT_EQ(null, prerender_manager()->FindEntry(url));
469 // When the user navigates away from a page, the prerenders it launched should
470 // have their time to expiry shortened from the default time to live.
471 TEST_F(PrerenderTest, LinkManagerNavigateAwayExpire) {
472 const TimeDelta time_to_live = TimeDelta::FromSeconds(300);
473 const TimeDelta abandon_time_to_live = TimeDelta::FromSeconds(20);
474 const TimeDelta test_advance = TimeDelta::FromSeconds(22);
475 ASSERT_LT(test_advance, time_to_live);
476 ASSERT_LT(abandon_time_to_live, test_advance);
478 prerender_manager()->mutable_config().time_to_live = time_to_live;
479 prerender_manager()->mutable_config().abandon_time_to_live =
480 abandon_time_to_live;
482 GURL url("http://example.com");
483 DummyPrerenderContents* prerender_contents =
484 prerender_manager()->CreateNextPrerenderContents(url,
485 FINAL_STATUS_TIMED_OUT);
486 EXPECT_TRUE(AddSimplePrerender(url));
487 EXPECT_TRUE(prerender_contents->prerendering_has_started());
488 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
489 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
490 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
491 last_prerender_id());
492 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
493 DummyPrerenderContents* null = NULL;
494 EXPECT_EQ(null, prerender_manager()->next_prerender_contents());
495 prerender_manager()->AdvanceTimeTicks(test_advance);
497 EXPECT_EQ(null, prerender_manager()->FindEntry(url));
500 // But when we navigate away very close to the original expiry of a prerender,
501 // we shouldn't expect it to be extended.
502 TEST_F(PrerenderTest, LinkManagerNavigateAwayNearExpiry) {
503 const TimeDelta time_to_live = TimeDelta::FromSeconds(300);
504 const TimeDelta abandon_time_to_live = TimeDelta::FromSeconds(20);
506 // We will expect the prerender to still be alive after advancing the clock
507 // by first_advance. But, after second_advance, we expect it to have timed
508 // out, demonstrating that you can't extend a prerender by navigating away
509 // from its launcher.
510 const TimeDelta first_advance = TimeDelta::FromSeconds(298);
511 const TimeDelta second_advance = TimeDelta::FromSeconds(4);
512 ASSERT_LT(first_advance, time_to_live);
513 ASSERT_LT(time_to_live - first_advance, abandon_time_to_live);
514 ASSERT_LT(time_to_live, first_advance + second_advance);
516 prerender_manager()->mutable_config().time_to_live = time_to_live;
517 prerender_manager()->mutable_config().abandon_time_to_live =
518 abandon_time_to_live;
520 GURL url("http://example2.com");
521 DummyPrerenderContents* prerender_contents =
522 prerender_manager()->CreateNextPrerenderContents(url,
523 FINAL_STATUS_TIMED_OUT);
524 EXPECT_TRUE(AddSimplePrerender(url));
525 EXPECT_TRUE(prerender_contents->prerendering_has_started());
526 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
527 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
529 prerender_manager()->AdvanceTimeTicks(first_advance);
530 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
532 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
533 last_prerender_id());
534 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
536 DummyPrerenderContents* null = NULL;
537 EXPECT_EQ(null, prerender_manager()->next_prerender_contents());
539 prerender_manager()->AdvanceTimeTicks(second_advance);
540 EXPECT_EQ(null, prerender_manager()->FindEntry(url));
543 // When the user navigates away from a page, and then launches a new prerender,
544 // the new prerender should preempt the abandoned prerender even if the
545 // abandoned prerender hasn't expired.
546 TEST_F(PrerenderTest, LinkManagerNavigateAwayLaunchAnother) {
547 const TimeDelta time_to_live = TimeDelta::FromSeconds(300);
548 const TimeDelta abandon_time_to_live = TimeDelta::FromSeconds(20);
549 const TimeDelta test_advance = TimeDelta::FromSeconds(5);
550 ASSERT_LT(test_advance, time_to_live);
551 ASSERT_GT(abandon_time_to_live, test_advance);
553 prerender_manager()->mutable_config().time_to_live = time_to_live;
554 prerender_manager()->mutable_config().abandon_time_to_live =
555 abandon_time_to_live;
557 GURL url("http://example.com");
558 prerender_manager()->CreateNextPrerenderContents(url, FINAL_STATUS_CANCELLED);
559 EXPECT_TRUE(AddSimplePrerender(url));
560 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
561 last_prerender_id());
563 prerender_manager()->AdvanceTimeTicks(test_advance);
565 GURL second_url("http://example2.com");
566 DummyPrerenderContents* second_prerender_contents =
567 prerender_manager()->CreateNextPrerenderContents(
568 second_url, FINAL_STATUS_MANAGER_SHUTDOWN);
569 EXPECT_TRUE(AddSimplePrerender(second_url));
570 EXPECT_EQ(second_prerender_contents,
571 prerender_manager()->FindEntry(second_url));
575 // Make sure that if we prerender more requests than we support, that we launch
576 // them in the order given up until we reach MaxConcurrency, at which point we
577 // queue them and launch them in the order given. As well, insure that limits
578 // are enforced for the system as a whole and on a per launcher basis.
579 TEST_F(PrerenderTest, MaxConcurrencyTest) {
580 struct TestConcurrency {
581 size_t max_link_concurrency;
582 size_t max_link_concurrency_per_launcher;
585 TestConcurrency concurrencies_to_test[] = {
586 { prerender_manager()->config().max_link_concurrency,
587 prerender_manager()->config().max_link_concurrency_per_launcher},
589 // With the system limit higher than the per launcher limit, the per
590 // launcher limit should be in effect.
591 { 2, 1 },
593 // With the per launcher limit higher than system limit, the system limit
594 // should be in effect.
595 { 2, 4 },
598 DummyPrerenderContents* null = NULL;
599 GURL url_to_delay("http://www.google.com/delayme");
601 for (size_t i = 0; i < arraysize(concurrencies_to_test); ++i) {
602 prerender_manager()->mutable_config().max_link_concurrency =
603 concurrencies_to_test[i].max_link_concurrency;
604 prerender_manager()->mutable_config().max_link_concurrency_per_launcher =
605 concurrencies_to_test[i].max_link_concurrency_per_launcher;
607 const size_t effective_max_link_concurrency =
608 std::min(concurrencies_to_test[i].max_link_concurrency,
609 concurrencies_to_test[i].max_link_concurrency_per_launcher);
611 std::vector<GURL> urls;
612 std::vector<PrerenderContents*> prerender_contentses;
614 // Launch prerenders up to the maximum this launcher can support.
615 for (size_t j = 0; j < effective_max_link_concurrency; ++j) {
616 urls.push_back(
617 GURL(base::StringPrintf("http://google.com/use#%" PRIuS, j)));
618 prerender_contentses.push_back(
619 prerender_manager()->CreateNextPrerenderContents(urls.back(),
620 FINAL_STATUS_USED));
621 EXPECT_TRUE(AddSimplePrerender(urls.back()));
622 EXPECT_EQ(null, prerender_manager()->next_prerender_contents());
623 EXPECT_TRUE(prerender_contentses.back()->prerendering_has_started());
626 if (concurrencies_to_test[i].max_link_concurrency >
627 effective_max_link_concurrency) {
628 // We should be able to launch more prerenders on this system, but not for
629 // the default launcher.
630 GURL extra_url("http://google.com/extraurl");
631 EXPECT_FALSE(AddSimplePrerender(extra_url));
632 const int prerender_id = last_prerender_id();
633 EXPECT_TRUE(LauncherHasScheduledPrerender(kDefaultChildId,
634 prerender_id));
635 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
636 prerender_id);
637 EXPECT_FALSE(LauncherHasScheduledPrerender(kDefaultChildId,
638 prerender_id));
641 DummyPrerenderContents* prerender_contents_to_delay =
642 prerender_manager()->CreateNextPrerenderContents(url_to_delay,
643 FINAL_STATUS_USED);
644 EXPECT_FALSE(AddSimplePrerender(url_to_delay));
645 EXPECT_FALSE(prerender_contents_to_delay->prerendering_has_started());
646 EXPECT_NE(null, prerender_manager()->next_prerender_contents());
647 EXPECT_EQ(null, prerender_manager()->FindEntry(url_to_delay));
648 for (size_t j = 0; j < effective_max_link_concurrency; ++j) {
649 EXPECT_EQ(prerender_contentses[j],
650 prerender_manager()->FindAndUseEntry(urls[j]));
651 EXPECT_TRUE(prerender_contents_to_delay->prerendering_has_started());
654 EXPECT_EQ(prerender_contents_to_delay,
655 prerender_manager()->FindAndUseEntry(url_to_delay));
656 EXPECT_EQ(null, prerender_manager()->next_prerender_contents());
660 TEST_F(PrerenderTest, AliasURLTest) {
661 SetConcurrency(7);
663 GURL url("http://www.google.com/");
664 GURL alias_url1("http://www.google.com/index.html");
665 GURL alias_url2("http://google.com/");
666 GURL not_an_alias_url("http://google.com/index.html");
667 std::vector<GURL> alias_urls;
668 alias_urls.push_back(alias_url1);
669 alias_urls.push_back(alias_url2);
671 // Test that all of the aliases work, but not_an_alias_url does not.
672 DummyPrerenderContents* prerender_contents =
673 prerender_manager()->CreateNextPrerenderContents(
674 url, alias_urls, FINAL_STATUS_USED);
675 EXPECT_TRUE(AddSimplePrerender(url));
676 ASSERT_EQ(NULL, prerender_manager()->FindEntry(not_an_alias_url));
677 ASSERT_EQ(prerender_contents,
678 prerender_manager()->FindAndUseEntry(alias_url1));
679 prerender_contents = prerender_manager()->CreateNextPrerenderContents(
680 url, alias_urls, FINAL_STATUS_USED);
681 EXPECT_TRUE(AddSimplePrerender(url));
682 ASSERT_EQ(prerender_contents,
683 prerender_manager()->FindAndUseEntry(alias_url2));
684 prerender_contents = prerender_manager()->CreateNextPrerenderContents(
685 url, alias_urls, FINAL_STATUS_USED);
686 EXPECT_TRUE(AddSimplePrerender(url));
687 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
689 // Test that alias URLs can not be added.
690 prerender_contents = prerender_manager()->CreateNextPrerenderContents(
691 url, alias_urls, FINAL_STATUS_USED);
692 EXPECT_TRUE(AddSimplePrerender(url));
693 EXPECT_TRUE(AddSimplePrerender(url));
694 EXPECT_TRUE(AddSimplePrerender(alias_url1));
695 EXPECT_TRUE(AddSimplePrerender(alias_url2));
696 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
699 TEST_F(PrerenderTest, PendingPrerenderTest) {
700 GURL url("http://www.google.com/");
701 DummyPrerenderContents* prerender_contents =
702 prerender_manager()->CreateNextPrerenderContents(
703 url,
704 FINAL_STATUS_USED);
705 EXPECT_TRUE(AddSimplePrerender(url));
707 int child_id;
708 int route_id;
709 ASSERT_TRUE(prerender_contents->GetChildId(&child_id));
710 ASSERT_TRUE(prerender_contents->GetRouteId(&route_id));
712 GURL pending_url("http://news.google.com/");
714 // Schedule a pending prerender launched from the prerender.
715 DummyPrerenderContents* pending_prerender_contents =
716 prerender_manager()->CreateNextPrerenderContents(
717 pending_url,
718 ORIGIN_GWS_PRERENDER,
719 FINAL_STATUS_USED);
720 prerender_link_manager()->OnAddPrerender(
721 child_id, GetNextPrerenderID(), pending_url, kDefaultRelTypes,
722 Referrer(url, blink::WebReferrerPolicyDefault),
723 kSize, route_id);
724 EXPECT_FALSE(LauncherHasRunningPrerender(child_id, last_prerender_id()));
725 EXPECT_FALSE(pending_prerender_contents->prerendering_has_started());
727 // Use the referring prerender.
728 EXPECT_TRUE(prerender_contents->prerendering_has_started());
729 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
731 // The pending prerender should start now.
732 EXPECT_TRUE(LauncherHasRunningPrerender(child_id, last_prerender_id()));
733 EXPECT_TRUE(pending_prerender_contents->prerendering_has_started());
734 ASSERT_EQ(pending_prerender_contents,
735 prerender_manager()->FindAndUseEntry(pending_url));
738 TEST_F(PrerenderTest, InvalidPendingPrerenderTest) {
739 GURL url("http://www.google.com/");
740 DummyPrerenderContents* prerender_contents =
741 prerender_manager()->CreateNextPrerenderContents(
742 url,
743 FINAL_STATUS_USED);
744 EXPECT_TRUE(AddSimplePrerender(url));
746 int child_id;
747 int route_id;
748 ASSERT_TRUE(prerender_contents->GetChildId(&child_id));
749 ASSERT_TRUE(prerender_contents->GetRouteId(&route_id));
751 // This pending URL has an unsupported scheme, and won't be able
752 // to start.
753 GURL pending_url("ftp://news.google.com/");
755 // Schedule a pending prerender launched from the prerender.
756 DummyPrerenderContents* pending_prerender_contents =
757 prerender_manager()->CreateNextPrerenderContents(
758 pending_url,
759 ORIGIN_GWS_PRERENDER,
760 FINAL_STATUS_UNSUPPORTED_SCHEME);
761 prerender_link_manager()->OnAddPrerender(
762 child_id, GetNextPrerenderID(), pending_url, kDefaultRelTypes,
763 Referrer(url, blink::WebReferrerPolicyDefault),
764 kSize, route_id);
765 EXPECT_FALSE(LauncherHasRunningPrerender(child_id, last_prerender_id()));
766 EXPECT_FALSE(pending_prerender_contents->prerendering_has_started());
768 // Use the referring prerender.
769 EXPECT_TRUE(prerender_contents->prerendering_has_started());
770 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
772 // The pending prerender still doesn't start.
773 EXPECT_FALSE(LauncherHasRunningPrerender(child_id, last_prerender_id()));
774 EXPECT_FALSE(pending_prerender_contents->prerendering_has_started());
777 TEST_F(PrerenderTest, CancelPendingPrerenderTest) {
778 GURL url("http://www.google.com/");
779 DummyPrerenderContents* prerender_contents =
780 prerender_manager()->CreateNextPrerenderContents(
781 url,
782 FINAL_STATUS_USED);
783 EXPECT_TRUE(AddSimplePrerender(url));
785 int child_id;
786 int route_id;
787 ASSERT_TRUE(prerender_contents->GetChildId(&child_id));
788 ASSERT_TRUE(prerender_contents->GetRouteId(&route_id));
790 GURL pending_url("http://news.google.com/");
792 // Schedule a pending prerender launched from the prerender.
793 prerender_link_manager()->OnAddPrerender(
794 child_id, GetNextPrerenderID(), pending_url, kDefaultRelTypes,
795 Referrer(url, blink::WebReferrerPolicyDefault),
796 kSize, route_id);
797 EXPECT_FALSE(LauncherHasRunningPrerender(child_id, last_prerender_id()));
799 // Cancel the pending prerender.
800 prerender_link_manager()->OnCancelPrerender(child_id, last_prerender_id());
802 // Use the referring prerender.
803 EXPECT_TRUE(prerender_contents->prerendering_has_started());
804 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
806 // The pending prerender doesn't start.
807 EXPECT_FALSE(LauncherHasRunningPrerender(child_id, last_prerender_id()));
810 // Tests that a PrerenderManager created for a browser session in the control
811 // group works as expected.
812 TEST_F(PrerenderTest, ControlGroup) {
813 RestorePrerenderMode restore_prerender_mode;
814 PrerenderManager::SetMode(
815 PrerenderManager::PRERENDER_MODE_EXPERIMENT_CONTROL_GROUP);
816 GURL url("http://www.google.com/");
817 DummyPrerenderContents* prerender_contents =
818 prerender_manager()->CreateNextPrerenderContents(
819 url,
820 FINAL_STATUS_MANAGER_SHUTDOWN);
821 EXPECT_TRUE(AddSimplePrerender(url));
822 EXPECT_FALSE(prerender_contents->prerendering_has_started());
825 // Tests that prerendering is cancelled when the source render view does not
826 // exist. On failure, the DCHECK in CreatePrerenderContents() above should be
827 // triggered.
828 TEST_F(PrerenderTest, SourceRenderViewClosed) {
829 GURL url("http://www.google.com/");
830 prerender_manager()->CreateNextPrerenderContents(
831 url,
832 FINAL_STATUS_MANAGER_SHUTDOWN);
833 prerender_link_manager()->OnAddPrerender(
834 100, GetNextPrerenderID(), url, kDefaultRelTypes, Referrer(), kSize, 200);
835 EXPECT_FALSE(LauncherHasRunningPrerender(100, last_prerender_id()));
838 // Tests that prerendering doesn't launch rel=next prerenders without the field
839 // trial.
840 TEST_F(PrerenderTest, NoRelNextByDefault) {
841 GURL url("http://www.google.com/");
842 prerender_manager()->CreateNextPrerenderContents(
843 url, FINAL_STATUS_MANAGER_SHUTDOWN);
844 DummyPrerenderContents* null = NULL;
846 prerender_link_manager()->OnAddPrerender(
847 kDefaultChildId, GetNextPrerenderID(), url, PrerenderRelTypeNext,
848 Referrer(), kSize, kDefaultRenderViewRouteId);
849 EXPECT_EQ(null, prerender_manager()->FindEntry(url));
852 // Tests that prerendering does launch rel=next prerenders with the field trial.
853 TEST_F(PrerenderTest, RelNextByFieldTrial) {
854 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("PrerenderRelNextTrial",
855 "Yes"));
856 GURL url("http://www.google.com/");
857 DummyPrerenderContents* prerender_contents =
858 prerender_manager()->CreateNextPrerenderContents(
859 url, ORIGIN_LINK_REL_NEXT, FINAL_STATUS_USED);
861 prerender_link_manager()->OnAddPrerender(
862 kDefaultChildId, GetNextPrerenderID(), url, PrerenderRelTypeNext,
863 Referrer(), kSize, kDefaultRenderViewRouteId);
864 EXPECT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
867 // Tests that prerendering is cancelled when we launch a second prerender of
868 // the same target within a short time interval.
869 TEST_F(PrerenderTest, RecentlyVisited) {
870 GURL url("http://www.google.com/");
872 prerender_manager()->RecordNavigation(url);
874 DummyPrerenderContents* prerender_contents =
875 prerender_manager()->CreateNextPrerenderContents(
876 url, FINAL_STATUS_RECENTLY_VISITED);
877 EXPECT_FALSE(AddSimplePrerender(url));
878 EXPECT_FALSE(prerender_contents->prerendering_has_started());
881 TEST_F(PrerenderTest, NotSoRecentlyVisited) {
882 GURL url("http://www.google.com/");
884 prerender_manager()->RecordNavigation(url);
885 prerender_manager()->AdvanceTimeTicks(
886 TimeDelta::FromMilliseconds(
887 UnitTestPrerenderManager::kNavigationRecordWindowMs + 500));
889 DummyPrerenderContents* prerender_contents =
890 prerender_manager()->CreateNextPrerenderContents(
891 url, FINAL_STATUS_USED);
892 EXPECT_TRUE(AddSimplePrerender(url));
893 EXPECT_TRUE(prerender_contents->prerendering_has_started());
894 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
897 // Tests that our PPLT dummy prerender gets created properly.
898 TEST_F(PrerenderTest, PPLTDummy) {
899 RestorePrerenderMode restore_prerender_mode;
900 PrerenderManager::SetMode(
901 PrerenderManager::PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP);
903 GURL url("http://www.google.com/");
904 DummyPrerenderContents* prerender_contents =
905 prerender_manager()->CreateNextPrerenderContents(
906 url, FINAL_STATUS_UNSUPPORTED_SCHEME);
907 EXPECT_TRUE(AddSimplePrerender(url));
908 EXPECT_TRUE(prerender_contents->prerendering_has_started());
909 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
911 DummyPrerenderContents* pplt_dummy_contents =
912 prerender_manager()->CreateNextPrerenderContents(url,
913 FINAL_STATUS_USED);
914 GURL ftp_url("ftp://ftp.google.com/");
915 // Adding this ftp URL will force the expected unsupported scheme error.
916 prerender_contents->AddAliasURL(ftp_url);
917 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
919 ASSERT_EQ(pplt_dummy_contents, prerender_manager()->FindAndUseEntry(url));
920 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
923 // Tests that our PPLT dummy prerender gets created properly, even
924 // when navigating to a page that has been recently navigated to.
925 TEST_F(PrerenderTest, RecentlyVisitedPPLTDummy) {
926 RestorePrerenderMode restore_prerender_mode;
927 PrerenderManager::SetMode(
928 PrerenderManager::PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP);
930 GURL url("http://www.google.com/");
931 DummyPrerenderContents* prerender_contents =
932 prerender_manager()->CreateNextPrerenderContents(
933 url, FINAL_STATUS_UNSUPPORTED_SCHEME);
934 EXPECT_TRUE(AddSimplePrerender(url));
935 EXPECT_TRUE(prerender_contents->prerendering_has_started());
937 DummyPrerenderContents* pplt_dummy_contents =
938 prerender_manager()->CreateNextPrerenderContents(url,
939 FINAL_STATUS_USED);
940 prerender_manager()->RecordNavigation(url);
941 GURL ftp_url("ftp://ftp.google.com/");
942 prerender_contents->AddAliasURL(ftp_url);
944 ASSERT_EQ(pplt_dummy_contents, prerender_manager()->FindAndUseEntry(url));
947 TEST_F(PrerenderTest, PPLTLateCancel) {
948 RestorePrerenderMode restore_prerender_mode;
949 PrerenderManager::SetMode(
950 PrerenderManager::PRERENDER_MODE_EXPERIMENT_MATCH_COMPLETE_GROUP);
952 GURL url("http://www.google.com");
953 DummyPrerenderContents* prerender_contents =
954 prerender_manager()->CreateNextPrerenderContents(
955 url, FINAL_STATUS_JAVASCRIPT_ALERT);
956 EXPECT_TRUE(AddSimplePrerender(url));
957 EXPECT_TRUE(prerender_contents->prerendering_has_started());
958 // Force the creation of a match complete dummy.
959 DummyPrerenderContents* duplicate_prerender_contents =
960 prerender_manager()->CreateNextPrerenderContents(url,
961 FINAL_STATUS_CANCELLED);
962 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
963 prerender_contents->Destroy(FINAL_STATUS_JAVASCRIPT_ALERT);
964 ASSERT_EQ(duplicate_prerender_contents, prerender_manager()->FindEntry(url));
966 // Make sure that events on prerender handles propogate to the match
967 // complete replacement.
968 DummyPrerenderContents* null = NULL;
969 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
970 last_prerender_id());
971 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
974 // Tests that the prerender manager matches include the fragment.
975 TEST_F(PrerenderTest, FragmentMatchesTest) {
976 GURL fragment_url("http://www.google.com/#test");
978 DummyPrerenderContents* prerender_contents =
979 prerender_manager()->CreateNextPrerenderContents(fragment_url,
980 FINAL_STATUS_USED);
981 EXPECT_TRUE(AddSimplePrerender(fragment_url));
982 EXPECT_TRUE(prerender_contents->prerendering_has_started());
983 ASSERT_EQ(prerender_contents,
984 prerender_manager()->FindAndUseEntry(fragment_url));
987 // Tests that the prerender manager uses fragment references when matching
988 // prerender URLs in the case a different fragment is in both URLs.
989 TEST_F(PrerenderTest, FragmentsDifferTest) {
990 GURL fragment_url("http://www.google.com/#test");
991 GURL other_fragment_url("http://www.google.com/#other_test");
993 DummyPrerenderContents* prerender_contents =
994 prerender_manager()->CreateNextPrerenderContents(fragment_url,
995 FINAL_STATUS_USED);
996 EXPECT_TRUE(AddSimplePrerender(fragment_url));
997 EXPECT_TRUE(prerender_contents->prerendering_has_started());
999 DummyPrerenderContents* null = NULL;
1000 ASSERT_EQ(null, prerender_manager()->FindEntry(other_fragment_url));
1002 ASSERT_EQ(prerender_contents,
1003 prerender_manager()->FindAndUseEntry(fragment_url));
1006 // Make sure that clearing works as expected.
1007 TEST_F(PrerenderTest, ClearTest) {
1008 GURL url("http://www.google.com/");
1009 DummyPrerenderContents* prerender_contents =
1010 prerender_manager()->CreateNextPrerenderContents(
1011 url,
1012 FINAL_STATUS_CACHE_OR_HISTORY_CLEARED);
1013 EXPECT_TRUE(AddSimplePrerender(url));
1014 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1015 prerender_manager()->ClearData(PrerenderManager::CLEAR_PRERENDER_CONTENTS);
1016 DummyPrerenderContents* null = NULL;
1017 EXPECT_EQ(null, prerender_manager()->FindEntry(url));
1020 // Make sure canceling works as expected.
1021 TEST_F(PrerenderTest, CancelAllTest) {
1022 GURL url("http://www.google.com/");
1023 DummyPrerenderContents* prerender_contents =
1024 prerender_manager()->CreateNextPrerenderContents(
1025 url, FINAL_STATUS_CANCELLED);
1026 EXPECT_TRUE(AddSimplePrerender(url));
1027 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1028 prerender_manager()->CancelAllPrerenders();
1029 const DummyPrerenderContents* null = NULL;
1030 EXPECT_EQ(null, prerender_manager()->FindEntry(url));
1033 TEST_F(PrerenderTest, OmniboxNotAllowedWhenDisabled) {
1034 DisablePrerender();
1035 EXPECT_FALSE(prerender_manager()->AddPrerenderFromOmnibox(
1036 GURL("http://www.example.com"), NULL, gfx::Size()));
1039 TEST_F(PrerenderTest, LinkRelNotAllowedWhenDisabled) {
1040 DisablePrerender();
1041 EXPECT_FALSE(AddSimplePrerender(
1042 GURL("http://www.example.com")));
1045 TEST_F(PrerenderTest, LinkManagerCancel) {
1046 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1047 GURL url("http://www.myexample.com");
1048 DummyPrerenderContents* prerender_contents =
1049 prerender_manager()->CreateNextPrerenderContents(
1050 url, FINAL_STATUS_CANCELLED);
1052 EXPECT_TRUE(AddSimplePrerender(url));
1054 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1055 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1056 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1057 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1058 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1059 last_prerender_id());
1061 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1062 DummyPrerenderContents* null = NULL;
1063 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1064 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1067 TEST_F(PrerenderTest, LinkManagerCancelThenAbandon) {
1068 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1069 GURL url("http://www.myexample.com");
1070 DummyPrerenderContents* prerender_contents =
1071 prerender_manager()->CreateNextPrerenderContents(
1072 url, FINAL_STATUS_CANCELLED);
1074 EXPECT_TRUE(AddSimplePrerender(url));
1076 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1077 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1078 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1079 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1080 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1081 last_prerender_id());
1083 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1084 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1085 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1086 last_prerender_id());
1088 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1089 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1090 DummyPrerenderContents* null = NULL;
1091 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1094 TEST_F(PrerenderTest, LinkManagerAbandon) {
1095 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1096 GURL url("http://www.myexample.com");
1097 DummyPrerenderContents* prerender_contents =
1098 prerender_manager()->CreateNextPrerenderContents(
1099 url, FINAL_STATUS_USED);
1101 EXPECT_TRUE(AddSimplePrerender(url));
1103 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1104 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1105 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1106 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1107 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1108 last_prerender_id());
1110 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1111 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
1114 TEST_F(PrerenderTest, LinkManagerAbandonThenCancel) {
1115 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1116 GURL url("http://www.myexample.com");
1117 DummyPrerenderContents* prerender_contents =
1118 prerender_manager()->CreateNextPrerenderContents(
1119 url, FINAL_STATUS_CANCELLED);
1121 EXPECT_TRUE(AddSimplePrerender(url));
1123 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1124 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1125 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1126 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1127 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1128 last_prerender_id());
1130 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1131 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1133 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1134 last_prerender_id());
1135 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1136 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1137 DummyPrerenderContents* null = NULL;
1138 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1141 TEST_F(PrerenderTest, LinkManagerCancelTwice) {
1142 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1143 GURL url("http://www.myexample.com");
1144 DummyPrerenderContents* prerender_contents =
1145 prerender_manager()->CreateNextPrerenderContents(
1146 url, FINAL_STATUS_CANCELLED);
1148 EXPECT_TRUE(AddSimplePrerender(url));
1149 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1150 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1151 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1152 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1153 last_prerender_id());
1155 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1156 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1157 DummyPrerenderContents* null = NULL;
1158 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1159 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1160 last_prerender_id());
1163 TEST_F(PrerenderTest, LinkManagerAddTwiceCancelTwice) {
1164 SetConcurrency(2);
1165 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1166 GURL url("http://www.myexample.com");
1167 DummyPrerenderContents* prerender_contents =
1168 prerender_manager()->CreateNextPrerenderContents(
1169 url, FINAL_STATUS_CANCELLED);
1171 EXPECT_TRUE(AddSimplePrerender(url));
1173 const int first_prerender_id = last_prerender_id();
1174 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1175 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1176 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1177 EXPECT_TRUE(AddSimplePrerender(url));
1179 const int second_prerender_id = last_prerender_id();
1180 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1181 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1182 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1183 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1184 first_prerender_id);
1186 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1187 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1188 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1189 second_prerender_id);
1191 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1192 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1193 DummyPrerenderContents* null = NULL;
1194 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1197 TEST_F(PrerenderTest, LinkManagerAddTwiceCancelTwiceThenAbandonTwice) {
1198 SetConcurrency(2);
1199 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1200 GURL url("http://www.myexample.com");
1201 DummyPrerenderContents* prerender_contents =
1202 prerender_manager()->CreateNextPrerenderContents(
1203 url, FINAL_STATUS_CANCELLED);
1205 EXPECT_TRUE(AddSimplePrerender(url));
1207 const int first_prerender_id = last_prerender_id();
1208 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1209 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1210 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1211 EXPECT_TRUE(AddSimplePrerender(url));
1213 const int second_prerender_id = last_prerender_id();
1214 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1215 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1216 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1217 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1218 first_prerender_id);
1220 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1221 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1222 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1223 second_prerender_id);
1225 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1226 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1227 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1228 first_prerender_id);
1230 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1231 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1232 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1233 second_prerender_id);
1235 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1236 EXPECT_TRUE(prerender_contents->prerendering_has_been_cancelled());
1237 DummyPrerenderContents* null = NULL;
1238 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1241 // TODO(gavinp): Update this test after abandon has an effect on Prerenders,
1242 // like shortening the timeouts.
1243 TEST_F(PrerenderTest, LinkManagerAddTwiceAbandonTwiceUseTwice) {
1244 SetConcurrency(2);
1245 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1246 GURL url("http://www.myexample.com");
1247 DummyPrerenderContents* prerender_contents =
1248 prerender_manager()->CreateNextPrerenderContents(
1249 url, FINAL_STATUS_USED);
1251 EXPECT_TRUE(AddSimplePrerender(url));
1253 const int first_prerender_id = last_prerender_id();
1254 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1255 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1256 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1257 EXPECT_TRUE(AddSimplePrerender(url));
1259 const int second_prerender_id = last_prerender_id();
1260 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1261 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1262 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1263 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1264 first_prerender_id);
1266 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1267 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1268 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1269 second_prerender_id);
1271 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1272 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
1273 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1276 // TODO(gavinp): After abandon shortens the expire time on a Prerender,
1277 // add a series of tests testing advancing the time by either the abandon
1278 // or normal expire, and verifying the expected behaviour with groups
1279 // of links.
1280 TEST_F(PrerenderTest, LinkManagerExpireThenCancel) {
1281 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1282 GURL url("http://www.myexample.com");
1283 DummyPrerenderContents* prerender_contents =
1284 prerender_manager()->CreateNextPrerenderContents(
1285 url, FINAL_STATUS_TIMED_OUT);
1287 EXPECT_TRUE(AddSimplePrerender(url));
1289 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1290 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1291 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1292 prerender_manager()->AdvanceTimeTicks(
1293 prerender_manager()->config().time_to_live + TimeDelta::FromSeconds(1));
1295 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1296 DummyPrerenderContents* null = NULL;
1297 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1298 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1299 last_prerender_id());
1301 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1302 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1305 TEST_F(PrerenderTest, LinkManagerExpireThenAddAgain) {
1306 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1307 GURL url("http://www.myexample.com");
1308 DummyPrerenderContents* first_prerender_contents =
1309 prerender_manager()->CreateNextPrerenderContents(
1310 url, FINAL_STATUS_TIMED_OUT);
1311 EXPECT_TRUE(AddSimplePrerender(url));
1312 EXPECT_TRUE(first_prerender_contents->prerendering_has_started());
1313 EXPECT_FALSE(first_prerender_contents->prerendering_has_been_cancelled());
1314 ASSERT_EQ(first_prerender_contents,
1315 prerender_manager()->FindEntry(url));
1316 prerender_manager()->AdvanceTimeTicks(
1317 prerender_manager()->config().time_to_live + TimeDelta::FromSeconds(1));
1318 DummyPrerenderContents* null = NULL;
1319 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1320 DummyPrerenderContents* second_prerender_contents =
1321 prerender_manager()->CreateNextPrerenderContents(
1322 url, FINAL_STATUS_USED);
1323 EXPECT_TRUE(AddSimplePrerender(url));
1324 EXPECT_TRUE(second_prerender_contents->prerendering_has_started());
1325 ASSERT_EQ(second_prerender_contents,
1326 prerender_manager()->FindAndUseEntry(url));
1329 TEST_F(PrerenderTest, LinkManagerCancelThenAddAgain) {
1330 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1331 GURL url("http://www.myexample.com");
1332 DummyPrerenderContents* first_prerender_contents =
1333 prerender_manager()->CreateNextPrerenderContents(
1334 url, FINAL_STATUS_CANCELLED);
1335 EXPECT_TRUE(AddSimplePrerender(url));
1336 EXPECT_TRUE(first_prerender_contents->prerendering_has_started());
1337 EXPECT_FALSE(first_prerender_contents->prerendering_has_been_cancelled());
1338 ASSERT_EQ(first_prerender_contents, prerender_manager()->FindEntry(url));
1339 prerender_link_manager()->OnCancelPrerender(kDefaultChildId,
1340 last_prerender_id());
1341 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1342 EXPECT_TRUE(first_prerender_contents->prerendering_has_been_cancelled());
1343 DummyPrerenderContents* null = NULL;
1344 ASSERT_EQ(null, prerender_manager()->FindEntry(url));
1345 DummyPrerenderContents* second_prerender_contents =
1346 prerender_manager()->CreateNextPrerenderContents(
1347 url, FINAL_STATUS_USED);
1348 EXPECT_TRUE(AddSimplePrerender(url));
1349 EXPECT_TRUE(second_prerender_contents->prerendering_has_started());
1350 ASSERT_EQ(second_prerender_contents,
1351 prerender_manager()->FindAndUseEntry(url));
1354 TEST_F(PrerenderTest, LinkManagerChannelClosing) {
1355 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1356 GURL url("http://www.myexample.com");
1357 DummyPrerenderContents* prerender_contents =
1358 prerender_manager()->CreateNextPrerenderContents(
1359 url, FINAL_STATUS_TIMED_OUT);
1361 EXPECT_TRUE(AddSimplePrerender(url));
1362 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1363 EXPECT_FALSE(prerender_contents->prerendering_has_been_cancelled());
1364 ASSERT_EQ(prerender_contents, prerender_manager()->FindEntry(url));
1366 prerender_link_manager()->OnChannelClosing(kDefaultChildId);
1368 prerender_manager()->AdvanceTimeTicks(
1369 prerender_manager()->config().abandon_time_to_live +
1370 TimeDelta::FromSeconds(1));
1372 DummyPrerenderContents* null = NULL;
1373 EXPECT_EQ(null, prerender_manager()->FindEntry(url));
1374 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1377 // Creates two prerenders, one of which should be blocked by the
1378 // max_link_concurrency; abandons both of them and waits to make sure both
1379 // are cleared from the PrerenderLinkManager.
1380 TEST_F(PrerenderTest, LinkManagerAbandonInactivePrerender) {
1381 SetConcurrency(1);
1382 ASSERT_LT(prerender_manager()->config().abandon_time_to_live,
1383 prerender_manager()->config().time_to_live);
1384 GURL first_url("http://www.myexample.com");
1385 DummyPrerenderContents* prerender_contents =
1386 prerender_manager()->CreateNextPrerenderContents(
1387 first_url, FINAL_STATUS_TIMED_OUT);
1388 EXPECT_TRUE(AddSimplePrerender(first_url));
1389 const int first_prerender_id = last_prerender_id();
1391 GURL second_url("http://www.neverlaunched.com");
1392 EXPECT_FALSE(AddSimplePrerender(second_url));
1393 const int second_prerender_id = last_prerender_id();
1395 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1397 DummyPrerenderContents* null = NULL;
1398 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(first_url));
1399 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url));
1401 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1402 first_prerender_id);
1403 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1404 second_prerender_id);
1406 prerender_manager()->AdvanceTimeTicks(
1407 prerender_manager()->config().abandon_time_to_live +
1408 TimeDelta::FromSeconds(1));
1409 EXPECT_EQ(null, prerender_manager()->FindEntry(first_url));
1410 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url));
1411 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1414 // Creates two prerenders, the second one started by the first, both of which
1415 // should be blocked by max_concurrency; abandons both of them and waits to make
1416 // sure both are cleared from the PrerenderLinkManager.
1417 TEST_F(PrerenderTest, LinkManagerClearOnPendingAbandon) {
1418 SetConcurrency(1);
1419 ASSERT_LT(prerender_manager()->config().abandon_time_to_live,
1420 prerender_manager()->config().time_to_live);
1421 GURL first_url("http://www.myexample.com");
1422 DummyPrerenderContents* prerender_contents =
1423 prerender_manager()->CreateNextPrerenderContents(
1424 first_url, FINAL_STATUS_TIMED_OUT);
1425 EXPECT_TRUE(AddSimplePrerender(first_url));
1426 const int first_prerender_id = last_prerender_id();
1428 int child_id;
1429 int route_id;
1430 ASSERT_TRUE(prerender_contents->GetChildId(&child_id));
1431 ASSERT_TRUE(prerender_contents->GetRouteId(&route_id));
1433 GURL pending_url("http://www.neverlaunched.com");
1434 prerender_link_manager()->OnAddPrerender(
1435 child_id, GetNextPrerenderID(), pending_url, kDefaultRelTypes,
1436 content::Referrer(), kSize, route_id);
1437 const int second_prerender_id = last_prerender_id();
1439 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1441 DummyPrerenderContents* null = NULL;
1442 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(first_url));
1443 EXPECT_EQ(null, prerender_manager()->FindEntry(pending_url));
1445 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1446 first_prerender_id);
1447 prerender_link_manager()->OnAbandonPrerender(kDefaultChildId,
1448 second_prerender_id);
1450 prerender_manager()->AdvanceTimeTicks(
1451 prerender_manager()->config().abandon_time_to_live +
1452 TimeDelta::FromSeconds(1));
1453 EXPECT_EQ(null, prerender_manager()->FindEntry(first_url));
1454 EXPECT_EQ(null, prerender_manager()->FindEntry(pending_url));
1455 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1458 // Creates two prerenders, one of which should be blocked by the
1459 // max_link_concurrency; uses one after the max wait to launch, and
1460 // ensures the second prerender does not start.
1461 TEST_F(PrerenderTest, LinkManagerWaitToLaunchNotLaunched) {
1462 SetConcurrency(1);
1463 ASSERT_LT(prerender_manager()->config().max_wait_to_launch,
1464 prerender_manager()->config().time_to_live);
1465 GURL first_url("http://www.myexample.com");
1466 DummyPrerenderContents* prerender_contents =
1467 prerender_manager()->CreateNextPrerenderContents(
1468 first_url, FINAL_STATUS_USED);
1469 EXPECT_TRUE(AddSimplePrerender(first_url));
1471 GURL second_url("http://www.neverlaunched.com");
1472 EXPECT_FALSE(AddSimplePrerender(second_url));
1474 EXPECT_FALSE(IsEmptyPrerenderLinkManager());
1476 DummyPrerenderContents* null = NULL;
1477 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(first_url));
1478 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url));
1480 prerender_manager()->AdvanceTimeTicks(
1481 prerender_manager()->config().max_wait_to_launch +
1482 TimeDelta::FromSeconds(1));
1483 EXPECT_EQ(prerender_contents, prerender_manager()->FindEntry(first_url));
1484 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url));
1486 EXPECT_EQ(prerender_contents,
1487 prerender_manager()->FindAndUseEntry(first_url));
1489 EXPECT_EQ(null, prerender_manager()->FindEntry(first_url));
1490 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url));
1491 EXPECT_TRUE(IsEmptyPrerenderLinkManager());
1494 // Creates two prerenders, one of which should start when the first one expires.
1495 TEST_F(PrerenderTest, LinkManagerExpireRevealingLaunch) {
1496 SetConcurrency(1);
1497 ASSERT_LT(prerender_manager()->config().max_wait_to_launch,
1498 prerender_manager()->config().time_to_live);
1500 GURL first_url("http://www.willexpire.com");
1501 DummyPrerenderContents* first_prerender_contents =
1502 prerender_manager()->CreateNextPrerenderContents(
1503 first_url, FINAL_STATUS_TIMED_OUT);
1504 EXPECT_TRUE(AddSimplePrerender(first_url));
1505 EXPECT_EQ(first_prerender_contents,
1506 prerender_manager()->FindEntry(first_url));
1508 // Insert the second prerender so it will be still be launchable when the
1509 // first expires.
1510 const TimeDelta wait_to_launch_second_prerender =
1511 prerender_manager()->config().time_to_live -
1512 prerender_manager()->config().max_wait_to_launch +
1513 TimeDelta::FromSeconds(2);
1514 const TimeDelta wait_for_first_prerender_to_expire =
1515 prerender_manager()->config().time_to_live -
1516 wait_to_launch_second_prerender +
1517 TimeDelta::FromSeconds(1);
1518 ASSERT_LT(prerender_manager()->config().time_to_live,
1519 wait_to_launch_second_prerender +
1520 wait_for_first_prerender_to_expire);
1521 ASSERT_GT(prerender_manager()->config().max_wait_to_launch.InSeconds(),
1522 wait_for_first_prerender_to_expire.InSeconds());
1524 prerender_manager()->AdvanceTimeTicks(wait_to_launch_second_prerender);
1525 GURL second_url("http://www.willlaunch.com");
1526 DummyPrerenderContents* second_prerender_contents =
1527 prerender_manager()->CreateNextPrerenderContents(
1528 second_url, FINAL_STATUS_USED);
1529 EXPECT_FALSE(AddSimplePrerender(second_url));
1531 // The first prerender is still running, but the second has not yet launched.
1532 EXPECT_EQ(first_prerender_contents,
1533 prerender_manager()->FindEntry(first_url));
1534 PrerenderContents* null = NULL;
1535 EXPECT_EQ(null, prerender_manager()->FindEntry(second_url));
1537 // The first prerender should have died, giving life to the second one.
1538 prerender_manager()->AdvanceTimeTicks(wait_for_first_prerender_to_expire);
1539 EXPECT_EQ(null, prerender_manager()->FindEntry(first_url));
1540 EXPECT_EQ(second_prerender_contents,
1541 prerender_manager()->FindAndUseEntry(second_url));
1544 TEST_F(PrerenderTest, InstantSearchNotAllowedWhenDisabled) {
1545 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1546 "EmbeddedSearch",
1547 "Group82 espv:8 use_cacheable_ntp:1 prefetch_results:1"));
1548 DisablePrerender();
1549 EXPECT_FALSE(prerender_manager()->AddPrerenderForInstant(
1550 GURL("http://www.example.com/instant_search"), NULL, gfx::Size()));
1553 TEST_F(PrerenderTest, PrerenderContentsForInstantSearch) {
1554 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
1555 "EmbeddedSearch",
1556 "Group82 espv:8 use_cacheable_ntp:1 prefetch_results:1"));
1557 GURL url("http://www.example.com/instant_search");
1558 DummyPrerenderContents* prerender_contents =
1559 prerender_manager()->CreateNextPrerenderContents(url, ORIGIN_INSTANT,
1560 FINAL_STATUS_USED);
1561 scoped_ptr<PrerenderHandle> prerender_handle(
1562 prerender_manager()->AddPrerenderForInstant(url, NULL, kSize));
1563 CHECK(prerender_handle.get());
1564 EXPECT_TRUE(prerender_handle->IsPrerendering());
1565 EXPECT_TRUE(prerender_contents->prerendering_has_started());
1566 EXPECT_EQ(prerender_contents, prerender_handle->contents());
1567 EXPECT_EQ(ORIGIN_INSTANT, prerender_handle->contents()->origin());
1568 ASSERT_EQ(prerender_contents, prerender_manager()->FindAndUseEntry(url));
1569 EXPECT_FALSE(prerender_handle->IsPrerendering());
1572 } // namespace prerender