_Ewk_Context(WKRetainPtr<WKContextRef> contextRef) : context(contextRef) , cookieManager(0) , requestManager(WKContextGetSoupRequestManager(contextRef.get())) { #if ENABLE(BATTERY_STATUS) WKBatteryManagerRef wkBatteryManager = WKContextGetBatteryManager(contextRef.get()); batteryProvider = BatteryProvider::create(wkBatteryManager); #endif #if ENABLE(VIBRATION) WKVibrationRef wkVibrationRef = WKContextGetVibration(contextRef.get()); vibrationProvider = VibrationProvider::create(wkVibrationRef); #endif #if ENABLE(MEMORY_SAMPLER) static bool initializeMemorySampler = false; static const char environmentVariable[] = "SAMPLE_MEMORY"; if (!initializeMemorySampler && getenv(environmentVariable)) { WKRetainPtr<WKDoubleRef> interval(AdoptWK, WKDoubleCreate(0.0)); WKContextStartMemorySampler(context.get(), interval.get()); initializeMemorySampler = true; } #endif ewk_context_request_manager_client_attach(this); ewk_context_download_client_attach(this); }
void InjectedBundle::done() { m_state = Stopping; m_useWorkQueue = false; page()->stopLoading(); setTopLoadingFrame(0); m_accessibilityController->resetToConsistentState(); WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("Done")); WKRetainPtr<WKMutableDictionaryRef> doneMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> pixelResultKey = adoptWK(WKStringCreateWithUTF8CString("PixelResult")); WKDictionarySetItem(doneMessageBody.get(), pixelResultKey.get(), m_pixelResult.get()); WKRetainPtr<WKStringRef> repaintRectsKey = adoptWK(WKStringCreateWithUTF8CString("RepaintRects")); WKDictionarySetItem(doneMessageBody.get(), repaintRectsKey.get(), m_repaintRects.get()); WKRetainPtr<WKStringRef> audioResultKey = adoptWK(WKStringCreateWithUTF8CString("AudioResult")); WKDictionarySetItem(doneMessageBody.get(), audioResultKey.get(), m_audioResult.get()); WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get()); closeOtherPages(); m_state = Idle; }
void InjectedBundle::done() { m_state = Stopping; page()->stopLoading(); setTopLoadingFrame(0); m_accessibilityController->resetToConsistentState(); WKRetainPtr<WKStringRef> doneMessageName(AdoptWK, WKStringCreateWithUTF8CString("Done")); WKRetainPtr<WKMutableDictionaryRef> doneMessageBody(AdoptWK, WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> textOutputKey(AdoptWK, WKStringCreateWithUTF8CString("TextOutput")); WKRetainPtr<WKStringRef> textOutput(AdoptWK, WKStringCreateWithUTF8CString(m_stringBuilder->toString().utf8().data())); WKDictionaryAddItem(doneMessageBody.get(), textOutputKey.get(), textOutput.get()); WKRetainPtr<WKStringRef> pixelResultKey = adoptWK(WKStringCreateWithUTF8CString("PixelResult")); WKDictionaryAddItem(doneMessageBody.get(), pixelResultKey.get(), m_pixelResult.get()); WKRetainPtr<WKStringRef> repaintRectsKey = adoptWK(WKStringCreateWithUTF8CString("RepaintRects")); WKDictionaryAddItem(doneMessageBody.get(), repaintRectsKey.get(), m_repaintRects.get()); WKBundlePostMessage(m_bundle, doneMessageName.get(), doneMessageBody.get()); closeOtherPages(); page()->resetAfterTest(); m_state = Idle; }
void EventSendingController::mouseDown(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); WKBundlePageSimulateMouseDown(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("MouseDown")); 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 }
WKPageRef EwkView::createNewPage(PassRefPtr<EwkUrlRequest>, WKDictionaryRef windowFeatures) { Ewk_View_Smart_Data* sd = smartData(); ASSERT(sd->api); if (!sd->api->window_create) return 0; WKPageRef wkPageRef = wkPage(); RefPtr<EwkWindowFeatures> ewkWindowFeatures = EwkWindowFeatures::create(windowFeatures, this); WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageCopyPageConfiguration(wkPageRef)); WKPageConfigurationSetRelatedPage(configuration.get(), wkPageRef); Ref<EwkViewConfiguration> ewkViewConfiguration = EwkViewConfiguration::create(configuration.get()); Evas_Object* newEwkView = sd->api->window_create(sd, &ewkViewConfiguration.get(), ewkWindowFeatures.get()); if (!newEwkView) return 0; EwkView* newViewImpl = toEwkView(newEwkView); ASSERT(newViewImpl); newViewImpl->m_windowFeatures = ewkWindowFeatures; return static_cast<WKPageRef>(WKRetain(newViewImpl->page())); }
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() { ASSERT(m_inspectedPage); #ifdef HAVE_ECORE_X const char* engine = "opengl_x11"; m_inspectorWindow = ecore_evas_new(engine, 0, 0, initialWindowWidth, initialWindowHeight, 0); // Gracefully fall back to software if evas_gl engine is not available. if (!m_inspectorWindow) #endif m_inspectorWindow = ecore_evas_new(0, 0, 0, initialWindowWidth, initialWindowHeight, 0); if (!m_inspectorWindow) return 0; WKContextRef wkContext = toAPI(&inspectorProcessPool()); WKRetainPtr<WKStringRef> wkGroupIdentifier = adoptWK(WKStringCreateWithUTF8CString(inspectorPageGroupIdentifier().utf8().data())); WKPageGroupRef wkPageGroup = WKPageGroupCreateWithIdentifier(wkGroupIdentifier.get()); WKRetainPtr<WKPageConfigurationRef> wkPageConfiguration = adoptWK(WKPageConfigurationCreate()); WKPageConfigurationSetContext(wkPageConfiguration.get(), wkContext); WKPageConfigurationSetPageGroup(wkPageConfiguration.get(), wkPageGroup); m_inspectorView = EWKViewCreate(wkContext, wkPageConfiguration.get(), ecore_evas_get(m_inspectorWindow), /* smart */ 0); WKViewRef wkView = EWKViewGetWKView(m_inspectorView); WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(DEFAULT_THEME_DIR "/default.edj")); WKViewSetThemePath(wkView, wkTheme.get()); WKPreferencesRef wkPreferences = WKPageGroupGetPreferences(wkPageGroup); WKPreferencesSetFileAccessFromFileURLsAllowed(wkPreferences, true); WKPreferencesSetJavaScriptRuntimeFlags(wkPreferences, 0); return toImpl(WKViewGetPage(wkView)); }
TEST(WebKit2, WKPageCopySessionStateWithFiltering) { WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); createSessionStates(context.get()); EXPECT_NOT_NULL(sessionStateWithFirstItemRemoved); PlatformWebView webView1(context.get()); setPageLoaderClient(webView1.page()); WKPageRestoreFromSessionState(webView1.page(), sessionStateWithFirstItemRemoved.get()); Util::run(&didFinishLoad); didFinishLoad = false; WKBackForwardListRef backForwardList1 = WKPageGetBackForwardList(webView1.page()); EXPECT_EQ(0u, WKBackForwardListGetBackListCount(backForwardList1)); EXPECT_EQ(1u, WKBackForwardListGetForwardListCount(backForwardList1)); EXPECT_NOT_NULL(sessionStateWithAllItemsRemoved); PlatformWebView webView2(context.get()); setPageLoaderClient(webView2.page()); WKPageRestoreFromSessionState(webView2.page(), sessionStateWithAllItemsRemoved.get()); // Because the session state ends up being empty, nothing is actually loaded. WKBackForwardListRef backForwardList2 = WKPageGetBackForwardList(webView2.page()); EXPECT_EQ(0u, WKBackForwardListGetBackListCount(backForwardList2)); EXPECT_EQ(0u, WKBackForwardListGetForwardListCount(backForwardList2)); }
TEST(WebKit2, ResizeWindowAfterCrash) { WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); TestStatesData states(context.get()); WKPageLoaderClientV0 loaderClient; memset(&loaderClient, 0, sizeof(loaderClient)); loaderClient.base.version = 0; loaderClient.base.clientInfo = &states; loaderClient.didFinishLoadForFrame = didFinishLoad; loaderClient.processDidCrash = didCrash; WKPageSetPageLoaderClient(states.webView.page(), &loaderClient.base); WKRetainPtr<WKURLRef> url = adoptWK(WKURLCreateWithUTF8CString("about:blank")); // Load a blank page and next kills WebProcess. WKPageLoadURL(states.webView.page(), url.get()); Util::run(&states.firstLoad); WKPageTerminate(states.webView.page()); // Let's try load a page and see what happens. WKPageLoadURL(states.webView.page(), url.get()); Util::run(&states.resizeAfterCrash); }
void TestRunner::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL) { WKRetainPtr<WKStringRef> contentWK = toWK(content); WKRetainPtr<WKStringRef> baseURLWK = baseURL ? toWK(baseURL) : WKRetainPtr<WKStringRef>(); WKRetainPtr<WKStringRef> unreachableURLWK = unreachableURL ? toWK(unreachableURL) : WKRetainPtr<WKStringRef>(); InjectedBundle::singleton().queueLoadHTMLString(contentWK.get(), baseURLWK.get(), unreachableURLWK.get()); }
static void updateLayoutType(const char* pathOrURL) { WKRetainPtr<WKMutableDictionaryRef> viewOptions = adoptWK(WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> useFixedLayoutKey = adoptWK(WKStringCreateWithUTF8CString("UseFixedLayout")); WKRetainPtr<WKBooleanRef> useFixedLayoutValue = adoptWK(WKBooleanCreate(shouldUseFixedLayout(pathOrURL))); WKDictionaryAddItem(viewOptions.get(), useFixedLayoutKey.get(), useFixedLayoutValue.get()); TestController::shared().ensureViewSupportsOptions(viewOptions.get()); }
TEST(WebKit2, WillSendSubmitEvent) { WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("WillSendSubmitEventTest")); setInjectedBundleClient(context.get()); PlatformWebView webView(context.get()); WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("auto-submitting-form", "html")).get()); Util::run(&didReceiveMessage); }
Evas_Object* EWKViewCreate(WKContextRef context, WKPageGroupRef pageGroup, Evas* canvas, Evas_Smart* smart) { WKRetainPtr<WKViewRef> wkView = adoptWK(WKViewCreate(context, pageGroup)); WKPageSetUseFixedLayout(WKViewGetPage(wkView.get()), true); if (EwkView* ewkView = EwkView::create(wkView.get(), canvas, smart)) return ewkView->evasObject(); return 0; }
const char* EwkView::customTextEncodingName() const { WKRetainPtr<WKStringRef> customEncoding = adoptWK(WKPageCopyCustomTextEncodingName(wkPage())); if (WKStringIsEmpty(customEncoding.get())) return 0; m_customEncoding = WKEinaSharedString(customEncoding.get()); return m_customEncoding; }
static void didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) { if (!WKBundleFrameIsMainFrame(frame)) { childFrame = frame; return; } bool isParentFrameCheckSuccessful = childFrame ? WKBundleFrameGetParentFrame(childFrame.get()) == frame : false; WKBundlePostMessage(testBundle.get(), Util::toWK("DidCheckParentFrame").get(), adoptWK(WKBooleanCreate(isParentFrameCheckSuccessful)).get()); }
TEST_F(WebKit2UserMessageRoundTripTest, WKURL) { WKRetainPtr<WKURLRef> url = adoptWK(WKURLCreateWithUTF8CString("http://webkit.org/")); roundTrip(url.get()); WKTypeRef roundTrippedTypeRef = recievedBody.get(); WKRetainPtr<WKURLRef> roundTrippedURL = static_cast<WKURLRef>(roundTrippedTypeRef); EXPECT_TRUE(WKURLIsEqual(roundTrippedURL.get(), url.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()); }
TEST_F(WebKit2UserMessageRoundTripTest, WKString) { WKRetainPtr<WKStringRef> string = adoptWK(WKStringCreateWithUTF8CString("An important string")); roundTrip(string.get()); WKTypeRef roundTrippedTypeRef = recievedBody.get(); WKRetainPtr<WKStringRef> roundTrippedString = static_cast<WKStringRef>(roundTrippedTypeRef); EXPECT_TRUE(WKStringIsEqual(roundTrippedString.get(), string.get())); }
/** * @internal * The url of view was changed by the frame loader. * * Emits signal: "url,changed" with pointer to new url string. */ void EwkView::informURLChange() { WKRetainPtr<WKURLRef> wkActiveURL = adoptWK(WKPageCopyActiveURL(wkPage())); WKRetainPtr<WKStringRef> wkURLString = wkActiveURL ? adoptWK(WKURLCopyString(wkActiveURL.get())) : adoptWK(WKStringCreateWithUTF8CString("")); if (WKStringIsEqualToUTF8CString(wkURLString.get(), m_url)) return; m_url = WKEinaSharedString(wkURLString.get()); smartCallback<URLChanged>().call(m_url); }
// Used to test sending a WKType round trip to the WebProcess and back. // Result is stored into the recievedBody member variable. void roundTrip(WKTypeRef object) { WKTypeID storedTypeID = WKGetTypeID(object); recievedBody.clear(); didReceiveMessage = false; WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("RoundTrip").get(), object); Util::run(&didReceiveMessage); EXPECT_NOT_NULL(recievedBody); EXPECT_EQ(storedTypeID, WKGetTypeID(recievedBody.get())); }
bool TestController::resetStateToConsistentValues() { m_state = Resetting; WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("Reset")); WKRetainPtr<WKMutableDictionaryRef> resetMessageBody = adoptWK(WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> shouldGCKey = adoptWK(WKStringCreateWithUTF8CString("ShouldGC")); WKRetainPtr<WKBooleanRef> shouldGCValue = adoptWK(WKBooleanCreate(m_gcBetweenTests)); WKDictionaryAddItem(resetMessageBody.get(), shouldGCKey.get(), shouldGCValue.get()); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), resetMessageBody.get()); // FIXME: This function should also ensure that there is only one page open. // Reset preferences WKPreferencesRef preferences = WKPageGroupGetPreferences(m_pageGroup.get()); WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true); WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing); WKPreferencesSetXSSAuditorEnabled(preferences, false); WKPreferencesSetDeveloperExtrasEnabled(preferences, true); WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(preferences, true); WKPreferencesSetJavaScriptCanAccessClipboard(preferences, true); WKPreferencesSetDOMPasteAllowed(preferences, true); WKPreferencesSetUniversalAccessFromFileURLsAllowed(preferences, true); WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true); #if ENABLE(FULLSCREEN_API) WKPreferencesSetFullScreenEnabled(preferences, true); #endif static WKStringRef standardFontFamily = WKStringCreateWithUTF8CString("Times"); static WKStringRef cursiveFontFamily = WKStringCreateWithUTF8CString("Apple Chancery"); static WKStringRef fantasyFontFamily = WKStringCreateWithUTF8CString("Papyrus"); static WKStringRef fixedFontFamily = WKStringCreateWithUTF8CString("Courier"); static WKStringRef sansSerifFontFamily = WKStringCreateWithUTF8CString("Helvetica"); static WKStringRef serifFontFamily = WKStringCreateWithUTF8CString("Times"); WKPreferencesSetStandardFontFamily(preferences, standardFontFamily); WKPreferencesSetCursiveFontFamily(preferences, cursiveFontFamily); WKPreferencesSetFantasyFontFamily(preferences, fantasyFontFamily); WKPreferencesSetFixedFontFamily(preferences, fixedFontFamily); WKPreferencesSetSansSerifFontFamily(preferences, sansSerifFontFamily); WKPreferencesSetSerifFontFamily(preferences, serifFontFamily); m_mainWebView->focus(); // Reset main page back to about:blank m_doneResetting = false; WKPageLoadURL(m_mainWebView->page(), blankURL()); runUntil(m_doneResetting, ShortTimeout); return m_doneResetting; }
static bool filterFirstItemCallback(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context) { if (!WKStringIsEqual(valueType, WKPageGetSessionBackForwardListItemValueType())) return true; ASSERT(WKGetTypeID(value) == WKBackForwardListItemGetTypeID()); WKBackForwardListItemRef backForwardListItem = static_cast<WKBackForwardListItemRef>(value); WKRetainPtr<WKURLRef> url = adoptWK(WKBackForwardListItemCopyURL(backForwardListItem)); WKRetainPtr<WKStringRef> path = adoptWK(WKURLCopyLastPathComponent(url.get())); return !WKStringIsEqualToUTF8CString(path.get(), "simple.html"); }
static void updateTiledDrawingForCurrentTest(const char* pathOrURL) { #if PLATFORM(MAC) WKRetainPtr<WKMutableDictionaryRef> viewOptions = adoptWK(WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> useTiledDrawingKey = adoptWK(WKStringCreateWithUTF8CString("TiledDrawing")); WKRetainPtr<WKBooleanRef> useTiledDrawingValue = adoptWK(WKBooleanCreate(shouldUseTiledDrawing(pathOrURL))); WKDictionaryAddItem(viewOptions.get(), useTiledDrawingKey.get(), useTiledDrawingValue.get()); TestController::shared().ensureViewSupportsOptions(viewOptions.get()); #else UNUSED_PARAM(pathOrURL); #endif }
static void willLoadDataRequest(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo) { WKRetainPtr<WKMutableDictionaryRef> messageBody = adoptWK(WKMutableDictionaryCreate()); WKDictionarySetItem(messageBody.get(), Util::toWK("URLRequestReturn").get(), request); WKDictionarySetItem(messageBody.get(), Util::toWK("DataReturn").get(), data); WKDictionarySetItem(messageBody.get(), Util::toWK("MIMETypeReturn").get(), MIMEType); WKDictionarySetItem(messageBody.get(), Util::toWK("EncodingNameReturn").get(), encodingName); WKDictionarySetItem(messageBody.get(), Util::toWK("UnreachableURLReturn").get(), unreachableURL); WKDictionarySetItem(messageBody.get(), Util::toWK("UserDataReturn").get(), userData); WKBundlePostMessage(InjectedBundleController::singleton().bundle(), Util::toWK("WillLoadDataRequestReturn").get(), messageBody.get()); }
TEST(WebKit2, CanHandleRequest) { WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("CanHandleRequestTest")); setInjectedBundleClient(context.get()); _WKContextRegisterURLSchemeAsEmptyDocument(context.get(), Util::toWK("emptyscheme").get()); PlatformWebView webView(context.get()); WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple", "html")).get()); WKContextPostMessageToInjectedBundle(context.get(), Util::toWK("CheckCanHandleRequest").get(), 0); Util::run(&didReceiveMessage); EXPECT_TRUE(canHandleRequest); }
void DOMWindowExtensionBasic::sendExtensionStateMessage() { char body[16384]; sprintf(body, "Extension states:\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s", m_extensionRecords[0].name, stateNames[m_extensionRecords[0].state], m_extensionRecords[1].name, stateNames[m_extensionRecords[1].state], m_extensionRecords[2].name, stateNames[m_extensionRecords[2].state], m_extensionRecords[3].name, stateNames[m_extensionRecords[3].state], m_extensionRecords[4].name, stateNames[m_extensionRecords[4].state], m_extensionRecords[5].name, stateNames[m_extensionRecords[5].state]); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("ExtensionStates")); WKRetainPtr<WKStringRef> messageBody = adoptWK(WKStringCreateWithUTF8CString(body)); WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get()); }
TEST(WebKit2, DownloadDecideDestinationCrash) { WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate()); setContextDownloadClient(context.get()); PlatformWebView webView(context.get()); setPagePolicyClient(webView.page()); // The length of this filename was specially chosen to trigger the crash conditions in // <http://webkit.org/b/61142>. Specifically, it causes ArgumentDecoder::m_bufferPos and m_bufferEnd // to be equal after the DecideDestinationWithSuggestedFilename message has been handled. WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("18-characters", "html")).get()); Util::run(&didDecideDestination); }
QWebPermissionRequestPrivate(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef geo = 0, WKNotificationPermissionRequestRef notify = 0, QWebPermissionRequest::RequestType reqType = QWebPermissionRequest::Geolocation) : origin(securityOrigin) , geolocationRequest(geo) , notificationRequest(notify) , type(reqType) , allow(false) { WKRetainPtr<WKStringRef> url = adoptWK(WKSecurityOriginCopyProtocol(origin.get())); securityInfo.setScheme(WKStringCopyQString(url.get())); WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(origin.get())); securityInfo.setHost(WKStringCopyQString(host.get())); securityInfo.setPort(static_cast<int>(WKSecurityOriginGetPort(origin.get()))); }
void TestInvocation::invoke() { sizeWebViewForCurrentTest(m_pathOrURL.c_str()); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest")); WKRetainPtr<WKBooleanRef> dumpPixels = adoptWK(WKBooleanCreate(m_dumpPixels)); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), dumpPixels.get()); TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout); if (!m_gotInitialResponse) { dump("Timed out waiting for initial response from web process\n"); return; } if (m_error) { dump("FAIL\n"); return; } if (shouldOpenWebInspector(m_pathOrURL.c_str())) WKInspectorShow(WKPageGetInspector(TestController::shared().mainWebView()->page())); WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get()); TestController::shared().runUntil(m_gotFinalMessage, TestController::LongTimeout); if (!m_gotFinalMessage) dump("Timed out waiting for final message from web process\n"); else if (m_error) dump("FAIL\n"); WKInspectorClose(WKPageGetInspector(TestController::shared().mainWebView()->page())); }
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() { ASSERT(m_page); #ifdef HAVE_ECORE_X const char* engine = "opengl_x11"; m_inspectorWindow = ecore_evas_new(engine, 0, 0, initialWindowWidth, initialWindowHeight, 0); // Gracefully fall back to software if evas_gl engine is not available. if (!m_inspectorWindow) #endif m_inspectorWindow = ecore_evas_new(0, 0, 0, initialWindowWidth, initialWindowHeight, 0); if (!m_inspectorWindow) return 0; WKContextRef wkContext = toAPI(page()->process()->context()); WKPageGroupRef wkPageGroup = toAPI(inspectorPageGroup()); m_inspectorView = EWKViewCreate(wkContext, wkPageGroup, ecore_evas_get(m_inspectorWindow), /* smart */ 0); WKViewRef wkView = EWKViewGetWKView(m_inspectorView); WKRetainPtr<WKStringRef> wkTheme = adoptWK(WKStringCreateWithUTF8CString(TEST_THEME_DIR "/default.edj")); WKViewSetThemePath(wkView, wkTheme.get()); WKPreferencesRef wkPreferences = WKPageGroupGetPreferences(wkPageGroup); WKPreferencesSetFileAccessFromFileURLsAllowed(wkPreferences, true); return toImpl(WKViewGetPage(wkView)); }
void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects) { PlatformWebView* webView = TestController::shared().mainWebView(); WKRetainPtr<WKImageRef> windowSnapshot = webView->windowSnapshotImage(); // There is no way at this time to fake a window's scale factor, so we need to avoid the window // snapshots for HiDPI tests. if (WKPageGetBackingScaleFactor(webView->page()) != 1) windowSnapshot = 0; RetainPtr<CGContextRef> context; if (windowSnapshot) context = adoptCF(createCGContextFromImage(windowSnapshot.get(), DontFlipGraphicsContext)); else context = adoptCF(createCGContextFromImage(image)); // A non-null repaintRects array means we're doing a repaint test. if (repaintRects) paintRepaintRectOverlay(context.get(), image, repaintRects); char actualHash[33]; computeMD5HashStringForContext(context.get(), actualHash); if (!compareActualHashToExpectedAndDumpResults(actualHash)) dumpBitmap(context.get(), actualHash); }