| Index: chrome/browser/extensions/extension_keybinding_apitest.cc
 | 
| ===================================================================
 | 
| --- chrome/browser/extensions/extension_keybinding_apitest.cc	(revision 127150)
 | 
| +++ chrome/browser/extensions/extension_keybinding_apitest.cc	(working copy)
 | 
| @@ -4,8 +4,12 @@
 | 
|  
 | 
|  #include "chrome/browser/extensions/extension_apitest.h"
 | 
|  #include "chrome/browser/extensions/browser_action_test_util.h"
 | 
| +#include "chrome/browser/sessions/restore_tab_helper.h"
 | 
|  #include "chrome/browser/ui/browser.h"
 | 
| +#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
 | 
|  #include "chrome/common/chrome_switches.h"
 | 
| +#include "chrome/common/extensions/extension.h"
 | 
| +#include "chrome/common/extensions/extension_action.h"
 | 
|  #include "chrome/test/base/ui_test_utils.h"
 | 
|  #include "content/public/browser/notification_service.h"
 | 
|  #include "content/public/browser/web_contents.h"
 | 
| @@ -24,17 +28,6 @@
 | 
|    BrowserActionTestUtil GetBrowserActionsBar() {
 | 
|      return BrowserActionTestUtil(browser());
 | 
|    }
 | 
| -
 | 
| -  bool OpenPopup(int index) {
 | 
| -    ResultCatcher catcher;
 | 
| -    ui_test_utils::WindowedNotificationObserver popup_observer(
 | 
| -        content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
 | 
| -        content::NotificationService::AllSources());
 | 
| -    GetBrowserActionsBar().Press(index);
 | 
| -    popup_observer.Wait();
 | 
| -    EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
 | 
| -    return GetBrowserActionsBar().HasPopup();
 | 
| -  }
 | 
|  };
 | 
|  
 | 
|  #if !defined(OS_MACOSX)
 | 
| @@ -50,7 +43,7 @@
 | 
|    ui_test_utils::NavigateToURL(browser(),
 | 
|        test_server()->GetURL("files/extensions/test_file.txt"));
 | 
|  
 | 
| -  // Simulate the browser action being clicked (Ctrl+Shift+F).
 | 
| +  // Activate the shortcut (Ctrl+Shift+F).
 | 
|    ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
 | 
|        browser(), ui::VKEY_F, true, true, false, false));
 | 
|  
 | 
| @@ -65,7 +58,7 @@
 | 
|        &result));
 | 
|    ASSERT_TRUE(result);
 | 
|  
 | 
| -  // Simulate the event being sent (Ctrl+Shift+Y).
 | 
| +  // Activate the shortcut (Ctrl+Shift+Y).
 | 
|    ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
 | 
|        browser(), ui::VKEY_Y, true, true, false, false));
 | 
|  
 | 
| @@ -78,4 +71,44 @@
 | 
|        &result));
 | 
|    ASSERT_TRUE(result);
 | 
|  }
 | 
| +
 | 
| +IN_PROC_BROWSER_TEST_F(KeybindingApiTest, PageAction) {
 | 
| +  ASSERT_TRUE(test_server()->Start());
 | 
| +  ASSERT_TRUE(RunExtensionTest("keybinding/page_action")) << message_;
 | 
| +  const Extension* extension = GetSingleLoadedExtension();
 | 
| +  ASSERT_TRUE(extension) << message_;
 | 
| +
 | 
| +  {
 | 
| +    // Load a page, the extension will detect the navigation and request to show
 | 
| +    // the page action icon.
 | 
| +    ResultCatcher catcher;
 | 
| +    ui_test_utils::NavigateToURL(browser(),
 | 
| +        test_server()->GetURL("files/extensions/test_file.txt"));
 | 
| +    ASSERT_TRUE(catcher.GetNextResult());
 | 
| +  }
 | 
| +
 | 
| +  // Make sure it appears and is the right one.
 | 
| +  ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
 | 
| +  int tab_id = browser()->GetSelectedTabContentsWrapper()->
 | 
| +      restore_tab_helper()->session_id().id();
 | 
| +  ExtensionAction* action = extension->page_action();
 | 
| +  ASSERT_TRUE(action);
 | 
| +  EXPECT_EQ("Make this page red", action->GetTitle(tab_id));
 | 
| +
 | 
| +  // Activate the shortcut (Ctrl+Shift+F).
 | 
| +  ASSERT_TRUE(ui_test_utils::SendKeyPressSync(
 | 
| +      browser(), ui::VKEY_F, true, true, false, false));
 | 
| +
 | 
| +  // Verify the command worked (the page action turns the page red).
 | 
| +  WebContents* tab = browser()->GetSelectedWebContents();
 | 
| +  bool result = false;
 | 
| +  ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
 | 
| +      tab->GetRenderViewHost(), L"",
 | 
| +      L"setInterval(function(){"
 | 
| +      L"  if(document.body.bgColor == 'red'){"
 | 
| +      L"    window.domAutomationController.send(true)}}, 100)",
 | 
| +      &result));
 | 
| +  ASSERT_TRUE(result);
 | 
| +}
 | 
| +
 | 
|  #endif  // !OS_MACOSX
 | 
| 
 |