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); }
bool DumpRenderTreeWKC::beginTest(const char* uri) { std::string path_or_url(uri); std::string expected_pixel_hash; size_t separator_pos = path_or_url.find("'"); if (separator_pos != std::string::npos) { path_or_url = std::string(uri, 0, separator_pos); expected_pixel_hash = std::string(uri, separator_pos + 1); } const std::string test_url(uri); resetDefaultsToConsistentValues(); fController = LayoutTestController::create(test_url, expected_pixel_hash).leakRef(); fTopLoadingFrame = 0; fDone = false; fController->setIconDatabaseEnabled(false); if (shouldLogFrameLoadDelegates(path_or_url.c_str())) fController->setDumpFrameLoadCallbacks(true); if (shouldOpenWebInspector(path_or_url.c_str())) fController->showWebInspector(); #if 0 bool isSVGW3CTest = (fController->testPathOrURL().find("svg/W3C-SVG-1.1") != string::npos); GtkAllocation size; size.x = size.y = 0; size.width = isSVGW3CTest ? 480 : maxViewWidth; size.height = isSVGW3CTest ? 360 : maxViewHeight; gtk_window_resize(GTK_WINDOW(window), size.width, size.height); gtk_widget_size_allocate(container, &size); #endif #if 0 if (prevTestBFItem) g_object_unref(prevTestBFItem); WebKitWebBackForwardList* bfList = webkit_web_view_get_back_forward_list(webView); prevTestBFItem = webkit_web_back_forward_list_get_current_item(bfList); if (prevTestBFItem) g_object_ref(prevTestBFItem); #endif fView->loadURI(uri); return true; }
void TestInvocation::invoke() { sizeWebViewForCurrentTest(m_pathOrURL.c_str()); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest")); WKRetainPtr<WKMutableDictionaryRef> beginTestMessageBody = adoptWK(WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> dumpFrameLoadDelegatesKey = adoptWK(WKStringCreateWithUTF8CString("DumpFrameLoadDelegates")); WKRetainPtr<WKBooleanRef> dumpFrameLoadDelegatesValue = adoptWK(WKBooleanCreate(shouldLogFrameLoadDelegates(m_pathOrURL.c_str()))); WKDictionaryAddItem(beginTestMessageBody.get(), dumpFrameLoadDelegatesKey.get(), dumpFrameLoadDelegatesValue.get()); WKRetainPtr<WKStringRef> dumpPixelsKey = adoptWK(WKStringCreateWithUTF8CString("DumpPixels")); WKRetainPtr<WKBooleanRef> dumpPixelsValue = adoptWK(WKBooleanCreate(m_dumpPixels)); WKDictionaryAddItem(beginTestMessageBody.get(), dumpPixelsKey.get(), dumpPixelsValue.get()); WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey = adoptWK(WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer")); WKRetainPtr<WKBooleanRef> useWaitToDumpWatchdogTimerValue = adoptWK(WKBooleanCreate(TestController::shared().useWaitToDumpWatchdogTimer())); WKDictionaryAddItem(beginTestMessageBody.get(), useWaitToDumpWatchdogTimerKey.get(), useWaitToDumpWatchdogTimerValue.get()); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), beginTestMessageBody.get()); TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout); if (!m_gotInitialResponse) { dump("Timed out waiting for initial response from web process\n"); return; } if (m_error) { dump("FAIL\n"); return; } #if ENABLE(INSPECTOR) if (shouldOpenWebInspector(m_pathOrURL.c_str())) WKInspectorShow(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get()); TestController::shared().runUntil(m_gotFinalMessage, TestController::shared().useWaitToDumpWatchdogTimer() ? TestController::LongTimeout : TestController::NoTimeout); if (!m_gotFinalMessage) dump("Timed out waiting for final message from web process\n"); else if (m_error) dump("FAIL\n"); #if ENABLE(INSPECTOR) WKInspectorClose(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) }
void TestInvocation::invoke() { sizeWebViewForCurrentTest(m_pathOrURL.c_str()); updateLayoutType(m_pathOrURL.c_str()); updateTiledDrawingForCurrentTest(m_pathOrURL.c_str()); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest")); WKRetainPtr<WKMutableDictionaryRef> beginTestMessageBody = adoptWK(WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> dumpFrameLoadDelegatesKey = adoptWK(WKStringCreateWithUTF8CString("DumpFrameLoadDelegates")); WKRetainPtr<WKBooleanRef> dumpFrameLoadDelegatesValue = adoptWK(WKBooleanCreate(shouldLogFrameLoadDelegates(m_pathOrURL.c_str()))); WKDictionaryAddItem(beginTestMessageBody.get(), dumpFrameLoadDelegatesKey.get(), dumpFrameLoadDelegatesValue.get()); WKRetainPtr<WKStringRef> dumpPixelsKey = adoptWK(WKStringCreateWithUTF8CString("DumpPixels")); WKRetainPtr<WKBooleanRef> dumpPixelsValue = adoptWK(WKBooleanCreate(m_dumpPixels)); WKDictionaryAddItem(beginTestMessageBody.get(), dumpPixelsKey.get(), dumpPixelsValue.get()); WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey = adoptWK(WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer")); WKRetainPtr<WKBooleanRef> useWaitToDumpWatchdogTimerValue = adoptWK(WKBooleanCreate(TestController::shared().useWaitToDumpWatchdogTimer())); WKDictionaryAddItem(beginTestMessageBody.get(), useWaitToDumpWatchdogTimerKey.get(), useWaitToDumpWatchdogTimerValue.get()); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), beginTestMessageBody.get()); TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout); if (!m_gotInitialResponse) { m_errorMessage = "Timed out waiting for initial response from web process\n"; m_webProcessIsUnresponsive = true; goto end; } if (m_error) goto end; #if ENABLE(INSPECTOR) if (shouldOpenWebInspector(m_pathOrURL.c_str())) WKInspectorShow(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get()); TestController::shared().runUntil(m_gotFinalMessage, TestController::shared().useWaitToDumpWatchdogTimer() ? TestController::LongTimeout : TestController::NoTimeout); if (!m_gotFinalMessage) { m_errorMessage = "Timed out waiting for final message from web process\n"; m_webProcessIsUnresponsive = true; goto end; } if (m_error) goto end; dumpResults(); end: #if ENABLE(INSPECTOR) if (m_gotInitialResponse) WKInspectorClose(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) if (m_webProcessIsUnresponsive) dumpWebProcessUnresponsiveness(); else if (!TestController::shared().resetStateToConsistentValues()) { m_errorMessage = "Timed out loading about:blank before the next test"; dumpWebProcessUnresponsiveness(); } }
void TestInvocation::invoke() { sizeWebViewForCurrentTest(m_pathOrURL.c_str()); WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest")); WKRetainPtr<WKMutableDictionaryRef> beginTestMessageBody = adoptWK(WKMutableDictionaryCreate()); WKRetainPtr<WKStringRef> dumpFrameLoadDelegatesKey = adoptWK(WKStringCreateWithUTF8CString("DumpFrameLoadDelegates")); WKRetainPtr<WKBooleanRef> dumpFrameLoadDelegatesValue = adoptWK(WKBooleanCreate(shouldLogFrameLoadDelegates(m_pathOrURL.c_str()))); WKDictionaryAddItem(beginTestMessageBody.get(), dumpFrameLoadDelegatesKey.get(), dumpFrameLoadDelegatesValue.get()); WKRetainPtr<WKStringRef> dumpPixelsKey = adoptWK(WKStringCreateWithUTF8CString("DumpPixels")); WKRetainPtr<WKBooleanRef> dumpPixelsValue = adoptWK(WKBooleanCreate(m_dumpPixels)); WKDictionaryAddItem(beginTestMessageBody.get(), dumpPixelsKey.get(), dumpPixelsValue.get()); WKRetainPtr<WKStringRef> useWaitToDumpWatchdogTimerKey = adoptWK(WKStringCreateWithUTF8CString("UseWaitToDumpWatchdogTimer")); WKRetainPtr<WKBooleanRef> useWaitToDumpWatchdogTimerValue = adoptWK(WKBooleanCreate(TestController::shared().useWaitToDumpWatchdogTimer())); WKDictionaryAddItem(beginTestMessageBody.get(), useWaitToDumpWatchdogTimerKey.get(), useWaitToDumpWatchdogTimerValue.get()); WKContextPostMessageToInjectedBundle(TestController::shared().context(), messageName.get(), beginTestMessageBody.get()); const char* errorMessage = 0; TestController::shared().runUntil(m_gotInitialResponse, TestController::ShortTimeout); if (!m_gotInitialResponse) { errorMessage = "Timed out waiting for initial response from web process\n"; goto end; } if (m_error) { errorMessage = "FAIL\n"; goto end; } #if ENABLE(INSPECTOR) if (shouldOpenWebInspector(m_pathOrURL.c_str())) WKInspectorShow(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) WKPageLoadURL(TestController::shared().mainWebView()->page(), m_url.get()); TestController::shared().runUntil(m_gotFinalMessage, TestController::shared().useWaitToDumpWatchdogTimer() ? TestController::LongTimeout : TestController::NoTimeout); if (!m_gotFinalMessage) { errorMessage = "Timed out waiting for final message from web process\n"; goto end; } if (m_error) { errorMessage = "FAIL\n"; goto end; } end: #if ENABLE(INSPECTOR) if (m_gotInitialResponse) WKInspectorClose(WKPageGetInspector(TestController::shared().mainWebView()->page())); #endif // ENABLE(INSPECTOR) bool resetDone = TestController::shared().resetStateToConsistentValues(); // We expect resetting to not fail if there was no error or timeout. ASSERT(resetDone || errorMessage); const char* errorMessageToStderr = 0; #if PLATFORM(MAC) char buffer[64]; if (!resetDone) { pid_t pid = WKPageGetProcessIdentifier(TestController::shared().mainWebView()->page()); sprintf(buffer, "#PROCESS UNRESPONSIVE - WebProcess (pid %ld)\n", static_cast<long>(pid)); errorMessageToStderr = buffer; } #else if (!resetDone) errorMessageToStderr = "#PROCESS UNRESPONSIVE - WebProcess"; #endif if (errorMessage) dump(errorMessage, errorMessageToStderr, true); }