Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / extensions / active_tab_apitest.cc
bloba27135a1bf566bda10f0e4649469367fc0f166b5
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/api/extension_action/extension_action_api.h"
7 #include "chrome/browser/extensions/extension_apitest.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 "extensions/test/result_catcher.h"
12 #include "net/test/embedded_test_server/embedded_test_server.h"
14 namespace extensions {
15 namespace {
17 // Times out on win syzyasan, http://crbug.com/166026
18 #if defined(SYZYASAN)
19 #define MAYBE_ActiveTab DISABLED_ActiveTab
20 #else
21 #define MAYBE_ActiveTab ActiveTab
22 #endif
23 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ActiveTab) {
24 ASSERT_TRUE(StartEmbeddedTestServer());
26 const Extension* extension =
27 LoadExtension(test_data_dir_.AppendASCII("active_tab"));
28 ASSERT_TRUE(extension);
30 // Shouldn't be initially granted based on activeTab.
32 ResultCatcher catcher;
33 ui_test_utils::NavigateToURL(
34 browser(),
35 embedded_test_server()->GetURL(
36 "/extensions/api_test/active_tab/page.html"));
37 EXPECT_TRUE(catcher.GetNextResult()) << message_;
40 // Granting to the extension should give it access to page.html.
42 ResultCatcher catcher;
43 ExtensionActionAPI::Get(browser()->profile())->ExecuteExtensionAction(
44 extension, browser(), true);
45 EXPECT_TRUE(catcher.GetNextResult()) << message_;
48 // Changing page should go back to it not having access.
50 ResultCatcher catcher;
51 ui_test_utils::NavigateToURL(
52 browser(),
53 embedded_test_server()->GetURL(
54 "/extensions/api_test/active_tab/final_page.html"));
55 EXPECT_TRUE(catcher.GetNextResult()) << message_;
59 } // namespace
60 } // namespace extensions