Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/extensions/extension_management_browsertest.cc

Issue 7003068: Fix crash when you uninstall a permissions-upgrade disabled extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initialize extension to NULL Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_disabled_infobar_delegate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/stl_util-inl.h" 6 #include "base/stl_util-inl.h"
7 #include "chrome/browser/extensions/autoupdate_interceptor.h" 7 #include "chrome/browser/extensions/autoupdate_interceptor.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_test_message_listener.h" 11 #include "chrome/browser/extensions/extension_test_message_listener.h"
12 #include "chrome/browser/extensions/extension_updater.h" 12 #include "chrome/browser/extensions/extension_updater.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/prefs/scoped_user_pref_update.h" 14 #include "chrome/browser/prefs/scoped_user_pref_update.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
17 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "chrome/test/ui_test_utils.h" 20 #include "chrome/test/ui_test_utils.h"
20 #include "content/browser/renderer_host/render_view_host.h" 21 #include "content/browser/renderer_host/render_view_host.h"
21 22
22 class ExtensionManagementTest : public ExtensionBrowserTest { 23 class ExtensionManagementTest : public ExtensionBrowserTest {
23 protected: 24 protected:
24 // Helper method that returns whether the extension is at the given version. 25 // Helper method that returns whether the extension is at the given version.
25 // This calls version(), which must be defined in the extension's bg page, 26 // This calls version(), which must be defined in the extension's bg page,
26 // as well as asking the extension itself. 27 // as well as asking the extension itself.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 ExtensionService* service = browser()->profile()->GetExtensionService(); 143 ExtensionService* service = browser()->profile()->GetExtensionService();
143 ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension()); 144 ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension());
144 const size_t size_before = service->extensions()->size(); 145 const size_t size_before = service->extensions()->size();
145 146
146 // Now try reenabling it. 147 // Now try reenabling it.
147 service->EnableExtension(service->disabled_extensions()->at(0)->id()); 148 service->EnableExtension(service->disabled_extensions()->at(0)->id());
148 EXPECT_EQ(size_before + 1, service->extensions()->size()); 149 EXPECT_EQ(size_before + 1, service->extensions()->size());
149 EXPECT_EQ(0u, service->disabled_extensions()->size()); 150 EXPECT_EQ(0u, service->disabled_extensions()->size());
150 } 151 }
151 152
153 // Tests uninstalling an extension that was disabled due to higher permissions.
154 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UpdatePermissionsAndUninstall) {
155 ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension());
156
157 // Make sure the "disable extension" infobar is present.
158 ASSERT_EQ(0, browser()->active_index());
159 TabContentsWrapper* wrapper = browser()->GetTabContentsWrapperAt(0);
160 ASSERT_EQ(1U, wrapper->infobar_count());
161
162 // Uninstall, and check that the infobar went away.
163 ExtensionService* service = browser()->profile()->GetExtensionService();
164 std::string id = service->disabled_extensions()->at(0)->id();
165 UninstallExtension(id);
166 ASSERT_EQ(0U, wrapper->infobar_count());
167
168 // Now select a new tab, and switch back to the first tab which had the
169 // infobar. We should not crash.
170 ASSERT_EQ(1, browser()->tab_count());
171 ASSERT_EQ(0, browser()->active_index());
172 browser()->NewTab();
173 ASSERT_EQ(2, browser()->tab_count());
174 ASSERT_EQ(1, browser()->active_index());
175 browser()->ActivateTabAt(0, true);
176 }
177
152 // Tests that we can uninstall a disabled extension. 178 // Tests that we can uninstall a disabled extension.
153 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UninstallDisabled) { 179 IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, UninstallDisabled) {
154 ExtensionService* service = browser()->profile()->GetExtensionService(); 180 ExtensionService* service = browser()->profile()->GetExtensionService();
155 ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension()); 181 ASSERT_TRUE(InstallAndUpdateIncreasingPermissionsExtension());
156 const size_t size_before = service->extensions()->size(); 182 const size_t size_before = service->extensions()->size();
157 183
158 // Now try uninstalling it. 184 // Now try uninstalling it.
159 UninstallExtension(service->disabled_extensions()->at(0)->id()); 185 UninstallExtension(service->disabled_extensions()->at(0)->id());
160 EXPECT_EQ(size_before, service->extensions()->size()); 186 EXPECT_EQ(size_before, service->extensions()->size());
161 EXPECT_EQ(0u, service->disabled_extensions()->size()); 187 EXPECT_EQ(0u, service->disabled_extensions()->size());
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 480
455 // Check that emptying the list triggers uninstall. 481 // Check that emptying the list triggers uninstall.
456 { 482 {
457 prefs->ClearPref(prefs::kExtensionInstallForceList); 483 prefs->ClearPref(prefs::kExtensionInstallForceList);
458 } 484 }
459 EXPECT_EQ(size_before + 1, extensions->size()); 485 EXPECT_EQ(size_before + 1, extensions->size());
460 ExtensionList::const_iterator i; 486 ExtensionList::const_iterator i;
461 for (i = extensions->begin(); i != extensions->end(); ++i) 487 for (i = extensions->begin(); i != extensions->end(); ++i)
462 EXPECT_NE(kExtensionId, (*i)->id()); 488 EXPECT_NE(kExtensionId, (*i)->id());
463 } 489 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_disabled_infobar_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698