TEST(WebKit2, CookieManager) { wkContext.adopt(WKContextCreate()); PlatformWebView webView(wkContext.get()); WKPageLoaderClientV0 loaderClient; memset(&loaderClient, 0, sizeof(loaderClient)); loaderClient.base.version = 0; loaderClient.didFinishLoadForFrame = didFinishLoadForFrame; WKPageSetPageLoaderClient(webView.page(), &loaderClient.base); WKPageLoadURL(webView.page(), adoptWK(WKURLCreateWithUTF8CString("about:blank")).get()); Util::run(&testDone); }
void LayoutTestController::evaluateScriptInIsolatedWorld(JSContextRef context, unsigned worldID, JSStringRef script) { // A worldID of 0 always corresponds to a new world. Any other worldID corresponds to a world // that is created once and cached forever. WKRetainPtr<WKBundleScriptWorldRef> world; if (!worldID) world.adopt(WKBundleScriptWorldCreateWorld()); else { WKRetainPtr<WKBundleScriptWorldRef>& worldSlot = worldMap().add(worldID, 0).first->second; if (!worldSlot) worldSlot.adopt(WKBundleScriptWorldCreateWorld()); world = worldSlot; } WKBundleFrameRef frame = WKBundleFrameForJavaScriptContext(context); if (!frame) frame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page()); JSGlobalContextRef jsContext = WKBundleFrameGetJavaScriptContextForWorld(frame, world.get()); JSEvaluateScript(jsContext, script, 0, 0, 0, 0); }