Changeset 268486 in webkit


Ignore:
Timestamp:
Oct 14, 2020 1:52:37 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, reverting r268431 and r268443.
https://bugs.webkit.org/show_bug.cgi?id=217728

Broke debug builds of GTK, WinCairo and Playstation ports

Reverted changesets:

"IPC testing JS API should expose a reply and describe the
list of arguments for each message"
https://bugs.webkit.org/show_bug.cgi?id=217565
https://trac.webkit.org/changeset/268431

"IPC testing JS API should expose a reply and describe the
list of arguments for each message"
https://bugs.webkit.org/show_bug.cgi?id=217565
https://trac.webkit.org/changeset/268443

Location:
trunk
Files:
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/CMakeLists.txt

    r268431 r268486  
    429429    add_custom_command(
    430430        OUTPUT
    431             ${WebKit_DERIVED_SOURCES_DIR}/MessageArgumentDescriptions.cpp
    432431            ${WebKit_DERIVED_SOURCES_DIR}/MessageNames.cpp
    433432            ${WebKit_DERIVED_SOURCES_DIR}/MessageNames.h
  • trunk/Source/WebKit/ChangeLog

    r268485 r268486  
     12020-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
    1202020-10-14  Don Olmstead  <don.olmstead@sony.com>
    221
  • trunk/Source/WebKit/DerivedSources-output.xcfilelist

    r268431 r268486  
    6969$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MediaPlayerPrivateRemoteMessages.h
    7070$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MediaPlayerPrivateRemoteMessagesReplies.h
    71 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MessageArgumentDescriptions.cpp
    7271$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MessageNames.cpp
    7372$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/MessageNames.h
  • trunk/Source/WebKit/DerivedSources.make

    r268431 r268486  
    258258MESSAGE_REPLIES_FILES := $(addsuffix MessagesReplies.h,$(notdir $(MESSAGE_RECEIVERS)))
    259259
    260 GENERATED_MESSAGES_FILES := $(MESSAGE_RECEIVER_FILES) $(MESSAGES_FILES) $(MESSAGE_REPLIES_FILES) MessageNames.h MessageNames.cpp MessageArgumentDescriptions.cpp
     260GENERATED_MESSAGES_FILES := $(MESSAGE_RECEIVER_FILES) $(MESSAGES_FILES) $(MESSAGE_REPLIES_FILES) MessageNames.h MessageNames.cpp
    261261GENERATED_MESSAGES_FILES_AS_PATTERNS := $(subst .,%,$(GENERATED_MESSAGES_FILES))
    262262
  • trunk/Source/WebKit/Platform/IPC/Decoder.h

    r268431 r268486  
    7373    static std::unique_ptr<Decoder> unwrapForTesting(Decoder&);
    7474
    75     const uint8_t* buffer() const { return m_buffer; }
    7675    size_t length() const { return m_bufferEnd - m_buffer; }
    7776
  • trunk/Source/WebKit/Scripts/generate-message-receiver.py

    r268431 r268486  
    3535    first_arg = True
    3636    second_arg = False
    37     receiver_header_files = []
    3837    for parameter in argv:
    3938        if first_arg:
     
    5554            implementation_output.write(webkit.messages.generate_message_handler(receiver))
    5655
    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:
    6057            header_output.write(webkit.messages.generate_messages_header(receiver))
    6158
     
    6966        message_names_implementation_output.write(webkit.messages.generate_message_names_implementation(receivers))
    7067
    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 
    7468    return 0
    7569
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r268431 r268486  
    624624        'WebCore::PasteboardWebContent': ['<WebCore/Pasteboard.h>'],
    625625        'WebCore::PaymentAuthorizationResult': ['<WebCore/ApplePaySessionPaymentRequest.h>'],
     626        'WebCore::PaymentMethodUpdate': ['<WebCore/ApplePaySessionPaymentRequest.h>'],
    626627        'WebCore::PlatformTextTrackData': ['<WebCore/PlatformTextTrack.h>'],
    627628        'WebCore::PluginInfo': ['<WebCore/PluginData.h>'],
     
    687688        'struct WebKit::WebUserStyleSheetData': ['"WebUserContentControllerDataTypes.h"'],
    688689        'struct WebKit::WebScriptMessageHandlerData': ['"WebUserContentControllerDataTypes.h"'],
    689         'webrtc::WebKitEncodedFrameInfo': ['<webrtc/sdk/WebKit/WebKitEncoder.h>', '<WebCore/LibWebRTCEnumTraits.h>'],
     690        'webrtc::WebKitEncodedFrameInfo': ['<webrtc/sdk/WebKit/WebKitEncoder.h>'],
    690691        'webrtc::WebKitRTPFragmentationHeader': ['<webrtc/sdk/WebKit/WebKitEncoder.h>'],
    691692    }
     
    714715
    715716
    716 def collect_header_conditions_for_receiver(receiver, header_conditions):
     717def generate_message_handler(receiver):
     718    header_conditions = {
     719        '"%s"' % messages_header_filename(receiver): [None],
     720        '"HandleMessage.h"': [None],
     721        '"Decoder.h"': [None],
     722    }
     723
    717724    type_conditions = {}
    718725    for parameter in receiver.iterparameters():
     
    757764                    header_conditions[header].append(message.condition)
    758765
    759     return header_conditions
    760 
    761 
    762 def generate_header_includes_from_conditions(header_conditions):
    763766    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)
    764776    for header in sorted(header_conditions):
    765777        if header_conditions[header] and not None in header_conditions[header]:
     
    769781        else:
    770782            result += ['#include %s\n' % header]
    771     return result
    772 
    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)
    794783    result.append('\n')
    795784
     
    10561045    result.append('} // namespace IPC\n')
    10571046    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 = None
    1068         for message in receiver.messages:
    1069             if not predicate(message):
    1070                 continue
    1071             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.condition
    1077             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 = None
    1099         for message in receiver.messages:
    1100             argument_list = arguments_from_message(message)
    1101             if argument_list is None:
    1102                 continue
    1103             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.condition
    1109             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                 continue
    1114 
    1115             result.append('        return Vector<ArgumentDescription> {\n')
    1116             for argument in argument_list:
    1117                 argument_type = argument.type
    1118                 enum_type = None
    1119                 is_optional = False
    1120                 if argument.kind.startswith('enum:'):
    1121                     enum_type = '"%s"' % argument_type
    1122                     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 = True
    1126                 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 result
    1138 
    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  
    2828#if ENABLE(APPLE_PAY)
    2929
    30 OBJC_CLASS NSArray;
    3130OBJC_CLASS PKPaymentSetupFeature;
    3231
  • trunk/Source/WebKit/SourcesCocoa.txt

    r268458 r268486  
    659659LibWebRTCCodecsProxyMessageReceiver.cpp
    660660LibWebRTCCodecsMessageReceiver.cpp
    661 MessageArgumentDescriptions.cpp @no-unify
    662661MessageNames.cpp
    663662RemoteAudioDestinationManagerMessageReceiver.cpp
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r268458 r268486  
    881881    WebProcessPool::didReceiveInvalidMessage(messageName);
    882882
    883 #if ENABLE(IPC_TESTING_API)
    884     if (processPool().defaultPageGroup().preferences().store().getBoolValueForKey(WebPreferencesKey::ipcTestingAPIEnabledKey()))
    885         return;
    886 #endif
    887 
    888883    // Terminate the WebContent process.
    889884    terminate();
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r268458 r268486  
    14241424                9B1229CE23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9B1229CC23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp */; };
    14251425                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 */; };
    14291426                9B5499AD2362A6F900DF8BA5 /* _WKTextManipulationConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5499AC2362A6F600DF8BA5 /* _WKTextManipulationConfiguration.h */; settings = {ATTRIBUTES = (Private, ); }; };
    14301427                9B5499B22362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5499B02362A7EC00DF8BA5 /* _WKTextManipulationExclusionRule.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    45294526                9B1229CF23FF2814008CA751 /* RemoteAudioDestinationManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteAudioDestinationManager.messages.in; sourceTree = "<group>"; };
    45304527                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>"; };
    45344528                9B5499AC2362A6F600DF8BA5 /* _WKTextManipulationConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKTextManipulationConfiguration.h; sourceTree = "<group>"; };
    45354529                9B5499AE2362A7A700DF8BA5 /* _WKTextManipulationConfiguration.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKTextManipulationConfiguration.mm; sourceTree = "<group>"; };
     
    64656459                                C0CE72AC1247E78D00BC0EC4 /* HandleMessage.h */,
    64666460                                1C9AF36124134D2300D3EC02 /* ImageDataReference.h */,
    6467                                 9B47908E253151CC00EC11AB /* JSIPCBinding.h */,
    6468                                 9B47908C25314D8300EC11AB /* MessageArgumentDescriptions.h */,
    64696461                                1AC4C82816B876A90069DCCD /* MessageFlags.h */,
    64706462                                1A3EED11161A53D600AEB4F5 /* MessageReceiver.h */,
     
    1009010082                                07E19EF923D401F00094FFB4 /* MediaPlayerPrivateRemoteMessages.h */,
    1009110083                                07E19EFA23D401F00094FFB4 /* MediaPlayerPrivateRemoteMessagesReplies.h */,
    10092                                 9B4790902531563200EC11AB /* MessageArgumentDescriptions.cpp */,
    1009310084                                51DD9F2616367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp */,
    1009410085                                51DD9F2716367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h */,
     
    1094410935                                C5BCE5DF1C50766A00CDE3FA /* InteractionInformationAtPosition.h in Headers */,
    1094510936                                2D4D2C811DF60BF3002EB10C /* InteractionInformationRequest.h in Headers */,
    10946                                 9B47908F253151CC00EC11AB /* JSIPCBinding.h in Headers */,
    1094710937                                1AE49A4911FFA8CE0048B464 /* JSNPMethod.h in Headers */,
    1094810938                                1AE4987811FF7FAA0048B464 /* JSNPObject.h in Headers */,
     
    1098110971                                07E19EFD23D401F10094FFB4 /* MediaPlayerPrivateRemoteMessagesReplies.h in Headers */,
    1098210972                                51933DEF1965EB31008AC3EA /* MenuUtilities.h in Headers */,
    10983                                 9B47908D25314D8300EC11AB /* MessageArgumentDescriptions.h in Headers */,
    1098410973                                1AC4C82916B876A90069DCCD /* MessageFlags.h in Headers */,
    1098510974                                1A3EED12161A53D600AEB4F5 /* MessageReceiver.h in Headers */,
     
    1285212841                                2D92A779212B6A6100F493FD /* Logging.cpp in Sources */,
    1285312842                                07E19EFB23D401F10094FFB4 /* MediaPlayerPrivateRemoteMessageReceiver.cpp in Sources */,
    12854                                 9B4790912531563200EC11AB /* MessageArgumentDescriptions.cpp in Sources */,
    1285512843                                2D92A781212B6A7100F493FD /* MessageReceiverMap.cpp in Sources */,
    1285612844                                2D92A782212B6A7100F493FD /* MessageSender.cpp in Sources */,
  • trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp

    r268431 r268486  
    3232#include "FrameInfoData.h"
    3333#include "GPUProcessConnection.h"
    34 #include "MessageArgumentDescriptions.h"
     34#include "MessageNames.h"
    3535#include "NetworkProcessConnection.h"
    3636#include "WebCoreArgumentCoders.h"
     
    8484    static JSValueRef visitedLinkStoreID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception);
    8585    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);
    8987    static JSValueRef retrieveID(JSContextRef, JSObjectRef thisObject, JSValueRef* exception, const WTF::Function<uint64_t(JSIPC&)>&);
    9088
     
    147145    static const JSStaticValue values[] = {
    148146        { "visitedLinkStoreID", visitedLinkStoreID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    149         { "frameID", frameID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    150         { "pageID", pageID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    151         { "sessionID", sessionID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    152147        { "webPageProxyID", webPageProxyID, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
     148        { "frameIdentifier", frameIdentifier, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    153149        { "messages", messages, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
    154150        { 0, 0, 0, 0 }
     
    242238}
    243239
    244 template<typename PointType> bool encodePointType(IPC::Encoder& encoder, JSC::JSGlobalObject* globalObject, JSC::JSObject* jsObject, JSC::CatchScope& scope)
     240template<typename RectType> bool encodeRectType(IPC::Encoder& encoder, JSC::JSGlobalObject* globalObject, JSC::JSObject* jsObject)
    245241{
    246242    auto& vm = globalObject->vm();
    247243    auto jsX = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "x"_s));
    248     if (scope.exception() || !jsX.isNumber())
     244    if (!jsX.isNumber())
    249245        return false;
    250246    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())
    265248        return false;
    266249    auto jsWidth = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "width"_s));
    267     if (scope.exception() || !jsWidth.isNumber())
     250    if (!jsWidth.isNumber())
    268251        return false;
    269252    auto jsHeight = jsObject->get(globalObject, JSC::Identifier::fromString(vm, "height"_s));
    270     if (scope.exception() || !jsHeight.isNumber())
     253    if (!jsHeight.isNumber())
    271254        return false;
    272255    encoder << RectType(jsX.asNumber(), jsY.asNumber(), jsWidth.asNumber(), jsHeight.asNumber());
     
    274257}
    275258
    276 template<typename IntegralType> bool encodeNumericType(IPC::Encoder& encoder, JSC::JSValue jsValue)
     259template<typename IntegralType> bool encodeIntegralType(IPC::Encoder& encoder, JSC::JSValue jsValue)
    277260{
    278261    if (jsValue.isBigInt()) {
     
    358341        return false;
    359342
    360     if (type == "IntPoint") {
    361         if (!encodePointType<WebCore::IntPoint>(encoder, globalObject, jsObject, scope)) {
    362             *exception = createTypeError(context, "Failed to convert IntPoint"_s);
     343    if (type == "IntRect") {
     344        if (!encodeRectType<WebCore::IntRect>(encoder, globalObject, jsObject)) {
     345            *exception = createTypeError(context, "Failed to convert IntRect"_s);
    363346            return false;
    364347        }
     
    366349    }
    367350
    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 
    384351    if (type == "FloatRect") {
    385         if (!encodeRectType<WebCore::FloatRect>(encoder, globalObject, jsObject, scope)) {
     352        if (!encodeRectType<WebCore::FloatRect>(encoder, globalObject, jsObject)) {
    386353            *exception = createTypeError(context, "Failed to convert FloatRect"_s);
    387354            return false;
     
    416383    }
    417384
    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 
    442385    if (type == "RGBA") {
    443386        if (!jsValue.isNumber()) {
     
    450393    }
    451394
    452     bool numericResult;
     395    bool integralResult;
    453396    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);
    459398    else if (type == "int8_t")
    460         numericResult = encodeNumericType<int8_t>(encoder, jsValue);
     399        integralResult = encodeIntegralType<int8_t>(encoder, jsValue);
    461400    else if (type == "int16_t")
    462         numericResult = encodeNumericType<int16_t>(encoder, jsValue);
     401        integralResult = encodeIntegralType<int16_t>(encoder, jsValue);
    463402    else if (type == "int32_t")
    464         numericResult = encodeNumericType<int32_t>(encoder, jsValue);
     403        integralResult = encodeIntegralType<int32_t>(encoder, jsValue);
    465404    else if (type == "int64_t")
    466         numericResult = encodeNumericType<int64_t>(encoder, jsValue);
     405        integralResult = encodeIntegralType<int64_t>(encoder, jsValue);
    467406    else if (type == "uint8_t")
    468         numericResult = encodeNumericType<uint8_t>(encoder, jsValue);
     407        integralResult = encodeIntegralType<uint8_t>(encoder, jsValue);
    469408    else if (type == "uint16_t")
    470         numericResult = encodeNumericType<uint16_t>(encoder, jsValue);
     409        integralResult = encodeIntegralType<uint16_t>(encoder, jsValue);
    471410    else if (type == "uint32_t")
    472         numericResult = encodeNumericType<uint32_t>(encoder, jsValue);
     411        integralResult = encodeIntegralType<uint32_t>(encoder, jsValue);
    473412    else if (type == "uint64_t")
    474         numericResult = encodeNumericType<uint64_t>(encoder, jsValue);
     413        integralResult = encodeIntegralType<uint64_t>(encoder, jsValue);
    475414    else {
    476415        *exception = createTypeError(context, "Bad type name"_s);
    477416        return false;
    478417    }
    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);
    481420        return false;
    482421    }
    483422    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;
    523423}
    524424
     
    529429    auto jsIPC = makeRefPtr(toWrapped(context, thisObject));
    530430    if (!jsIPC) {
    531         *exception = createTypeError(context, "Wrong type"_s);
     431        *exception = toRef(JSC::createTypeError(toJS(context), "Wrong type"_s));
    532432        return JSValueMakeUndefined(context);
    533433    }
    534434
    535435    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));
    537437        return JSValueMakeUndefined(context);
    538438    }
     
    550450        return JSValueMakeUndefined(context);
    551451
    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);
    594453
    595454    if (argumentCount > 3) {
     
    602461    connection->sendMessage(WTFMove(encoder), { });
    603462
    604     return returnValue;
     463    return JSValueMakeUndefined(context);
    605464}
    606465
     
    611470    auto jsIPC = makeRefPtr(toWrapped(context, thisObject));
    612471    if (!jsIPC) {
    613         *exception = createTypeError(context, "Wrong type"_s);
     472        *exception = toRef(JSC::createTypeError(toJS(context), "Wrong type"_s));
    614473        return JSValueMakeUndefined(context);
    615474    }
    616475
    617476    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));
    619478        return JSValueMakeUndefined(context);
    620479    }
     
    636495        auto jsValue = toJS(globalObject, arguments[3]);
    637496        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));
    639498            return JSValueMakeUndefined(context);
    640499        }
    641500        timeout = Seconds { jsValue.asNumber() };
    642501    }
    643 
     502   
    644503    // FIXME: Support the options.
    645504
    646505    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);
    649507
    650508    if (argumentCount > 4) {
     
    653511    }
    654512
    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.
    665515
    666516    return JSValueMakeUndefined(context);
     
    675525}
    676526
    677 JSValueRef JSIPC::frameID(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)
     527JSValueRef 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
     534JSValueRef JSIPC::frameIdentifier(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)
    678535{
    679536    return retrieveID(context, thisObject, exception, [](JSIPC& wrapped) {
     
    682539}
    683540
    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 
    705541JSValueRef JSIPC::retrieveID(JSContextRef context, JSObjectRef thisObject, JSValueRef* exception, const WTF::Function<uint64_t(JSIPC&)>& callback)
    706542{
     
    720556}
    721557
    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 
    757558JSValueRef JSIPC::messages(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception)
    758559{
     
    767568    }
    768569
    769     auto scope = DECLARE_CATCH_SCOPE(vm);
    770570    JSC::JSObject* messagesObject = constructEmptyObject(globalObject, globalObject->objectPrototype());
    771     RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context));
    772 
    773571    auto nameIdent = JSC::Identifier::fromString(vm, "name");
    774     auto replyArgumentsIdent = JSC::Identifier::fromString(vm, "replyArguments");
    775572    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));
    777574
    778575        JSC::JSObject* dictionary = constructEmptyObject(globalObject, globalObject->objectPrototype());
    779         RETURN_IF_EXCEPTION(scope, JSValueMakeUndefined(context));
    780 
    781576        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);
    798581    }
    799582
  • trunk/Tools/ChangeLog

    r268479 r268486  
     12020-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
    1202020-10-14  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm

    r268443 r268486  
    3535
    3636static bool done = false;
    37 static bool didCrash = false;
    3837static RetainPtr<NSString> alertMessage;
    39 static RetainPtr<NSString> promptDefault;
    40 static RetainPtr<NSString> promptResult;
    4138
    42 @interface IPCTestingAPIDelegate : NSObject <WKUIDelegate, WKNavigationDelegate>
     39@interface IPCTestingAPIDelegate : NSObject <WKUIDelegate>
    4340@end
    4441   
     
    5047    done = true;
    5148    completionHandler();
    52 }
    53 
    54 - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * _Nullable))completionHandler
    55 {
    56     promptDefault = defaultText;
    57     done = true;
    58     completionHandler(promptResult.get());
    59 }
    60 
    61 - (void)_webView:(WKWebView *)webView webContentProcessDidTerminateWithReason:(_WKProcessTerminationReason)reason
    62 {
    63     didCrash = false;
    64     done = true;
    6549}
    6650
     
    9882    done = false;
    9983    [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>IPC.sendSyncMessage('UI', IPC.webPageProxyID, IPC.messages.WebPageProxy_RunJavaScriptAlert.name, 100,"
    100         "[{type: 'uint64_t', value: IPC.frameID}, {type: 'FrameInfoData'}, {'type': 'String', 'value': 'hi'}]);</script>"];
     84        "[{type: 'uint64_t', value: IPC.frameIdentifier}, {type: 'FrameInfoData'}, {'type': 'String', 'value': 'hi'}]);</script>"];
    10185    TestWebKitAPI::Util::run(&done);
    10286
     
    10488}
    10589
    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 }
    15490#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.