Changeset 277199 in webkit
- Timestamp:
- May 7, 2021, 2:32:50 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Platform/IPC/JSIPCBinding.cpp (modified) (5 diffs)
-
Source/WebKit/Platform/IPC/JSIPCBinding.h (modified) (3 diffs)
-
Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp (modified) (11 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r277196 r277199 1 2021-05-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 IPC testing API should have the ability to create and receive IPC::Semaphore 4 https://bugs.webkit.org/show_bug.cgi?id=225537 5 6 Reviewed by Wenson Hsieh. 7 8 This patch adds the capability to create IPC::Semaphore for IPC testing purposes. 9 It adds IPC.createSemaphore which creates a JavaScript object representing a semaphore 10 with signal and waitFor methods like IPC::Semaphore but waitFor taking milliseconds 11 to be consistent with other JavaScript APIs. 12 13 This patch also adds the support for encoding RemoteRenderingBackendCreationParameters 14 to facilitate creating a remote rendering backend during IPC testing. 15 16 Tests: TestWebKitAPI.IPCTestingAPI.CanReceiveIPCSemaphore 17 TestWebKitAPI.IPCTestingAPI.CanCreateIPCSemaphore 18 19 * Platform/IPC/JSIPCBinding.cpp: 20 (IPC::jsValueForDecodedArgumentValue): Takes r-value reference since IPC::Semaphore 21 doesn't have a copy constructor. 22 * Platform/IPC/JSIPCBinding.h: 23 (IPC::jsValueForDecodedArgumentValue): Ditto. Added a specialization for IPC::Semaphore. 24 (IPC::putJSValueForDecodeArgumentInArray): 25 * WebProcess/WebPage/IPCTestingAPI.cpp: 26 (WebKit::IPCTestingAPI::JSIPCSemaphore): Added. 27 (WebKit::IPCTestingAPI::JSIPCSemaphore::create): Added. 28 (WebKit::IPCTestingAPI::JSIPCSemaphore::exchange): Added. 29 (WebKit::IPCTestingAPI::JSIPCSemaphore::JSIPCSemaphore): Added. 30 (WebKit::IPCTestingAPI::createTypeError): Moved up. 31 (WebKit::IPCTestingAPI::JSIPCSemaphore::createJSWrapper): Added. 32 (WebKit::IPCTestingAPI::JSIPCSemaphore::wrapperClass): Added. 33 (WebKit::IPCTestingAPI::JSIPCSemaphore::unwrap): Added. 34 (WebKit::IPCTestingAPI::JSIPCSemaphore::toWrapped): Added. 35 (WebKit::IPCTestingAPI::JSIPCSemaphore::initialize): Added. 36 (WebKit::IPCTestingAPI::JSIPCSemaphore::finalize): Added. 37 (WebKit::IPCTestingAPI::JSIPCSemaphore::staticFunctions): Added. 38 (WebKit::IPCTestingAPI::JSIPCSemaphore::signal): Added. 39 (WebKit::IPCTestingAPI::JSIPCSemaphore::waitFor): Added. 40 (WebKit::IPCTestingAPI::JSIPC::wrapperClass): 41 (WebKit::IPCTestingAPI::JSIPC::staticFunctions): Added IPC.createSemaphore. 42 (WebKit::IPCTestingAPI::getObjectIdentifierFromProperty): Added. 43 (WebKit::IPCTestingAPI::encodeRemoteRenderingBackendCreationParameters): Added. 44 (WebKit::IPCTestingAPI::encodeArgument): Added the support for encoding 45 RemoteRenderingBackendCreationParameters as an IPC argument. 46 (WebKit::IPCTestingAPI::JSIPC::createSemaphore): Added. 47 (IPC::jsValueForDecodedArgumentValue): Defined the aforementioned specialization for 48 IPC::Semaphore with IPCTestingAPI . 49 1 50 2021-05-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 51 -
trunk/Source/WebKit/Platform/IPC/JSIPCBinding.cpp
r273058 r277199 52 52 53 53 template<> 54 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, const String& value)54 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, String&& value) 55 55 { 56 56 return jsValueForDecodedStringArgumentValue(globalObject, value, "String"_s); … … 58 58 59 59 template<> 60 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, const URL& value)60 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, URL&& value) 61 61 { 62 62 return jsValueForDecodedStringArgumentValue(globalObject, value.string(), "URL"_s); … … 64 64 65 65 template<> 66 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, const WebCore::RegistrableDomain& value)66 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, WebCore::RegistrableDomain&& value) 67 67 { 68 68 return jsValueForDecodedStringArgumentValue(globalObject, value.string(), "RegistrableDomain"_s); … … 184 184 185 185 template<> 186 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, const WebCore::IntRect& value)186 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, WebCore::IntRect&& value) 187 187 { 188 188 return jsValueForDecodedArgumentRect(globalObject, value, "IntRect"); … … 190 190 191 191 template<> 192 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, const WebCore::FloatRect& value)192 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, WebCore::FloatRect&& value) 193 193 { 194 194 return jsValueForDecodedArgumentRect(globalObject, value, "FloatRect"); -
trunk/Source/WebKit/Platform/IPC/JSIPCBinding.h
r272592 r277199 54 54 namespace IPC { 55 55 56 class Semaphore; 57 56 58 template<typename T, std::enable_if_t<!std::is_arithmetic<T>::value && !std::is_enum<T>::value>* = nullptr> 57 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, const T&)59 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, T&&) 58 60 { 59 61 return JSC::jsUndefined(); 60 62 } 61 63 62 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, const String&); 63 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, const URL&); 64 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, const WebCore::RegistrableDomain&); 64 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, String&&); 65 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, URL&&); 66 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, WebCore::RegistrableDomain&&); 67 68 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, IPC::Semaphore&&); 65 69 66 70 template<typename T, std::enable_if_t<std::is_arithmetic<T>::value>* = nullptr> … … 90 94 91 95 template<typename U> 92 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, const ObjectIdentifier<U>& value)96 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, ObjectIdentifier<U>&& value) 93 97 { 94 98 return jsValueForDecodedArgumentValue(globalObject, value.toUInt64()); 95 99 } 96 100 97 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, const WebCore::IntRect&);98 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, const WebCore::FloatRect&);101 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, WebCore::IntRect&&); 102 template<> JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject*, WebCore::FloatRect&&); 99 103 100 104 template<typename U> 101 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, const OptionSet<U>& value)105 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, OptionSet<U>&& value) 102 106 { 103 107 auto& vm = globalObject->vm(); … … 130 134 return WTF::nullopt; 131 135 132 auto jsValue = jsValueForDecodedArgumentValue(globalObject, *value);136 auto jsValue = jsValueForDecodedArgumentValue(globalObject, WTFMove(*value)); 133 137 if (jsValue.isEmpty()) 134 138 return jsValue; -
trunk/Source/WebKit/WebProcess/WebPage/IPCTestingAPI.cpp
r276678 r277199 32 32 #include "FrameInfoData.h" 33 33 #include "GPUProcessConnection.h" 34 #include "IPCSemaphore.h" 35 #include "JSIPCBinding.h" 34 36 #include "MessageArgumentDescriptions.h" 35 37 #include "NetworkProcessConnection.h" 38 #include "RemoteRenderingBackendCreationParameters.h" 36 39 #include "WebCoreArgumentCoders.h" 37 40 #include "WebFrame.h" … … 51 54 #include <WebCore/RegistrableDomain.h> 52 55 #include <WebCore/ScriptController.h> 56 #include <wtf/PageBlock.h> 53 57 54 58 namespace WebKit { 55 59 56 60 namespace IPCTestingAPI { 61 62 class JSIPCSemaphore : public RefCounted<JSIPCSemaphore> { 63 public: 64 static Ref<JSIPCSemaphore> create(IPC::Semaphore&& semaphore = { }) 65 { 66 return adoptRef(*new JSIPCSemaphore(WTFMove(semaphore))); 67 } 68 69 JSObjectRef createJSWrapper(JSContextRef); 70 71 static JSIPCSemaphore* toWrapped(JSContextRef, JSValueRef); 72 73 IPC::Semaphore exchange(IPC::Semaphore&& semaphore = { }) 74 { 75 return std::exchange(m_semaphore, WTFMove(semaphore)); 76 } 77 78 private: 79 JSIPCSemaphore(IPC::Semaphore&& semaphore) 80 : m_semaphore(WTFMove(semaphore)) 81 { } 82 83 static JSClassRef wrapperClass(); 84 static JSIPCSemaphore* unwrap(JSObjectRef); 85 static void initialize(JSContextRef, JSObjectRef); 86 static void finalize(JSObjectRef); 87 88 static const JSStaticFunction* staticFunctions(); 89 90 static JSValueRef signal(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 91 static JSValueRef waitFor(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 92 93 IPC::Semaphore m_semaphore; 94 }; 57 95 58 96 class JSIPC; … … 107 145 static JSValueRef sendSyncMessage(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 108 146 147 static JSValueRef createSemaphore(JSContextRef, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); 148 109 149 static JSValueRef visitedLinkStoreID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); 110 150 static JSValueRef webPageProxyID(JSContextRef, JSObjectRef, JSStringRef, JSValueRef* exception); … … 121 161 }; 122 162 163 static JSValueRef createTypeError(JSContextRef context, const String& message) 164 { 165 JSC::JSLockHolder lock(toJS(context)->vm()); 166 return toRef(JSC::createTypeError(toJS(context), message)); 167 } 168 169 JSObjectRef JSIPCSemaphore::createJSWrapper(JSContextRef context) 170 { 171 auto* globalObject = toJS(context); 172 auto& vm = globalObject->vm(); 173 JSC::JSLockHolder lock(vm); 174 auto scope = DECLARE_CATCH_SCOPE(vm); 175 JSObjectRef wrapperObject = JSObjectMake(toGlobalRef(globalObject), wrapperClass(), this); 176 scope.clearException(); 177 return wrapperObject; 178 } 179 180 JSClassRef JSIPCSemaphore::wrapperClass() 181 { 182 static JSClassRef jsClass; 183 if (!jsClass) { 184 JSClassDefinition definition = kJSClassDefinitionEmpty; 185 definition.className = "Semaphore"; 186 definition.parentClass = nullptr; 187 definition.staticValues = nullptr; 188 definition.staticFunctions = staticFunctions(); 189 definition.initialize = initialize; 190 definition.finalize = finalize; 191 jsClass = JSClassCreate(&definition); 192 } 193 return jsClass; 194 } 195 196 inline JSIPCSemaphore* JSIPCSemaphore::unwrap(JSObjectRef object) 197 { 198 return static_cast<JSIPCSemaphore*>(JSObjectGetPrivate(object)); 199 } 200 201 JSIPCSemaphore* JSIPCSemaphore::toWrapped(JSContextRef context, JSValueRef value) 202 { 203 if (!context || !value || !JSValueIsObjectOfClass(context, value, wrapperClass())) 204 return nullptr; 205 return unwrap(JSValueToObject(context, value, 0)); 206 } 207 208 void JSIPCSemaphore::initialize(JSContextRef, JSObjectRef object) 209 { 210 unwrap(object)->ref(); 211 } 212 213 void JSIPCSemaphore::finalize(JSObjectRef object) 214 { 215 unwrap(object)->deref(); 216 } 217 218 const JSStaticFunction* JSIPCSemaphore::staticFunctions() 219 { 220 static const JSStaticFunction functions[] = { 221 { "signal", signal, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 222 { "waitFor", waitFor, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 223 { 0, 0, 0 } 224 }; 225 return functions; 226 } 227 228 JSValueRef JSIPCSemaphore::signal(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 229 { 230 auto* globalObject = toJS(context); 231 JSC::JSLockHolder lock(globalObject->vm()); 232 auto isIPCSemaphore = makeRefPtr(toWrapped(context, thisObject)); 233 if (!isIPCSemaphore) { 234 *exception = createTypeError(context, "Wrong type"_s); 235 return JSValueMakeUndefined(context); 236 } 237 238 isIPCSemaphore->m_semaphore.signal(); 239 240 return JSValueMakeUndefined(context); 241 } 242 243 JSValueRef JSIPCSemaphore::waitFor(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 244 { 245 auto* globalObject = toJS(context); 246 JSC::JSLockHolder lock(globalObject->vm()); 247 auto isIPCSemaphore = makeRefPtr(toWrapped(context, thisObject)); 248 if (!isIPCSemaphore) { 249 *exception = createTypeError(context, "Wrong type"_s); 250 return JSValueMakeUndefined(context); 251 } 252 253 if (argumentCount < 1) { 254 *exception = createTypeError(context, "Must specify the timeout in milliseconds as the first argument"_s); 255 return JSValueMakeUndefined(context); 256 } 257 258 auto jsValue = toJS(globalObject, arguments[0]); 259 Seconds timeout; 260 if (jsValue.isNumber()) { 261 double milliseconds = jsValue.asNumber(); 262 if (std::isfinite(milliseconds) && milliseconds > 0) 263 timeout = Seconds::fromMilliseconds(milliseconds); 264 } 265 if (!timeout) { 266 *exception = createTypeError(context, "Timeout must be a positive number"_s); 267 return JSValueMakeUndefined(context); 268 } 269 270 auto result = isIPCSemaphore->m_semaphore.waitFor(timeout); 271 272 return JSValueMakeBoolean(context, result); 273 } 274 123 275 JSClassRef JSIPC::wrapperClass() 124 276 { … … 127 279 JSClassDefinition definition = kJSClassDefinitionEmpty; 128 280 definition.className = "IPC"; 129 definition.parentClass = 0;281 definition.parentClass = nullptr; 130 282 definition.staticValues = staticValues(); 131 283 definition.staticFunctions = staticFunctions(); … … 166 318 { "sendMessage", sendMessage, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 167 319 { "sendSyncMessage", sendSyncMessage, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 320 { "createSemaphore", createSemaphore, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly }, 168 321 { 0, 0, 0 } 169 322 }; … … 198 351 } 199 352 200 static JSValueRef createTypeError(JSContextRef context, const String& message)201 {202 JSC::JSLockHolder lock(toJS(context)->vm());203 return toRef(JSC::createTypeError(toJS(context), message));204 }205 206 353 static RefPtr<IPC::Connection> processTargetFromArgument(JSC::JSGlobalObject* globalObject, JSValueRef valueRef, JSValueRef* exception) 207 354 { … … 364 511 } 365 512 513 #if ENABLE(GPU_PROCESS) 514 template <typename ObjectIdentifierType> 515 Optional<ObjectIdentifier<ObjectIdentifierType>> getObjectIdentifierFromProperty(JSC::JSGlobalObject* globalObject, JSC::JSObject* jsObject, ASCIILiteral propertyName, JSC::CatchScope& scope) 516 { 517 auto jsPropertyValue = jsObject->get(globalObject, JSC::Identifier::fromString(globalObject->vm(), propertyName)); 518 if (scope.exception()) 519 return WTF::nullopt; 520 if (jsPropertyValue.isBigInt()) 521 return makeObjectIdentifier<ObjectIdentifierType>(JSC::JSBigInt::toBigUInt64(jsPropertyValue)); 522 if (jsPropertyValue.isNumber()) 523 return makeObjectIdentifier<ObjectIdentifierType>(jsPropertyValue.asNumber()); 524 return WTF::nullopt; 525 } 526 527 static bool encodeRemoteRenderingBackendCreationParameters(IPC::Encoder& encoder, JSC::JSGlobalObject* globalObject, JSC::JSObject* jsObject, JSC::CatchScope& scope) 528 { 529 auto identifier = getObjectIdentifierFromProperty<RenderingBackendIdentifierType>(globalObject, jsObject, "identifier"_s, scope); 530 if (!identifier) 531 return false; 532 533 auto jsSemaphore = jsObject->get(globalObject, JSC::Identifier::fromString(globalObject->vm(), "semaphore"_s)); 534 if (scope.exception()) 535 return false; 536 auto semaphoreObject = makeRefPtr(JSIPCSemaphore::toWrapped(toRef(globalObject), toRef(jsSemaphore))); 537 if (!semaphoreObject) 538 return false; 539 540 auto pageProxyID = getObjectIdentifierFromProperty<WebPageProxyIdentifierType>(globalObject, jsObject, "pageProxyID"_s, scope); 541 if (!pageProxyID) 542 return false; 543 544 auto pageID = getObjectIdentifierFromProperty<WebCore::PageIdentifierType>(globalObject, jsObject, "pageID"_s, scope); 545 if (!pageID) 546 return false; 547 548 auto semaphore = semaphoreObject->exchange(); 549 RemoteRenderingBackendCreationParameters parameters { *identifier, WTFMove(semaphore), *pageProxyID, *pageID }; 550 encoder << parameters; 551 semaphoreObject->exchange(WTFMove(parameters.resumeDisplayListSemaphore)); 552 return true; 553 } 554 #endif 555 366 556 static bool encodeArgument(IPC::Encoder&, JSIPC&, JSContextRef, JSValueRef, JSValueRef* exception); 367 557 … … 475 665 return true; 476 666 } 667 668 #if ENABLE(GPU_PROCESS) 669 if (type == "RemoteRenderingBackendCreationParameters") { 670 if (!encodeRemoteRenderingBackendCreationParameters(encoder, globalObject, jsObject, scope)) { 671 *exception = createTypeError(context, "Failed to convert RemoteRenderingBackendCreationParameters"_s); 672 return false; 673 } 674 return true; 675 } 676 #endif 477 677 478 678 if (type == "FrameInfoData") { … … 761 961 } 762 962 963 JSValueRef JSIPC::createSemaphore(JSContextRef context, JSObjectRef, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 964 { 965 return JSIPCSemaphore::create()->createJSWrapper(context); 966 } 967 763 968 JSValueRef JSIPC::visitedLinkStoreID(JSContextRef context, JSObjectRef thisObject, JSStringRef, JSValueRef* exception) 764 969 { … … 1018 1223 } // namespace WebKit 1019 1224 1225 namespace IPC { 1226 1227 template<> 1228 JSC::JSValue jsValueForDecodedArgumentValue(JSC::JSGlobalObject* globalObject, IPC::Semaphore&& value) 1229 { 1230 auto& vm = globalObject->vm(); 1231 auto scope = DECLARE_THROW_SCOPE(vm); 1232 auto* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype()); 1233 RETURN_IF_EXCEPTION(scope, JSC::JSValue()); 1234 object->putDirect(vm, JSC::Identifier::fromString(vm, "type"_s), JSC::jsNontrivialString(vm, "Semaphore")); 1235 RETURN_IF_EXCEPTION(scope, JSC::JSValue()); 1236 auto jsValue = toJS(globalObject, WebKit::IPCTestingAPI::JSIPCSemaphore::create(WTFMove(value))->createJSWrapper(toRef(globalObject))); 1237 object->putDirect(vm, JSC::Identifier::fromString(vm, "value"_s), jsValue); 1238 RETURN_IF_EXCEPTION(scope, JSC::JSValue()); 1239 return object; 1240 } 1241 1242 } // namespace IPC 1243 1020 1244 #endif -
trunk/Tools/ChangeLog
r277180 r277199 1 2021-05-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 IPC testing API should have the ability to create and receive IPC::Semaphore 4 https://bugs.webkit.org/show_bug.cgi?id=225537 5 6 Reviewed by Wenson Hsieh. 7 8 Added tests to make sure IPC testing API allows creation of a semaphore, 9 and receiving one as a reply to an IPC message. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm: 12 (IPCTestingAPI.CanReceiveIPCSemaphore): Added. 13 (IPCTestingAPI.CanCreateIPCSemaphore): Added. 14 1 15 2021-05-07 Aakash Jain <aakash_jain@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/IPCTestingAPI.mm
r276733 r277199 210 210 EXPECT_FALSE([webView stringByEvaluatingJavaScript:@"result.arguments[0].value"].boolValue); 211 211 } 212 213 TEST(IPCTestingAPI, CanReceiveIPCSemaphore) 214 { 215 auto webView = createWebViewWithIPCTestingAPI(); 216 217 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); 218 [webView setUIDelegate:delegate.get()]; 219 220 done = false; 221 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>" 222 "const semaphore = IPC.createSemaphore();" 223 "IPC.sendMessage('GPU', 0, IPC.messages.GPUConnectionToWebProcess_CreateRenderingBackend.name," 224 " [{type: 'RemoteRenderingBackendCreationParameters', 'identifier': 123, semaphore, 'pageProxyID': IPC.webPageProxyID, 'pageID': IPC.pageID}]);" 225 "const result = IPC.sendSyncMessage('GPU', 123, IPC.messages.RemoteRenderingBackend_SemaphoreForGetImageData.name, 100, []);" 226 "semaphore.signal();" 227 "alert(result.arguments.length + ':' + result.arguments[0].type + ':' + result.arguments[0].value.waitFor(100));" 228 "</script>"]; 229 TestWebKitAPI::Util::run(&done); 230 231 EXPECT_STREQ([alertMessage UTF8String], "1:Semaphore:false"); 232 } 212 233 #endif 234 235 TEST(IPCTestingAPI, CanCreateIPCSemaphore) 236 { 237 auto webView = createWebViewWithIPCTestingAPI(); 238 239 auto delegate = adoptNS([[IPCTestingAPIDelegate alloc] init]); 240 [webView setUIDelegate:delegate.get()]; 241 242 done = false; 243 [webView synchronouslyLoadHTMLString:@"<!DOCTYPE html><script>alert(IPC.createSemaphore().waitFor(100));</script>"]; 244 TestWebKitAPI::Util::run(&done); 245 246 EXPECT_FALSE([alertMessage boolValue]); 247 } 213 248 214 249 TEST(IPCTestingAPI, DecodesReplyArgumentsForPrompt)
Note:
See TracChangeset
for help on using the changeset viewer.