Changeset 268486 in webkit
- Timestamp:
- Oct 14, 2020 1:52:37 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/CMakeLists.txt
r268431 r268486 429 429 add_custom_command( 430 430 OUTPUT 431 ${WebKit_DERIVED_SOURCES_DIR}/MessageArgumentDescriptions.cpp432 431 ${WebKit_DERIVED_SOURCES_DIR}/MessageNames.cpp 433 432 ${WebKit_DERIVED_SOURCES_DIR}/MessageNames.h -
trunk/Source/WebKit/ChangeLog
r268485 r268486 1 2020-10-14 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r268431 and r268443. 4 https://bugs.webkit.org/show_bug.cgi?id=217728 5 6 Broke debug builds of GTK, WinCairo and Playstation ports 7 8 Reverted changesets: 9 10 "IPC testing JS API should expose a reply and describe the 11 list of arguments for each message" 12 https://bugs.webkit.org/show_bug.cgi?id=217565 13 https://trac.webkit.org/changeset/268431 14 15 "IPC testing JS API should expose a reply and describe the 16 list of arguments for each message" 17 https://bugs.webkit.org/show_bug.cgi?id=217565 18 https://trac.webkit.org/changeset/268443 19 1 20 2020-10-14 Don Olmstead <don.olmstead@sony.com> 2 21 -
trunk/Source/WebKit/DerivedSources-output.xcfilelist
r268431 r268486 69 69 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MediaPlayerPrivateRemoteMessages.h 70 70 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MediaPlayerPrivateRemoteMessagesReplies.h 71 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MessageArgumentDescriptions.cpp72 71 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MessageNames.cpp 73 72 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MessageNames.h -
trunk/Source/WebKit/DerivedSources.make
r268431 r268486 258 258 MESSAGE_REPLIES_FILES := $(addsuffix MessagesReplies.h,$(notdir $(MESSAGE_RECEIVERS))) 259 259 260 GENERATED_MESSAGES_FILES := $(MESSAGE_RECEIVER_FILES) $(MESSAGES_FILES) $(MESSAGE_REPLIES_FILES) MessageNames.h MessageNames.cpp MessageArgumentDescriptions.cpp260 GENERATED_MESSAGES_FILES := $(MESSAGE_RECEIVER_FILES) $(MESSAGES_FILES) $(MESSAGE_REPLIES_FILES) MessageNames.h MessageNames.cpp 261 261 GENERATED_MESSAGES_FILES_AS_PATTERNS := $(subst .,%,$(GENERATED_MESSAGES_FILES)) 262 262 -
trunk/Source/WebKit/Platform/IPC/Decoder.h
r268431 r268486 73 73 static std::unique_ptr<Decoder> unwrapForTesting(Decoder&); 74 74 75 const uint8_t* buffer() const { return m_buffer; }76 75 size_t length() const { return m_bufferEnd - m_buffer; } 77 76 -
trunk/Source/WebKit/Scripts/generate-message-receiver.py
r268431 r268486 35 35 first_arg = True 36 36 second_arg = False 37 receiver_header_files = []38 37 for parameter in argv: 39 38 if first_arg: … … 55 54 implementation_output.write(webkit.messages.generate_message_handler(receiver)) 56 55 57 receiver_message_header = '%sMessages.h' % receiver_name 58 receiver_header_files.append(receiver_message_header) 59 with open(receiver_message_header, "w+") as header_output: 56 with open('%sMessages.h' % receiver_name, "w+") as header_output: 60 57 header_output.write(webkit.messages.generate_messages_header(receiver)) 61 58 … … 69 66 message_names_implementation_output.write(webkit.messages.generate_message_names_implementation(receivers)) 70 67 71 with open('MessageArgumentDescriptions.cpp', "w+") as message_descriptions_implementation_output:72 message_descriptions_implementation_output.write(webkit.messages.generate_message_argument_description_implementation(receivers, receiver_header_files))73 74 68 return 0 75 69 -
trunk/Source/WebKit/Scripts/webkit/messages.py
r268431 r268486 624 624 'WebCore::PasteboardWebContent': ['<WebCore/Pasteboard.h>'], 625 625 'WebCore::PaymentAuthorizationResult': ['<WebCore/ApplePaySessionPaymentRequest.h>'], 626 'WebCore::PaymentMethodUpdate': ['<WebCore/ApplePaySessionPaymentRequest.h>'], 626 627 'WebCore::PlatformTextTrackData': ['<WebCore/PlatformTextTrack.h>'], 627 628 'WebCore::PluginInfo': ['<WebCore/PluginData.h>'], … … 687 688 'struct WebKit::WebUserStyleSheetData': ['"WebUserContentControllerDataTypes.h"'], 688 689 'struct WebKit::WebScriptMessageHandlerData': ['"WebUserContentControllerDataTypes.h"'], 689 'webrtc::WebKitEncodedFrameInfo': ['<webrtc/sdk/WebKit/WebKitEncoder.h>' , '<WebCore/LibWebRTCEnumTraits.h>'],690 'webrtc::WebKitEncodedFrameInfo': ['<webrtc/sdk/WebKit/WebKitEncoder.h>'], 690 691 'webrtc::WebKitRTPFragmentationHeader': ['<webrtc/sdk/WebKit/WebKitEncoder.h>'], 691 692 } … … 714 715 715 716 716 def collect_header_conditions_for_receiver(receiver, header_conditions): 717 def generate_message_handler(receiver): 718 header_conditions = { 719 '"%s"' % messages_header_filename(receiver): [None], 720 '"HandleMessage.h"': [None], 721 '"Decoder.h"': [None], 722 } 723 717 724 type_conditions = {} 718 725 for parameter in receiver.iterparameters(): … … 757 764 header_conditions[header].append(message.condition) 758 765 759 return header_conditions760 761 762 def generate_header_includes_from_conditions(header_conditions):763 766 result = [] 767 768 result.append(_license_header) 769 result.append('#include "config.h"\n') 770 result.append('\n') 771 772 if receiver.condition: 773 result.append('#if %s\n\n' % receiver.condition) 774 775 result.append('#include "%s.h"\n\n' % receiver.name) 764 776 for header in sorted(header_conditions): 765 777 if header_conditions[header] and not None in header_conditions[header]: … … 769 781 else: 770 782 result += ['#include %s\n' % header] 771 return result772 773 774 def generate_message_handler(receiver):775 header_conditions = {776 '"%s"' % messages_header_filename(receiver): [None],777 '"HandleMessage.h"': [None],778 '"Decoder.h"': [None],779 }780 781 collect_header_conditions_for_receiver(receiver, header_conditions)782 783 result = []784 785 result.append(_license_header)786 result.append('#include "config.h"\n')787 result.append('\n')788 789 if receiver.condition:790 result.append('#if %s\n\n' % receiver.condition)791 792 result.append('#include "%s.h"\n\n' % receiver.name)793 result += generate_header_includes_from_conditions(header_conditions)794 783 result.append('\n') 795 784 … … 1056 1045 result.append('} // namespace IPC\n') 1057 1046 return ''.join(result) 1058 1059 1060 def generate_js_value_conversion_function(result, receivers, function_name, argument_type, predicate=lambda message: True):1061 result.append('Optional<JSC::JSValue> %s(JSC::JSGlobalObject* globalObject, MessageName name, Decoder& decoder)\n' % function_name)1062 result.append('{\n')1063 result.append(' switch (name) {\n')1064 for receiver in receivers:1065 if receiver.condition:1066 result.append('#if %s\n' % receiver.condition)1067 prevision_message_condition = None1068 for message in receiver.messages:1069 if not predicate(message):1070 continue1071 if prevision_message_condition != message.condition:1072 if prevision_message_condition:1073 result.append('#endif\n')1074 if message.condition:1075 result.append('#if %s\n' % message.condition)1076 prevision_message_condition = message.condition1077 result.append(' case MessageName::%s_%s:\n' % (receiver.name, message.name))1078 result.append(' return jsValueForDecodedArguments<Messages::%s::%s::%s>(globalObject, decoder);\n' % (receiver.name, message.name, argument_type))1079 if prevision_message_condition:1080 result.append('#endif\n')1081 if receiver.condition:1082 result.append('#endif\n')1083 result.append(' default:\n')1084 result.append(' break;\n')1085 result.append(' }\n')1086 result.append(' return WTF::nullopt;\n')1087 result.append('}\n')1088 1089 1090 def generate_js_argument_descriptions(receivers, function_name, arguments_from_message):1091 result = []1092 result.append('Optional<Vector<ArgumentDescription>> %s(MessageName name)\n' % function_name)1093 result.append('{\n')1094 result.append(' switch (name) {\n')1095 for receiver in receivers:1096 if receiver.condition:1097 result.append('#if %s\n' % receiver.condition)1098 prevision_message_condition = None1099 for message in receiver.messages:1100 argument_list = arguments_from_message(message)1101 if argument_list is None:1102 continue1103 if prevision_message_condition != message.condition:1104 if prevision_message_condition:1105 result.append('#endif\n')1106 if message.condition:1107 result.append('#if %s\n' % message.condition)1108 prevision_message_condition = message.condition1109 result.append(' case MessageName::%s_%s:\n' % (receiver.name, message.name))1110 1111 if not len(argument_list):1112 result.append(' return Vector<ArgumentDescription> { };\n')1113 continue1114 1115 result.append(' return Vector<ArgumentDescription> {\n')1116 for argument in argument_list:1117 argument_type = argument.type1118 enum_type = None1119 is_optional = False1120 if argument.kind.startswith('enum:'):1121 enum_type = '"%s"' % argument_type1122 argument_type = argument.kind[5:]1123 if argument_type.startswith('Optional<') and argument_type.endswith('>'):1124 argument_type = argument_type[9:-1]1125 is_optional = True1126 result.append(' {"%s", "%s", %s, %s},\n' % (argument.name, argument_type, enum_type or 'nullptr', 'true' if is_optional else 'false'))1127 result.append(' };\n')1128 if prevision_message_condition:1129 result.append('#endif\n')1130 if receiver.condition:1131 result.append('#endif\n')1132 result.append(' default:\n')1133 result.append(' break;\n')1134 result.append(' }\n')1135 result.append(' return WTF::nullopt;\n')1136 result.append('}\n')1137 return result1138 1139 1140 def generate_message_argument_description_implementation(receivers, receiver_headers):1141 header_conditions = {1142 '"JSIPCBinding.h"': [None]1143 }1144 for receiver in receivers:1145 header_conditions['"%s"' % messages_header_filename(receiver)] = [None]1146 collect_header_conditions_for_receiver(receiver, header_conditions)1147 1148 result = []1149 result.append(_license_header)1150 result.append('#include "config.h"\n')1151 result.append('#include "MessageArgumentDescriptions.h"\n')1152 result.append('\n')1153 result.append('#if ENABLE(IPC_TESTING_API)\n')1154 result.append('\n')1155 result += generate_header_includes_from_conditions(header_conditions)1156 result.append('\n')1157 1158 for header in receiver_headers:1159 result.append('#include "%s"\n' % (header))1160 1161 result.append('\n')1162 result.append('namespace IPC {\n')1163 result.append('\n')1164 1165 generate_js_value_conversion_function(result, receivers, 'jsValueForArguments', 'Arguments')1166 1167 result.append('\n')1168 1169 generate_js_value_conversion_function(result, receivers, 'jsValueForReplyArguments', 'ReplyArguments', lambda message: message.reply_parameters is not None and (message.has_attribute(SYNCHRONOUS_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE)))1170 1171 result.append('\n')1172 1173 result += generate_js_argument_descriptions(receivers, 'messageArgumentDescriptions', lambda message: message.parameters)1174 1175 result.append('\n')1176 1177 result += generate_js_argument_descriptions(receivers, 'messageReplyArgumentDescriptions', lambda message: message.reply_parameters if message.has_attribute(SYNCHRONOUS_ATTRIBUTE) or message.has_attribute(ASYNC_ATTRIBUTE) else None)1178 1179 result.append('\n')1180 1181 result.append('} // namespace WebKit\n')1182 result.append('\n')1183 result.append('#endif\n')1184 return ''.join(result) -
trunk/Source/WebKit/Shared/ApplePay/ApplePayPaymentSetupFeaturesWebKit.h
r268431 r268486 28 28 #if ENABLE(APPLE_PAY) 29 29 30 OBJC_CLASS NSArray;31 30 OBJC_CLASS PKPaymentSetupFeature; 32 31 -
trunk/Source/WebKit/SourcesCocoa.txt
r268458 r268486 659 659 LibWebRTCCodecsProxyMessageReceiver.cpp 660 660 LibWebRTCCodecsMessageReceiver.cpp 661 MessageArgumentDescriptions.cpp @no-unify662 661 MessageNames.cpp 663 662 RemoteAudioDestinationManagerMessageReceiver.cpp -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r268458 r268486 881 881 WebProcessPool::didReceiveInvalidMessage(messageName); 882 882 883 #if ENABLE(IPC_TESTING_API)884 if (processPool().defaultPageGroup().preferences().store().getBoolValueForKey(WebPreferencesKey::ipcTestingAPIEnabledKey()))885 return;886 #endif887 888 883 // Terminate the WebContent process. 889 884 terminate(); -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r268458 r268486 1424 1424 9B1229CE23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B1229CC23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp */; }; 1425 1425 9B1229D223FF2BCC008CA751 /* RemoteAudioDestinationIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */; }; 1426 9B47908D25314D8300EC11AB /* MessageArgumentDescriptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B47908C25314D8300EC11AB /* MessageArgumentDescriptions.h */; };1427 9B47908F253151CC00EC11AB /* JSIPCBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B47908E253151CC00EC11AB /* JSIPCBinding.h */; };1428 9B4790912531563200EC11AB /* MessageArgumentDescriptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B4790902531563200EC11AB /* MessageArgumentDescriptions.cpp */; };1429 1426 9B5499AD2362A6F900DF8BA5 /* _WKTextManipulationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5499AC2362A6F600DF8BA5 /* _WKTextManipulationConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1430 1427 9B5499B22362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5499B02362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4529 4526 9B1229CF23FF2814008CA751 /* RemoteAudioDestinationManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteAudioDestinationManager.messages.in; sourceTree = "<group>"; }; 4530 4527 9B1229D023FF2A5E008CA751 /* RemoteAudioDestinationIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioDestinationIdentifier.h; sourceTree = "<group>"; }; 4531 9B47908C25314D8300EC11AB /* MessageArgumentDescriptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageArgumentDescriptions.h; sourceTree = "<group>"; };4532 9B47908E253151CC00EC11AB /* JSIPCBinding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSIPCBinding.h; sourceTree = "<group>"; };4533 9B4790902531563200EC11AB /* MessageArgumentDescriptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MessageArgumentDescriptions.cpp; path = MessageArgumentDescriptions.cpp; sourceTree = "<group>"; };4534 4528 9B5499AC2362A6F600DF8BA5 /* _WKTextManipulationConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKTextManipulationConfiguration.h; sourceTree = "<group>"; }; 4535 4529 9B5499AE2362A7A700DF8BA5 /* _WKTextManipulationConfiguration.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationConfiguration.mm; sourceTree = "<group>"; }; … … 6465 6459 C0CE72AC1247E78D00BC0EC4 /* HandleMessage.h */, 6466 6460 1C9AF36124134D2300D3EC02 /* ImageDataReference.h */, 6467 9B47908E253151CC00EC11AB /* JSIPCBinding.h */,6468 9B47908C25314D8300EC11AB /* MessageArgumentDescriptions.h */,6469 6461 1AC4C82816B876A90069DCCD /* MessageFlags.h */, 6470 6462 1A3EED11161A53D600AEB4F5 /* MessageReceiver.h */, … … 10090 10082 07E19EF923D401F00094FFB4 /* MediaPlayerPrivateRemoteMessages.h */, 10091 10083 07E19EFA23D401F00094FFB4 /* MediaPlayerPrivateRemoteMessagesReplies.h */, 10092 9B4790902531563200EC11AB /* MessageArgumentDescriptions.cpp */,10093 10084 51DD9F2616367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp */, 10094 10085 51DD9F2716367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h */, … … 10944 10935 C5BCE5DF1C50766A00CDE3FA /* InteractionInformationAtPosition.h in Headers */, 10945 10936 2D4D2C811DF60BF3002EB10C /* InteractionInformationRequest.h in Headers */, 10946 9B47908F253151CC00EC11AB /* JSIPCBinding.h in Headers */,10947 10937 1AE49A4911FFA8CE0048B464 /* JSNPMethod.h in Headers */, 10948 10938 1AE4987811FF7FAA0048B464 /* JSNPObject.h in Headers */, … … 10981 10971 07E19EFD23D401F10094FFB4 /* MediaPlayerPrivateRemoteMessagesReplies.h in Headers */, 10982 10972 51933DEF1965EB31008AC3EA /* MenuUtilities.h in Headers */, 10983 9B47908D25314D8300EC11AB /* MessageArgumentDescriptions.h in Headers */,10984 10973 1AC4C82916B876A90069DCCD /* MessageFlags.h in Headers */, 10985 10974 1A3EED12161A53D600AEB4F5 /* MessageReceiver.h in Headers */, … … 12852 12841 2D92A779212B6A6100F493FD /* Logging.cpp in Sources */, 12853 12842 07E19EFB23D401F10094FFB4 /* MediaPlayerPrivateRemoteMessageReceiver.cpp in Sources */, 12854 9B4790912531563200EC11AB /* MessageArgumentDescriptions.cpp in Sources */,12855 12843 2D92A781212B6A7100F493FD /* MessageReceiverMap.cpp in Sources */, 12856 12844 2D92A782212B6A7100F493FD /* MessageSender.cpp in Sources */, -
trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp
r268431 r268486 32 32 #include "FrameInfoData.h" 33 33 #include "GPUProcessConnection.h" 34 #include "Message ArgumentDescriptions.h"34 #include "MessageNames.h" 35 35 #include "NetworkProcessConnection.h" 36 36 #include "WebCoreArgumentCoders.h" … … 84 84 static JSValueRef visitedLinkStoreID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); 85 85 static JSValueRef webPageProxyID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); 86 static JSValueRef sessionID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); 87 static JSValueRef pageID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); 88 static JSValueRef frameID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); 86 static JSValueRef frameIdentifier(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); 89 87 static JSValueRef retrieveID(JSContextRef, JSObjectRef thisObject, JSValueRef* exception, const WTF::Function<uint64_t(JSIPC&)>&); 90 88 … … 147 145 static const JSStaticValue values[] = { 148 146 { "visitedLinkStoreID", visitedLinkStoreID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 149 { "frameID", frameID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },150 { "pageID", pageID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },151 { "sessionID", sessionID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },152 147 { "webPageProxyID", webPageProxyID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 148 { "frameIdentifier", frameIdentifier, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 153 149 { "messages", messages, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 154 150 { 0, 0, 0, 0 } … … 242 238 } 243 239 244 template<typename PointType> bool encodePointType(IPC::Encoder& encoder, JSC::JSGlobalObject* globalObject, JSC::JSObject* jsObject, JSC::CatchScope& scope)240 template<typename RectType> bool encodeRectType(IPC::Encoder& encoder, JSC::JSGlobalObject* globalObject, JSC::JSObject* jsObject) 245 241 { 246 242 auto& vm = globalObject->vm(); 247 243 auto jsX = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "x"_s)); 248 if ( scope.exception() ||!jsX.isNumber())244 if (!jsX.isNumber()) 249 245 return false; 250 246 auto jsY = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "y"_s)); 251 if (scope.exception() || !jsY.isNumber()) 252 return false; 253 encoder << PointType(jsX.asNumber(), jsY.asNumber()); 254 return true; 255 } 256 257 template<typename RectType> bool encodeRectType(IPC::Encoder& encoder, JSC::JSGlobalObject* globalObject, JSC::JSObject* jsObject, JSC::CatchScope& scope) 258 { 259 auto& vm = globalObject->vm(); 260 auto jsX = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "x"_s)); 261 if (scope.exception() || !jsX.isNumber()) 262 return false; 263 auto jsY = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "y"_s)); 264 if (scope.exception() || !jsY.isNumber()) 247 if (!jsY.isNumber()) 265 248 return false; 266 249 auto jsWidth = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "width"_s)); 267 if ( scope.exception() ||!jsWidth.isNumber())250 if (!jsWidth.isNumber()) 268 251 return false; 269 252 auto jsHeight = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "height"_s)); 270 if ( scope.exception() ||!jsHeight.isNumber())253 if (!jsHeight.isNumber()) 271 254 return false; 272 255 encoder << RectType(jsX.asNumber(), jsY.asNumber(), jsWidth.asNumber(), jsHeight.asNumber()); … … 274 257 } 275 258 276 template<typename IntegralType> bool encode NumericType(IPC::Encoder& encoder, JSC::JSValue jsValue)259 template<typename IntegralType> bool encodeIntegralType(IPC::Encoder& encoder, JSC::JSValue jsValue) 277 260 { 278 261 if (jsValue.isBigInt()) { … … 358 341 return false; 359 342 360 if (type == "Int Point") {361 if (!encode PointType<WebCore::IntPoint>(encoder, globalObject, jsObject, scope)) {362 *exception = createTypeError(context, "Failed to convert Int Point"_s);343 if (type == "IntRect") { 344 if (!encodeRectType<WebCore::IntRect>(encoder, globalObject, jsObject)) { 345 *exception = createTypeError(context, "Failed to convert IntRect"_s); 363 346 return false; 364 347 } … … 366 349 } 367 350 368 if (type == "FloatPoint") {369 if (!encodePointType<WebCore::IntPoint>(encoder, globalObject, jsObject, scope)) {370 *exception = createTypeError(context, "Failed to convert FloatPoint"_s);371 return false;372 }373 return true;374 }375 376 if (type == "IntRect") {377 if (!encodeRectType<WebCore::IntRect>(encoder, globalObject, jsObject, scope)) {378 *exception = createTypeError(context, "Failed to convert IntRect"_s);379 return false;380 }381 return true;382 }383 384 351 if (type == "FloatRect") { 385 if (!encodeRectType<WebCore::FloatRect>(encoder, globalObject, jsObject , scope)) {352 if (!encodeRectType<WebCore::FloatRect>(encoder, globalObject, jsObject)) { 386 353 *exception = createTypeError(context, "Failed to convert FloatRect"_s); 387 354 return false; … … 416 383 } 417 384 418 if (type == "URL") {419 if (jsValue.isUndefinedOrNull()) {420 encoder << URL { };421 return true;422 }423 auto string = jsValue.toWTFString(globalObject);424 if (scope.exception())425 return false;426 encoder << URL { URL { }, string };427 return true;428 }429 430 if (type == "RegistrableDomain") {431 if (jsValue.isUndefinedOrNull()) {432 encoder << RegistrableDomain { };433 return true;434 }435 auto string = jsValue.toWTFString(globalObject);436 if (scope.exception())437 return false;438 encoder << RegistrableDomain { URL { URL { }, string } };439 return true;440 }441 442 385 if (type == "RGBA") { 443 386 if (!jsValue.isNumber()) { … … 450 393 } 451 394 452 bool numericResult;395 bool integralResult; 453 396 if (type == "bool") 454 numericResult = encodeNumericType<bool>(encoder, jsValue); 455 else if (type == "double") 456 numericResult = encodeNumericType<double>(encoder, jsValue); 457 else if (type == "float") 458 numericResult = encodeNumericType<float>(encoder, jsValue); 397 integralResult = encodeIntegralType<bool>(encoder, jsValue); 459 398 else if (type == "int8_t") 460 numericResult = encodeNumericType<int8_t>(encoder, jsValue);399 integralResult = encodeIntegralType<int8_t>(encoder, jsValue); 461 400 else if (type == "int16_t") 462 numericResult = encodeNumericType<int16_t>(encoder, jsValue);401 integralResult = encodeIntegralType<int16_t>(encoder, jsValue); 463 402 else if (type == "int32_t") 464 numericResult = encodeNumericType<int32_t>(encoder, jsValue);403 integralResult = encodeIntegralType<int32_t>(encoder, jsValue); 465 404 else if (type == "int64_t") 466 numericResult = encodeNumericType<int64_t>(encoder, jsValue);405 integralResult = encodeIntegralType<int64_t>(encoder, jsValue); 467 406 else if (type == "uint8_t") 468 numericResult = encodeNumericType<uint8_t>(encoder, jsValue);407 integralResult = encodeIntegralType<uint8_t>(encoder, jsValue); 469 408 else if (type == "uint16_t") 470 numericResult = encodeNumericType<uint16_t>(encoder, jsValue);409 integralResult = encodeIntegralType<uint16_t>(encoder, jsValue); 471 410 else if (type == "uint32_t") 472 numericResult = encodeNumericType<uint32_t>(encoder, jsValue);411 integralResult = encodeIntegralType<uint32_t>(encoder, jsValue); 473 412 else if (type == "uint64_t") 474 numericResult = encodeNumericType<uint64_t>(encoder, jsValue);413 integralResult = encodeIntegralType<uint64_t>(encoder, jsValue); 475 414 else { 476 415 *exception = createTypeError(context, "Bad type name"_s); 477 416 return false; 478 417 } 479 if (! numericResult) {480 *exception = createTypeError(context, "Failed to encode a number"_s);418 if (!integralResult) { 419 *exception = createTypeError(context, "Failed to encode an integer"_s); 481 420 return false; 482 421 } 483 422 return true; 484 }485 486 487 static JSC::JSObject* jsResultFromReplyDecoder(JSC::JSGlobalObject* globalObject, IPC::MessageName messageName, IPC::Decoder& decoder)488 {489 auto& vm = globalObject->vm();490 auto scope = DECLARE_THROW_SCOPE(vm);491 492 auto arrayBuffer = JSC::ArrayBuffer::create(decoder.buffer(), decoder.length());493 JSC::JSArrayBuffer* jsArrayBuffer = nullptr;494 if (auto* structure = globalObject->arrayBufferStructure(arrayBuffer->sharingMode()))495 jsArrayBuffer = JSC::JSArrayBuffer::create(vm, structure, WTFMove(arrayBuffer));496 if (!jsArrayBuffer) {497 throwException(globalObject, scope, JSC::createTypeError(globalObject, "Failed to create the array buffer for the reply"_s));498 return nullptr;499 }500 501 auto jsReplyArguments = jsValueForReplyArguments(globalObject, messageName, decoder);502 if (!jsReplyArguments) {503 throwException(globalObject, scope, JSC::createTypeError(globalObject, "Failed to decode the reply"_s));504 return nullptr;505 }506 507 if (jsReplyArguments->isEmpty()) {508 throwException(globalObject, scope, JSC::createTypeError(globalObject, "Failed to convert the reply to an JS array"_s));509 return nullptr;510 }511 512 auto catchScope = DECLARE_CATCH_SCOPE(vm);513 JSC::JSObject* jsResult = constructEmptyObject(globalObject, globalObject->objectPrototype());514 RETURN_IF_EXCEPTION(catchScope, nullptr);515 516 jsResult->putDirect(vm, vm.propertyNames->arguments, *jsReplyArguments);517 RETURN_IF_EXCEPTION(catchScope, nullptr);518 519 jsResult->putDirect(vm, JSC::Identifier::fromString(vm, "buffer"), jsArrayBuffer);520 RETURN_IF_EXCEPTION(catchScope, nullptr);521 522 return jsResult;523 423 } 524 424 … … 529 429 auto jsIPC = makeRefPtr(toWrapped(context, thisObject)); 530 430 if (!jsIPC) { 531 *exception = createTypeError(context, "Wrong type"_s);431 *exception = toRef(JSC::createTypeError(toJS(context), "Wrong type"_s)); 532 432 return JSValueMakeUndefined(context); 533 433 } 534 434 535 435 if (argumentCount < 3) { 536 *exception = createTypeError(context, "Must specify the target process, desination ID, and message ID as the first three arguments"_s);436 *exception = toRef(JSC::createTypeError(toJS(context), "Must specify the target process, desination ID, and message ID as the first three arguments"_s)); 537 437 return JSValueMakeUndefined(context); 538 438 } … … 550 450 return JSValueMakeUndefined(context); 551 451 552 auto messageName = static_cast<IPC::MessageName>(*messageID); 553 auto encoder = makeUnique<IPC::Encoder>(messageName, *destinationID); 554 555 JSValueRef returnValue = JSValueMakeUndefined(context); 556 557 bool hasReply = !!messageReplyArgumentDescriptions(messageName); 558 if (hasReply) { 559 uint64_t listenerID = IPC::nextAsyncReplyHandlerID(); 560 encoder->encode(listenerID); 561 562 JSObjectRef resolve; 563 JSObjectRef reject; 564 ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN 565 returnValue = JSObjectMakeDeferredPromise(context, &resolve, &reject, exception); 566 ALLOW_NEW_API_WITHOUT_GUARDS_END 567 if (!returnValue) 568 return JSValueMakeUndefined(context); 569 570 JSGlobalContextRetain(JSContextGetGlobalContext(context)); 571 JSValueProtect(context, resolve); 572 JSValueProtect(context, reject); 573 IPC::addAsyncReplyHandler(*connection, listenerID, [messageName, context, resolve, reject](IPC::Decoder* replyDecoder) { 574 auto* globalObject = toJS(context); 575 auto& vm = globalObject->vm(); 576 JSC::JSLockHolder lock(vm); 577 578 auto scope = DECLARE_CATCH_SCOPE(vm); 579 auto* jsResult = jsResultFromReplyDecoder(globalObject, messageName, *replyDecoder); 580 if (auto* exception = scope.exception()) { 581 scope.clearException(); 582 JSValueRef arguments[] = { toRef(globalObject, exception) }; 583 JSObjectCallAsFunction(context, reject, reject, 1, arguments, nullptr); 584 } else { 585 JSValueRef arguments[] = { toRef(globalObject, jsResult) }; 586 JSObjectCallAsFunction(context, resolve, resolve, 1, arguments, nullptr); 587 } 588 589 JSValueUnprotect(context, reject); 590 JSValueUnprotect(context, resolve); 591 JSGlobalContextRelease(JSContextGetGlobalContext(context)); 592 }); 593 } 452 auto encoder = makeUnique<IPC::Encoder>(static_cast<IPC::MessageName>(static_cast<uint64_t>(*messageID)), *destinationID); 594 453 595 454 if (argumentCount > 3) { … … 602 461 connection->sendMessage(WTFMove(encoder), { }); 603 462 604 return returnValue;463 return JSValueMakeUndefined(context); 605 464 } 606 465 … … 611 470 auto jsIPC = makeRefPtr(toWrapped(context, thisObject)); 612 471 if (!jsIPC) { 613 *exception = createTypeError(context, "Wrong type"_s);472 *exception = toRef(JSC::createTypeError(toJS(context), "Wrong type"_s)); 614 473 return JSValueMakeUndefined(context); 615 474 } 616 475 617 476 if (argumentCount < 4) { 618 *exception = createTypeError(context, "Must specify the target process, desination ID, and message ID as the first three arguments"_s);477 *exception = toRef(JSC::createTypeError(toJS(context), "Must specify the target process, desination ID, message ID, and timeout as the first four arguments"_s)); 619 478 return JSValueMakeUndefined(context); 620 479 } … … 636 495 auto jsValue = toJS(globalObject, arguments[3]); 637 496 if (!jsValue.isNumber()) { 638 *exception = createTypeError(context, "Timeout must be a number"_s);497 *exception = toRef(JSC::createTypeError(globalObject, "timeout must be a number"_s)); 639 498 return JSValueMakeUndefined(context); 640 499 } 641 500 timeout = Seconds { jsValue.asNumber() }; 642 501 } 643 502 644 503 // FIXME: Support the options. 645 504 646 505 uint64_t syncRequestID = 0; 647 auto messageName = static_cast<IPC::MessageName>(*messageID); 648 auto encoder = connection->createSyncMessageEncoder(messageName, *destinationID, syncRequestID); 506 auto encoder = connection->createSyncMessageEncoder(static_cast<IPC::MessageName>(static_cast<uint64_t>(*messageID)), *destinationID, syncRequestID); 649 507 650 508 if (argumentCount > 4) { … … 653 511 } 654 512 655 if (auto replyDecoder = connection->sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, { })) { 656 auto scope = DECLARE_CATCH_SCOPE(globalObject->vm()); 657 auto* jsResult = jsResultFromReplyDecoder(globalObject, messageName, *replyDecoder); 658 if (scope.exception()) { 659 *exception = toRef(globalObject, scope.exception()); 660 scope.clearException(); 661 return JSValueMakeUndefined(context); 662 } 663 return toRef(globalObject, jsResult); 664 } 513 auto replyDecoder = connection->sendSyncMessage(syncRequestID, WTFMove(encoder), timeout, { }); 514 // FIXME: Decode the reply. 665 515 666 516 return JSValueMakeUndefined(context); … … 675 525 } 676 526 677 JSValueRef JSIPC::frameID(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception) 527 JSValueRef JSIPC::webPageProxyID(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception) 528 { 529 return retrieveID(context, thisObject, exception, [](JSIPC& wrapped) { 530 return wrapped.m_webPage->webPageProxyID(); 531 }); 532 } 533 534 JSValueRef JSIPC::frameIdentifier(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception) 678 535 { 679 536 return retrieveID(context, thisObject, exception, [](JSIPC& wrapped) { … … 682 539 } 683 540 684 JSValueRef JSIPC::pageID(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)685 {686 return retrieveID(context, thisObject, exception, [](JSIPC& wrapped) {687 return wrapped.m_webPage->identifier().toUInt64();688 });689 }690 691 JSValueRef JSIPC::sessionID(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)692 {693 return retrieveID(context, thisObject, exception, [](JSIPC& wrapped) {694 return wrapped.m_webPage->sessionID().toUInt64();695 });696 }697 698 JSValueRef JSIPC::webPageProxyID(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)699 {700 return retrieveID(context, thisObject, exception, [](JSIPC& wrapped) {701 return wrapped.m_webPage->webPageProxyID();702 });703 }704 705 541 JSValueRef JSIPC::retrieveID(JSContextRef context, JSObjectRef thisObject, JSValueRef* exception, const WTF::Function<uint64_t(JSIPC&)>& callback) 706 542 { … … 720 556 } 721 557 722 static JSC::JSValue createJSArrayForArgumentDescriptions(JSC::JSGlobalObject* globalObject, Optional<Vector<IPC::ArgumentDescription>>&& argumentDescriptions)723 {724 if (!argumentDescriptions)725 return JSC::jsNull();726 727 auto& vm = globalObject->vm();728 auto scope = DECLARE_CATCH_SCOPE(vm);729 JSC::JSObject* argumentsArray = JSC::constructEmptyArray(globalObject, nullptr);730 RETURN_IF_EXCEPTION(scope, JSC::jsTDZValue());731 732 for (unsigned argumentIndex = 0; argumentIndex < argumentDescriptions->size(); ++argumentIndex) {733 auto& description = argumentDescriptions->at(argumentIndex);734 JSC::JSObject* jsDescriptions = constructEmptyObject(globalObject, globalObject->objectPrototype());735 RETURN_IF_EXCEPTION(scope, JSC::jsTDZValue());736 737 argumentsArray->putDirectIndex(globalObject, argumentIndex, jsDescriptions);738 RETURN_IF_EXCEPTION(scope, JSC::jsTDZValue());739 740 jsDescriptions->putDirect(vm, JSC::Identifier::fromString(vm, "name"), JSC::jsString(vm, String(description.name)));741 RETURN_IF_EXCEPTION(scope, JSC::jsTDZValue());742 743 jsDescriptions->putDirect(vm, JSC::Identifier::fromString(vm, "type"), JSC::jsString(vm, String(description.type)));744 RETURN_IF_EXCEPTION(scope, JSC::jsTDZValue());745 746 jsDescriptions->putDirect(vm, JSC::Identifier::fromString(vm, "optional"), JSC::jsBoolean(description.isOptional));747 RETURN_IF_EXCEPTION(scope, JSC::jsTDZValue());748 749 if (description.enumName) {750 jsDescriptions->putDirect(vm, JSC::Identifier::fromString(vm, "enum"), JSC::jsString(vm, String(description.enumName)));751 RETURN_IF_EXCEPTION(scope, JSC::jsTDZValue());752 }753 }754 return argumentsArray;755 }756 757 558 JSValueRef JSIPC::messages(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception) 758 559 { … … 767 568 } 768 569 769 auto scope = DECLARE_CATCH_SCOPE(vm);770 570 JSC::JSObject* messagesObject = constructEmptyObject(globalObject, globalObject->objectPrototype()); 771 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context));772 773 571 auto nameIdent = JSC::Identifier::fromString(vm, "name"); 774 auto replyArgumentsIdent = JSC::Identifier::fromString(vm, "replyArguments");775 572 for (unsigned i = 0; i < static_cast<unsigned>(IPC::MessageName::Last); ++i) { 776 auto name = static_cast<IPC::MessageName>(i);573 auto* messageName = description(static_cast<IPC::MessageName>(i)); 777 574 778 575 JSC::JSObject* dictionary = constructEmptyObject(globalObject, globalObject->objectPrototype()); 779 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context));780 781 576 dictionary->putDirect(vm, nameIdent, JSC::JSValue(i)); 782 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context)); 783 784 auto argumentDescriptions = createJSArrayForArgumentDescriptions(globalObject, IPC::messageArgumentDescriptions(name)); 785 if (argumentDescriptions.isEmpty()) 786 return JSValueMakeUndefined(context); 787 dictionary->putDirect(vm, vm.propertyNames->arguments, argumentDescriptions); 788 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context)); 789 790 auto replyArgumentDescriptions = createJSArrayForArgumentDescriptions(globalObject, IPC::messageReplyArgumentDescriptions(name)); 791 if (replyArgumentDescriptions.isEmpty()) 792 return JSValueMakeUndefined(context); 793 dictionary->putDirect(vm, replyArgumentsIdent, replyArgumentDescriptions); 794 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context)); 795 796 messagesObject->putDirect(vm, JSC::Identifier::fromString(vm, description(name)), dictionary); 797 RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context)); 577 578 // FIXME: Add argument names. 579 580 messagesObject->putDirect(vm, JSC::Identifier::fromString(vm, messageName), dictionary); 798 581 } 799 582 -
trunk/Tools/ChangeLog
r268479 r268486 1 2020-10-14 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r268431 and r268443. 4 https://bugs.webkit.org/show_bug.cgi?id=217728 5 6 Broke debug builds of GTK, WinCairo and Playstation ports 7 8 Reverted changesets: 9 10 "IPC testing JS API should expose a reply and describe the 11 list of arguments for each message" 12 https://bugs.webkit.org/show_bug.cgi?id=217565 13 https://trac.webkit.org/changeset/268431 14 15 "IPC testing JS API should expose a reply and describe the 16 list of arguments for each message" 17 https://bugs.webkit.org/show_bug.cgi?id=217565 18 https://trac.webkit.org/changeset/268443 19 1 20 2020-10-14 Alex Christensen <achristensen@webkit.org> 2 21 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm
r268443 r268486 35 35 36 36 static bool done = false; 37 static bool didCrash = false;38 37 static RetainPtr<NSString> alertMessage; 39 static RetainPtr<NSString> promptDefault;40 static RetainPtr<NSString> promptResult;41 38 42 @interface IPCTestingAPIDelegate : NSObject <WKUIDelegate , WKNavigationDelegate>39 @interface IPCTestingAPIDelegate : NSObject <WKUIDelegate> 43 40 @end 44 41 … … 50 47 done = true; 51 48 completionHandler(); 52 }53 54 - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * _Nullable))completionHandler55 {56 promptDefault = defaultText;57 done = true;58 completionHandler(promptResult.get());59 }60 61 - (void)_webView:(WKWebView *)webView webContentProcessDidTerminateWithReason:(_WKProcessTerminationReason)reason62 {63 didCrash = false;64 done = true;65 49 } 66 50 … … 98 82 done = false; 99 83 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>IPC.sendSyncMessage('UI', IPC.webPageProxyID, IPC.messages.WebPageProxy_RunJavaScriptAlert.name, 100," 100 "[{type: 'uint64_t', value: IPC.frameI D}, {type: 'FrameInfoData'}, {'type': 'String', 'value': 'hi'}]);</script>"];84 "[{type: 'uint64_t', value: IPC.frameIdentifier}, {type: 'FrameInfoData'}, {'type': 'String', 'value': 'hi'}]);</script>"]; 101 85 TestWebKitAPI::Util::run(&done); 102 86 … … 104 88 } 105 89 106 TEST(IPCTestingAPI, DecodesReplyArgumentsForPrompt)107 {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()]);116 117 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);118 [webView setUIDelegate:delegate.get()];119 120 done = false;121 promptResult = @"foo";122 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>result = IPC.sendSyncMessage('UI', IPC.webPageProxyID, IPC.messages.WebPageProxy_RunJavaScriptPrompt.name, 100,"123 "[{type: 'uint64_t', value: IPC.frameID}, {type: 'FrameInfoData'}, {'type': 'String', 'value': 'hi'}, {'type': 'String', 'value': 'bar'}]);</script>"];124 TestWebKitAPI::Util::run(&done);125 126 EXPECT_STREQ([promptDefault UTF8String], "bar");127 EXPECT_STREQ([[webView stringByEvaluatingJavaScript:@"JSON.stringify(result.arguments)"] UTF8String], "[{\"type\":\"String\",\"value\":\"foo\"}]");128 }129 130 #if ENABLE(RESOURCE_LOAD_STATISTICS)131 TEST(IPCTestingAPI, DecodesReplyArgumentsForAsyncMessage)132 {133 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);134 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) {135 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) {136 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature];137 break;138 }139 }140 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]);141 142 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);143 [webView setUIDelegate:delegate.get()];144 145 done = false;146 promptResult = @"foo";147 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>IPC.sendMessage(\"Networking\", 0, IPC.messages.NetworkConnectionToWebProcess_HasStorageAccess.name,"148 "[{type: 'RegistrableDomain', value: 'https://ipctestingapi.com'}, {type: 'RegistrableDomain', value: 'https://webkit.org'}, {type: 'uint64_t', value: IPC.frameID},"149 "{type: 'uint64_t', value: IPC.pageID}]).then((result) => alert(JSON.stringify(result.arguments)));</script>"];150 TestWebKitAPI::Util::run(&done);151 152 EXPECT_STREQ([alertMessage UTF8String], "[{\"type\":\"bool\",\"value\":false}]");153 }154 90 #endif 155 156 TEST(IPCTestingAPI, DescribesArguments)157 {158 RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);159 for (_WKInternalDebugFeature *feature in [WKPreferences _internalDebugFeatures]) {160 if ([feature.key isEqualToString:@"IPCTestingAPIEnabled"]) {161 [[configuration preferences] _setEnabled:YES forInternalDebugFeature:feature];162 break;163 }164 }165 RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get()]);166 167 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]);168 [webView setUIDelegate:delegate.get()];169 170 done = false;171 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>window.args = IPC.messages.WebPageProxy_RunJavaScriptAlert.arguments; alert('ok')</script>"];172 TestWebKitAPI::Util::run(&done);173 174 EXPECT_STREQ([[webView stringByEvaluatingJavaScript:@"args.length"] UTF8String], "3");175 EXPECT_STREQ([[webView stringByEvaluatingJavaScript:@"args[0].type"] UTF8String], "WebCore::FrameIdentifier");176 EXPECT_STREQ([[webView stringByEvaluatingJavaScript:@"args[1].type"] UTF8String], "WebKit::FrameInfoData");177 EXPECT_STREQ([[webView stringByEvaluatingJavaScript:@"args[2].name"] UTF8String], "message");178 EXPECT_STREQ([[webView stringByEvaluatingJavaScript:@"args[2].type"] UTF8String], "String");179 }180 181 #endif
Note: See TracChangeset
for help on using the changeset viewer.