Remove no longer needed toolbar layer method.
[chromium-blink-merge.git] / chrome / browser / chrome_site_per_process_browsertest.cc
blob1ed8186121bac34b433561f9449fced949aeaed8
1 // Copyright 2014 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 "base/command_line.h"
6 #include "base/strings/stringprintf.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_service.h"
13 #include "content/public/browser/notification_types.h"
14 #include "content/public/browser/render_frame_host.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/common/content_switches.h"
18 #include "content/public/test/browser_test_utils.h"
19 #include "content/public/test/content_browser_test_utils.h"
20 #include "content/public/test/test_utils.h"
21 #include "net/dns/mock_host_resolver.h"
22 #include "net/test/embedded_test_server/embedded_test_server.h"
23 #include "url/gurl.h"
25 class ChromeSitePerProcessTest : public InProcessBrowserTest {
26 public:
27 ChromeSitePerProcessTest() {}
28 ~ChromeSitePerProcessTest() override {}
30 void SetUpCommandLine(base::CommandLine* command_line) override {
31 command_line->AppendSwitch(switches::kSitePerProcess);
34 void SetUpOnMainThread() override {
35 host_resolver()->AddRule("*", "127.0.0.1");
36 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
37 content::SetupCrossSiteRedirector(embedded_test_server());
40 private:
41 DISALLOW_COPY_AND_ASSIGN(ChromeSitePerProcessTest);
44 // Verify that browser shutdown path works correctly when there's a
45 // RenderFrameProxyHost for a child frame.
46 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest, RenderFrameProxyHostShutdown) {
47 GURL main_url(embedded_test_server()->GetURL(
48 "a.com",
49 "/frame_tree/page_with_two_frames_remote_and_local.html"));
50 ui_test_utils::NavigateToURL(browser(), main_url);
53 // Verify that origin replication allows JS access to localStorage, database,
54 // and FileSystem APIs. These features involve a check on the
55 // WebSecurityOrigin of the topmost WebFrame in ContentSettingsObserver, and
56 // this test ensures this check works when the top frame is remote.
57 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest,
58 OriginReplicationAllowsAccessToStorage) {
59 // Navigate to a page with a same-site iframe.
60 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
61 ui_test_utils::NavigateToURL(browser(), main_url);
63 // Navigate subframe cross-site.
64 content::WebContents* active_web_contents =
65 browser()->tab_strip_model()->GetActiveWebContents();
66 GURL cross_site_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
67 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", cross_site_url));
69 // Find the subframe's RenderFrameHost.
70 content::RenderFrameHost* frame_host = FrameMatchingPredicate(
71 active_web_contents,
72 base::Bind(&content::FrameHasSourceUrl, cross_site_url));
73 ASSERT_TRUE(frame_host);
74 EXPECT_TRUE(frame_host->IsCrossProcessSubframe());
76 // Check that JS storage APIs can be accessed successfully.
77 EXPECT_TRUE(
78 content::ExecuteScript(frame_host, "localStorage['foo'] = 'bar'"));
79 std::string result;
80 EXPECT_TRUE(ExecuteScriptAndExtractString(
81 frame_host, "window.domAutomationController.send(localStorage['foo']);",
82 &result));
83 EXPECT_EQ(result, "bar");
84 bool is_object_created = false;
85 EXPECT_TRUE(ExecuteScriptAndExtractBool(
86 frame_host,
87 "window.domAutomationController.send(!!indexedDB.open('testdb', 2));",
88 &is_object_created));
89 EXPECT_TRUE(is_object_created);
90 is_object_created = false;
91 EXPECT_TRUE(ExecuteScriptAndExtractBool(
92 frame_host,
93 "window.domAutomationController.send(!!openDatabase("
94 "'foodb', '1.0', 'Test DB', 1024));",
95 &is_object_created));
96 EXPECT_TRUE(is_object_created);
97 EXPECT_TRUE(ExecuteScript(frame_host,
98 "window.webkitRequestFileSystem("
99 "window.TEMPORARY, 1024, function() {});"));