Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/chrome_site_per_process_browsertest.cc

Issue 789273006: Make ContentSettingsObserver security checks work with OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
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"
24
25 class ChromeSitePerProcessTest : public InProcessBrowserTest {
26 public:
27 ChromeSitePerProcessTest() {}
28 ~ChromeSitePerProcessTest() override {}
29
30 void SetUpCommandLine(base::CommandLine* command_line) override {
31 command_line->AppendSwitch(switches::kSitePerProcess);
32 }
33
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());
38 }
39
40 private:
41 DISALLOW_COPY_AND_ASSIGN(ChromeSitePerProcessTest);
42 };
43
44 // Verify that origin replication allows JS access to localStorage, database,
45 // and FileSystem APIs. These features involve a check on the
46 // WebSecurityOrigin of the topmost WebFrame in ContentSettingsObserver, and
47 // this test ensures this check works when the top frame is remote.
48 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest,
49 OriginReplicationAllowsAccessToStorage) {
50 // Navigate to a page with a same-site iframe.
51 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
52 ui_test_utils::NavigateToURL(browser(), main_url);
53
54 // Navigate subframe cross-site.
55 content::WebContents* active_web_contents =
56 browser()->tab_strip_model()->GetActiveWebContents();
57 GURL cross_site_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
58 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", cross_site_url));
59
60 // Find the subframe's RenderFrameHost.
61 content::RenderFrameHost* frame_host = FrameMatchingPredicate(
62 active_web_contents,
63 base::Bind(&content::FrameHasSourceUrl, cross_site_url));
64 ASSERT_TRUE(frame_host);
65 EXPECT_TRUE(frame_host->IsCrossProcessSubframe());
66
67 // Check that JS storage APIs can be accessed successfully.
68 EXPECT_TRUE(
69 content::ExecuteScript(frame_host, "localStorage['foo'] = 'bar'"));
70 std::string result;
71 EXPECT_TRUE(ExecuteScriptAndExtractString(
72 frame_host, "window.domAutomationController.send(localStorage['foo']);",
73 &result));
74 EXPECT_EQ(result, "bar");
75 bool is_object_created = false;
76 EXPECT_TRUE(ExecuteScriptAndExtractBool(
77 frame_host,
78 "window.domAutomationController.send(!!indexedDB.open('testdb', 2));",
79 &is_object_created));
80 EXPECT_TRUE(is_object_created);
81 is_object_created = false;
82 EXPECT_TRUE(ExecuteScriptAndExtractBool(
83 frame_host,
84 "window.domAutomationController.send(!!openDatabase("
85 "'foodb', '1.0', 'Test DB', 1024));",
86 &is_object_created));
87 EXPECT_TRUE(is_object_created);
88 EXPECT_TRUE(ExecuteScript(frame_host,
89 "window.webkitRequestFileSystem("
90 "window.TEMPORARY, 1024, function() {});"));
91 }
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698