bool XSSAuditor::findInRequest(const FindTask& task) const { bool result = false; Frame* parentFrame = m_frame->tree()->parent(); Frame* blockFrame = parentFrame; if (parentFrame && m_frame->document()->url() == blankURL()) result = findInRequest(parentFrame, task); if (!result) { result = findInRequest(m_frame, task); blockFrame = m_frame; } if (!result) return false; switch (xssProtection()) { case XSSProtectionDisabled: return false; case XSSProtectionEnabled: break; case XSSProtectionBlockEnabled: if (blockFrame) { blockFrame->loader()->stopAllLoaders(); blockFrame->redirectScheduler()->scheduleLocationChange(blankURL(), String()); } break; default: ASSERT_NOT_REACHED(); } return true; }
PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal) { DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); KURL unreachableURL = documentLoader ? documentLoader->unreachableURL() : KURL(); KURL url; KURL originalURL; if (!unreachableURL.isEmpty()) { url = unreachableURL; originalURL = unreachableURL; } else { originalURL = documentLoader ? documentLoader->originalURL() : KURL(); if (useOriginal) url = originalURL; else if (documentLoader) url = documentLoader->requestURL(); } LOG(History, "WebCoreHistory: Creating item for %s", url.string().ascii().data()); // Frames that have never successfully loaded any content // may have no URL at all. Currently our history code can't // deal with such things, so we nip that in the bud here. // Later we may want to learn to live with nil for URL. // See bug 3368236 and related bugs for more information. if (url.isEmpty()) url = blankURL(); if (originalURL.isEmpty()) originalURL = blankURL(); Frame* parentFrame = m_frame->tree()->parent(); String parent = parentFrame ? parentFrame->tree()->uniqueName() : ""; String title = documentLoader ? documentLoader->title() : ""; RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->uniqueName(), parent, title); item->setOriginalURLString(originalURL.string()); if (!unreachableURL.isEmpty() || !documentLoader || documentLoader->response().httpStatusCode() >= 400) item->setLastVisitWasFailure(true); // Save form state if this is a POST if (documentLoader) { if (useOriginal) item->setFormInfoFromRequest(documentLoader->originalRequest()); else item->setFormInfoFromRequest(documentLoader->request()); } // Set the item for which we will save document state m_frameLoadComplete = false; m_previousItem = m_currentItem; m_currentItem = item; return item.release(); }
void DocumentLoader::startLoadingMainResource() { timing().markNavigationStart(); ASSERT(!m_mainResource); ASSERT(m_state == NotStarted); m_state = Provisional; if (maybeLoadEmpty()) return; ASSERT(timing().navigationStart()); ASSERT(!timing().fetchStart()); timing().markFetchStart(); DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext)); FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, mainResourceLoadOptions); m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData); if (!m_mainResource) { m_request = ResourceRequest(blankURL()); maybeLoadEmpty(); return; } // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those. // Even when using a cached resource, we may make some modification to the request, e.g. adding the referer header. m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest(); m_mainResource->addClient(this); }
inline DOMURL::DOMURL(const String& url, ExceptionCode& ec) : m_baseURL(blankURL()) , m_url(m_baseURL, url) { if (!m_url.isValid()) ec = TypeError; }
static bool shouldLoadAsEmptyDocument(const KURL& url) { #if PLATFORM(TORCHMOBILE) return url.isEmpty() || (url.protocolIs("about") && equalIgnoringRef(url, blankURL())); #else return url.isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(url.protocol()); #endif }
void HistoryController::initializeItem(HistoryItem* item) { DocumentLoader* documentLoader = m_frame->loader()->documentLoader(); ASSERT(documentLoader); KURL unreachableURL = documentLoader->unreachableURL(); KURL url; KURL originalURL; if (!unreachableURL.isEmpty()) { url = unreachableURL; originalURL = unreachableURL; } else { url = documentLoader->url(); originalURL = documentLoader->originalURL(); } // Frames that have never successfully loaded any content // may have no URL at all. Currently our history code can't // deal with such things, so we nip that in the bud here. // Later we may want to learn to live with nil for URL. // See bug 3368236 and related bugs for more information. if (url.isEmpty()) url = blankURL(); if (originalURL.isEmpty()) originalURL = blankURL(); Frame* parentFrame = m_frame->tree()->parent(); String parent = parentFrame ? parentFrame->tree()->uniqueName() : ""; StringWithDirection title = documentLoader->title(); item->setURL(url); item->setTarget(m_frame->tree()->uniqueName()); item->setParent(parent); // FIXME: should store title directionality in history as well. item->setTitle(title.string()); item->setOriginalURLString(originalURL.string()); if (!unreachableURL.isEmpty() || documentLoader->response().httpStatusCode() >= 400) item->setLastVisitWasFailure(true); // Save form state if this is a POST item->setFormInfoFromRequest(documentLoader->request()); }
XSSProtectionDisposition XSSAuditor::xssProtection() const { DEFINE_STATIC_LOCAL(String, XSSProtectionHeader, ("X-XSS-Protection")); Frame* frame = m_frame; if (frame->document()->url() == blankURL()) frame = m_frame->tree()->parent(); return parseXSSProtectionHeader(frame->loader()->documentLoader()->response().httpHeaderField(XSSProtectionHeader)); }
inline const KURL& Location::url() const { ASSERT(m_frame); const KURL& url = m_frame->document()->url(); if (!url.isValid()) return blankURL(); // Use "about:blank" while the page is still loading (before we have a frame). return url; }
KURL DocumentLoader::documentURL() const { KURL url = substituteData().responseURL(); if (url.isEmpty()) url = requestURL(); if (url.isEmpty()) url = responseURL(); if (url.isEmpty()) url = blankURL(); return url; }
bool MockPagePopup::initialize() { const char scriptToSetUpPagePopupController[] = "<script>window.pagePopupController = parent.internals.pagePopupController;</script>"; RefPtr<SharedBuffer> data = SharedBuffer::create(scriptToSetUpPagePopupController, sizeof(scriptToSetUpPagePopupController)); m_popupClient->writeDocument(data.get()); LocalFrame* localFrame = toLocalFrame(m_iframe->contentFrame()); if (!localFrame) return false; localFrame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(), ForceSynchronousLoad))); return true; }
void DOMURL::setInput(const String& value) { KURL url(blankURL(), value); if (url.isValid()) { m_url = url; m_input = String(); } else { m_url = KURL(); m_input = value; } }
static void loadDataIntoFrame(Frame* frame, KURL baseUrl, const String& url, const String& data) { if (baseUrl.isEmpty()) { baseUrl = blankURL(); } ResourceRequest request(baseUrl); CString cstr = data.utf8(); RefPtr<WebCore::SharedBuffer> buf = WebCore::SharedBuffer::create(cstr.data(), cstr.length()); SubstituteData subData(buf, String("text/html"), String("utf-8"), KURL(KURL(), url)); frame->loader()->load(request, subData, false); }
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; }
bool DocumentLoader::maybeLoadEmpty() { bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol())); if (!shouldLoadEmpty) return false; if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument()) m_request.setURL(blankURL()); m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, String()); finishedLoading(monotonicallyIncreasingTime()); return true; }
bool DocumentLoader::maybeLoadEmpty() { bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol())); if (!shouldLoadEmpty && !frameLoader()->client()->representationExistsForURLScheme(m_request.url().protocol())) return false; m_loadingEmptyDocument = true; if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument()) m_request.setURL(blankURL()); String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->generatedMIMETypeForURLScheme(m_request.url().protocol()); setResponse(ResourceResponse(m_request.url(), mimeType, 0, String(), String())); finishedLoading(); return true; }
KURL DocumentLoader::documentURL() const { KURL url = substituteData().responseURL(); #if ENABLE(WEB_ARCHIVE) if (url.isEmpty() && m_archive && m_archive->type() == Archive::WebArchive) url = m_archive->mainResource()->url(); #endif if (url.isEmpty()) url = requestURL(); if (url.isEmpty()) url = responseURL(); if (url.isEmpty()) url = blankURL(); return url; }
void TestController::didFinishLoadForFrame(WKPageRef page, WKFrameRef frame) { if (m_state != Resetting) return; if (!WKFrameIsMainFrame(frame)) return; WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKFrameCopyURL(frame)); if (!WKURLIsEqual(wkURL.get(), blankURL())) return; m_doneResetting = true; shared().notifyDone(); }
bool WebPagePopupImpl::initializePage() { Page::PageClients pageClients; fillWithEmptyClients(pageClients); m_chromeClient = PagePopupChromeClient::create(this); pageClients.chromeClient = m_chromeClient.get(); Settings& mainSettings = m_webView->page()->settings(); m_page = Page::create(pageClients); m_page->settings().setScriptEnabled(true); m_page->settings().setAllowScriptsToCloseWindows(true); m_page->settings().setDeviceSupportsTouch(mainSettings.deviceSupportsTouch()); m_page->settings().setMinimumFontSize(mainSettings.minimumFontSize()); m_page->settings().setMinimumLogicalFontSize( mainSettings.minimumLogicalFontSize()); // FIXME: Should we support enabling a11y while a popup is shown? m_page->settings().setAccessibilityEnabled( mainSettings.accessibilityEnabled()); m_page->settings().setScrollAnimatorEnabled( mainSettings.scrollAnimatorEnabled()); provideContextFeaturesTo(*m_page, WTF::makeUnique<PagePopupFeaturesClient>()); DEFINE_STATIC_LOCAL(FrameLoaderClient, emptyFrameLoaderClient, (EmptyFrameLoaderClient::create())); LocalFrame* frame = LocalFrame::create(&emptyFrameLoaderClient, &m_page->frameHost(), 0); frame->setPagePopupOwner(m_popupClient->ownerElement()); frame->setView(FrameView::create(*frame)); frame->init(); frame->view()->setParentVisible(true); frame->view()->setSelfVisible(true); frame->view()->setTransparent(false); if (AXObjectCache* cache = m_popupClient->ownerElement().document().existingAXObjectCache()) cache->childrenChanged(&m_popupClient->ownerElement()); DCHECK(frame->domWindow()); PagePopupSupplement::install(*frame, *this, m_popupClient); DCHECK_EQ(m_popupClient->ownerElement().document().existingAXObjectCache(), frame->document()->existingAXObjectCache()); RefPtr<SharedBuffer> data = SharedBuffer::create(); m_popupClient->writeDocument(data.get()); frame->loader().load(FrameLoadRequest( 0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(), ForceSynchronousLoad))); frame->setPageZoomFactor(m_popupClient->zoomFactor()); return true; }
bool SVGImage::dataChanged(bool allDataReceived) { TRACE_EVENT0("webkit", "SVGImage::dataChanged"); // Don't do anything if is an empty image. if (!data()->size()) return true; if (allDataReceived) { static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClient; Page::PageClients pageClients; fillWithEmptyClients(pageClients); m_chromeClient = adoptPtr(new SVGImageChromeClient(this)); pageClients.chromeClient = m_chromeClient.get(); // FIXME: If this SVG ends up loading itself, we might leak the world. // The Cache code does not know about ImageResources holding Frames and // won't know to break the cycle. // This will become an issue when SVGImage will be able to load other // SVGImage objects, but we're safe now, because SVGImage can only be // loaded by a top-level document. OwnPtr<Page> page = adoptPtr(new Page(pageClients)); page->settings().setScriptEnabled(false); page->settings().setPluginsEnabled(false); page->settings().setAcceleratedCompositingEnabled(false); RefPtr<LocalFrame> frame = LocalFrame::create(dummyFrameLoaderClient, &page->frameHost(), 0); frame->setView(FrameView::create(frame.get())); frame->init(); FrameLoader& loader = frame->loader(); loader.forceSandboxFlags(SandboxAll); frame->view()->setScrollbarsSuppressed(true); frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars. frame->view()->setTransparent(true); // SVG Images are transparent. m_page = page.release(); loader.load(FrameLoadRequest(0, blankURL(), SubstituteData(data(), "image/svg+xml", "UTF-8", KURL(), ForceSynchronousLoad))); // Set the intrinsic size before a container size is available. m_intrinsicSize = containerSize(); } return m_page; }
// Documentation for the CF_HTML format is available at http://msdn.microsoft.com/workshop/networking/clipboard/htmlclipboard.asp void markupToCF_HTML(const String& markup, const String& srcURL, Vector<char>& result) { if (markup.isEmpty()) return; #define MAX_DIGITS 10 #define MAKE_NUMBER_FORMAT_1(digits) MAKE_NUMBER_FORMAT_2(digits) #define MAKE_NUMBER_FORMAT_2(digits) "%0" #digits "u" #define NUMBER_FORMAT MAKE_NUMBER_FORMAT_1(MAX_DIGITS) const char* header = "Version:0.9\n" "StartHTML:" NUMBER_FORMAT "\n" "EndHTML:" NUMBER_FORMAT "\n" "StartFragment:" NUMBER_FORMAT "\n" "EndFragment:" NUMBER_FORMAT "\n"; const char* sourceURLPrefix = "SourceURL:"; const char* startMarkup = "<HTML>\n<BODY>\n<!--StartFragment-->\n"; const char* endMarkup = "\n<!--EndFragment-->\n</BODY>\n</HTML>"; CString sourceURLUTF8 = srcURL == blankURL() ? "" : srcURL.utf8(); CString markupUTF8 = markup.utf8(); // calculate offsets unsigned startHTMLOffset = strlen(header) - strlen(NUMBER_FORMAT) * 4 + MAX_DIGITS * 4; if (sourceURLUTF8.length()) startHTMLOffset += strlen(sourceURLPrefix) + sourceURLUTF8.length() + 1; unsigned startFragmentOffset = startHTMLOffset + strlen(startMarkup); unsigned endFragmentOffset = startFragmentOffset + markupUTF8.length(); unsigned endHTMLOffset = endFragmentOffset + strlen(endMarkup); append(result, String::format(header, startHTMLOffset, endHTMLOffset, startFragmentOffset, endFragmentOffset).utf8()); if (sourceURLUTF8.length()) { append(result, sourceURLPrefix); append(result, sourceURLUTF8); result.append('\n'); } append(result, startMarkup); append(result, markupUTF8); append(result, endMarkup); #undef MAX_DIGITS #undef MAKE_NUMBER_FORMAT_1 #undef MAKE_NUMBER_FORMAT_2 #undef NUMBER_FORMAT }
DocumentFragment* createFragmentFromMarkup( Document& document, const String& markup, const String& baseURL, ParserContentPolicy parserContentPolicy) { // We use a fake body element here to trick the HTML parser to using the // InBody insertion mode. HTMLBodyElement* fakeBody = HTMLBodyElement::create(document); DocumentFragment* fragment = DocumentFragment::create(document); fragment->parseHTML(markup, fakeBody, parserContentPolicy); if (!baseURL.isEmpty() && baseURL != blankURL() && baseURL != document.baseURL()) completeURLs(*fragment, baseURL); return fragment; }
void DocumentLoader::startLoadingMainResource() { timing().markNavigationStart(); DCHECK(!m_mainResource); DCHECK_EQ(m_state, NotStarted); m_state = Provisional; if (maybeLoadEmpty()) return; DCHECK(timing().navigationStart()); // PlzNavigate: // The fetch has already started in the browser. Don't mark it again. if (!m_frame->settings()->browserSideNavigationEnabled()) { DCHECK(!timing().fetchStart()); timing().markFetchStart(); } DEFINE_STATIC_LOCAL( ResourceLoaderOptions, mainResourceLoadOptions, (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, CheckContentSecurityPolicy, DocumentContext)); FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, mainResourceLoadOptions); m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_substituteData); // PlzNavigate: // The final access checks are still performed here, potentially rejecting // the "provisional" load, but the browser side already expects the renderer // to be able to unconditionally commit. if (!m_mainResource || (m_frame->settings()->browserSideNavigationEnabled() && m_mainResource->errorOccurred())) { m_request = ResourceRequest(blankURL()); maybeLoadEmpty(); return; } // A bunch of headers are set when the underlying resource load begins, and // m_request needs to include those. Even when using a cached resource, we may // make some modification to the request, e.g. adding the referer header. m_request = m_mainResource->isLoading() ? m_mainResource->resourceRequest() : fetchRequest.resourceRequest(); m_mainResource->addClient(this); }
bool NavigationScheduler::mustLockBackForwardList(Frame* targetFrame) { // Non-user navigation before the page has finished firing onload should not create a new back/forward item. // See https://webkit.org/b/42861 for the original motivation for this. if (!UserGestureIndicator::processingUserGesture() && !targetFrame->document()->loadEventFinished()) return true; // From the HTML5 spec for location.assign(): // "If the browsing context's session history contains only one Document, // and that was the about:blank Document created when the browsing context // was created, then the navigation must be done with replacement enabled." if (!targetFrame->loader().stateMachine()->committedMultipleRealLoads() && equalIgnoringCase(targetFrame->document()->url(), blankURL())) return true; // Navigation of a subframe during loading of an ancestor frame does not create a new back/forward item. // The definition of "during load" is any time before all handlers for the load event have been run. // See https://bugs.webkit.org/show_bug.cgi?id=14957 for the original motivation for this. return targetFrame->tree().parent() && !targetFrame->tree().parent()->loader().allAncestorsAreComplete(); }
PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight) { if (!m_webFrame) return 0; QWebFrameData frameData(m_frame->page(), m_frame, ownerElement, name); if (url.isEmpty()) frameData.url = blankURL(); else frameData.url = url; frameData.referrer = referrer; frameData.allowsScrolling = allowsScrolling; frameData.marginWidth = marginWidth; frameData.marginHeight = marginHeight; QPointer<QWebFrame> webFrame = new QWebFrame(m_webFrame, &frameData); // The creation of the frame may have run arbitrary JavaScript that removed it from the page already. if (!webFrame->d->frame->page()) { frameData.frame.release(); ASSERT(webFrame.isNull()); return 0; } emit m_webFrame->page()->frameCreated(webFrame); // ### set override encoding if we have one frameData.frame->loader()->loadURLIntoChildFrame(frameData.url, frameData.referrer, frameData.frame.get()); // The frame's onload handler may have removed it from the document. if (!frameData.frame->tree()->parent()) return 0; return frameData.frame.release(); }
bool WebPagePopupImpl::initializePage() { Page::PageClients pageClients; fillWithEmptyClients(pageClients); m_chromeClient = PagePopupChromeClient::create(this); pageClients.chromeClient = m_chromeClient.get(); m_page = adoptPtrWillBeNoop(new Page(pageClients)); m_page->settings().setScriptEnabled(true); m_page->settings().setAllowScriptsToCloseWindows(true); m_page->setDeviceScaleFactor(m_webView->deviceScaleFactor()); m_page->settings().setDeviceSupportsTouch(m_webView->page()->settings().deviceSupportsTouch()); // FIXME: Should we support enabling a11y while a popup is shown? m_page->settings().setAccessibilityEnabled(m_webView->page()->settings().accessibilityEnabled()); m_page->settings().setScrollAnimatorEnabled(m_webView->page()->settings().scrollAnimatorEnabled()); provideContextFeaturesTo(*m_page, adoptPtr(new PagePopupFeaturesClient())); DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<FrameLoaderClient>, emptyFrameLoaderClient, (EmptyFrameLoaderClient::create())); RefPtrWillBeRawPtr<LocalFrame> frame = LocalFrame::create(emptyFrameLoaderClient.get(), &m_page->frameHost(), 0); frame->setPagePopupOwner(m_popupClient->ownerElement()); frame->setView(FrameView::create(frame.get())); frame->init(); frame->view()->resize(m_popupClient->contentSize()); frame->view()->setTransparent(false); if (AXObjectCache* cache = m_popupClient->ownerElement().document().existingAXObjectCache()) cache->childrenChanged(&m_popupClient->ownerElement()); ASSERT(frame->localDOMWindow()); DOMWindowPagePopup::install(*frame->localDOMWindow(), *this, m_popupClient); ASSERT(m_popupClient->ownerElement().document().existingAXObjectCache() == frame->document()->existingAXObjectCache()); RefPtr<SharedBuffer> data = SharedBuffer::create(); m_popupClient->writeDocument(data.get()); frame->loader().load(FrameLoadRequest(0, blankURL(), SubstituteData(data, "text/html", "UTF-8", KURL(), ForceSynchronousLoad))); return true; }
bool KURL::isAboutBlankURL() const { return *this == blankURL(); }
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; }
bool HistoryController::currentItemShouldBeReplaced() const { // From the HTML5 spec for location.assign(): // "If the browsing context's session history contains only one Document, // and that was the about:blank Document created when the browsing context // was created, then the navigation must be done with replacement enabled." return m_currentItem && !m_previousItem && equalIgnoringCase(m_currentItem->urlString(), blankURL()); }
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; }
PassRefPtr<LegacyWebArchive> LegacyWebArchive::createFromSelection(Frame* frame) { if (!frame) return 0; RefPtr<Range> selectionRange = frame->selection()->toNormalizedRange(); Vector<Node*> nodeList; String markupString = frame->documentTypeString() + createMarkup(selectionRange.get(), &nodeList, AnnotateForInterchange); RefPtr<LegacyWebArchive> archive = create(markupString, frame, nodeList); if (!frame->document() || !frame->document()->isFrameSet()) return archive.release(); // Wrap the frameset document in an iframe so it can be pasted into // another document (which will have a body or frameset of its own). String iframeMarkup = "<iframe frameborder=\"no\" marginwidth=\"0\" marginheight=\"0\" width=\"98%%\" height=\"98%%\" src=\"" + frame->loader()->documentLoader()->response().url().string() + "\"></iframe>"; RefPtr<ArchiveResource> iframeResource = ArchiveResource::create(utf8Buffer(iframeMarkup), blankURL(), "text/html", "UTF-8", String()); Vector<PassRefPtr<ArchiveResource> > subresources; Vector<PassRefPtr<LegacyWebArchive> > subframeArchives; subframeArchives.append(archive); archive = create(iframeResource.release(), subresources, subframeArchives); return archive.release(); }