void DumpRenderTree::runTest(const String& url, const String& imageHash) { mainFrame->loader()->stopForUserCancel(); resetToConsistentStateBeforeTesting(url, imageHash); if (shouldLogFrameLoadDelegates(url)) gTestRunner->setDumpFrameLoadCallbacks(true); if (!runFromCommandLine) { createFile(m_resultsDir + *m_currentTest + ".dump.crash"); String stdoutFile = m_resultsDir + *m_currentTest + ".dump"; String stderrFile = m_resultsDir + *m_currentTest + ".stderr"; // FIXME: we should preserve the original stdout and stderr here but aren't doing // that yet due to issues with dup, etc. freopen(stdoutFile.utf8().data(), "wb", stdout); freopen(stderrFile.utf8().data(), "wb", stderr); } FILE* current = fopen(m_currentTestFile.utf8().data(), "w"); if (current) { fwrite(m_currentTest->utf8().data(), 1, m_currentTest->utf8().length(), current); fclose(current); } BlackBerry::Platform::NetworkRequest request; STATIC_LOCAL_STRING(s_get, "GET"); request.setRequestUrl(url, s_get); m_page->load(request); }
SocketStreamHandle::SocketStreamHandle(const String& groupName, const KURL& url, SocketStreamHandleClient* client) : SocketStreamHandleBase(url, client) { LOG(Network, "SocketStreamHandle %p new client %p", this, m_client); // Find a playerId to pass to the platform client. It can be from any page // in the PageGroup, since they all share the same network profile and // resources. PageGroup* pageGroup = PageGroup::pageGroup(groupName); ASSERT(pageGroup && !pageGroup->pages().isEmpty()); Page* page = *(pageGroup->pages().begin()); ASSERT(page && page->mainFrame()); int playerId = static_cast<FrameLoaderClientBlackBerry*>(page->mainFrame()->loader()->client())->playerId(); // Create a platform socket stream BlackBerry::Platform::NetworkStreamFactory* factory = page->chrome()->platformPageClient()->networkStreamFactory(); ASSERT(factory); m_socketStream = adoptPtr(factory->createSocketStream(playerId)); ASSERT(m_socketStream); m_socketStream->setListener(this); // Open the socket BlackBerry::Platform::NetworkRequest request; request.setRequestUrl(url.string().latin1().data(), "CONNECT"); m_socketStream->setRequest(request); m_socketStream->streamOpen(); }
int NetworkManager::startJob(int playerId, const String& pageGroupName, PassRefPtr<ResourceHandle> job, const ResourceRequest& request, BlackBerry::Platform::NetworkStreamFactory* streamFactory, Frame* frame, int deferLoadingCount, int redirectCount, bool rereadCookies) { // Make sure the ResourceHandle doesn't go out of scope while calling callbacks. RefPtr<ResourceHandle> guardJob(job); KURL url = request.url(); // Only load the initial url once. bool isInitial = (url == m_initialURL); if (isInitial) m_initialURL = KURL(); // Always reread cookies on a redirect if (redirectCount) rereadCookies = true; BlackBerry::Platform::NetworkRequest platformRequest; request.initializePlatformRequest(platformRequest, frame->loader() && frame->loader()->client() && static_cast<FrameLoaderClientBlackBerry*>(frame->loader()->client())->cookiesEnabled(), isInitial, rereadCookies); // GURL and KURL consider valid URLs differently, for example http:// is parsed as // http:/ by KURL and considered valid, while GURL considers it invalid. if (!platformRequest.url().is_valid()) return BlackBerry::Platform::FilterStream::StatusErrorInvalidUrl; const String& documentUrl = frame->document()->url().string(); if (!documentUrl.isEmpty()) platformRequest.setReferrer(documentUrl); platformRequest.setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); // Attach any applicable auth credentials to the NetworkRequest. setAuthCredentials(platformRequest, guardJob->getInternal()->m_hostWebChallenge); setAuthCredentials(platformRequest, guardJob->getInternal()->m_proxyWebChallenge); if (!request.overrideContentType().isEmpty()) platformRequest.setOverrideContentType(request.overrideContentType()); NetworkJob* networkJob = new NetworkJob; networkJob->initialize(playerId, pageGroupName, url, platformRequest, guardJob, streamFactory, frame, deferLoadingCount, redirectCount); // Make sure we have only one NetworkJob for one ResourceHandle. ASSERT(!findJobForHandle(guardJob)); m_jobs.append(networkJob); switch (networkJob->streamOpen()) { case BlackBerry::Platform::FilterStream::ResultOk: return BlackBerry::Platform::FilterStream::StatusSuccess; case BlackBerry::Platform::FilterStream::ResultNotReady: return BlackBerry::Platform::FilterStream::StatusErrorNotReady; case BlackBerry::Platform::FilterStream::ResultNotHandled: default: // This should never happen. break; } ASSERT_NOT_REACHED(); return BlackBerry::Platform::FilterStream::StatusErrorConnectionFailed; }
bool NetworkJob::initialize(int playerId, const String& pageGroupName, const KURL& url, const BlackBerry::Platform::NetworkRequest& request, PassRefPtr<ResourceHandle> handle, BlackBerry::Platform::NetworkStreamFactory* streamFactory, const Frame& frame, int deferLoadingCount, int redirectCount) { m_playerId = playerId; m_pageGroupName = pageGroupName; m_response.setURL(url); m_isFile = url.protocolIs("file") || url.protocolIs("local"); m_isFTP = url.protocolIs("ftp"); m_handle = handle; m_streamFactory = streamFactory; m_frame = &frame; if (m_frame && m_frame->loader()->pageDismissalEventBeingDispatched() != FrameLoader::NoDismissal) { // In the case the frame will be detached soon, we still need to ping the server, but it is // no longer safe to reference the Frame object. // See http://trac.webkit.org/changeset/65910 and https://bugs.webkit.org/show_bug.cgi?id=30457. m_frame = 0; } m_redirectCount = redirectCount; m_deferLoadingCount = deferLoadingCount; // We don't need to explicitly call notifyHeaderReceived, as the Content-Type // will ultimately get parsed when sendResponseIfNeeded gets called. if (!request.getOverrideContentType().empty()) { m_contentType = String(request.getOverrideContentType()); m_isOverrideContentType = true; } if (!request.getSuggestedSaveName().empty()) m_contentDisposition = "filename=" + String(request.getSuggestedSaveName()); BlackBerry::Platform::FilterStream* wrappedStream = m_streamFactory->createNetworkStream(request, m_playerId); if (!wrappedStream) return false; BlackBerry::Platform::NetworkRequest::TargetType targetType = request.getTargetType(); if ((targetType == BlackBerry::Platform::NetworkRequest::TargetIsMainFrame || targetType == BlackBerry::Platform::NetworkRequest::TargetIsSubframe) && !m_isOverrideContentType) { RSSFilterStream* filter = new RSSFilterStream(); filter->setWrappedStream(wrappedStream); wrappedStream = filter; } setWrappedStream(wrappedStream); return true; }
bool NetworkJob::initialize(int playerId, const String& pageGroupName, const KURL& url, const BlackBerry::Platform::NetworkRequest& request, PassRefPtr<ResourceHandle> handle, BlackBerry::Platform::NetworkStreamFactory* streamFactory, const Frame& frame, int deferLoadingCount, int redirectCount) { m_playerId = playerId; m_pageGroupName = pageGroupName; m_response.setURL(url); m_isFile = url.protocolIs("file") || url.protocolIs("local"); m_isData = url.protocolIs("data"); m_isAbout = url.protocolIs("about"); m_isFTP = url.protocolIs("ftp"); m_handle = handle; m_streamFactory = streamFactory; m_frame = &frame; m_redirectCount = redirectCount; m_deferLoadingCount = deferLoadingCount; // We don't need to explicitly call notifyHeaderReceived, as the Content-Type // will ultimately get parsed when sendResponseIfNeeded gets called. if (!request.getOverrideContentType().empty()) m_contentType = String(request.getOverrideContentType().c_str()); // No need to create the streams for data and about. if (m_isData || m_isAbout) return true; BlackBerry::Platform::FilterStream* wrappedStream = m_streamFactory->createNetworkStream(request, m_playerId); if (!wrappedStream) return false; setWrappedStream(wrappedStream); m_isXHR = request.getTargetType() == BlackBerry::Platform::NetworkRequest::TargetIsXMLHTTPRequest; return true; }
bool NetworkManager::startJob(int playerId, const String& pageGroupName, PassRefPtr<ResourceHandle> job, const ResourceRequest& request, BlackBerry::Platform::NetworkStreamFactory* streamFactory, Frame* frame, int deferLoadingCount, int redirectCount) { // Make sure the ResourceHandle doesn't go out of scope while calling callbacks. RefPtr<ResourceHandle> guardJob(job); KURL url = request.url(); // Only load the initial url once. bool isInitial = (url == m_initialURL); if (isInitial) m_initialURL = KURL(); BlackBerry::Platform::NetworkRequest platformRequest; request.initializePlatformRequest(platformRequest, frame->loader() && frame->loader()->client() && static_cast<FrameLoaderClientBlackBerry*>(frame->loader()->client())->cookiesEnabled(), isInitial, redirectCount); const String& documentUrl = frame->document()->url().string(); if (!documentUrl.isEmpty()) { platformRequest.setReferrer(documentUrl); } platformRequest.setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); // Attach any applicable auth credentials to the NetworkRequest. AuthenticationChallenge& challenge = guardJob->getInternal()->m_currentWebChallenge; if (!challenge.isNull()) { Credential credential = challenge.proposedCredential(); const ProtectionSpace& protectionSpace = challenge.protectionSpace(); String username = credential.user(); String password = credential.password(); BlackBerry::Platform::NetworkRequest::AuthType authType = BlackBerry::Platform::NetworkRequest::AuthTypeNone; switch (protectionSpace.serverType()) { case ProtectionSpaceServerHTTP: authType = BlackBerry::Platform::NetworkRequest::AuthTypeHTTP; break; case ProtectionSpaceServerHTTPS: authType = BlackBerry::Platform::NetworkRequest::AuthTypeHTTPS; break; case ProtectionSpaceServerFTP: authType = BlackBerry::Platform::NetworkRequest::AuthTypeFTP; break; case ProtectionSpaceServerFTPS: authType = BlackBerry::Platform::NetworkRequest::AuthTypeFTPS; break; case ProtectionSpaceProxyHTTP: authType = BlackBerry::Platform::NetworkRequest::AuthTypeProxyHTTP; break; case ProtectionSpaceProxyHTTPS: authType = BlackBerry::Platform::NetworkRequest::AuthTypeProxyHTTPS; break; case ProtectionSpaceProxyFTP: authType = BlackBerry::Platform::NetworkRequest::AuthTypeProxyFTP; break; default: ASSERT_NOT_REACHED(); break; } BlackBerry::Platform::NetworkRequest::AuthScheme authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeNone; switch (protectionSpace.authenticationScheme()) { case ProtectionSpaceAuthenticationSchemeDefault: authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeDefault; break; case ProtectionSpaceAuthenticationSchemeHTTPBasic: authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeHTTPBasic; break; case ProtectionSpaceAuthenticationSchemeHTTPDigest: authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeHTTPDigest; break; case ProtectionSpaceAuthenticationSchemeNegotiate: authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeNegotiate; break; case ProtectionSpaceAuthenticationSchemeNTLM: authScheme = BlackBerry::Platform::NetworkRequest::AuthSchemeNTLM; break; default: ASSERT_NOT_REACHED(); break; } if (authType != BlackBerry::Platform::NetworkRequest::AuthTypeNone && authScheme != BlackBerry::Platform::NetworkRequest::AuthSchemeNone) platformRequest.setCredentials(username.utf8().data(), password.utf8().data(), authType, authScheme); } if (!request.overrideContentType().isEmpty()) platformRequest.setOverrideContentType(request.overrideContentType().latin1().data()); NetworkJob* networkJob = new NetworkJob; if (!networkJob) return false; if (!networkJob->initialize(playerId, pageGroupName, url, platformRequest, guardJob, streamFactory, frame, deferLoadingCount, redirectCount)) { delete networkJob; return false; } // Make sure we have only one NetworkJob for one ResourceHandle. ASSERT(!findJobForHandle(guardJob)); m_jobs.append(networkJob); int result = networkJob->streamOpen(); if (result) return false; return true; }