static void didFinishDocumentLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo) { WKPageSetScrollPinningBehavior(page, kWKScrollPinningBehaviorPinToBottom); EXPECT_JS_EQ(page, "window.scrollY", "2434"); PlatformWebView* webView = (PlatformWebView*)clientInfo; webView->resizeTo(800, 200); EXPECT_JS_EQ(page, "window.scrollY", "2834"); EXPECT_JS_EQ(page, "window.scrollTo(0,0)", "undefined"); EXPECT_JS_EQ(page, "window.scrollY", "2834"); WKPageSetScrollPinningBehavior(page, kWKScrollPinningBehaviorPinToTop); EXPECT_JS_EQ(page, "window.scrollY", "0"); EXPECT_JS_EQ(page, "window.scrollTo(0,200)", "undefined"); EXPECT_JS_EQ(page, "window.scrollY", "0"); WKPageSetScrollPinningBehavior(page, kWKScrollPinningBehaviorDoNotPin); EXPECT_JS_EQ(page, "window.scrollY", "0"); EXPECT_JS_EQ(page, "window.scrollTo(0,200)", "undefined"); EXPECT_JS_EQ(page, "window.scrollY", "200"); testDone = true; }
WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WKDictionaryRef, WKEventModifiers, WKEventMouseButton, const void*) { PlatformWebView* view = new PlatformWebView(WKPageGetContext(oldPage), WKPageGetPageGroup(oldPage)); WKPageRef newPage = view->page(); view->resizeTo(800, 600); WKPageUIClient otherPageUIClient = { kWKPageUIClientCurrentVersion, view, 0, // createNewPage_deprecatedForUseWithV0 0, // showPage closeOtherPage, 0, // takeFocus focus, unfocus, 0, // runJavaScriptAlert 0, // runJavaScriptConfirm 0, // runJavaScriptPrompt 0, // setStatusText 0, // mouseDidMoveOverElement_deprecatedForUseWithV0 0, // missingPluginButtonClicked 0, // didNotHandleKeyEvent 0, // didNotHandleWheelEvent 0, // toolbarsAreVisible 0, // setToolbarsAreVisible 0, // menuBarIsVisible 0, // setMenuBarIsVisible 0, // statusBarIsVisible 0, // setStatusBarIsVisible 0, // isResizable 0, // setIsResizable getWindowFrameOtherPage, setWindowFrameOtherPage, runBeforeUnloadConfirmPanel, 0, // didDraw 0, // pageDidScroll exceededDatabaseQuota, 0, // runOpenPanel 0, // decidePolicyForGeolocationPermissionRequest 0, // headerHeight 0, // footerHeight 0, // drawHeader 0, // drawFooter 0, // printFrame runModal, 0, // didCompleteRubberBandForMainFrame 0, // saveDataToFileInDownloadsFolder 0, // shouldInterruptJavaScript createOtherPage, 0, // mouseDidMoveOverElement 0, // decidePolicyForNotificationPermissionRequest }; WKPageSetPageUIClient(newPage, &otherPageUIClient); WKRetain(newPage); return newPage; }
static void didLayout(WKPageRef page, WKLayoutMilestones milestones, WKTypeRef, const void* clientInfo) { if (milestones & kWKDidFirstLayoutAfterSuppressedIncrementalRendering) { PlatformWebView* webView = (PlatformWebView*)clientInfo; unsigned pageCount = WKPageGetPageCount(page); EXPECT_EQ(expectedPageCount, pageCount); webView->resizeTo((pageLength * pageCount) + (pageGap * (pageCount - 1)), 500); EXPECT_JS_EQ(page, "window.scrollX", "0"); testDone = true; } }