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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/renderer/extensions/messaging_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 "});", receiver->id().c_str()))); 922 "});", receiver->id().c_str())));
923 923
924 EXPECT_EQ("true", 924 EXPECT_EQ("true",
925 ExecuteScriptInBackgroundPage(sender->id(), 925 ExecuteScriptInBackgroundPage(sender->id(),
926 base::StringPrintf( 926 base::StringPrintf(
927 "chrome.test.runWithUserGesture(function() {\n" 927 "chrome.test.runWithUserGesture(function() {\n"
928 " chrome.runtime.sendMessage('%s', {}, function(response) {\n" 928 " chrome.runtime.sendMessage('%s', {}, function(response) {\n"
929 " window.domAutomationController.send('' + response.result);\n" 929 " window.domAutomationController.send('' + response.result);\n"
930 " });\n" 930 " });\n"
931 "});", receiver->id().c_str()))); 931 "});", receiver->id().c_str())));
932
933 // Messges sent from a setTimeout handler should not forward the user gesture
934 // again.
935 EXPECT_EQ(
936 "false",
937 ExecuteScriptInBackgroundPage(
938 sender->id(),
939 base::StringPrintf(
940 "chrome.test.runWithUserGesture(function() {\n"
941 " window.setTimeout(function() {\n"
942 " chrome.runtime.sendMessage('%s', {}, function(response) {\n"
943 " window.domAutomationController.send('' + "
944 " response.result);\n"
945 " });\n"
946 " }, 0);\n"
947 "});",
948 receiver->id().c_str())));
949
950 // The user gesture should not be send back with the reply message, gestures
951 // are only forwarded once.
952 EXPECT_EQ(
953 "false",
954 ExecuteScriptInBackgroundPage(
955 sender->id(),
956 base::StringPrintf(
957 "chrome.test.runWithUserGesture(function() {\n"
958 " chrome.runtime.sendMessage('%s', {}, function(response) {\n"
959 " window.domAutomationController.send('' + "
960 " chrome.test.isProcessingUserGesture());\n"
961 " });\n"
962 "});",
963 receiver->id().c_str())));
932 } 964 }
933 965
934 // Tests that a hosted app on a connectable site doesn't interfere with the 966 // Tests that a hosted app on a connectable site doesn't interfere with the
935 // connectability of that site. 967 // connectability of that site.
936 IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, HostedAppOnWebsite) { 968 IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, HostedAppOnWebsite) {
937 InitializeTestServer(); 969 InitializeTestServer();
938 970
939 LoadChromiumHostedApp(); 971 LoadChromiumHostedApp();
940 972
941 // The presence of the hosted app shouldn't give the ability to send messages. 973 // The presence of the hosted app shouldn't give the ability to send messages.
(...skipping 23 matching lines...) Expand all
965 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); 997 ui_test_utils::NavigateToURL(browser(), chromium_org_url());
966 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR , 998 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR ,
967 CanConnectAndSendMessagesToMainFrame("invalid")); 999 CanConnectAndSendMessagesToMainFrame("invalid"));
968 } 1000 }
969 1001
970 #endif // !defined(OS_WIN) - http://crbug.com/350517. 1002 #endif // !defined(OS_WIN) - http://crbug.com/350517.
971 1003
972 } // namespace 1004 } // namespace
973 1005
974 }; // namespace extensions 1006 }; // namespace extensions
OLDNEW
« 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