| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/extensions/browser_action_test_util.h" | 16 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 17 #include "chrome/browser/extensions/extension_browsertest.h" | 17 #include "chrome/browser/extensions/extension_browsertest.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/test_extension_dir.h" | 19 #include "chrome/browser/extensions/test_extension_dir.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/extensions/extension_process_policy.h" | 23 #include "chrome/common/extensions/extension_process_policy.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/test/base/in_process_browser_test.h" | 25 #include "chrome/test/base/in_process_browser_test.h" |
| 26 #include "chrome/test/base/ui_test_utils.h" | 26 #include "chrome/test/base/ui_test_utils.h" |
| 27 #include "components/guest_view/browser/test_guest_view_manager.h" | 27 #include "components/guest_view/browser/test_guest_view_manager.h" |
| 28 #include "content/public/browser/child_process_security_policy.h" | 28 #include "content/public/browser/child_process_security_policy.h" |
| 29 #include "content/public/browser/navigation_entry.h" |
| 29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/render_frame_host.h" | 31 #include "content/public/browser/render_frame_host.h" |
| 31 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
| 32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/common/browser_side_navigation_policy.h" | 34 #include "content/public/common/browser_side_navigation_policy.h" |
| 34 #include "content/public/test/browser_test_utils.h" | 35 #include "content/public/test/browser_test_utils.h" |
| 35 #include "content/public/test/test_navigation_observer.h" | 36 #include "content/public/test/test_navigation_observer.h" |
| 36 #include "content/public/test/test_utils.h" | 37 #include "content/public/test/test_utils.h" |
| 37 #include "extensions/browser/app_window/app_window.h" | 38 #include "extensions/browser/app_window/app_window.h" |
| 38 #include "extensions/browser/app_window/app_window_registry.h" | 39 #include "extensions/browser/app_window/app_window_registry.h" |
| (...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 // frame's (a.com) process. | 1227 // frame's (a.com) process. |
| 1227 GURL b_url(embedded_test_server()->GetURL("b.com", "/empty.html")); | 1228 GURL b_url(embedded_test_server()->GetURL("b.com", "/empty.html")); |
| 1228 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", b_url)); | 1229 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", b_url)); |
| 1229 { | 1230 { |
| 1230 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0); | 1231 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0); |
| 1231 EXPECT_EQ(subframe->GetProcess(), main_frame->GetProcess()); | 1232 EXPECT_EQ(subframe->GetProcess(), main_frame->GetProcess()); |
| 1232 EXPECT_EQ(subframe->GetSiteInstance(), main_frame->GetSiteInstance()); | 1233 EXPECT_EQ(subframe->GetSiteInstance(), main_frame->GetSiteInstance()); |
| 1233 } | 1234 } |
| 1234 } | 1235 } |
| 1235 | 1236 |
| 1237 // Test to verify that loading a resource other than an icon file is |
| 1238 // disallowed for hosted apps, while icons are allowed. |
| 1239 // See https://crbug.com/717626. |
| 1240 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, HostedAppFilesAccess) { |
| 1241 // Load an extension with a background page. |
| 1242 scoped_refptr<const Extension> extension = |
| 1243 LoadExtension(test_data_dir_.AppendASCII("hosted_app")); |
| 1244 ASSERT_TRUE(extension); |
| 1245 |
| 1246 content::WebContents* tab = |
| 1247 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1248 |
| 1249 // Navigating to the manifest should be blocked with an error page. |
| 1250 { |
| 1251 content::TestNavigationObserver observer(tab); |
| 1252 NavigateToURL(extension->GetResourceURL("/manifest.json")); |
| 1253 EXPECT_FALSE(observer.last_navigation_succeeded()); |
| 1254 EXPECT_EQ(tab->GetController().GetLastCommittedEntry()->GetPageType(), |
| 1255 content::PAGE_TYPE_ERROR); |
| 1256 } |
| 1257 |
| 1258 // Navigation to the icon file should succeed. |
| 1259 { |
| 1260 content::TestNavigationObserver observer(tab); |
| 1261 NavigateToURL(extension->GetResourceURL("/icon.png")); |
| 1262 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 1263 EXPECT_EQ(tab->GetController().GetLastCommittedEntry()->GetPageType(), |
| 1264 content::PAGE_TYPE_NORMAL); |
| 1265 } |
| 1266 } |
| 1267 |
| 1236 } // namespace extensions | 1268 } // namespace extensions |
| OLD | NEW |