Test for golden version-7 safe-browsing file.
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client_browsertest.cc
blob75e17085b2da550c7f62f6e9f652a795612fc265
1 // Copyright 2013 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 "chrome/renderer/chrome_content_renderer_client.h"
7 #include <vector>
9 #include "base/command_line.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/render_messages.h"
12 #include "chrome/renderer/chrome_content_renderer_client.h"
13 #include "chrome/test/base/chrome_render_view_test.h"
14 #include "url/gurl.h"
16 typedef ChromeRenderViewTest InstantProcessNavigationTest;
18 // Tests that renderer-initiated navigations from an Instant render process get
19 // bounced back to the browser to be rebucketed into a non-Instant renderer if
20 // necessary.
21 TEST_F(InstantProcessNavigationTest, ForkForNavigationsFromInstantProcess) {
22 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kInstantProcess);
23 bool unused;
24 ChromeContentRendererClient* client =
25 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get());
26 EXPECT_TRUE(client->ShouldFork(
27 GetMainFrame(), GURL("http://foo"), "GET", false, false, &unused));
30 // Tests that renderer-initiated navigations from a non-Instant render process
31 // to potentially Instant URLs get bounced back to the browser to be rebucketed
32 // into an Instant renderer if necessary.
33 TEST_F(InstantProcessNavigationTest, ForkForNavigationsToSearchURLs) {
34 ChromeContentRendererClient* client =
35 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get());
36 chrome_render_thread_->set_io_message_loop_proxy(
37 base::MessageLoopProxy::current());
38 client->RenderThreadStarted();
39 std::vector<GURL> search_urls;
40 search_urls.push_back(GURL("http://example.com/search"));
41 chrome_render_thread_->Send(new ChromeViewMsg_SetSearchURLs(
42 search_urls, GURL("http://example.com/newtab")));
43 bool unused;
44 EXPECT_TRUE(client->ShouldFork(
45 GetMainFrame(), GURL("http://example.com/newtab"), "GET", false, false,
46 &unused));
47 EXPECT_TRUE(client->ShouldFork(
48 GetMainFrame(), GURL("http://example.com/search?q=foo"), "GET", false,
49 false, &unused));
50 EXPECT_FALSE(client->ShouldFork(
51 GetMainFrame(), GURL("http://example.com/"), "GET", false, false,
52 &unused));