void BrowserView::create(RECT webViewRect, BrowserWindow* parentWindow) { assert(!m_webView); bool isShiftKeyDown = ::GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT; WKContextRef context; if (isShiftKeyDown) context = WKContextGetSharedThreadContext(); else context = WKContextGetSharedProcessContext(); WKPageNamespaceRef pageNamespace = WKPageNamespaceCreate(context); m_webView = WKViewCreate(webViewRect, pageNamespace, parentWindow->window()); WKPageUIClient uiClient = { 0, /* version */ parentWindow, /* clientInfo */ createNewPage, showPage, closePage, runJavaScriptAlert, runJavaScriptConfirm, runJavaScriptPrompt, setStatusText, contentsSizeChanged }; WKPageSetPageUIClient(WKViewGetPage(m_webView), &uiClient); }
TEST(WebKit2, TranslateMessageGeneratesWMChar) { WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); PlatformWebView webView(context.get()); webView.simulateAKeyDown(); // WebKit should call TranslateMessage() on the WM_KEYDOWN message to generate the WM_CHAR message. runAndWatchForWMChar(&didSeeWMChar); didSeeWMChar = false; WKPageUIClient uiClient; memset(&uiClient, 0, sizeof(uiClient)); uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback; WKPageSetPageUIClient(webView.page(), &uiClient); webView.simulateAKeyDown(); runAndWatchForWMChar(&didNotHandleKeyEventCalled); // WebKit should not have called TranslateMessage() on the WM_KEYDOWN message since we installed a didNotHandleKeyEvent callback. EXPECT_FALSE(didSeeWMChar); }
void BrowserView::create(RECT webViewRect, BrowserWindow* parentWindow) { assert(!m_webView); static WKContextRef context = WKContextCreate(); m_webView = WKViewCreate(webViewRect, context, 0, parentWindow->window()); WKPageUIClient uiClient = { kWKPageUIClientCurrentVersion, parentWindow, /* clientInfo */ 0, /* createNewPage_deprecatedForUseWithV0 */ showPage, closePage, 0, /* takeFocus */ 0, /* focus */ 0, /* unfocus */ runJavaScriptAlert, runJavaScriptConfirm, runJavaScriptPrompt, 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 */ 0, /* getWindowFrame */ 0, /* setWindowFrame */ 0, /* runBeforeUnloadConfirmPanel */ 0, /* didDraw */ 0, /* pageDidScroll */ 0, /* exceededDatabaseQuota */ 0, /* runOpenPanel */ 0, /* decidePolicyForGeolocationPermissionRequest */ 0, /* headerHeight */ 0, /* footerHeight */ 0, /* drawHeader */ 0, /* drawFooter */ 0, /* printFrame */ 0, /* runModal */ 0, /* didCompleteRubberBandForMainFrame */ 0, /* saveDataToFileInDownloadsFolder */ 0, /* shouldInterruptJavaScript */ createNewPage, mouseDidMoveOverElement, }; WKPageSetPageUIClient(WKViewGetPage(m_webView), &uiClient); WKViewSetIsInWindow(m_webView, 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; }
void setupView(PlatformWebView& webView) { WKPageUIClientV2 uiClient; memset(&uiClient, 0, sizeof(uiClient)); uiClient.base.version = 2; uiClient.decidePolicyForGeolocationPermissionRequest = decidePolicyForGeolocationPermissionRequestCallBack; WKPageSetPageUIClient(webView.page(), &uiClient.base); }
TEST(WebKit2, SpacebarScrolling) { WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get())); PlatformWebView webView(pageNamespace.get()); WKPageLoaderClient loaderClient; memset(&loaderClient, 0, sizeof(loaderClient)); loaderClient.version = 0; loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; WKPageSetPageLoaderClient(webView.page(), &loaderClient); WKPageUIClient uiClient; memset(&uiClient, 0, sizeof(uiClient)); uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback; WKPageSetPageUIClient(webView.page(), &uiClient); WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("spacebar-scrolling", "html")); WKPageLoadURL(webView.page(), url.get()); Util::run(&didFinishLoad); TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false")); TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "false")); webView.simulateSpacebarKeyPress(); TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false")); TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true")); // On Mac, a key down event represents both a raw key down and a key press. On Windows, a key // down event only represents a raw key down. We expect the key press to be handled (because it // inserts text into the text field). But the raw key down should not be handled. #if PLATFORM(MAC) TEST_ASSERT(!didNotHandleKeyDownEvent); #elif PLATFORM(WIN) TEST_ASSERT(didNotHandleKeyDownEvent); #endif TEST_ASSERT(runJSTest(webView.page(), "blurTextField()", "undefined")); didNotHandleKeyDownEvent = false; webView.simulateSpacebarKeyPress(); TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "true")); TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true")); #if PLATFORM(MAC) TEST_ASSERT(!didNotHandleKeyDownEvent); #elif PLATFORM(WIN) TEST_ASSERT(didNotHandleKeyDownEvent); #endif }
void TestController::ensureViewSupportsOptions(WKDictionaryRef options) { if (m_mainWebView && !m_mainWebView->viewSupportsOptions(options)) { WKPageSetPageUIClient(m_mainWebView->page(), 0); WKPageSetPageLoaderClient(m_mainWebView->page(), 0); WKPageSetPagePolicyClient(m_mainWebView->page(), 0); WKPageClose(m_mainWebView->page()); m_mainWebView = nullptr; createWebViewWithOptions(options); resetStateToConsistentValues(); } }
QtWebPageUIClient::QtWebPageUIClient(WKPageRef pageRef, QQuickWebView* webView) : m_webView(webView) { WKPageUIClient uiClient; memset(&uiClient, 0, sizeof(WKPageUIClient)); uiClient.version = kWKPageUIClientCurrentVersion; uiClient.clientInfo = this; uiClient.runJavaScriptAlert = runJavaScriptAlert; uiClient.runJavaScriptConfirm = runJavaScriptConfirm; uiClient.runJavaScriptPrompt = runJavaScriptPrompt; uiClient.runOpenPanel = runOpenPanel; uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement; uiClient.exceededDatabaseQuota = exceededDatabaseQuota; uiClient.decidePolicyForGeolocationPermissionRequest = policyForGeolocationPermissionRequest; WKPageSetPageUIClient(pageRef, &uiClient); }
void BrowserView::create(RECT webViewRect, BrowserWindow* parentWindow) { assert(!m_webView); bool isShiftKeyDown = ::GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT; WKContextRef context; if (isShiftKeyDown) context = WKContextGetSharedThreadContext(); else context = WKContextGetSharedProcessContext(); m_webView = WKViewCreate(webViewRect, context, 0, parentWindow->window()); WKPageUIClient uiClient = { 0, /* version */ parentWindow, /* clientInfo */ createNewPage, showPage, closePage, runJavaScriptAlert, runJavaScriptConfirm, runJavaScriptPrompt, setStatusText, mouseDidMoveOverElement, 0, /* didNotHandleKeyEvent */ 0, /* toolbarsAreVisible */ 0, /* setToolbarsAreVisible */ 0, /* menuBarIsVisible */ 0, /* setMenuBarIsVisible */ 0, /* statusBarIsVisible */ 0, /* setStatusBarIsVisible */ 0, /* isResizable */ 0, /* setIsResizable */ 0, /* getWindowFrame */ 0, /* setWindowFrame */ 0, /* runBeforeUnloadConfirmPanel */ 0, /* didDraw */ 0, /* pageDidScroll */ 0, /* exceededDatabaseQuota */ 0 /* runOpenPanel */ }; WKPageSetPageUIClient(WKViewGetPage(m_webView), &uiClient); }
static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef urlRequest, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo) { EXPECT_TRUE(openedWebView == nullptr); openedWebView = std::make_unique<PlatformWebView>(page); WKPageUIClientV5 uiClient; memset(&uiClient, 0, sizeof(uiClient)); uiClient.base.version = 5; uiClient.runJavaScriptAlert = runJavaScriptAlert; WKPageSetPageUIClient(openedWebView->page(), &uiClient.base); WKPageClose(page); WKRetain(openedWebView->page()); return openedWebView->page(); }
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); }
void Tab::init() { m_view = WKViewCreate(m_context, m_browser->contentPageGroup()); WKViewInitialize(m_view); WKViewSetIsFocused(m_view, true); WKViewSetIsVisible(m_view, true); m_page = WKViewGetPage(m_view); WKStringRef appName = WKStringCreateWithUTF8CString("Drowser"); WKPageSetApplicationNameForUserAgent(m_page, appName); WKRelease(appName); WKViewClient client; std::memset(&client, 0, sizeof(WKViewClient)); client.version = kWKViewClientCurrentVersion; client.clientInfo = this; client.viewNeedsDisplay = &Tab::onViewNeedsDisplayCallback; WKViewSetViewClient(m_view, &client); WKPageLoaderClient loaderClient; memset(&loaderClient, 0, sizeof(WKPageLoaderClient)); loaderClient.version = kWKPageLoaderClientCurrentVersion; loaderClient.clientInfo = this; loaderClient.didStartProgress = &Tab::onStartProgressCallback; loaderClient.didChangeProgress = &Tab::onChangeProgressCallback; loaderClient.didFinishProgress = &Tab::onFinishProgressCallback; loaderClient.didCommitLoadForFrame = &Tab::onCommitLoadForFrame; loaderClient.didReceiveTitleForFrame = &Tab::onReceiveTitleForFrame; loaderClient.didFailProvisionalLoadWithErrorForFrame = &Tab::onFailProvisionalLoadWithErrorForFrameCallback; WKPageSetPageLoaderClient(m_page, &loaderClient); WKPageUIClient uiClient; memset(&uiClient, 0, sizeof(WKPageUIClient)); uiClient.version = kWKPageUIClientCurrentVersion; uiClient.clientInfo = this; uiClient.createNewPage = &Tab::createNewPageCallback; uiClient.mouseDidMoveOverElement = &Tab::onMouseDidMoveOverElement; WKPageSetPageUIClient(m_page, &uiClient); }
TEST(WebKit2, CloseFromWithinCreatePage) { WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); PlatformWebView webView(context.get()); WKPageUIClientV5 uiClient; memset(&uiClient, 0, sizeof(uiClient)); uiClient.base.version = 5; uiClient.createNewPage = createNewPage; uiClient.runJavaScriptAlert = runJavaScriptAlert; WKPageSetPageUIClient(webView.page(), &uiClient.base); WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("close-from-within-create-page", "html")); WKPageLoadURL(webView.page(), url.get()); Util::run(&testDone); openedWebView = nullptr; }
void ewk_view_ui_client_attach(WKPageRef pageRef, Evas_Object* ewkView) { WKPageUIClient uiClient; memset(&uiClient, 0, sizeof(WKPageUIClient)); uiClient.version = kWKPageUIClientCurrentVersion; uiClient.clientInfo = ewkView; uiClient.close = closePage; uiClient.createNewPage = createNewPage; uiClient.runJavaScriptAlert = runJavaScriptAlert; uiClient.runJavaScriptConfirm = runJavaScriptConfirm; uiClient.runJavaScriptPrompt = runJavaScriptPrompt; #if ENABLE(SQL_DATABASE) uiClient.exceededDatabaseQuota = exceededDatabaseQuota; #endif #if ENABLE(INPUT_TYPE_COLOR) uiClient.showColorPicker = showColorPicker; uiClient.hideColorPicker = hideColorPicker; #endif WKPageSetPageUIClient(pageRef, &uiClient); }
TEST(WebKit2, AltKeyGeneratesWMSysCommand) { WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate()); PlatformWebView webView(context.get()); WKPageUIClient uiClient; memset(&uiClient, 0, sizeof(uiClient)); uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback; WKPageSetPageUIClient(webView.page(), &uiClient); WMSysCommandObserver observer; webView.setParentWindowMessageObserver(&observer); webView.simulateAltKeyPress(); Util::run(&didNotHandleWMSysKeyUp); webView.setParentWindowMessageObserver(0); // The WM_SYSKEYUP message should have generated a WM_SYSCOMMAND message that was sent to the // WKView's parent window. EXPECT_TRUE(observer.windowDidReceiveWMSysCommand()); }
void TestController::createWebViewWithOptions(WKDictionaryRef options) { m_mainWebView = adoptPtr(new PlatformWebView(m_context.get(), m_pageGroup.get(), 0, options)); WKPageUIClient pageUIClient = { kWKPageUIClientCurrentVersion, m_mainWebView.get(), 0, // createNewPage_deprecatedForUseWithV0 0, // showPage 0, // close 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 getWindowFrame, setWindowFrame, runBeforeUnloadConfirmPanel, 0, // didDraw 0, // pageDidScroll exceededDatabaseQuota, 0, // runOpenPanel decidePolicyForGeolocationPermissionRequest, 0, // headerHeight 0, // footerHeight 0, // drawHeader 0, // drawFooter 0, // printFrame runModal, 0, // didCompleteRubberBandForMainFrame 0, // saveDataToFileInDownloadsFolder 0, // shouldInterruptJavaScript createOtherPage, 0, // mouseDidMoveOverElement decidePolicyForNotificationPermissionRequest, // decidePolicyForNotificationPermissionRequest 0, // unavailablePluginButtonClicked_deprecatedForUseWithV1 0, // showColorPicker 0, // hideColorPicker unavailablePluginButtonClicked, }; WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient); WKPageLoaderClient pageLoaderClient = { kWKPageLoaderClientCurrentVersion, this, 0, // didStartProvisionalLoadForFrame 0, // didReceiveServerRedirectForProvisionalLoadForFrame 0, // didFailProvisionalLoadWithErrorForFrame didCommitLoadForFrame, 0, // didFinishDocumentLoadForFrame didFinishLoadForFrame, 0, // didFailLoadWithErrorForFrame 0, // didSameDocumentNavigationForFrame 0, // didReceiveTitleForFrame 0, // didFirstLayoutForFrame 0, // didFirstVisuallyNonEmptyLayoutForFrame 0, // didRemoveFrameFromHierarchy 0, // didFailToInitializePlugin 0, // didDisplayInsecureContentForFrame 0, // canAuthenticateAgainstProtectionSpaceInFrame didReceiveAuthenticationChallengeInFrame, // didReceiveAuthenticationChallengeInFrame 0, // didStartProgress 0, // didChangeProgress 0, // didFinishProgress 0, // didBecomeUnresponsive 0, // didBecomeResponsive processDidCrash, 0, // didChangeBackForwardList 0, // shouldGoToBackForwardListItem 0, // didRunInsecureContentForFrame 0, // didDetectXSSForFrame 0, // didNewFirstVisuallyNonEmptyLayout 0, // willGoToBackForwardListItem 0, // interactionOccurredWhileProcessUnresponsive 0, // pluginDidFail_deprecatedForUseWithV1 0, // didReceiveIntentForFrame 0, // registerIntentServiceForFrame 0, // didLayout 0, // pluginLoadPolicy 0, // pluginDidFail }; WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient); WKPagePolicyClient pagePolicyClient = { kWKPagePolicyClientCurrentVersion, this, decidePolicyForNavigationAction, 0, // decidePolicyForNewWindowAction decidePolicyForResponse, 0, // unableToImplementPolicy }; WKPageSetPagePolicyClient(m_mainWebView->page(), &pagePolicyClient); m_mainWebView->didInitializeClients(); }
void TestController::initialize(int argc, const char* argv[]) { platformInitialize(); if (argc < 2) { fputs("Usage: WebKitTestRunner [options] filename [filename2..n]\n", stderr); // FIXME: Refactor option parsing to allow us to print // an auto-generated list of options. exit(1); } bool printSupportedFeatures = false; for (int i = 1; i < argc; ++i) { std::string argument(argv[i]); if (argument == "--timeout" && i + 1 < argc) { m_longTimeout = atoi(argv[++i]); // Scale up the short timeout to match. m_shortTimeout = defaultShortTimeout * m_longTimeout / defaultLongTimeout; continue; } if (argument == "--skip-pixel-test-if-no-baseline") { m_skipPixelTestOption = true; continue; } if (argument == "--pixel-tests") { m_dumpPixels = true; continue; } if (argument == "--verbose") { m_verbose = true; continue; } if (argument == "--gc-between-tests") { m_gcBetweenTests = true; continue; } if (argument == "--print-supported-features") { printSupportedFeatures = true; break; } // Skip any other arguments that begin with '--'. if (argument.length() >= 2 && argument[0] == '-' && argument[1] == '-') continue; m_paths.push_back(argument); } if (printSupportedFeatures) { // FIXME: On Windows, DumpRenderTree uses this to expose whether it supports 3d // transforms and accelerated compositing. When we support those features, we // should match DRT's behavior. exit(0); } m_usingServerMode = (m_paths.size() == 1 && m_paths[0] == "-"); if (m_usingServerMode) m_printSeparators = true; else m_printSeparators = m_paths.size() > 1; initializeInjectedBundlePath(); initializeTestPluginDirectory(); WKRetainPtr<WKStringRef> pageGroupIdentifier(AdoptWK, WKStringCreateWithUTF8CString("WebKitTestRunnerPageGroup")); m_pageGroup.adopt(WKPageGroupCreateWithIdentifier(pageGroupIdentifier.get())); m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath())); const char* path = libraryPathForTesting(); if (path) { Vector<char> databaseDirectory(strlen(path) + strlen("/Databases") + 1); sprintf(databaseDirectory.data(), "%s%s", path, "/Databases"); WKRetainPtr<WKStringRef> databaseDirectoryWK(AdoptWK, WKStringCreateWithUTF8CString(databaseDirectory.data())); WKContextSetDatabaseDirectory(m_context.get(), databaseDirectoryWK.get()); } platformInitializeContext(); WKContextInjectedBundleClient injectedBundleClient = { kWKContextInjectedBundleClientCurrentVersion, this, didReceiveMessageFromInjectedBundle, didReceiveSynchronousMessageFromInjectedBundle }; WKContextSetInjectedBundleClient(m_context.get(), &injectedBundleClient); WKContextSetAdditionalPluginsDirectory(m_context.get(), testPluginDirectory()); m_mainWebView = adoptPtr(new PlatformWebView(m_context.get(), m_pageGroup.get())); WKPageUIClient pageUIClient = { kWKPageUIClientCurrentVersion, this, 0, // createNewPage_deprecatedForUseWithV0 0, // showPage 0, // close 0, // takeFocus 0, // focus 0, // 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 getWindowFrameMainPage, setWindowFrameMainPage, 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(m_mainWebView->page(), &pageUIClient); WKPageLoaderClient pageLoaderClient = { kWKPageLoaderClientCurrentVersion, this, 0, // didStartProvisionalLoadForFrame 0, // didReceiveServerRedirectForProvisionalLoadForFrame 0, // didFailProvisionalLoadWithErrorForFrame didCommitLoadForFrame, 0, // didFinishDocumentLoadForFrame didFinishLoadForFrame, 0, // didFailLoadWithErrorForFrame 0, // didSameDocumentNavigationForFrame 0, // didReceiveTitleForFrame 0, // didFirstLayoutForFrame 0, // didFirstVisuallyNonEmptyLayoutForFrame 0, // didRemoveFrameFromHierarchy 0, // didFailToInitializePlugin 0, // didDisplayInsecureContentForFrame 0, // canAuthenticateAgainstProtectionSpaceInFrame 0, // didReceiveAuthenticationChallengeInFrame 0, // didStartProgress 0, // didChangeProgress 0, // didFinishProgress 0, // didBecomeUnresponsive 0, // didBecomeResponsive processDidCrash, 0, // didChangeBackForwardList 0, // shouldGoToBackForwardListItem 0, // didRunInsecureContentForFrame 0, // didDetectXSSForFrame 0 // didNewFirstVisuallyNonEmptyLayout }; WKPageSetPageLoaderClient(m_mainWebView->page(), &pageLoaderClient); }
WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() { ASSERT(inspectedPage()); ASSERT(!m_inspectorView); RefPtr<WebPreferences> preferences = WebPreferences::create(String(), "WebKit2.", "WebKit2."); #ifndef NDEBUG // Allow developers to inspect the Web Inspector in debug builds without changing settings. preferences->setDeveloperExtrasEnabled(true); preferences->setLogsPageMessagesToSystemConsoleEnabled(true); #endif preferences->setJavaScriptRuntimeFlags({ }); RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(inspectorPageGroupIdentifier(), false, false); auto pageConfiguration = API::PageConfiguration::create(); pageConfiguration->setProcessPool(&inspectorProcessPool(inspectionLevel())); pageConfiguration->setPreferences(preferences.get()); pageConfiguration->setPageGroup(pageGroup.get()); m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(*pageConfiguration.ptr())); g_object_add_weak_pointer(G_OBJECT(m_inspectorView), reinterpret_cast<void**>(&m_inspectorView)); WKPageUIClientV2 uiClient = { { 2, this }, nullptr, // createNewPage_deprecatedForUseWithV0 nullptr, // showPage nullptr, // closePage nullptr, // takeFocus nullptr, // focus nullptr, // unfocus nullptr, // runJavaScriptAlert nullptr, // runJavaScriptConfirm nullptr, // runJavaScriptPrompt nullptr, // setStatusText nullptr, // mouseDidMoveOverElement_deprecatedForUseWithV0 nullptr, // missingPluginButtonClicked_deprecatedForUseWithV0 nullptr, // didNotHandleKeyEvent nullptr, // didNotHandleWheelEvent nullptr, // areToolbarsVisible nullptr, // setToolbarsVisible nullptr, // isMenuBarVisible nullptr, // setMenuBarVisible nullptr, // isStatusBarVisible nullptr, // setStatusBarVisible nullptr, // isResizable nullptr, // setResizable nullptr, // getWindowFrame, nullptr, // setWindowFrame, nullptr, // runBeforeUnloadConfirmPanel nullptr, // didDraw nullptr, // pageDidScroll exceededDatabaseQuota, nullptr, // runOpenPanel, nullptr, // decidePolicyForGeolocationPermissionRequest nullptr, // headerHeight nullptr, // footerHeight nullptr, // drawHeader nullptr, // drawFooter nullptr, // printFrame nullptr, // runModal nullptr, // unused nullptr, // saveDataToFileInDownloadsFolder nullptr, // shouldInterruptJavaScript nullptr, // createPage nullptr, // mouseDidMoveOverElement nullptr, // decidePolicyForNotificationPermissionRequest nullptr, // unavailablePluginButtonClicked_deprecatedForUseWithV1 nullptr, // showColorPicker nullptr, // hideColorPicker nullptr, // unavailablePluginButtonClicked }; WebPageProxy* inspectorPage = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView)); ASSERT(inspectorPage); WKPageSetPageUIClient(toAPI(inspectorPage), &uiClient.base); return inspectorPage; }