Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1632)

Unified Diff: chrome/browser/extensions/extension_messages_apitest.cc

Issue 256623008: Mark forwarded user gestures as forwarded, and don't forward already forwarded user gestures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/renderer/extensions/messaging_bindings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_messages_apitest.cc
diff --git a/chrome/browser/extensions/extension_messages_apitest.cc b/chrome/browser/extensions/extension_messages_apitest.cc
index cc1417486e4781737b82e4939b9b65d8c162c554..c683220a06bd25a12fea94737315aa71977f8deb 100644
--- a/chrome/browser/extensions/extension_messages_apitest.cc
+++ b/chrome/browser/extensions/extension_messages_apitest.cc
@@ -929,6 +929,38 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MessagingUserGesture) {
" window.domAutomationController.send('' + response.result);\n"
" });\n"
"});", receiver->id().c_str())));
+
+ // Messges sent from a setTimeout handler should not forward the user gesture
+ // again.
+ EXPECT_EQ(
+ "false",
+ ExecuteScriptInBackgroundPage(
+ sender->id(),
+ base::StringPrintf(
+ "chrome.test.runWithUserGesture(function() {\n"
+ " window.setTimeout(function() {\n"
+ " chrome.runtime.sendMessage('%s', {}, function(response) {\n"
+ " window.domAutomationController.send('' + "
+ " response.result);\n"
+ " });\n"
+ " }, 0);\n"
+ "});",
+ receiver->id().c_str())));
+
+ // The user gesture should not be send back with the reply message, gestures
+ // are only forwarded once.
+ EXPECT_EQ(
+ "false",
+ ExecuteScriptInBackgroundPage(
+ sender->id(),
+ base::StringPrintf(
+ "chrome.test.runWithUserGesture(function() {\n"
+ " chrome.runtime.sendMessage('%s', {}, function(response) {\n"
+ " window.domAutomationController.send('' + "
+ " chrome.test.isProcessingUserGesture());\n"
+ " });\n"
+ "});",
+ receiver->id().c_str())));
}
// Tests that a hosted app on a connectable site doesn't interfere with the
« no previous file with comments | « no previous file | chrome/renderer/extensions/messaging_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698