permissions_apitest.cc revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 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_apitest.h"
6#include "chrome/common/chrome_switches.h"
7
8class ExperimentalApiTest : public ExtensionApiTest {
9public:
10  void SetUpCommandLine(CommandLine* command_line) {
11    ExtensionApiTest::SetUpCommandLine(command_line);
12    command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
13  }
14};
15
16IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PermissionsFail) {
17  ASSERT_TRUE(RunExtensionTest("permissions/disabled")) << message_;
18
19  // Since the experimental APIs require a flag, this will fail even though
20  // It's enabled.
21  // TODO(erikkay) This test is currently broken because LoadExtension in
22  // ExtensionBrowserTest doesn't actually fail, it just times out.  To fix this
23  // I'll need to add an EXTENSION_LOAD_ERROR notification, which is probably
24  // too much for the branch.  I'll enable this on trunk later.
25  //ASSERT_FALSE(RunExtensionTest("permissions/enabled"))) << message_;
26}
27
28IN_PROC_BROWSER_TEST_F(ExperimentalApiTest, PermissionsSucceed) {
29  ASSERT_TRUE(RunExtensionTest("permissions/enabled")) << message_;
30}
31
32IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ExperimentalPermissionsFail) {
33  // At the time this test is being created, there is no experimental
34  // function that will not be graduating soon, and does not require a
35  // tab id as an argument.  So, we need the tab permission to get
36  // a tab id.
37  ASSERT_TRUE(RunExtensionTest("permissions/experimental_disabled"))
38      << message_;
39}
40
41IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FavIconPermission) {
42  ASSERT_TRUE(RunExtensionTest("permissions/favicon")) << message_;
43}
44
45// Test functions and APIs that are always allowed (even if you ask for no
46// permissions.
47IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlwaysAllowed) {
48  ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_;
49}
50
51// TODO(gregoryd): run the NaCl test on all systems once
52// http://code.google.com/p/chromium/issues/detail?id=51335 is fixed.
53// Meanwhile we run it on Mac OSX only, since we can be sure that an x86-32 NaCl
54// module will work there.
55// Mark as Flaky.  http://crbug.com/51861
56#if defined(OS_MACOSX)
57IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FLAKY_NaClPermissionEnabled) {
58  CommandLine::ForCurrentProcess()->AppendSwitch(switches::kInternalNaCl);
59  ASSERT_TRUE(RunExtensionTest("permissions/nacl_enabled")) << message_;
60}
61#endif
62