void EventSendingController::keyDown(JSStringRef key, JSValueRef modifierArray, int location) { WKBundlePageRef page = InjectedBundle::shared().page()->page(); WKBundleFrameRef frame = WKBundlePageGetMainFrame(page); JSContextRef context = WKBundleFrameGetJavaScriptContext(frame); WKEventModifiers modifiers = parseModifierArray(context, modifierArray); WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("KeyDown")); WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); WKRetainPtr<WKStringRef> keyKey(AdoptWK, WKStringCreateWithUTF8CString("Key")); WKDictionaryAddItem(EventSenderMessageBody.get(), keyKey.get(), toWK(key).get()); WKRetainPtr<WKStringRef> modifiersKey(AdoptWK, WKStringCreateWithUTF8CString("Modifiers")); WKRetainPtr<WKUInt64Ref> modifiersRef(AdoptWK, WKUInt64Create(modifiers)); WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get()); WKRetainPtr<WKStringRef> locationKey(AdoptWK, WKStringCreateWithUTF8CString("Location")); WKRetainPtr<WKUInt64Ref> locationRef(AdoptWK, WKUInt64Create(location)); WKDictionaryAddItem(EventSenderMessageBody.get(), locationKey.get(), locationRef.get()); WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); }
void EventSendingController::setTouchModifier(const JSStringRef &modifier, bool enable) { WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("SetTouchModifier")); WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); WKEventModifiers mod = 0; if (JSStringIsEqualToUTF8CString(modifier, "ctrl")) mod = kWKEventModifiersControlKey; if (JSStringIsEqualToUTF8CString(modifier, "shift")) mod = kWKEventModifiersShiftKey; if (JSStringIsEqualToUTF8CString(modifier, "alt")) mod = kWKEventModifiersAltKey; if (JSStringIsEqualToUTF8CString(modifier, "meta")) mod = kWKEventModifiersMetaKey; WKRetainPtr<WKStringRef> modifierKey(AdoptWK, WKStringCreateWithUTF8CString("Modifier")); WKRetainPtr<WKUInt64Ref> modifierRef(AdoptWK, WKUInt64Create(mod)); WKDictionaryAddItem(EventSenderMessageBody.get(), modifierKey.get(), modifierRef.get()); WKRetainPtr<WKStringRef> enableKey(AdoptWK, WKStringCreateWithUTF8CString("Enable")); WKRetainPtr<WKUInt64Ref> enableRef(AdoptWK, WKUInt64Create(enable)); WKDictionaryAddItem(EventSenderMessageBody.get(), enableKey.get(), enableRef.get()); WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); }
void EventSendingController::mouseUp(int button, JSValueRef modifierArray) { WKBundlePageRef page = InjectedBundle::shared().page()->page(); WKBundleFrameRef frame = WKBundlePageGetMainFrame(page); JSContextRef context = WKBundleFrameGetJavaScriptContext(frame); WKEventModifiers modifiers = parseModifierArray(context, modifierArray); #ifdef USE_WEBPROCESS_EVENT_SIMULATION updateClickCount(button); WKBundlePageSimulateMouseUp(page, button, m_position, m_clickCount, modifiers, m_time); #else WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("MouseUp")); WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); WKRetainPtr<WKStringRef> buttonKey(AdoptWK, WKStringCreateWithUTF8CString("Button")); WKRetainPtr<WKUInt64Ref> buttonRef(AdoptWK, WKUInt64Create(button)); WKDictionaryAddItem(EventSenderMessageBody.get(), buttonKey.get(), buttonRef.get()); WKRetainPtr<WKStringRef> modifiersKey(AdoptWK, WKStringCreateWithUTF8CString("Modifiers")); WKRetainPtr<WKUInt64Ref> modifiersRef(AdoptWK, WKUInt64Create(modifiers)); WKDictionaryAddItem(EventSenderMessageBody.get(), modifiersKey.get(), modifiersRef.get()); WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); #endif }
void InjectedBundle::queueForwardNavigation(unsigned howFarForward) { m_useWorkQueue = true; WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("QueueForwardNavigation")); WKRetainPtr<WKUInt64Ref> messageBody(AdoptWK, WKUInt64Create(howFarForward)); WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get()); }
static void didAssociateFormControls(WKBundlePageRef page, WKArrayRef elementHandles, const void*) { WKRetainPtr<WKMutableDictionaryRef> messageBody = adoptWK(WKMutableDictionaryCreate()); WKDictionarySetItem(messageBody.get(), Util::toWK("Page").get(), page); WKRetainPtr<WKUInt64Ref> numberOfElements = adoptWK(WKUInt64Create(WKArrayGetSize(elementHandles))); WKDictionarySetItem(messageBody.get(), Util::toWK("NumberOfControls").get(), numberOfElements.get()); WKBundlePostMessage(InjectedBundleController::singleton().bundle(), Util::toWK("DidReceiveDidAssociateFormControls").get(), messageBody.get()); }
void EventSendingController::setTouchPointRadius(int radiusX, int radiusY) { WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("SetTouchPointRadius")); WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); WKRetainPtr<WKStringRef> xKey(AdoptWK, WKStringCreateWithUTF8CString("RadiusX")); WKRetainPtr<WKUInt64Ref> xRef(AdoptWK, WKUInt64Create(radiusX)); WKDictionaryAddItem(EventSenderMessageBody.get(), xKey.get(), xRef.get()); WKRetainPtr<WKStringRef> yKey(AdoptWK, WKStringCreateWithUTF8CString("RadiusY")); WKRetainPtr<WKUInt64Ref> yRef(AdoptWK, WKUInt64Create(radiusY)); WKDictionaryAddItem(EventSenderMessageBody.get(), yKey.get(), yRef.get()); WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); }
void EventSendingController::updateTouchPoint(int index, int x, int y) { WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("UpdateTouchPoint")); WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); WKRetainPtr<WKStringRef> indexKey(AdoptWK, WKStringCreateWithUTF8CString("Index")); WKRetainPtr<WKUInt64Ref> indexRef(AdoptWK, WKUInt64Create(index)); WKDictionaryAddItem(EventSenderMessageBody.get(), indexKey.get(), indexRef.get()); WKRetainPtr<WKStringRef> xKey(AdoptWK, WKStringCreateWithUTF8CString("X")); WKRetainPtr<WKUInt64Ref> xRef(AdoptWK, WKUInt64Create(x)); WKDictionaryAddItem(EventSenderMessageBody.get(), xKey.get(), xRef.get()); WKRetainPtr<WKStringRef> yKey(AdoptWK, WKStringCreateWithUTF8CString("Y")); WKRetainPtr<WKUInt64Ref> yRef(AdoptWK, WKUInt64Create(y)); WKDictionaryAddItem(EventSenderMessageBody.get(), yKey.get(), yRef.get()); WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); }
void InjectedBundle::setVisibilityState(WKPageVisibilityState visibilityState, bool isInitialState) { WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetVisibilityState")); WKRetainPtr<WKMutableDictionaryRef> messageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> visibilityStateKeyWK(AdoptWK, WKStringCreateWithUTF8CString("visibilityState")); WKRetainPtr<WKUInt64Ref> visibilityStateWK(AdoptWK, WKUInt64Create(visibilityState)); WKDictionaryAddItem(messageBody.get(), visibilityStateKeyWK.get(), visibilityStateWK.get()); WKRetainPtr<WKStringRef> isInitialKeyWK(AdoptWK, WKStringCreateWithUTF8CString("isInitialState")); WKRetainPtr<WKBooleanRef> isInitialWK(AdoptWK, WKBooleanCreate(isInitialState)); WKDictionaryAddItem(messageBody.get(), isInitialKeyWK.get(), isInitialWK.get()); WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get()); }
void EventSendingController::leapForward(int milliseconds) { #ifdef USE_WEBPROCESS_EVENT_SIMULATION m_time += milliseconds / 1000.0; #else WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("LeapForward")); WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); WKRetainPtr<WKStringRef> timeKey(AdoptWK, WKStringCreateWithUTF8CString("TimeInMilliseconds")); WKRetainPtr<WKUInt64Ref> timeRef(AdoptWK, WKUInt64Create(milliseconds)); WKDictionaryAddItem(EventSenderMessageBody.get(), timeKey.get(), timeRef.get()); WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); #endif }
void EventSendingController::continuousMouseScrollBy(int x, int y, bool paged) { WKRetainPtr<WKStringRef> EventSenderMessageName(AdoptWK, WKStringCreateWithUTF8CString("EventSender")); WKRetainPtr<WKMutableDictionaryRef> EventSenderMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> subMessageKey(AdoptWK, WKStringCreateWithUTF8CString("SubMessage")); WKRetainPtr<WKStringRef> subMessageName(AdoptWK, WKStringCreateWithUTF8CString("ContinuousMouseScrollBy")); WKDictionaryAddItem(EventSenderMessageBody.get(), subMessageKey.get(), subMessageName.get()); WKRetainPtr<WKStringRef> xKey(AdoptWK, WKStringCreateWithUTF8CString("X")); WKRetainPtr<WKDoubleRef> xRef(AdoptWK, WKDoubleCreate(x)); WKDictionaryAddItem(EventSenderMessageBody.get(), xKey.get(), xRef.get()); WKRetainPtr<WKStringRef> yKey(AdoptWK, WKStringCreateWithUTF8CString("Y")); WKRetainPtr<WKDoubleRef> yRef(AdoptWK, WKDoubleCreate(y)); WKDictionaryAddItem(EventSenderMessageBody.get(), yKey.get(), yRef.get()); WKRetainPtr<WKStringRef> pagedKey(AdoptWK, WKStringCreateWithUTF8CString("Paged")); WKRetainPtr<WKUInt64Ref> pagedRef(AdoptWK, WKUInt64Create(paged)); WKDictionaryAddItem(EventSenderMessageBody.get(), pagedKey.get(), pagedRef.get()); WKBundlePostSynchronousMessage(InjectedBundle::shared().bundle(), EventSenderMessageName.get(), EventSenderMessageBody.get(), 0); }
void InjectedBundle::postSimulateWebNotificationClick(uint64_t notificationID) { WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SimulateWebNotificationClick")); WKRetainPtr<WKUInt64Ref> messageBody(AdoptWK, WKUInt64Create(notificationID)); WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get()); }
void TestInvocation::invoke() { TestController::TimeoutDuration timeoutToUse = TestController::LongTimeout; sizeWebViewForCurrentTest(m_pathOrURL.c_str()); updateLayoutType(m_pathOrURL.c_str()); updateTiledDrawingForCurrentTest(m_pathOrURL.c_str()); m_textOutput.clear(); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest")); WKRetainPtr<WKMutableDictionaryRef> beginTestMessageBody = adoptWK(WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> dumpFrameLoadDelegatesKey = adoptWK(WKStringCreateWithUTF8CString("DumpFrameLoadDelegates")); WKRetainPtr<WKBooleanRef> dumpFrameLoadDelegatesValue = adoptWK(WKBooleanCreate(shouldLogFrameLoadDelegates(m_pathOrURL.c_str()))); WKDictionaryAddItem(beginTestMessageBody.get(), dumpFrameLoadDelegatesKey.get(), dumpFrameLoadDelegatesValue.get()); WKRetainPtr<WKStringRef> dumpPixelsKey = adoptWK(WKStringCreateWithUTF8CString("DumpPixels")); WKRetainPtr<WKBooleanRef> dumpPixelsValue = adoptWK(WKBooleanCreate(m_dumpPixels)); WKDictionaryAddItem(beginTestMessageBody.get(), dumpPixelsKey.get(), dumpPixelsValue.get()); WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey = adoptWK(WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer")); WKRetainPtr<WKBooleanRef> useWaitToDumpWatchdogTimerValue = adoptWK(WKBooleanCreate(TestController::shared().useWaitToDumpWatchdogTimer())); WKDictionaryAddItem(beginTestMessageBody.get(), useWaitToDumpWatchdogTimerKey.get(), useWaitToDumpWatchdogTimerValue.get()); WKRetainPtr<WKStringRef> timeoutKey = adoptWK(WKStringCreateWithUTF8CString("Timeout")); WKRetainPtr<WKUInt64Ref> timeoutValue = adoptWK(WKUInt64Create(m_timeout)); WKDictionaryAddItem(beginTestMessageBody.get(), timeoutKey.get(), timeoutValue.get()); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), beginTestMessageBody.get()); TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout); if (!m_gotInitialResponse) { m_errorMessage = "Timed out waiting for initial response from web process\n"; m_webProcessIsUnresponsive = true; goto end; } if (m_error) goto end; #if ENABLE(INSPECTOR) if (shouldOpenWebInspector(m_pathOrURL.c_str())) WKInspectorShow(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get()); if (TestController::shared().useWaitToDumpWatchdogTimer()) { if (m_timeout > 0) timeoutToUse = TestController::CustomTimeout; } else timeoutToUse = TestController::NoTimeout; TestController::shared().runUntil(m_gotFinalMessage, timeoutToUse); if (!m_gotFinalMessage) { m_errorMessage = "Timed out waiting for final message from web process\n"; m_webProcessIsUnresponsive = true; goto end; } if (m_error) goto end; dumpResults(); end: #if ENABLE(INSPECTOR) if (m_gotInitialResponse) WKInspectorClose(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) if (m_webProcessIsUnresponsive) dumpWebProcessUnresponsiveness(); else if (!TestController::shared().resetStateToConsistentValues()) { m_errorMessage = "Timed out loading about:blank before the next test"; dumpWebProcessUnresponsiveness(); } }