Changeset 268633 in webkit
- Timestamp:
- Oct 16, 2020 9:21:09 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r268632 r268633 1 2020-10-16 Ryosuke Niwa <rniwa@webkit.org> 2 3 IPC testing API should expose whether a given IPC message has sync reply or not 4 https://bugs.webkit.org/show_bug.cgi?id=217861 5 6 Reviewed by Darin Adler. 7 8 This patch adds IPC.messages.*.isSync to indicate whether a given IPC message has a sync reply or not. 9 10 Test: TestWebKitAPI.IPCTestingAPI.AlertIsSyncMessage 11 12 * Platform/IPC/MessageArgumentDescriptions.h: 13 * Scripts/webkit/messages.py: 14 (generate_js_value_conversion_function): Fixed a typo. 15 (generate_js_argument_descriptions): Ditto. 16 (generate_message_argument_description_implementation): Generate messageIsSync function. 17 * WebProcess/WebPage/IPCTestingAPI.cpp: 18 (WebKit::JSIPC::wrapperClass): Updated the class name to match the implementation. 19 (WebKit::IPCTestingAPI::JSIPC::messages): Added isSync as a boolean property on message description. 20 1 21 2020-10-16 Peng Liu <peng.liu6@apple.com> 2 22 -
trunk/Source/WebKit/Platform/IPC/MessageArgumentDescriptions.h
r268503 r268633 53 53 Optional<Vector<ArgumentDescription>> messageArgumentDescriptions(MessageName); 54 54 Optional<Vector<ArgumentDescription>> messageReplyArgumentDescriptions(MessageName); 55 bool messageIsSync(MessageName); 55 56 56 57 } -
trunk/Source/WebKit/Scripts/webkit/messages.py
r268503 r268633 1065 1065 if receiver.condition: 1066 1066 result.append('#if %s\n' % receiver.condition) 1067 previ sion_message_condition = None1067 previous_message_condition = None 1068 1068 for message in receiver.messages: 1069 1069 if not predicate(message): 1070 1070 continue 1071 if previ sion_message_condition != message.condition:1072 if previ sion_message_condition:1071 if previous_message_condition != message.condition: 1072 if previous_message_condition: 1073 1073 result.append('#endif\n') 1074 1074 if message.condition: 1075 1075 result.append('#if %s\n' % message.condition) 1076 previ sion_message_condition = message.condition1076 previous_message_condition = message.condition 1077 1077 result.append(' case MessageName::%s_%s:\n' % (receiver.name, message.name)) 1078 1078 result.append(' return jsValueForDecodedArguments<Messages::%s::%s::%s>(globalObject, decoder);\n' % (receiver.name, message.name, argument_type)) 1079 if previ sion_message_condition:1079 if previous_message_condition: 1080 1080 result.append('#endif\n') 1081 1081 if receiver.condition: … … 1096 1096 if receiver.condition: 1097 1097 result.append('#if %s\n' % receiver.condition) 1098 previ sion_message_condition = None1098 previous_message_condition = None 1099 1099 for message in receiver.messages: 1100 1100 argument_list = arguments_from_message(message) 1101 1101 if argument_list is None: 1102 1102 continue 1103 if previ sion_message_condition != message.condition:1104 if previ sion_message_condition:1103 if previous_message_condition != message.condition: 1104 if previous_message_condition: 1105 1105 result.append('#endif\n') 1106 1106 if message.condition: 1107 1107 result.append('#if %s\n' % message.condition) 1108 previ sion_message_condition = message.condition1108 previous_message_condition = message.condition 1109 1109 result.append(' case MessageName::%s_%s:\n' % (receiver.name, message.name)) 1110 1110 … … 1126 1126 result.append(' {"%s", "%s", %s, %s},\n' % (argument.name, argument_type, enum_type or 'nullptr', 'true' if is_optional else 'false')) 1127 1127 result.append(' };\n') 1128 if previ sion_message_condition:1128 if previous_message_condition: 1129 1129 result.append('#endif\n') 1130 1130 if receiver.condition: … … 1178 1178 1179 1179 result.append('\n') 1180 result.append('bool messageIsSync(MessageName name)\n') 1181 result.append('{\n') 1182 result.append(' switch (name) {\n') 1183 for receiver in receivers: 1184 has_emit_receiver_condition = False 1185 previous_message_condition = None 1186 for message in receiver.messages: 1187 if message.reply_parameters is None or not message.has_attribute(SYNCHRONOUS_ATTRIBUTE): 1188 continue 1189 if not has_emit_receiver_condition and receiver.condition: 1190 has_emit_receiver_condition = True 1191 result.append('#if %s\n' % receiver.condition) 1192 if previous_message_condition != message.condition: 1193 if previous_message_condition: 1194 result.append('#endif\n') 1195 if message.condition: 1196 result.append('#if %s\n' % message.condition) 1197 previous_message_condition = message.condition 1198 result.append(' case MessageName::%s_%s:\n' % (receiver.name, message.name)) 1199 result.append(' return true;\n') 1200 if previous_message_condition: 1201 result.append('#endif\n') 1202 if has_emit_receiver_condition: 1203 result.append('#endif\n') 1204 result.append(' default:\n') 1205 result.append(' break;\n') 1206 result.append(' }\n') 1207 result.append(' return false;\n') 1208 result.append('}\n') 1209 result.append('\n') 1180 1210 1181 1211 result.append('} // namespace WebKit\n') -
trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp
r268503 r268633 100 100 if (!jsClass) { 101 101 JSClassDefinition definition = kJSClassDefinitionEmpty; 102 definition.className = " UIProcess";102 definition.className = "IPC"; 103 103 definition.parentClass = 0; 104 104 definition.staticValues = staticValues(); … … 773 773 auto nameIdent = JSC::Identifier::fromString(vm, "name"); 774 774 auto replyArgumentsIdent = JSC::Identifier::fromString(vm, "replyArguments"); 775 auto isSyncIdent = JSC::Identifier::fromString(vm, "isSync"); 775 776 for (unsigned i = 0; i < static_cast<unsigned>(IPC::MessageName::Last); ++i) { 776 777 auto name = static_cast<IPC::MessageName>(i); … … 792 793 return JSValueMakeUndefined(context); 793 794 dictionary->putDirect(vm, replyArgumentsIdent, replyArgumentDescriptions); 795 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context)); 796 797 dictionary->putDirect(vm, isSyncIdent, JSC::jsBoolean(messageIsSync(name))); 794 798 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context)); 795 799 -
trunk/Tools/ChangeLog
r268616 r268633 1 2020-10-16 Ryosuke Niwa <rniwa@webkit.org> 2 3 IPC testing API should expose whether a given IPC message has sync reply or not 4 https://bugs.webkit.org/show_bug.cgi?id=217861 5 6 Reviewed by Darin Adler. 7 8 Added a test for IPC.messages.*.isSync using RunJavaScriptAlert. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm: 11 (createWebViewWithIPCTestingAPI): Extracted to share more code between tests. 12 (IPCTestingAPI.AlertIsSyncMessage): Added. 13 1 14 2020-10-16 Antoine Quint <graouts@webkit.org> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm
r268503 r268633 82 82 #if ENABLE(IPC_TESTING_API) 83 83 84 TEST(IPCTestingAPI, CanSendAlert)84 static RetainPtr<TestWKWebView> createWebViewWithIPCTestingAPI() 85 85 { 86 86 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); … … 91 91 } 92 92 } 93 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 93 return adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 94 } 95 96 TEST(IPCTestingAPI, CanSendAlert) 97 { 98 auto webView = createWebViewWithIPCTestingAPI(); 94 99 95 100 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); … … 104 109 } 105 110 111 TEST(IPCTestingAPI, AlertIsSyncMessage) 112 { 113 auto webView = createWebViewWithIPCTestingAPI(); 114 115 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); 116 [webView setUIDelegate:delegate.get()]; 117 118 done = false; 119 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>alert(IPC.messages.WebPageProxy_RunJavaScriptAlert.isSync);</script>"]; 120 TestWebKitAPI::Util::run(&done); 121 122 EXPECT_STREQ([alertMessage UTF8String], "true"); 123 } 124 106 125 TEST(IPCTestingAPI, CanSendInvalidAsyncMessageWithoutTermination) 107 126 { 108 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 109 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) { 110 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) { 111 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature]; 112 break; 113 } 114 } 115 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 127 auto webView = createWebViewWithIPCTestingAPI(); 116 128 117 129 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); … … 129 141 TEST(IPCTestingAPI, CanSendInvalidMessageWithoutTermination) 130 142 { 131 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 132 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) { 133 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) { 134 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature]; 135 break; 136 } 137 } 138 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 143 auto webView = createWebViewWithIPCTestingAPI(); 139 144 140 145 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); … … 152 157 TEST(IPCTestingAPI, DecodesReplyArgumentsForPrompt) 153 158 { 154 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 155 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) { 156 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) { 157 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature]; 158 break; 159 } 160 } 161 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 159 auto webView = createWebViewWithIPCTestingAPI(); 162 160 163 161 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); … … 177 175 TEST(IPCTestingAPI, DecodesReplyArgumentsForAsyncMessage) 178 176 { 179 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 180 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) { 181 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) { 182 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature]; 183 break; 184 } 185 } 186 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 177 auto webView = createWebViewWithIPCTestingAPI(); 187 178 188 179 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); … … 202 193 TEST(IPCTestingAPI, DescribesArguments) 203 194 { 204 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 205 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) { 206 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) { 207 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature]; 208 break; 209 } 210 } 211 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]); 195 auto webView = createWebViewWithIPCTestingAPI(); 212 196 213 197 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);
Note: See TracChangeset
for help on using the changeset viewer.