summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_install_prompt_unittest.cc
diff options
context:
space:
mode:
authorrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 15:48:13 +0000
committerrdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 15:49:39 +0000
commita397ec0fe120a2018cbba1009d1394ce1667d4fc (patch)
treefdc6ef321247aaeaf58ebb7e0bb4c3be7af27495 /chrome/browser/extensions/extension_install_prompt_unittest.cc
parent6827a944fb605731c65a6969e3ef5426adc3b2fb (diff)
downloadchromium_src-a397ec0fe120a2018cbba1009d1394ce1667d4fc.zip
chromium_src-a397ec0fe120a2018cbba1009d1394ce1667d4fc.tar.gz
chromium_src-a397ec0fe120a2018cbba1009d1394ce1667d4fc.tar.bz2
Fix permission regression where warnings aren't shown in the dialog
A regression was introduced in r275142 causing the permissions dialog to not show permissions. Obviously very bad. Fixed, and added a regression test. BUG=397900 Review URL: https://codereview.chromium.org/448883002 Cr-Commit-Position: refs/heads/master@{#288365} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288365 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_install_prompt_unittest.cc')
-rw-r--r--chrome/browser/extensions/extension_install_prompt_unittest.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_install_prompt_unittest.cc b/chrome/browser/extensions/extension_install_prompt_unittest.cc
new file mode 100644
index 0000000..347db0f
--- /dev/null
+++ b/chrome/browser/extensions/extension_install_prompt_unittest.cc
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/memory/ref_counted.h"
+#include "base/run_loop.h"
+#include "chrome/browser/extensions/extension_install_prompt.h"
+#include "content/public/test/test_browser_thread_bundle.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_builder.h"
+#include "extensions/common/permissions/api_permission.h"
+#include "extensions/common/permissions/api_permission_set.h"
+#include "extensions/common/permissions/manifest_permission_set.h"
+#include "extensions/common/permissions/permission_set.h"
+#include "extensions/common/url_pattern_set.h"
+#include "extensions/common/value_builder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+
+void VerifyPromptPermissionsCallback(
+ const base::Closure& quit_closure,
+ const ExtensionInstallPrompt::ShowParams& params,
+ ExtensionInstallPrompt::Delegate* delegate,
+ scoped_refptr<ExtensionInstallPrompt::Prompt> install_prompt) {
+ ASSERT_TRUE(install_prompt.get());
+ EXPECT_EQ(1u, install_prompt->GetPermissionCount());
+ quit_closure.Run();
+}
+
+TEST(ExtensionInstallPromptUnittest, PromptShowsPermissionWarnings) {
+ content::TestBrowserThreadBundle thread_bundle;
+ APIPermissionSet api_permissions;
+ api_permissions.insert(APIPermission::kTab);
+ scoped_refptr<PermissionSet> permission_set =
+ new PermissionSet(api_permissions,
+ ManifestPermissionSet(),
+ URLPatternSet(),
+ URLPatternSet());
+ scoped_refptr<const Extension> extension =
+ ExtensionBuilder().SetManifest(
+ DictionaryBuilder().Set("name", "foo")
+ .Set("version", "1.0")
+ .Set("manifest_version", 2)
+ .Set("description", "Random Ext")).Build();
+ ExtensionInstallPrompt prompt(NULL /* no web contents in this test */);
+ base::RunLoop run_loop;
+ prompt.set_callback_for_test(base::Bind(&VerifyPromptPermissionsCallback,
+ run_loop.QuitClosure()));
+ prompt.ConfirmPermissions(NULL, // no delegate
+ extension,
+ permission_set);
+ run_loop.Run();
+}
+
+} // namespace extensions