Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / renderer / chrome_content_renderer_client_browsertest.cc
blob3424e5c34e623a07ad0cebc1ddd35ce21995cb6f
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 <string>
8 #include <vector>
10 #include "base/command_line.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "base/thread_task_runner_handle.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/render_messages.h"
15 #include "chrome/grit/generated_resources.h"
16 #include "chrome/renderer/chrome_content_renderer_client.h"
17 #include "chrome/test/base/chrome_render_view_test.h"
18 #include "content/public/common/content_constants.h"
19 #include "content/public/renderer/render_frame.h"
20 #include "content/public/renderer/render_view.h"
21 #include "content/public/test/mock_render_thread.h"
22 #include "ipc/ipc_listener.h"
23 #include "ipc/ipc_sender.h"
24 #include "ipc/ipc_test_sink.h"
25 #include "testing/gmock/include/gmock/gmock.h"
26 #include "third_party/WebKit/public/web/WebLocalFrame.h"
27 #include "third_party/WebKit/public/web/WebPluginParams.h"
28 #include "ui/base/l10n/l10n_util.h"
29 #include "url/gurl.h"
31 using testing::_;
32 using testing::SetArgPointee;
34 typedef ChromeRenderViewTest InstantProcessNavigationTest;
36 // Tests that renderer-initiated navigations from an Instant render process get
37 // bounced back to the browser to be rebucketed into a non-Instant renderer if
38 // necessary.
39 TEST_F(InstantProcessNavigationTest, ForkForNavigationsFromInstantProcess) {
40 base::CommandLine::ForCurrentProcess()->AppendSwitch(
41 switches::kInstantProcess);
42 bool unused;
43 ChromeContentRendererClient* client =
44 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get());
45 EXPECT_TRUE(client->ShouldFork(
46 GetMainFrame(), GURL("http://foo"), "GET", false, false, &unused));
49 // Tests that renderer-initiated navigations from a non-Instant render process
50 // to potentially Instant URLs get bounced back to the browser to be rebucketed
51 // into an Instant renderer if necessary.
52 TEST_F(InstantProcessNavigationTest, ForkForNavigationsToSearchURLs) {
53 ChromeContentRendererClient* client =
54 static_cast<ChromeContentRendererClient*>(content_renderer_client_.get());
55 chrome_render_thread_->set_io_message_loop_proxy(
56 base::ThreadTaskRunnerHandle::Get());
57 client->RenderThreadStarted();
58 std::vector<GURL> search_urls;
59 search_urls.push_back(GURL("http://example.com/search"));
60 chrome_render_thread_->Send(new ChromeViewMsg_SetSearchURLs(
61 search_urls, GURL("http://example.com/newtab")));
62 bool unused;
63 EXPECT_TRUE(client->ShouldFork(
64 GetMainFrame(), GURL("http://example.com/newtab"), "GET", false, false,
65 &unused));
66 EXPECT_TRUE(client->ShouldFork(
67 GetMainFrame(), GURL("http://example.com/search?q=foo"), "GET", false,
68 false, &unused));
69 EXPECT_FALSE(client->ShouldFork(
70 GetMainFrame(), GURL("http://example.com/"), "GET", false, false,
71 &unused));