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)); }
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)); }
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; }
TEST(WebKit2, WebWorker) { // This test cover the binding between functions of JavaScript Workers and // functions defined at a previously loaded bundle. It verifies the two // types of Workers, dedicated and shared. WKRetainPtr<WKContextRef> context = adoptWK(Util::createContextForInjectedBundleTest("WebWorkerTest")); PlatformWebView view(context.get()); WKPageLoaderClientV3 pageLoaderClient; memset(&pageLoaderClient, 0, sizeof(pageLoaderClient)); pageLoaderClient.base.version = 3; pageLoaderClient.didReceiveTitleForFrame = didReceiveTitleForFrame; WKPageSetPageLoaderClient(WKViewGetPage(view.platformView()), &pageLoaderClient.base); WKContextInjectedBundleClientV1 injectedBundleClient; memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); injectedBundleClient.base.version = 1; injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base); WKPageGroupRef pageGroup = WKPageGetPageGroup(WKViewGetPage(view.platformView())); WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup); WKPreferencesSetFileAccessFromFileURLsAllowed(preferences, true); WKRetainPtr<WKURLRef> url = adoptWK(Util::createURLForResource("../WebKit2/WebWorkerTest", "html")); WKPageLoadURL(WKViewGetPage(view.platformView()), url.get()); Util::run(&initialized); Util::run(&terminated); Util::run(&changedTitle); url = adoptWK(Util::createURLForResource("../WebKit2/WebWorkerSharedTest", "html")); WKPageLoadURL(WKViewGetPage(view.platformView()), url.get()); Util::run(&initializedShared); Util::run(&terminatedShared); Util::run(&changedTitleShared); }
bool TestController::resetStateToConsistentValues() { m_state = Resetting; m_beforeUnloadReturnValue = true; 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()); WKContextSetShouldUseFontSmoothing(TestController::shared().context(), false); WKContextSetCacheModel(TestController::shared().context(), kWKCacheModelDocumentBrowser); // FIXME: This function should also ensure that there is only one page open. // Reset the EventSender for each test. #if PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL) m_eventSenderProxy = adoptPtr(new EventSenderProxy(this)); #endif // Reset preferences WKPreferencesRef preferences = WKPageGroupGetPreferences(m_pageGroup.get()); WKPreferencesResetTestRunnerOverrides(preferences); WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true); WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing); WKPreferencesSetXSSAuditorEnabled(preferences, false); WKPreferencesSetWebAudioEnabled(preferences, true); WKPreferencesSetDeveloperExtrasEnabled(preferences, true); WKPreferencesSetJavaScriptExperimentsEnabled(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 WKPreferencesSetPageCacheEnabled(preferences, false); WKPreferencesSetAsynchronousPluginInitializationEnabled(preferences, false); WKPreferencesSetAsynchronousPluginInitializationEnabledForAllPlugins(preferences, false); WKPreferencesSetArtificialPluginInitializationDelayEnabled(preferences, false); WKPreferencesSetTabToLinksEnabled(preferences, false); WKPreferencesSetInteractiveFormValidationEnabled(preferences, true); WKPreferencesSetMockScrollbarsEnabled(preferences, true); #if !PLATFORM(QT) static WKStringRef standardFontFamily = WKStringCreateWithUTF8CString("Times"); static WKStringRef cursiveFontFamily = WKStringCreateWithUTF8CString("Apple Chancery"); static WKStringRef fantasyFontFamily = WKStringCreateWithUTF8CString("Papyrus"); static WKStringRef fixedFontFamily = WKStringCreateWithUTF8CString("Courier"); static WKStringRef pictographFontFamily = WKStringCreateWithUTF8CString("Apple Color Emoji"); static WKStringRef sansSerifFontFamily = WKStringCreateWithUTF8CString("Helvetica"); static WKStringRef serifFontFamily = WKStringCreateWithUTF8CString("Times"); WKPreferencesSetStandardFontFamily(preferences, standardFontFamily); WKPreferencesSetCursiveFontFamily(preferences, cursiveFontFamily); WKPreferencesSetFantasyFontFamily(preferences, fantasyFontFamily); WKPreferencesSetFixedFontFamily(preferences, fixedFontFamily); WKPreferencesSetPictographFontFamily(preferences, pictographFontFamily); WKPreferencesSetSansSerifFontFamily(preferences, sansSerifFontFamily); WKPreferencesSetSerifFontFamily(preferences, serifFontFamily); #endif WKPreferencesSetScreenFontSubstitutionEnabled(preferences, true); WKPreferencesSetInspectorUsesWebKitUserInterface(preferences, true); WKPreferencesSetAsynchronousSpellCheckingEnabled(preferences, false); #if !PLATFORM(MAC) WKTextCheckerContinuousSpellCheckingEnabledStateChanged(true); #endif // in the case that a test using the chrome input field failed, be sure to clean up for the next test m_mainWebView->removeChromeInputField(); m_mainWebView->focus(); // Re-set to the default backing scale factor by setting the custom scale factor to 0. WKPageSetCustomBackingScaleFactor(m_mainWebView->page(), 0); #if PLATFORM(EFL) // EFL use a real window while other ports such as Qt don't. // In EFL, we need to resize the window to the original size after calls to window.resizeTo. WKRect rect = m_mainWebView->windowFrame(); m_mainWebView->setWindowFrame(WKRectMake(rect.origin.x, rect.origin.y, TestController::viewWidth, TestController::viewHeight)); #endif // Reset notification permissions m_webNotificationProvider.reset(); // Reset Geolocation permissions. m_geolocationPermissionRequests.clear(); m_isGeolocationPermissionSet = false; m_isGeolocationPermissionAllowed = false; // Reset Custom Policy Delegate. setCustomPolicyDelegate(false, false); m_workQueueManager.clearWorkQueue(); m_handlesAuthenticationChallenges = false; m_authenticationUsername = String(); m_authenticationPassword = String(); // Reset main page back to about:blank m_doneResetting = false; WKPageLoadURL(m_mainWebView->page(), blankURL()); runUntil(m_doneResetting, ShortTimeout); return m_doneResetting; }
bool TestController::resetStateToConsistentValues() { m_state = Resetting; m_beforeUnloadReturnValue = true; 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()); WKContextSetShouldUseFontSmoothing(TestController::shared().context(), false); // FIXME: This function should also ensure that there is only one page open. // Reset preferences WKPreferencesRef preferences = WKPageGroupGetPreferences(m_pageGroup.get()); WKPreferencesResetTestRunnerOverrides(preferences); 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 WKPreferencesSetPageCacheEnabled(preferences, false); // [Qt][WK2]REGRESSION(r104881):It broke hundreds of tests // FIXME: https://bugs.webkit.org/show_bug.cgi?id=76247 #if !PLATFORM(QT) WKPreferencesSetMockScrollbarsEnabled(preferences, true); #endif #if !PLATFORM(QT) static WKStringRef standardFontFamily = WKStringCreateWithUTF8CString("Times"); static WKStringRef cursiveFontFamily = WKStringCreateWithUTF8CString("Apple Chancery"); static WKStringRef fantasyFontFamily = WKStringCreateWithUTF8CString("Papyrus"); static WKStringRef fixedFontFamily = WKStringCreateWithUTF8CString("Courier"); static WKStringRef pictographFontFamily = WKStringCreateWithUTF8CString("Apple Color Emoji"); static WKStringRef sansSerifFontFamily = WKStringCreateWithUTF8CString("Helvetica"); static WKStringRef serifFontFamily = WKStringCreateWithUTF8CString("Times"); WKPreferencesSetStandardFontFamily(preferences, standardFontFamily); WKPreferencesSetCursiveFontFamily(preferences, cursiveFontFamily); WKPreferencesSetFantasyFontFamily(preferences, fantasyFontFamily); WKPreferencesSetFixedFontFamily(preferences, fixedFontFamily); WKPreferencesSetPictographFontFamily(preferences, pictographFontFamily); WKPreferencesSetSansSerifFontFamily(preferences, sansSerifFontFamily); WKPreferencesSetSerifFontFamily(preferences, serifFontFamily); #endif // in the case that a test using the chrome input field failed, be sure to clean up for the next test m_mainWebView->removeChromeInputField(); m_mainWebView->focus(); // Re-set to the default backing scale factor by setting the custom scale factor to 0. WKPageSetCustomBackingScaleFactor(m_mainWebView->page(), 0); // Reset main page back to about:blank m_doneResetting = false; WKPageLoadURL(m_mainWebView->page(), blankURL()); runUntil(m_doneResetting, ShortTimeout); return m_doneResetting; }
void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute attr, bool enable) { WKPreferencesRef preferencesRef = WKPageGroupGetPreferences(webViewPrivate->pageGroup.get()); switch (attr) { case AutoLoadImages: WKPreferencesSetLoadsImagesAutomatically(preferencesRef, enable); break; #if ENABLE(FULLSCREEN_API) case FullScreenEnabled: WKPreferencesSetFullScreenEnabled(preferencesRef, enable); break; #endif case JavascriptEnabled: WKPreferencesSetJavaScriptEnabled(preferencesRef, enable); break; case PluginsEnabled: WKPreferencesSetPluginsEnabled(preferencesRef, enable); break; case OfflineWebApplicationCacheEnabled: WKPreferencesSetOfflineWebApplicationCacheEnabled(preferencesRef, enable); break; case LocalStorageEnabled: WKPreferencesSetLocalStorageEnabled(preferencesRef, enable); break; case XSSAuditingEnabled: WKPreferencesSetXSSAuditorEnabled(preferencesRef, enable); break; case PrivateBrowsingEnabled: WKPreferencesSetPrivateBrowsingEnabled(preferencesRef, enable); break; case DnsPrefetchEnabled: WKPreferencesSetDNSPrefetchingEnabled(preferencesRef, enable); break; case FrameFlatteningEnabled: WKPreferencesSetFrameFlatteningEnabled(preferencesRef, enable); case DeveloperExtrasEnabled: WKPreferencesSetDeveloperExtrasEnabled(preferencesRef, enable); break; #if ENABLE(WEBGL) case WebGLEnabled: WKPreferencesSetWebGLEnabled(preferencesRef, enable); break; #if ENABLE(CSS_SHADERS) case CSSCustomFilterEnabled: WKPreferencesSetCSSCustomFilterEnabled(preferencesRef, enable); break; #endif #endif #if ENABLE(WEB_AUDIO) case WebAudioEnabled: WKPreferencesSetWebAudioEnabled(preferencesRef, enable); break; #endif case CaretBrowsingEnabled: // FIXME: Caret browsing doesn't make much sense in touch mode. WKPreferencesSetCaretBrowsingEnabled(preferencesRef, enable); break; case NotificationsEnabled: WKPreferencesSetNotificationsEnabled(preferencesRef, enable); break; case UniversalAccessFromFileURLsAllowed: WKPreferencesSetUniversalAccessFromFileURLsAllowed(preferencesRef, enable); break; case FileAccessFromFileURLsAllowed: WKPreferencesSetFileAccessFromFileURLsAllowed(preferencesRef, enable); break; default: ASSERT_NOT_REACHED(); } }