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

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

Issue 165414: Disable an extension when it is upgraded to a version that requires more (Closed)
Patch Set: more comments Created 11 years, 4 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/ref_counted.h" 5 #include "base/ref_counted.h"
6 #include "chrome/browser/browser.h" 6 #include "chrome/browser/browser.h"
7 #include "chrome/browser/browser_list.h" 7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/renderer_host/render_view_host.h" 8 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Tests that installing and uninstalling extensions don't crash with an 144 // Tests that installing and uninstalling extensions don't crash with an
145 // incognito window open. 145 // incognito window open.
146 // This test is disabled. see bug 16106. 146 // This test is disabled. see bug 16106.
147 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Incognito) { 147 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, Incognito) {
148 // Open an incognito window to the extensions management page. We just 148 // Open an incognito window to the extensions management page. We just
149 // want to make sure that we don't crash while playing with extensions when 149 // want to make sure that we don't crash while playing with extensions when
150 // this guy is around. 150 // this guy is around.
151 Browser::OpenURLOffTheRecord(browser()->profile(), 151 Browser::OpenURLOffTheRecord(browser()->profile(),
152 GURL(chrome::kChromeUIExtensionsURL)); 152 GURL(chrome::kChromeUIExtensionsURL));
153 153
154 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("good.crx"))); 154 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("good.crx"), 1));
155 UninstallExtension("ldnnhddmnhbkjipkidpdiheffobcpfmf"); 155 UninstallExtension("ldnnhddmnhbkjipkidpdiheffobcpfmf");
156 } 156 }
157 157
158 // Tests that we can load extension pages into the tab area and they can call 158 // Tests that we can load extension pages into the tab area and they can call
159 // extension APIs. 159 // extension APIs.
160 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TabContents) { 160 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TabContents) {
161 ASSERT_TRUE(LoadExtension( 161 ASSERT_TRUE(LoadExtension(
162 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 162 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
163 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 163 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
164 .AppendASCII("1.0.0.0"))); 164 .AppendASCII("1.0.0.0")));
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 ui_test_utils::ExecuteJavaScriptAndExtractBool( 408 ui_test_utils::ExecuteJavaScriptAndExtractBool(
409 host->render_view_host(), L"", L"testDisconnect()", &result); 409 host->render_view_host(), L"", L"testDisconnect()", &result);
410 EXPECT_TRUE(result); 410 EXPECT_TRUE(result);
411 411
412 // Test disconnect is fired on tab close. 412 // Test disconnect is fired on tab close.
413 result = false; 413 result = false;
414 ui_test_utils::ExecuteJavaScriptAndExtractBool( 414 ui_test_utils::ExecuteJavaScriptAndExtractBool(
415 host->render_view_host(), L"", L"testDisconnectOnClose()", &result); 415 host->render_view_host(), L"", L"testDisconnectOnClose()", &result);
416 EXPECT_TRUE(result); 416 EXPECT_TRUE(result);
417 } 417 }
418
419 // Tests the process of updating an extension to one that requires higher
420 // permissions.
421 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UpdatePermissions) {
422 TabContents* contents = browser()->GetSelectedTabContents();
423 ASSERT_TRUE(contents);
424
425 // Install the initial version, which should happen just fine.
426 ASSERT_TRUE(InstallExtension(
427 test_data_dir_.AppendASCII("permissions-low-v1.crx"), 1));
428 DCHECK_EQ(0, contents->infobar_delegate_count());
429
430 // Upgrade to a version that wants more permissions. We should disable the
431 // extension and prompt the user to reenable.
432 ASSERT_TRUE(InstallExtension(
433 test_data_dir_.AppendASCII("permissions-high-v2.crx"), -1));
434 EXPECT_EQ(1, contents->infobar_delegate_count());
435
436 ExtensionsService* service = browser()->profile()->GetExtensionsService();
437 EXPECT_EQ(0u, service->extensions()->size());
438 ASSERT_EQ(1u, service->disabled_extensions()->size());
439
440 // Now try reenabling it, which should also dismiss the infobar.
441 service->EnableExtension(service->disabled_extensions()->at(0)->id());
442 EXPECT_EQ(0, contents->infobar_delegate_count());
443 EXPECT_EQ(1u, service->extensions()->size());
444 EXPECT_EQ(0u, service->disabled_extensions()->size());
445 }
446
447 // Tests that we can uninstall a disabled extension.
448 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UninstallDisabled) {
449 // Install and upgrade, so that we have a disabled extension.
450 ASSERT_TRUE(InstallExtension(
451 test_data_dir_.AppendASCII("permissions-low-v1.crx"), 1));
452 ASSERT_TRUE(InstallExtension(
453 test_data_dir_.AppendASCII("permissions-high-v2.crx"), -1));
454
455 ExtensionsService* service = browser()->profile()->GetExtensionsService();
456 EXPECT_EQ(0u, service->extensions()->size());
457 ASSERT_EQ(1u, service->disabled_extensions()->size());
458
459 // Now try uninstalling it.
460 UninstallExtension(service->disabled_extensions()->at(0)->id());
461 EXPECT_EQ(0u, service->extensions()->size());
462 EXPECT_EQ(0u, service->disabled_extensions()->size());
463 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/browser/extensions/extension_disabled_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698