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/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 content::TestNavigationObserver nav_observer(web_contents, 1); | 317 content::TestNavigationObserver nav_observer(web_contents, 1); |
318 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 318 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
319 web_contents, navigation_starting_script, &ignored_script_result)); | 319 web_contents, navigation_starting_script, &ignored_script_result)); |
320 | 320 |
321 // Verify that the navigation succeeded. | 321 // Verify that the navigation succeeded. |
322 nav_observer.Wait(); | 322 nav_observer.Wait(); |
323 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); | 323 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); |
324 | 324 |
325 // Verify that the navigation transferred the contents to another renderer | 325 // Verify that the navigation transferred the contents to another renderer |
326 // process. | 326 // process. |
327 if (extensions::IsIsolateExtensionsEnabled()) { | 327 content::RenderProcessHost* new_process_host = |
328 content::RenderProcessHost* new_process_host = | 328 web_contents->GetMainFrame()->GetProcess(); |
329 web_contents->GetMainFrame()->GetProcess(); | 329 EXPECT_NE(old_process_host, new_process_host); |
330 EXPECT_NE(old_process_host, new_process_host); | |
331 } | |
332 } | 330 } |
333 | 331 |
334 IN_PROC_BROWSER_TEST_F(ChromeWebStoreProcessTest, | 332 IN_PROC_BROWSER_TEST_F(ChromeWebStoreProcessTest, |
335 NavigateWebTabToChromeWebStoreViaPost) { | 333 NavigateWebTabToChromeWebStoreViaPost) { |
336 // Navigate a tab to a web page with a form. | 334 // Navigate a tab to a web page with a form. |
337 GURL web_url = embedded_test_server()->GetURL("foo.com", "/form.html"); | 335 GURL web_url = embedded_test_server()->GetURL("foo.com", "/form.html"); |
338 ui_test_utils::NavigateToURL(browser(), web_url); | 336 ui_test_utils::NavigateToURL(browser(), web_url); |
339 WebContents* web_contents = | 337 WebContents* web_contents = |
340 browser()->tab_strip_model()->GetActiveWebContents(); | 338 browser()->tab_strip_model()->GetActiveWebContents(); |
341 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); | 339 EXPECT_EQ(web_url, web_contents->GetLastCommittedURL()); |
(...skipping 17 matching lines...) Expand all Loading... | |
359 "setTimeout(\n" | 357 "setTimeout(\n" |
360 " function() { window.domAutomationController.send(true); },\n" | 358 " function() { window.domAutomationController.send(true); },\n" |
361 " 0);\n"; | 359 " 0);\n"; |
362 | 360 |
363 // Trigger a renderer-initiated POST navigation (via the form) to a Chrome Web | 361 // Trigger a renderer-initiated POST navigation (via the form) to a Chrome Web |
364 // Store gallery URL (which will commit into a chrome-extension://cws-app-id). | 362 // Store gallery URL (which will commit into a chrome-extension://cws-app-id). |
365 bool ignored_script_result = false; | 363 bool ignored_script_result = false; |
366 content::TestNavigationObserver nav_observer(web_contents, 1); | 364 content::TestNavigationObserver nav_observer(web_contents, 1); |
367 content::RenderProcessHostWatcher crash_observer( | 365 content::RenderProcessHostWatcher crash_observer( |
368 web_contents->GetMainFrame()->GetProcess(), | 366 web_contents->GetMainFrame()->GetProcess(), |
369 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 367 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
ncarter (slow)
2017/05/01 20:15:19
Remove |crash_observer|
nasko
2017/05/01 21:25:37
Done.
| |
370 | 368 |
371 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 369 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
372 web_contents, navigation_starting_script, &ignored_script_result)); | 370 web_contents, navigation_starting_script, &ignored_script_result)); |
373 | 371 |
374 // When --isolate-extensions is enabled, the expectation is that the store | 372 // The expectation is that the store will be properly put in its own process, |
375 // will be properly put in its own process, otherwise the renderer process | 373 // otherwise the renderer process is going to be terminated. |
376 // is going to be terminated. | |
377 if (!extensions::IsIsolateExtensionsEnabled()) { | |
378 crash_observer.Wait(); | |
379 return; | |
380 } | |
381 | |
382 // Verify that the navigation succeeded. | 374 // Verify that the navigation succeeded. |
383 nav_observer.Wait(); | 375 nav_observer.Wait(); |
384 EXPECT_EQ(cws_web_url, web_contents->GetLastCommittedURL()); | 376 EXPECT_EQ(cws_web_url, web_contents->GetLastCommittedURL()); |
385 | 377 |
386 // Verify that we really have the Chrome Web Store app loaded in the Web | 378 // Verify that we really have the Chrome Web Store app loaded in the Web |
387 // Contents. | 379 // Contents. |
388 content::RenderProcessHost* new_process_host = | 380 content::RenderProcessHost* new_process_host = |
389 web_contents->GetMainFrame()->GetProcess(); | 381 web_contents->GetMainFrame()->GetProcess(); |
390 EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains( | 382 EXPECT_TRUE(extensions::ProcessMap::Get(profile())->Contains( |
391 extensions::kWebStoreAppId, new_process_host->GetID())); | 383 extensions::kWebStoreAppId, new_process_host->GetID())); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 // the process is the same for all SiteInstances. This allows us to verify | 443 // the process is the same for all SiteInstances. This allows us to verify |
452 // that the site-to-process map for the extension hasn't been overwritten by | 444 // that the site-to-process map for the extension hasn't been overwritten by |
453 // the process of the |blocked_url|. | 445 // the process of the |blocked_url|. |
454 scoped_refptr<content::SiteInstance> new_site_instance = | 446 scoped_refptr<content::SiteInstance> new_site_instance = |
455 content::SiteInstance::CreateForURL(web_contents->GetBrowserContext(), | 447 content::SiteInstance::CreateForURL(web_contents->GetBrowserContext(), |
456 extension->GetResourceURL("")); | 448 extension->GetResourceURL("")); |
457 EXPECT_TRUE(new_site_instance->HasProcess()); | 449 EXPECT_TRUE(new_site_instance->HasProcess()); |
458 EXPECT_EQ(new_site_instance->GetProcess(), | 450 EXPECT_EQ(new_site_instance->GetProcess(), |
459 web_contents->GetSiteInstance()->GetProcess()); | 451 web_contents->GetSiteInstance()->GetProcess()); |
460 } | 452 } |
OLD | NEW |