TEST(WebKit2, ScrollPinningBehaviors) { WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); // Turn off threaded scrolling; synchronously waiting for the main thread scroll position to // update using WKPageForceRepaint would be better, but for some reason doesn't block until // it's updated after the initial WKPageSetScrollPinningBehavior above. WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(Util::toWK("NoThreadedScrollingPageGroup").get())); WKPreferencesRef preferences = WKPageGroupGetPreferences(pageGroup.get()); WKPreferencesSetThreadedScrollingEnabled(preferences, false); PlatformWebView webView(context.get(), pageGroup.get()); WKPageLoaderClient loaderClient; memset(&loaderClient, 0, sizeof(loaderClient)); loaderClient.version = kWKPageLoaderClientCurrentVersion; loaderClient.didFinishDocumentLoadForFrame = didFinishDocumentLoadForFrame; loaderClient.clientInfo = &webView; WKPageSetPageLoaderClient(webView.page(), &loaderClient); WKPageLoadURL(webView.page(), adoptWK(Util::createURLForResource("simple-tall", "html")).get()); Util::run(&testDone); EXPECT_TRUE(testDone); }
bool CaptionUserPreferences::userPrefersCaptions() const { Page* page = *(pageGroup()->pages().begin()); if (!page) return false; return page->settings()->shouldDisplayCaptions(); }
void CaptionUserPreferences::setUserPrefersCaptions(bool preference) { Page* page = *(pageGroup()->pages().begin()); if (!page) return; page->settings()->setShouldDisplayCaptions(preference); notify(); }
TEST(WebKit2, DISABLED_DOMWindowExtensionBasic) { WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(WKStringCreateWithUTF8CString("DOMWindowExtensionBasicPageGroup"))); WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("DOMWindowExtensionBasic", pageGroup.get())); WKContextInjectedBundleClientV0 injectedBundleClient; memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); injectedBundleClient.base.version = 0; injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base); // The default cache model has a capacity of 0, so it is necessary to switch to a cache // model that actually allows for a page cache. WKContextSetCacheModel(context.get(), kWKCacheModelDocumentBrowser); PlatformWebView webView(context.get(), pageGroup.get()); // Make sure the extensions for each frame are installed in each world. WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple-iframe", "html")); WKPageLoadURL(webView.page(), url1.get()); Util::run(&finished); finished = false; // Make sure those first 4 extensions are disconnected, and 2 new ones are installed. WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple", "html")); WKPageLoadURL(webView.page(), url2.get()); Util::run(&finished); finished = false; // Make sure those two are disconnected, and the first four are reconnected. WKPageGoBack(webView.page()); Util::run(&finished); finished = false; // Make sure the 2 disconnected extensions in the page cache and the 4 active extensions are all removed. WKPageClose(webView.page()); Util::run(&finished); const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*); EXPECT_EQ(expectedSize, messages.size()); if (messages.size() != expectedSize) return; for (size_t i = 0; i < messages.size(); ++i) EXPECT_WK_STREQ(expectedMessages[i], messages[i].get()); }
TEST(WebKit2, DISABLED_DOMWindowExtensionNoCache) { WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(WKStringCreateWithUTF8CString("DOMWindowExtensionNoCachePageGroup"))); WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("DOMWindowExtensionNoCache", pageGroup.get())); WKContextInjectedBundleClientV1 injectedBundleClient; memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); injectedBundleClient.base.version = 1; injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base); // Disable the page cache. WKContextSetCacheModel(context.get(), kWKCacheModelDocumentViewer); PlatformWebView webView(context.get(), pageGroup.get()); // Make sure the extensions for each frame are installed in each world. WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple-iframe", "html")); WKPageLoadURL(webView.page(), url1.get()); Util::run(&finished); finished = false; // Make sure those first 4 extensions are destroyed, and 2 new ones are installed. WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple", "html")); WKPageLoadURL(webView.page(), url2.get()); Util::run(&finished); finished = false; // Make sure those 2 are destroyed, and the first 4 are recreated. WKPageGoBack(webView.page()); Util::run(&finished); finished = false; WKPageClose(webView.page()); Util::run(&finished); const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*); EXPECT_EQ(expectedSize, messages.size()); if (messages.size() != expectedSize) return; for (size_t i = 0; i < messages.size(); ++i) EXPECT_WK_STREQ(expectedMessages[i], messages[i].get()); }
TEST(WebKit2, InjectedBundleMakeAllShadowRootOpenTest) { WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(WKStringCreateWithUTF8CString("InjectedBundleMakeAllShadowRootOpenTestPageGroup"))); WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("InjectedBundleMakeAllShadowRootOpenTest", pageGroup.get())); PlatformWebView webView(context.get(), pageGroup.get()); WKPageUIClientV0 uiClient; memset(&uiClient, 0, sizeof(uiClient)); uiClient.base.version = 0; uiClient.runJavaScriptAlert = runJavaScriptAlert; WKPageSetPageUIClient(webView.page(), &uiClient.base); WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("closed-shadow-tree-test", "html")); WKPageLoadURL(webView.page(), url.get()); Util::run(&done); }