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

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: Nits Created 6 years 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') | chrome/renderer/content_settings_observer.cc » ('J')
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() {}
jochen (gone - plz use gerrit) 2015/01/07 13:42:46 nit. please add a virtual dtor
alexmos 2015/01/07 20:43:12 Done.
28
29 void SetUpCommandLine(CommandLine* command_line) override {
30 command_line->AppendSwitch(switches::kSitePerProcess);
31 }
32
33 void SetUpOnMainThread() override {
34 host_resolver()->AddRule("*", "127.0.0.1");
35 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
36 content::SetupCrossSiteRedirector(embedded_test_server());
37 }
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(ChromeSitePerProcessTest);
41 };
42
43 // Verify that origin replication allows JS access to localStorage, database,
44 // and FileSystem APIs. These features involve a check on the
45 // WebSecurityOrigin of the topmost WebFrame in ContentSettingsObserver, and
46 // this test ensures this check works when the top frame is remote.
47 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest,
48 OriginReplicationAllowsAccessToStorage) {
49 // Navigate to a page with a same-site iframe.
50 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
51 ui_test_utils::NavigateToURL(browser(), main_url);
52
53 // Navigate subframe cross-site.
54 content::WebContents* active_web_contents =
55 browser()->tab_strip_model()->GetActiveWebContents();
56 GURL cross_site_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
57 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", cross_site_url));
58
59 // Find the subframe's RenderFrameHost.
60 content::RenderFrameHost* frame_host = FrameMatchingPredicate(
61 active_web_contents,
62 base::Bind(&content::FrameHasSourceUrl, cross_site_url));
63 ASSERT_TRUE(frame_host);
64 EXPECT_TRUE(frame_host->IsCrossProcessSubframe());
65
66 // Check that JS storage APIs can be accessed successfully.
67 EXPECT_TRUE(
68 content::ExecuteScript(frame_host, "localStorage['foo'] = 'bar'"));
69 std::string result;
70 EXPECT_TRUE(ExecuteScriptAndExtractString(
71 frame_host, "window.domAutomationController.send(localStorage['foo']);",
72 &result));
73 EXPECT_EQ(result, "bar");
74 bool is_object_created = false;
75 EXPECT_TRUE(ExecuteScriptAndExtractBool(
76 frame_host,
77 "window.domAutomationController.send(!!indexedDB.open('testdb', 2));",
78 &is_object_created));
79 EXPECT_TRUE(is_object_created);
80 is_object_created = false;
81 EXPECT_TRUE(ExecuteScriptAndExtractBool(
82 frame_host,
83 "window.domAutomationController.send(!!openDatabase("
84 "'foodb', '1.0', 'Test DB', 1024));",
85 &is_object_created));
86 EXPECT_TRUE(is_object_created);
87 EXPECT_TRUE(ExecuteScript(frame_host,
88 "window.webkitRequestFileSystem("
89 "window.TEMPORARY, 1024, function() {});"));
90 }
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | chrome/renderer/content_settings_observer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698