Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/extension_browsertest.h" | |
| 6 #include "chrome/browser/extensions/extension_service.h" | |
| 7 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 8 #include "chrome/test/base/ui_test_utils.h" | |
| 9 #include "ui/base/window_open_disposition.h" | |
| 10 | |
| 11 namespace extensions { | |
| 12 | |
| 13 using ExtensionUnloadBrowserTest = ExtensionBrowserTest; | |
| 14 | |
| 15 IN_PROC_BROWSER_TEST_F(ExtensionUnloadBrowserTest, TestUnload) { | |
| 16 // Load an extension that installs unload and beforeunload listeners. | |
| 17 const Extension* extension = | |
| 18 LoadExtension(test_data_dir_.AppendASCII("unload_listener")); | |
| 19 ASSERT_TRUE(extension); | |
| 20 std::string id = extension->id(); | |
| 21 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | |
| 22 GURL initial_tab_url = | |
| 23 browser()->tab_strip_model()->GetWebContentsAt(0)->GetLastCommittedURL(); | |
| 24 ui_test_utils::NavigateToURLWithDisposition( | |
| 25 browser(), extension->GetResourceURL("page.html"), | |
| 26 WindowOpenDisposition::NEW_FOREGROUND_TAB, | |
| 27 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 28 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | |
| 29 extension_service()->UnloadExtension(id, | |
| 30 UnloadedExtensionInfo::REASON_DISABLE); | |
| 31 // There should only be one remaining web contents - the initial one. | |
| 32 ASSERT_EQ(1, browser()->tab_strip_model()->count()); | |
|
Charlie Reis
2016/09/21 18:29:33
Sanity check: This failed before because the remov
Devlin
2016/09/22 00:35:21
Correct.
| |
| 33 EXPECT_EQ( | |
| 34 initial_tab_url, | |
| 35 browser()->tab_strip_model()->GetWebContentsAt(0)->GetLastCommittedURL()); | |
| 36 } | |
| 37 | |
| 38 // TODO(devlin): We should replicate this behavior for terminated extensions. | |
|
Charlie Reis
2016/09/21 18:29:33
I'm less concerned about terminated extensions (wh
Devlin
2016/09/22 00:35:21
Don't quite follow. It wouldn't be the extension
Charlie Reis
2016/09/22 20:37:47
I'm confused. In your example, the tab is showing
Devlin
2016/09/26 19:44:46
Ah, right. I was distracted by the browser code t
| |
| 39 | |
| 40 } // namespace extensions | |
| OLD | NEW |