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.
4
5#include "chrome/browser/extensions/extension_action.h"
6#include "chrome/browser/extensions/extension_apitest.h"
7#include "chrome/browser/extensions/extension_service.h"
8#include "chrome/browser/profiles/profile.h"
9#include "chrome/browser/ui/browser.h"
10#include "chrome/test/base/ui_test_utils.h"
11#include "extensions/test/result_catcher.h"
12
13namespace extensions {
14
15// Times out on win syzyasan, http://crbug.com/166026
16#if defined(SYZYASAN)
17#define MAYBE_ContextMenus DISABLED_ContextMenus
18#else
19#define MAYBE_ContextMenus ContextMenus
20#endif
21IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_ContextMenus) {
22  ASSERT_TRUE(RunExtensionTest("context_menus/basics")) << message_;
23  ASSERT_TRUE(RunExtensionTest("context_menus/no_perms")) << message_;
24  ASSERT_TRUE(RunExtensionTest("context_menus/item_ids")) << message_;
25  ASSERT_TRUE(RunExtensionTest("context_menus/event_page")) << message_;
26}
27
28// crbug.com/51436 -- creating context menus from multiple script contexts
29// should work.
30IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContextMenusFromMultipleContexts) {
31  ASSERT_TRUE(test_server()->Start());
32  ASSERT_TRUE(RunExtensionTest("context_menus/add_from_multiple_contexts"))
33      << message_;
34  const extensions::Extension* extension = GetSingleLoadedExtension();
35  ASSERT_TRUE(extension) << message_;
36
37  {
38    // Tell the extension to update the page action state.
39    ResultCatcher catcher;
40    ui_test_utils::NavigateToURL(browser(),
41        extension->GetResourceURL("popup.html"));
42    ASSERT_TRUE(catcher.GetNextResult());
43  }
44
45  {
46    // Tell the extension to update the page action state again.
47    ResultCatcher catcher;
48    ui_test_utils::NavigateToURL(browser(),
49        extension->GetResourceURL("popup2.html"));
50    ASSERT_TRUE(catcher.GetNextResult());
51  }
52}
53
54}  // namespace extensions
55