OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
8 #include "chrome/test/base/ui_test_utils.h" | 8 #include "chrome/test/base/ui_test_utils.h" |
9 #include "content/public/test/browser_test_utils.h" | 9 #include "content/public/test/browser_test_utils.h" |
10 | 10 |
11 namespace extensions { | 11 namespace extensions { |
12 | 12 |
13 // Test that opening a window with an extension recorded as active, then | 13 // Test that opening a window with an extension recorded as active, then |
14 // unloading the extension, all before the renderer is fully initialized, | 14 // unloading the extension, all before the renderer is fully initialized, |
15 // doesn't crash. This addresses crbug.com/528026, where messages could be sent | 15 // doesn't crash. This addresses crbug.com/528026, where messages could be sent |
16 // out of order if an extension unloaded before the activation message was sent. | 16 // out of order if an extension unloaded before the activation message was sent. |
17 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, | 17 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, |
18 TestRendererStartupWithConflictingMessages) { | 18 TestRendererStartupWithConflictingMessages) { |
19 // Load up an extension an begin opening an URL to a page within it. Since | 19 // Load up an extension an begin opening an URL to a page within it. Since |
20 // this will be an extension tab, the extension will be active within that | 20 // this will be an extension tab, the extension will be active within that |
21 // process. | 21 // process. |
22 const Extension* extension = | 22 const Extension* extension = |
23 LoadExtension(test_data_dir_.AppendASCII("simple_with_file")); | 23 LoadExtension(test_data_dir_.AppendASCII("simple_with_file")); |
24 ASSERT_TRUE(extension); | 24 ASSERT_TRUE(extension); |
25 GURL url = extension->GetResourceURL("file.html"); | 25 GURL url = extension->GetResourceURL("file.html"); |
26 browser()->OpenURL(content::OpenURLParams(url, content::Referrer(), | 26 browser()->OpenURL(content::OpenURLParams( |
27 NEW_FOREGROUND_TAB, | 27 url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB, |
28 ui::PAGE_TRANSITION_TYPED, false)); | 28 ui::PAGE_TRANSITION_TYPED, false)); |
29 // Without waiting for the tab to finish, unload the extension. | 29 // Without waiting for the tab to finish, unload the extension. |
30 extension_service()->UnloadExtension(extension->id(), | 30 extension_service()->UnloadExtension(extension->id(), |
31 UnloadedExtensionInfo::REASON_TERMINATE); | 31 UnloadedExtensionInfo::REASON_TERMINATE); |
32 content::WebContents* web_contents = | 32 content::WebContents* web_contents = |
33 browser()->tab_strip_model()->GetActiveWebContents(); | 33 browser()->tab_strip_model()->GetActiveWebContents(); |
34 // Wait for the web contents to stop loading. | 34 // Wait for the web contents to stop loading. |
35 content::WaitForLoadStop(web_contents); | 35 content::WaitForLoadStop(web_contents); |
36 EXPECT_EQ(url, web_contents->GetLastCommittedURL()); | 36 EXPECT_EQ(url, web_contents->GetLastCommittedURL()); |
37 ASSERT_FALSE(web_contents->IsCrashed()); | 37 ASSERT_FALSE(web_contents->IsCrashed()); |
38 } | 38 } |
(...skipping 10 matching lines...) Expand all Loading... |
49 ui_test_utils::NavigateToURL(browser(), url); | 49 ui_test_utils::NavigateToURL(browser(), url); |
50 content::WebContents* web_contents = | 50 content::WebContents* web_contents = |
51 browser()->tab_strip_model()->GetActiveWebContents(); | 51 browser()->tab_strip_model()->GetActiveWebContents(); |
52 // Wait for the web contents to stop loading. | 52 // Wait for the web contents to stop loading. |
53 content::WaitForLoadStop(web_contents); | 53 content::WaitForLoadStop(web_contents); |
54 EXPECT_EQ(url, web_contents->GetLastCommittedURL()); | 54 EXPECT_EQ(url, web_contents->GetLastCommittedURL()); |
55 ASSERT_FALSE(web_contents->IsCrashed()); | 55 ASSERT_FALSE(web_contents->IsCrashed()); |
56 } | 56 } |
57 | 57 |
58 } // namespace extensions | 58 } // namespace extensions |
OLD | NEW |