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 "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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 "});", receiver->id().c_str()))); | 1004 "});", receiver->id().c_str()))); |
1005 | 1005 |
1006 EXPECT_EQ("true", | 1006 EXPECT_EQ("true", |
1007 ExecuteScriptInBackgroundPage(sender->id(), | 1007 ExecuteScriptInBackgroundPage(sender->id(), |
1008 base::StringPrintf( | 1008 base::StringPrintf( |
1009 "chrome.test.runWithUserGesture(function() {\n" | 1009 "chrome.test.runWithUserGesture(function() {\n" |
1010 " chrome.runtime.sendMessage('%s', {}, function(response) {\n" | 1010 " chrome.runtime.sendMessage('%s', {}, function(response) {\n" |
1011 " window.domAutomationController.send('' + response.result);\n" | 1011 " window.domAutomationController.send('' + response.result);\n" |
1012 " });\n" | 1012 " });\n" |
1013 "});", receiver->id().c_str()))); | 1013 "});", receiver->id().c_str()))); |
1014 | |
1015 // Messges sent from a setTimeout handler should not forward the user gesture | |
1016 // again. | |
1017 EXPECT_EQ( | |
1018 "false", | |
1019 ExecuteScriptInBackgroundPage( | |
1020 sender->id(), | |
1021 base::StringPrintf( | |
1022 "chrome.test.runWithUserGesture(function() {\n" | |
1023 " window.setTimeout(function() {\n" | |
1024 " chrome.runtime.sendMessage('%s', {}, function(response) {\n" | |
1025 " window.domAutomationController.send('' + " | |
1026 " response.result);\n" | |
1027 " });\n" | |
1028 " }, 0);\n" | |
1029 "});", | |
1030 receiver->id().c_str()))); | |
1031 | |
1032 // The user gesture should not be send back with the reply message, gestures | |
1033 // are only forwarded once. | |
1034 EXPECT_EQ( | |
1035 "false", | |
1036 ExecuteScriptInBackgroundPage( | |
1037 sender->id(), | |
1038 base::StringPrintf( | |
1039 "chrome.test.runWithUserGesture(function() {\n" | |
1040 " chrome.runtime.sendMessage('%s', {}, function(response) {\n" | |
1041 " window.domAutomationController.send('' + " | |
1042 " chrome.test.isProcessingUserGesture());\n" | |
1043 " });\n" | |
1044 "});", | |
1045 receiver->id().c_str()))); | |
1046 } | 1014 } |
1047 | 1015 |
1048 // Tests that a hosted app on a connectable site doesn't interfere with the | 1016 // Tests that a hosted app on a connectable site doesn't interfere with the |
1049 // connectability of that site. | 1017 // connectability of that site. |
1050 IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, HostedAppOnWebsite) { | 1018 IN_PROC_BROWSER_TEST_F(ExternallyConnectableMessagingTest, HostedAppOnWebsite) { |
1051 InitializeTestServer(); | 1019 InitializeTestServer(); |
1052 | 1020 |
1053 scoped_refptr<const Extension> app = LoadChromiumHostedApp(); | 1021 scoped_refptr<const Extension> app = LoadChromiumHostedApp(); |
1054 | 1022 |
1055 // The presence of the hosted app shouldn't give the ability to send messages. | 1023 // The presence of the hosted app shouldn't give the ability to send messages. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); | 1057 ui_test_utils::NavigateToURL(browser(), chromium_org_url()); |
1090 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, | 1058 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, |
1091 CanConnectAndSendMessagesToMainFrame(invalid)); | 1059 CanConnectAndSendMessagesToMainFrame(invalid)); |
1092 } | 1060 } |
1093 | 1061 |
1094 #endif // !defined(OS_WIN) - http://crbug.com/350517. | 1062 #endif // !defined(OS_WIN) - http://crbug.com/350517. |
1095 | 1063 |
1096 } // namespace | 1064 } // namespace |
1097 | 1065 |
1098 }; // namespace extensions | 1066 }; // namespace extensions |
OLD | NEW |