Home | History | Annotate | Download | only in extensions
      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 
      8 class ExperimentalApiTest : public ExtensionApiTest {
      9 public:
     10   void SetUpCommandLine(CommandLine* command_line) {
     11     ExtensionApiTest::SetUpCommandLine(command_line);
     12     command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
     13   }
     14 };
     15 
     16 IN_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 
     28 IN_PROC_BROWSER_TEST_F(ExperimentalApiTest, PermissionsSucceed) {
     29   ASSERT_TRUE(RunExtensionTest("permissions/enabled")) << message_;
     30 }
     31 
     32 IN_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 
     41 IN_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).
     47 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlwaysAllowed) {
     48   ASSERT_TRUE(RunExtensionTest("permissions/always_allowed")) << message_;
     49 }
     50