| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/active_tab_permission_granter.h" | 5 #include "chrome/browser/extensions/active_tab_permission_granter.h" |
| 6 #include "chrome/browser/extensions/browser_action_test_util.h" | 6 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 7 #include "chrome/browser/extensions/extension_action.h" | 7 #include "chrome/browser/extensions/extension_action.h" |
| 8 #include "chrome/browser/extensions/extension_action_manager.h" | 8 #include "chrome/browser/extensions/extension_action_manager.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // Activate the shortcut (Ctrl+Shift+F). | 83 // Activate the shortcut (Ctrl+Shift+F). |
| 84 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 84 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 85 browser(), ui::VKEY_F, true, true, false, false)); | 85 browser(), ui::VKEY_F, true, true, false, false)); |
| 86 | 86 |
| 87 // activeTab should now be granted. | 87 // activeTab should now be granted. |
| 88 EXPECT_TRUE(granter->IsGranted(extension)); | 88 EXPECT_TRUE(granter->IsGranted(extension)); |
| 89 | 89 |
| 90 // Verify the command worked. | 90 // Verify the command worked. |
| 91 bool result = false; | 91 bool result = false; |
| 92 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 92 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 93 tab->GetRenderViewHost(), | 93 tab->GetRenderViewHost(), L"", |
| 94 "", | 94 L"setInterval(function(){" |
| 95 "setInterval(function(){" | 95 L" if(document.body.bgColor == 'red'){" |
| 96 " if(document.body.bgColor == 'red'){" | 96 L" window.domAutomationController.send(true)}}, 100)", |
| 97 " window.domAutomationController.send(true)}}, 100)", | |
| 98 &result)); | 97 &result)); |
| 99 ASSERT_TRUE(result); | 98 ASSERT_TRUE(result); |
| 100 | 99 |
| 101 // Activate the shortcut (Ctrl+Shift+Y). | 100 // Activate the shortcut (Ctrl+Shift+Y). |
| 102 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 101 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 103 browser(), ui::VKEY_Y, true, true, false, false)); | 102 browser(), ui::VKEY_Y, true, true, false, false)); |
| 104 | 103 |
| 105 result = false; | 104 result = false; |
| 106 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 105 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 107 tab->GetRenderViewHost(), | 106 tab->GetRenderViewHost(), L"", |
| 108 "", | 107 L"setInterval(function(){" |
| 109 "setInterval(function(){" | 108 L" if(document.body.bgColor == 'blue'){" |
| 110 " if(document.body.bgColor == 'blue'){" | 109 L" window.domAutomationController.send(true)}}, 100)", |
| 111 " window.domAutomationController.send(true)}}, 100)", | |
| 112 &result)); | 110 &result)); |
| 113 ASSERT_TRUE(result); | 111 ASSERT_TRUE(result); |
| 114 } | 112 } |
| 115 | 113 |
| 116 // Flaky on linux and chromeos, http://crbug.com/165825 | 114 // Flaky on linux and chromeos, http://crbug.com/165825 |
| 117 #if defined(OS_MACOSX) || defined(OS_WIN) | 115 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 118 #define MAYBE_PageAction PageAction | 116 #define MAYBE_PageAction PageAction |
| 119 #else | 117 #else |
| 120 #define MAYBE_PageAction DISABLED_PageAction | 118 #define MAYBE_PageAction DISABLED_PageAction |
| 121 #endif | 119 #endif |
| (...skipping 23 matching lines...) Expand all Loading... |
| 145 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); | 143 EXPECT_EQ("Make this page red", action->GetTitle(tab_id)); |
| 146 | 144 |
| 147 // Activate the shortcut (Alt+Shift+F). | 145 // Activate the shortcut (Alt+Shift+F). |
| 148 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( | 146 ASSERT_TRUE(ui_test_utils::SendKeyPressSync( |
| 149 browser(), ui::VKEY_F, false, true, true, false)); | 147 browser(), ui::VKEY_F, false, true, true, false)); |
| 150 | 148 |
| 151 // Verify the command worked (the page action turns the page red). | 149 // Verify the command worked (the page action turns the page red). |
| 152 WebContents* tab = chrome::GetActiveWebContents(browser()); | 150 WebContents* tab = chrome::GetActiveWebContents(browser()); |
| 153 bool result = false; | 151 bool result = false; |
| 154 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( | 152 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 155 tab->GetRenderViewHost(), | 153 tab->GetRenderViewHost(), L"", |
| 156 "", | 154 L"setInterval(function(){" |
| 157 "setInterval(function(){" | 155 L" if(document.body.bgColor == 'red'){" |
| 158 " if(document.body.bgColor == 'red'){" | 156 L" window.domAutomationController.send(true)}}, 100)", |
| 159 " window.domAutomationController.send(true)}}, 100)", | |
| 160 &result)); | 157 &result)); |
| 161 ASSERT_TRUE(result); | 158 ASSERT_TRUE(result); |
| 162 } | 159 } |
| 163 | 160 |
| 164 // Checked-in in a disabled state, because the necessary functionality to | 161 // Checked-in in a disabled state, because the necessary functionality to |
| 165 // automatically verify that the test works hasn't been implemented for the | 162 // automatically verify that the test works hasn't been implemented for the |
| 166 // script badges yet (see http://crbug.com/140016). The test results, can be | 163 // script badges yet (see http://crbug.com/140016). The test results, can be |
| 167 // verified manually by running the test and verifying that the synthesized | 164 // verified manually by running the test and verifying that the synthesized |
| 168 // popup for script badges appear. When bug 140016 has been fixed, the popup | 165 // popup for script badges appear. When bug 140016 has been fixed, the popup |
| 169 // code can signal to the test that the test passed. | 166 // code can signal to the test that the test passed. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 193 | 190 |
| 194 // This test validates that the getAll query API function returns registered | 191 // This test validates that the getAll query API function returns registered |
| 195 // commands as well as synthesized ones and that inactive commands (like the | 192 // commands as well as synthesized ones and that inactive commands (like the |
| 196 // synthesized ones are in nature) have no shortcuts. | 193 // synthesized ones are in nature) have no shortcuts. |
| 197 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { | 194 IN_PROC_BROWSER_TEST_F(CommandsApiTest, SynthesizedCommand) { |
| 198 ASSERT_TRUE(test_server()->Start()); | 195 ASSERT_TRUE(test_server()->Start()); |
| 199 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; | 196 ASSERT_TRUE(RunExtensionTest("keybinding/synthesized")) << message_; |
| 200 } | 197 } |
| 201 | 198 |
| 202 } // extensions | 199 } // extensions |
| OLD | NEW |