Beispiel #1
0
static String dumpFramesAsText(Evas_Object* frame)
{
    String result;

    if (browser->mainFrame() != frame) {
        result.append("\n--------\nFrame: '");
        result.append(String::fromUTF8(ewk_frame_name_get(frame)));
        result.append("'\n--------\n");
    }

    const char* frameContents = ewk_frame_plain_text_get(frame);
    result.append(String::fromUTF8(frameContents));
    result.append("\n");
    eina_stringshare_del(frameContents);

    if (gTestRunner->dumpChildFramesAsText()) {
        Eina_List* children = DumpRenderTreeSupportEfl::frameChildren(frame);
        void* iterator;

        EINA_LIST_FREE(children, iterator) {
            Evas_Object* currentFrame = static_cast<Evas_Object*>(iterator);
            String tempText(dumpFramesAsText(currentFrame));

            if (tempText.isEmpty())
                continue;

            result.append(tempText);
        }
void DumpRenderTree::dump()
{
    // Prevent any further frame load or resource load callbacks from appearing after we dump the result.
    DumpRenderTreeSupportQt::dumpFrameLoader(false);
    DumpRenderTreeSupportQt::dumpResourceLoadCallbacks(false);

    QWebFrame *mainFrame = m_page->mainFrame();

    if (isStandAloneMode()) {
        QString markup = mainFrame->toHtml();
        fprintf(stdout, "Source:\n\n%s\n", markup.toUtf8().constData());
    }

    QString mimeType = DumpRenderTreeSupportQt::responseMimeType(mainFrame);
    if (mimeType == "text/plain")
        m_controller->dumpAsText();

    // Dump render text...
    QString resultString;
    if (m_controller->shouldDumpAsText())
        resultString = dumpFramesAsText(mainFrame);
    else {
        resultString = mainFrame->renderTreeDump();
        resultString += dumpFrameScrollPosition(mainFrame);
    }
    if (!resultString.isEmpty()) {
        fprintf(stdout, "Content-Type: text/plain\n");
        fprintf(stdout, "%s", resultString.toUtf8().constData());

        if (m_controller->shouldDumpBackForwardList()) {
            fprintf(stdout, "%s", dumpBackForwardList(webPage()).toUtf8().constData());
            foreach (QObject* widget, windows) {
                QWebPage* page = qobject_cast<QWebPage*>(widget->findChild<QWebPage*>());
                fprintf(stdout, "%s", dumpBackForwardList(page).toUtf8().constData());
            }
QString DumpRenderTree::dumpFramesAsText(QWebFrame* frame)
{
    if (!frame || !DumpRenderTreeSupportQt::hasDocumentElement(frame))
        return QString();

    QString result;
    QWebFrame* parent = qobject_cast<QWebFrame*>(frame->parent());
    if (parent) {
        result.append(QLatin1String("\n--------\nFrame: '"));
        result.append(frame->frameName());
        result.append(QLatin1String("'\n--------\n"));
    }

    QString innerText = frame->toPlainText();
    result.append(innerText);
    result.append(QLatin1String("\n"));

    if (m_controller->shouldDumpChildrenAsText()) {
        QList<QWebFrame *> children = frame->childFrames();
        for (int i = 0; i < children.size(); ++i)
            result += dumpFramesAsText(children.at(i));
    }

    return result;
}
Beispiel #4
0
void DumpRenderTree::dump()
{
    if (testDone)
        return;

    invalidateAnyPreviousWaitToDumpWatchdog();

    String dumpFile = m_resultsDir + *m_currentTest + ".dump";

    String resultMimeType = "text/plain";
    String responseMimeType = mainFrame->loader()->documentLoader()->responseMIMEType();

    bool dumpAsText = gTestRunner->dumpAsText() || responseMimeType == "text/plain";
    String data = dumpAsText ? dumpFramesAsText(mainFrame) : renderTreeDump();

    if (gTestRunner->dumpBackForwardList())
        data = data + dumpBackForwardListForWebView();

    String result = "Content-Type: " + resultMimeType + "\n" + data;

    dumpToFile(result);

    if (!runFromCommandLine) {
        // There are two scenarios for dumping pixels:
        // 1. When the test case explicitly asks for it by calling dumpAsText(true) with that extra true passed as a parameter value, from JavaScript
        bool explicitPixelResults = gTestRunner->dumpAsText() && gTestRunner->generatePixelResults();
        // 2. When the test case implicitly allows it by not calling dumpAsText() at all (with no parameters).
        bool implicitPixelResults = !gTestRunner->dumpAsText();

        // But only if m_enablePixelTests is set, to say that the user wants to run pixel tests at all.
        bool generatePixelResults = m_enablePixelTests && (explicitPixelResults || implicitPixelResults);
        if (generatePixelResults) {
            // signal end of text block
            fputs("#EOF\n", stdout);
            dumpWebViewAsPixelsAndCompareWithExpected(gTestRunner->expectedPixelHash());
        }

        String crashFile = dumpFile + ".crash";
        unlink(crashFile.utf8().data());

        String doneFile =  m_resultsDir + *m_currentTest + ".done";
        createFile(doneFile);
    }
    testDone = true;
    runRemainingTests();
}
Beispiel #5
0
String DumpRenderTree::dumpFramesAsText(WebCore::Frame* frame)
{
    String s;
    WebCore::Element* documentElement = frame->document()->documentElement();
    if (!documentElement)
        return s.utf8().data();

    if (frame->tree()->parent())
        s = String::format("\n--------\nFrame: '%s'\n--------\n", frame->tree()->uniqueName().string().utf8().data());

    s = s + documentElement->innerText() + "\n";

    if (gTestRunner->dumpChildFramesAsText()) {
        WebCore::FrameTree* tree = frame->tree();
        for (WebCore::Frame* child = tree->firstChild(); child; child = child->tree()->nextSibling())
            s = s + dumpFramesAsText(child);
    }
    return s;
}
Beispiel #6
0
void
DumpRenderTreeWKC::dump_()
{
    fWaitForPolicy = false;

    WKC::Frame* wkcframe = fMainFrame->core();
    WebCore::Frame* coreframe= wkcframe->priv().webcore();

    bool dump_as_text = fController->dumpAsText();
    if (fDumpTree) {
        char* result = 0;
        WebCore::DocumentLoader* doc_loader = coreframe->loader().documentLoader();
        WTF::String mime_type = doc_loader->responseMIMEType();
        if (mime_type.contains("text/plain", true)) {
            dump_as_text = true;
        }

        // Test can request controller to be dumped as text even
        // while test's response mime type is not text/plain.
        // Overriding this behavior with dumpAsText being false is a bad idea.
        if (dump_as_text)
            fController->setDumpAsText(dump_as_text);

        if (fController->dumpAsText())
            result = dumpFramesAsText(fMainFrame);
        else
            result = dumpRenderTree(fMainFrame);

        if (!result) {
            const char* error_message;
            if (fController->dumpAsText())
                error_message = "[documentElement innerText]";
            else if (fController->dumpDOMAsWebArchive())
                error_message = "[[mainFrame DOMDocument] webArchive]";
            else if (fController->dumpSourceAsWebArchive())
                error_message = "[[mainFrame dataSource] webArchive]";
            else
                error_message = "[mainFrame renderTreeAsExternalRepresentation]";
            fUI.dumpRenderTreePrintf("ERROR: nil result from %s", error_message);
        } else {
            fUI.dumpRenderTreePrintf("%s", result);
            free(result);
            if (!fController->dumpAsText() && !fController->dumpDOMAsWebArchive() && !fController->dumpSourceAsWebArchive()) {
//                dumpFrameScrollPosition(fMainFrame);
            }

            if (fController->dumpBackForwardList()) {
//                dumpBackForwardListForAllWebViews();
            }
        }

//        if (fPrintSeparators) {
//            fUI.dumpRenderTreePrintf("#EOF");
//        }
    }

    if (fDumpPixels) {
        if (!fController->dumpAsText() && !fController->dumpDOMAsWebArchive() && !fController->dumpSourceAsWebArchive()) {
            // FIXME: Add support for dumping pixels
        }
    }

    // FIXME: call displayWebView here when we support --paint

    fDone = true;

    fUI.dumpRenderTreeNotifyFinished();
}