void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) { if (WKStringIsEqualToUTF8CString(messageName, "BeginTest")) { ASSERT(messageBody); ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> dumpPixelsKey(AdoptWK, WKStringCreateWithUTF8CString("DumpPixels")); m_dumpPixels = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, dumpPixelsKey.get()))); WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey(AdoptWK, WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer")); m_useWaitToDumpWatchdogTimer = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, useWaitToDumpWatchdogTimerKey.get()))); WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack")); WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest")); WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get()); beginTesting(messageBodyDictionary); return; } else if (WKStringIsEqualToUTF8CString(messageName, "Reset")) { ASSERT(messageBody); ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> shouldGCKey(AdoptWK, WKStringCreateWithUTF8CString("ShouldGC")); bool shouldGC = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, shouldGCKey.get()))); if (shouldGC) WKBundleGarbageCollectJavaScriptObjects(m_bundle); m_state = Idle; m_dumpPixels = false; resetLocalSettings(); m_testRunner->removeAllWebNotificationPermissions(); return; } if (WKStringIsEqualToUTF8CString(messageName, "CallAddChromeInputFieldCallback")) { m_testRunner->callAddChromeInputFieldCallback(); return; } if (WKStringIsEqualToUTF8CString(messageName, "CallRemoveChromeInputFieldCallback")) { m_testRunner->callRemoveChromeInputFieldCallback(); return; } if (WKStringIsEqualToUTF8CString(messageName, "CallFocusWebViewCallback")) { m_testRunner->callFocusWebViewCallback(); return; } if (WKStringIsEqualToUTF8CString(messageName, "CallSetBackingScaleFactorCallback")) { m_testRunner->callSetBackingScaleFactorCallback(); return; } WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error")); WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown")); WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get()); }
void InjectedBundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) { if (WKStringIsEqualToUTF8CString(messageName, "BeginTest")) { ASSERT(messageBody); ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID()); m_dumpPixels = WKBooleanGetValue(static_cast<WKBooleanRef>(messageBody)); WKRetainPtr<WKStringRef> ackMessageName(AdoptWK, WKStringCreateWithUTF8CString("Ack")); WKRetainPtr<WKStringRef> ackMessageBody(AdoptWK, WKStringCreateWithUTF8CString("BeginTest")); WKBundlePostMessage(m_bundle, ackMessageName.get(), ackMessageBody.get()); beginTesting(); return; } else if (WKStringIsEqualToUTF8CString(messageName, "Reset")) { ASSERT(messageBody); ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); WKRetainPtr<WKStringRef> shouldGCKey(AdoptWK, WKStringCreateWithUTF8CString("ShouldGC")); bool shouldGC = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, shouldGCKey.get()))); if (shouldGC) WKBundleGarbageCollectJavaScriptObjects(m_bundle); m_state = Idle; m_dumpPixels = false; resetLocalSettings(); return; } WKRetainPtr<WKStringRef> errorMessageName(AdoptWK, WKStringCreateWithUTF8CString("Error")); WKRetainPtr<WKStringRef> errorMessageBody(AdoptWK, WKStringCreateWithUTF8CString("Unknown")); WKBundlePostMessage(m_bundle, errorMessageName.get(), errorMessageBody.get()); }