1 // Copyright (c) 2012 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.
5 #include "base/logging.h"
6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_toolbar_model.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/ui_test_utils.h"
10 #include "extensions/common/extension.h"
11 #include "net/test/embedded_test_server/embedded_test_server.h"
13 namespace extensions
{
16 // Times out on win asan, http://crbug.com/166026
17 #if defined(OS_WIN) && defined(ADDRESS_SANITIZER)
18 #define MAYBE_ActiveTab DISABLED_ActiveTab
20 #define MAYBE_ActiveTab ActiveTab
22 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, MAYBE_ActiveTab
) {
23 ASSERT_TRUE(StartEmbeddedTestServer());
25 const Extension
* extension
=
26 LoadExtension(test_data_dir_
.AppendASCII("active_tab"));
27 ASSERT_TRUE(extension
);
29 ExtensionToolbarModel
* toolbar_model
=
30 ExtensionToolbarModel::Get(browser()->profile());
32 // Shouldn't be initially granted based on activeTab.
34 ResultCatcher catcher
;
35 ui_test_utils::NavigateToURL(
37 embedded_test_server()->GetURL(
38 "/extensions/api_test/active_tab/page.html"));
39 EXPECT_TRUE(catcher
.GetNextResult()) << message_
;
42 // Granting to the extension should give it access to page.html.
44 ResultCatcher catcher
;
45 toolbar_model
->ExecuteBrowserAction(extension
, browser(), NULL
, true);
46 EXPECT_TRUE(catcher
.GetNextResult()) << message_
;
49 // Changing page should go back to it not having access.
51 ResultCatcher catcher
;
52 ui_test_utils::NavigateToURL(
54 embedded_test_server()->GetURL(
55 "/extensions/api_test/active_tab/final_page.html"));
56 EXPECT_TRUE(catcher
.GetNextResult()) << message_
;
61 } // namespace extensions