OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/extensions/extension_process_policy.h" | 16 #include "chrome/common/extensions/extension_process_policy.h" |
17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/site_instance.h" | 22 #include "content/public/browser/site_instance.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
25 #include "content/public/test/test_navigation_observer.h" | 25 #include "content/public/test/test_navigation_observer.h" |
26 #include "extensions/browser/extension_host.h" | 26 #include "extensions/browser/extension_host.h" |
27 #include "extensions/browser/process_manager.h" | 27 #include "extensions/browser/process_manager.h" |
28 #include "extensions/browser/process_map.h" | 28 #include "extensions/browser/process_map.h" |
29 #include "extensions/common/extension_urls.h" | |
29 #include "extensions/common/switches.h" | 30 #include "extensions/common/switches.h" |
30 #include "net/dns/mock_host_resolver.h" | 31 #include "net/dns/mock_host_resolver.h" |
31 #include "net/test/embedded_test_server/embedded_test_server.h" | 32 #include "net/test/embedded_test_server/embedded_test_server.h" |
32 | 33 |
33 using content::NavigationController; | 34 using content::NavigationController; |
34 using content::WebContents; | 35 using content::WebContents; |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 class ProcessManagementTest : public ExtensionBrowserTest { | 39 class ProcessManagementTest : public ExtensionBrowserTest { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 // Verify that we really have the Chrome Web Store app loaded in the Web | 384 // Verify that we really have the Chrome Web Store app loaded in the Web |
384 // Contents. | 385 // Contents. |
385 content::RenderProcessHost* new_process_host = | 386 content::RenderProcessHost* new_process_host = |
386 web_contents->GetMainFrame()->GetProcess(); | 387 web_contents->GetMainFrame()->GetProcess(); |
387 EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains( | 388 EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains( |
388 extensions::kWebStoreAppId, new_process_host->GetID())); | 389 extensions::kWebStoreAppId, new_process_host->GetID())); |
389 | 390 |
390 // Verify that Chrome Web Store is isolated in a separate renderer process. | 391 // Verify that Chrome Web Store is isolated in a separate renderer process. |
391 EXPECT_NE(old_process_host, new_process_host); | 392 EXPECT_NE(old_process_host, new_process_host); |
392 } | 393 } |
394 | |
395 // This problem is similar to https://crbug.com/622385. It happens when an | |
396 // iframe error page with the Chrome Web Store URL is displayed and the iframe | |
397 // and its parent reside in the same process. In this case, the renderer | |
398 // process is killed with the RFH_CAN_COMMIT_URL_BLOCKED error code. This test | |
399 // asserts that the renderer is still alive after the navigation. | |
nasko
2017/03/09 17:18:11
nit: "renderer process". One of the main goals I h
arthursonzogni
2017/03/10 09:25:47
Done.
| |
400 IN_PROC_BROWSER_TEST_F(ChromeWebStoreProcessTest, | |
401 ChromeWebStoreBlockedByFrameSrc) { | |
402 GURL url = | |
403 embedded_test_server()->GetURL("/extensions/iframe-child-src-none.html"); | |
404 ui_test_utils::NavigateToURL(browser(), url); | |
405 | |
406 WebContents* web_contents = | |
407 browser()->tab_strip_model()->GetActiveWebContents(); | |
408 | |
409 // Make the iframe navigate to the Chrome Web Store and wait for the 'load' | |
410 // event. This is also a check that the renderer is still alive after the | |
411 // navigation. | |
412 std::string message; | |
413 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
414 web_contents, | |
415 "var iframe = document.getElementById('test'); iframe.onload = " | |
nasko
2017/03/09 17:18:11
nit: I'd put the iframe.onload on the new line and
arthursonzogni
2017/03/10 09:25:47
Done.
| |
416 "function() { domAutomationController.send('iframe loaded'); }; " | |
417 "iframe.src = '" + | |
418 std::string(extension_urls::kChromeWebstoreBaseURL) + "';", | |
419 &message)); | |
nasko
2017/03/09 17:18:11
Doesn't ExecuteScriptAndExtractString basically re
arthursonzogni
2017/03/10 09:25:47
It is waiting that the domAutomationController sen
| |
420 EXPECT_EQ("iframe loaded", message); | |
421 } | |
OLD | NEW |