| 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()); |
| 33 EXPECT_EQ( |
| 34 initial_tab_url, |
| 35 browser()->tab_strip_model()->GetWebContentsAt(0)->GetLastCommittedURL()); |
| 36 } |
| 37 |
| 38 // TODO(devlin): Investigate what to do for embedded iframes. |
| 39 |
| 40 } // namespace extensions |
| OLD | NEW |