Changeset 137127 in webkit


Ignore:
Timestamp:
Dec 10, 2012 2:44:33 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[WTR] Move text output accumulation to the UIProcess
https://bugs.webkit.org/show_bug.cgi?id=104214

Patch by Martin Robinson <mrobinson@igalia.com> on 2012-12-10
Reviewed by Darin Adler.

Instead of accumulating text output in the InjectedBundle and then sending it to the UIProcess
once a test is finished, immediately send any text output to the UIProcess. This will allow
WebKitTestRunner to output text from the UIProcess as well.

  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: Remove the handling of the text output

StringBuilder. Add a method to send output to the UIProcess.

  • WebKitTestRunner/InjectedBundle/InjectedBundle.h:

(InjectedBundle):

  • WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: Change code that appends to the StringBuilder

to use the new outputText method.

  • WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp: Ditto.
  • WebKitTestRunner/InjectedBundle/atk/AccessibilityControllerAtk.cpp: Ditto.
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::TestInvocation): Intialize the StringBuilder.
(WTR::TestInvocation::invoke): Clear the StringBuilder when a new tests starts.
(WTR::TestInvocation::dumpResults): m_textOutput is a StringBuilder now so the
method of printing the text is slightly different.
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Handle the new TextOutput
message by appending the results to the StringBuilder.

  • WebKitTestRunner/TestInvocation.h:

(TestInvocation): Switch the type of m_textOutput.

Location:
trunk/Tools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r137118 r137127  
     12012-12-10  Martin Robinson  <mrobinson@igalia.com>
     2
     3        [WTR] Move text output accumulation to the UIProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=104214
     5
     6        Reviewed by Darin Adler.
     7
     8        Instead of accumulating text output in the InjectedBundle and then sending it to the UIProcess
     9        once a test is finished, immediately send any text output to the UIProcess. This will allow
     10        WebKitTestRunner to output text from the UIProcess as well.
     11
     12        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: Remove the handling of the text output
     13        StringBuilder. Add a method to send output to the UIProcess.
     14        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
     15        (InjectedBundle):
     16        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp: Change code that appends to the StringBuilder
     17        to use the new outputText method.
     18        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
     19        * WebKitTestRunner/InjectedBundle/TestRunner.cpp: Ditto.
     20        * WebKitTestRunner/InjectedBundle/atk/AccessibilityControllerAtk.cpp: Ditto.
     21        * WebKitTestRunner/TestInvocation.cpp:
     22        (WTR::TestInvocation::TestInvocation): Intialize the StringBuilder.
     23        (WTR::TestInvocation::invoke): Clear the StringBuilder when a new tests starts.
     24        (WTR::TestInvocation::dumpResults): m_textOutput is a StringBuilder now so the
     25        method of printing the text is slightly different.
     26        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle): Handle the new TextOutput
     27        message by appending the results to the StringBuilder.
     28        * WebKitTestRunner/TestInvocation.h:
     29        (TestInvocation): Switch the type of m_textOutput.
     30
    1312012-12-10  Mihnea Ovidenie  <mihnea@adobe.com>
    232
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r135508 r137127  
    8787{
    8888    m_bundle = bundle;
    89     m_stringBuilder = WTF::adoptPtr(new WTF::StringBuilder());
    9089
    9190    WKBundleClient client = {
     
    219218    WKTypeRef value = WKDictionaryGetItemForKey(dictionary, wkKey.get());
    220219    if (WKGetTypeID(value) != WKBooleanGetTypeID()) {
    221         stringBuilder()->appendLiteral("Boolean value for key \"");
    222         stringBuilder()->append(key);
    223         stringBuilder()->appendLiteral("\" not found in dictionary\n");
     220        outputText(makeString("Boolean value for key", key, " not found in dictionary\n"));
    224221        return false;
    225222    }
     
    233230    m_pixelResult.clear();
    234231    m_repaintRects.clear();
    235     m_stringBuilder->clear();
    236232
    237233    m_testRunner = TestRunner::create();
     
    293289    WKRetainPtr<WKMutableDictionaryRef> doneMessageBody(AdoptWK, WKMutableDictionaryCreate());
    294290
    295     WKRetainPtr<WKStringRef> textOutputKey(AdoptWK, WKStringCreateWithUTF8CString("TextOutput"));
    296     WKRetainPtr<WKStringRef> textOutput(AdoptWK, WKStringCreateWithUTF8CString(m_stringBuilder->toString().utf8().data()));
    297     WKDictionaryAddItem(doneMessageBody.get(), textOutputKey.get(), textOutput.get());
    298    
    299291    WKRetainPtr<WKStringRef> pixelResultKey = adoptWK(WKStringCreateWithUTF8CString("PixelResult"));
    300292    WKDictionaryAddItem(doneMessageBody.get(), pixelResultKey.get(), m_pixelResult.get());
     
    323315}
    324316
    325 void InjectedBundle::dumpBackForwardListsForAllPages()
     317void InjectedBundle::dumpBackForwardListsForAllPages(StringBuilder& stringBuilder)
    326318{
    327319    size_t size = m_pages.size();
    328320    for (size_t i = 0; i < size; ++i)
    329         m_pages[i]->dumpBackForwardList();
    330 }
    331    
     321        m_pages[i]->dumpBackForwardList(stringBuilder);
     322}
     323
     324void InjectedBundle::outputText(const String& output)
     325{
     326    if (m_state != Testing)
     327        return;
     328    if (output.isEmpty())
     329        return;
     330    WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("TextOutput"));
     331    WKRetainPtr<WKStringRef> messageBody(AdoptWK, WKStringCreateWithUTF8CString(output.utf8().data()));
     332    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
     333}
     334
    332335void InjectedBundle::postNewBeforeUnloadReturnValue(bool value)
    333336{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h

    r132914 r137127  
    3434#include <WebKit2/WKBase.h>
    3535#include <WebKit2/WKRetainPtr.h>
     36#include <sstream>
     37#include <wtf/Forward.h>
    3638#include <wtf/OwnPtr.h>
    3739#include <wtf/RefPtr.h>
    3840#include <wtf/Vector.h>
    39 
    40 #include <sstream>
    41 
    42 namespace WTF {
    43 class StringBuilder;
    44 }
    4541
    4642namespace WTR {
     
    6864    void closeOtherPages();
    6965
    70     void dumpBackForwardListsForAllPages();
     66    void dumpBackForwardListsForAllPages(StringBuilder&);
    7167
    7268    void done();
    73     WTF::StringBuilder* stringBuilder() { return m_stringBuilder.get(); }
    7469    void setPixelResult(WKImageRef image) { m_pixelResult = image; }
    7570    void setRepaintRects(WKArrayRef rects) { m_repaintRects = rects; }
     
    8378    bool useWaitToDumpWatchdogTimer() const { return m_useWaitToDumpWatchdogTimer; }
    8479   
     80    void outputText(const String&);
    8581    void postNewBeforeUnloadReturnValue(bool);
    8682    void postAddChromeInputField();
     
    145141    WKBundleFrameRef m_topLoadingFrame;
    146142
    147     OwnPtr<WTF::StringBuilder> m_stringBuilder;
    148    
    149143    enum State {
    150144        Idle,
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

    r137067 r137127  
    105105    JSValueRef parentNode = propertyValue(context, nodeValue, "parentNode");
    106106
    107     WTF::StringBuilder stringBuilder;
     107    StringBuilder stringBuilder;
    108108    stringBuilder.append(toWTFString(nodeName));
    109109
     
    154154    int endOffset = propertyValueInt(context, rangeObject, "endOffset");
    155155
    156     WTF::StringBuilder stringBuilder;
     156    StringBuilder stringBuilder;
    157157    stringBuilder.appendLiteral("range from ");
    158158    stringBuilder.appendNumber(startOffset);
     
    190190    // No existing tests actually hit this code path at the time of this writing, because WebCore doesn't call
    191191    // the editing client if the styling operation source is CommandFromDOM or CommandFromDOMWithUserInterface.
    192     WTF::StringBuilder stringBuilder;
     192    StringBuilder stringBuilder;
    193193    stringBuilder.appendLiteral("<DOMCSSStyleDeclaration ADDRESS>");
    194194    return stringBuilder.toString();
     
    197197static WTF::String securityOriginToStr(WKSecurityOriginRef origin)
    198198{
    199     WTF::StringBuilder stringBuilder;
     199    StringBuilder stringBuilder;
    200200    stringBuilder.append('{');
    201201    stringBuilder.append(toWTFString(adoptWK(WKSecurityOriginCopyProtocol(origin))));
     
    212212{
    213213    WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame));
    214     WTF::StringBuilder stringBuilder;
     214    StringBuilder stringBuilder;
    215215    if (WKBundleFrameIsMainFrame(frame)) {
    216216        if (!WKStringIsEmpty(name.get())) {
     
    250250
    251251    String pathString = toWTFString(adoptWK(WKURLCopyPath(fileUrl)));
    252     WTF::StringBuilder stringBuilder;
     252    StringBuilder stringBuilder;
    253253
    254254    // Remove the leading path from file urls.
     
    285285static HashMap<uint64_t, String> assignedUrlsCache;
    286286
    287 static inline void dumpResourceURL(uint64_t identifier)
     287static inline void dumpResourceURL(uint64_t identifier, StringBuilder& stringBuilder)
    288288{
    289289    if (assignedUrlsCache.contains(identifier))
    290         InjectedBundle::shared().stringBuilder()->append(assignedUrlsCache.get(identifier));
     290        stringBuilder.append(assignedUrlsCache.get(identifier));
    291291    else
    292         InjectedBundle::shared().stringBuilder()->appendLiteral("<unknown>");
     292        stringBuilder.appendLiteral("<unknown>");
    293293}
    294294
     
    454454
    455455// String output must be identical to -[WebFrame _drt_descriptionSuitableForTestResult].
    456 static void dumpFrameDescriptionSuitableForTestResult(WKBundleFrameRef frame)
     456static void dumpFrameDescriptionSuitableForTestResult(WKBundleFrameRef frame, StringBuilder& stringBuilder)
    457457{
    458458    WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame));
    459459    if (WKBundleFrameIsMainFrame(frame)) {
    460460        if (WKStringIsEmpty(name.get())) {
    461             InjectedBundle::shared().stringBuilder()->appendLiteral("main frame");
     461            stringBuilder.appendLiteral("main frame");
    462462            return;
    463463        }
    464464
    465         InjectedBundle::shared().stringBuilder()->appendLiteral("main frame \"");
    466         InjectedBundle::shared().stringBuilder()->append(toWTFString(name));
    467         InjectedBundle::shared().stringBuilder()->append('"');
     465        stringBuilder.appendLiteral("main frame \"");
     466        stringBuilder.append(toWTFString(name));
     467        stringBuilder.append('"');
    468468        return;
    469469    }
    470470
    471471    if (WKStringIsEmpty(name.get())) {
    472         InjectedBundle::shared().stringBuilder()->appendLiteral("frame (anonymous)");
    473         return;
    474     }
    475 
    476     InjectedBundle::shared().stringBuilder()->appendLiteral("frame \"");
    477     InjectedBundle::shared().stringBuilder()->append(toWTFString(name));
    478     InjectedBundle::shared().stringBuilder()->append('"');
    479 }
    480 
    481 static inline void dumpRequestDescriptionSuitableForTestResult(WKURLRequestRef request)
     472        stringBuilder.appendLiteral("frame (anonymous)");
     473        return;
     474    }
     475
     476    stringBuilder.appendLiteral("frame \"");
     477    stringBuilder.append(toWTFString(name));
     478    stringBuilder.append('"');
     479}
     480
     481static void dumpLoadEvent(WKBundleFrameRef frame, const char* eventName)
     482{
     483    StringBuilder stringBuilder;
     484    dumpFrameDescriptionSuitableForTestResult(frame, stringBuilder);
     485    stringBuilder.appendLiteral(" - ");
     486    stringBuilder.append(eventName);
     487    stringBuilder.append('\n');
     488    InjectedBundle::shared().outputText(stringBuilder.toString());
     489}
     490
     491static inline void dumpRequestDescriptionSuitableForTestResult(WKURLRequestRef request, StringBuilder& stringBuilder)
    482492{
    483493    WKRetainPtr<WKURLRef> url = adoptWK(WKURLRequestCopyURL(request));
     
    485495    WKRetainPtr<WKStringRef> httpMethod = adoptWK(WKURLRequestCopyHTTPMethod(request));
    486496
    487     InjectedBundle::shared().stringBuilder()->appendLiteral("<NSURLRequest URL ");
    488     InjectedBundle::shared().stringBuilder()->append(pathSuitableForTestResult(url.get()));
    489     InjectedBundle::shared().stringBuilder()->appendLiteral(", main document URL ");
    490     InjectedBundle::shared().stringBuilder()->append(urlSuitableForTestResult(firstParty.get()));
    491     InjectedBundle::shared().stringBuilder()->appendLiteral(", http method ");
     497    stringBuilder.appendLiteral("<NSURLRequest URL ");
     498    stringBuilder.append(pathSuitableForTestResult(url.get()));
     499    stringBuilder.appendLiteral(", main document URL ");
     500    stringBuilder.append(urlSuitableForTestResult(firstParty.get()));
     501    stringBuilder.appendLiteral(", http method ");
    492502
    493503    if (WKStringIsEmpty(httpMethod.get()))
    494         InjectedBundle::shared().stringBuilder()->appendLiteral("(none)");
     504        stringBuilder.appendLiteral("(none)");
    495505    else
    496         InjectedBundle::shared().stringBuilder()->append(toWTFString(httpMethod));
    497 
    498     InjectedBundle::shared().stringBuilder()->append('>');
    499 }
    500 
    501 static inline void dumpResponseDescriptionSuitableForTestResult(WKURLResponseRef response)
     506        stringBuilder.append(toWTFString(httpMethod));
     507
     508    stringBuilder.append('>');
     509}
     510
     511static inline void dumpResponseDescriptionSuitableForTestResult(WKURLResponseRef response, StringBuilder& stringBuilder)
    502512{
    503513    WKRetainPtr<WKURLRef> url = adoptWK(WKURLResponseCopyURL(response));
    504514    if (!url) {
    505         InjectedBundle::shared().stringBuilder()->appendLiteral("(null)");
    506         return;
    507     }
    508     InjectedBundle::shared().stringBuilder()->appendLiteral("<NSURLResponse ");
    509     InjectedBundle::shared().stringBuilder()->append(pathSuitableForTestResult(url.get()));
    510     InjectedBundle::shared().stringBuilder()->appendLiteral(", http status code ");
    511     InjectedBundle::shared().stringBuilder()->appendNumber(WKURLResponseHTTPStatusCode(response));
    512     InjectedBundle::shared().stringBuilder()->append('>');
    513 }
    514 
    515 static inline void dumpErrorDescriptionSuitableForTestResult(WKErrorRef error)
     515        stringBuilder.appendLiteral("(null)");
     516        return;
     517    }
     518    stringBuilder.appendLiteral("<NSURLResponse ");
     519    stringBuilder.append(pathSuitableForTestResult(url.get()));
     520    stringBuilder.appendLiteral(", http status code ");
     521    stringBuilder.appendNumber(WKURLResponseHTTPStatusCode(response));
     522    stringBuilder.append('>');
     523}
     524
     525static inline void dumpErrorDescriptionSuitableForTestResult(WKErrorRef error, StringBuilder& stringBuilder)
    516526{
    517527    WKRetainPtr<WKStringRef> errorDomain = adoptWK(WKErrorCopyDomain(error));
     
    527537        errorDomain = adoptWK(WKStringCreateWithUTF8CString("WebKitErrorDomain"));
    528538
    529     InjectedBundle::shared().stringBuilder()->appendLiteral("<NSError domain ");
    530     InjectedBundle::shared().stringBuilder()->append(toWTFString(errorDomain));
    531     InjectedBundle::shared().stringBuilder()->appendLiteral(", code ");
    532     InjectedBundle::shared().stringBuilder()->appendNumber(errorCode);
     539    stringBuilder.appendLiteral("<NSError domain ");
     540    stringBuilder.append(toWTFString(errorDomain));
     541    stringBuilder.appendLiteral(", code ");
     542    stringBuilder.appendNumber(errorCode);
    533543
    534544    WKRetainPtr<WKURLRef> url = adoptWK(WKErrorCopyFailingURL(error));
    535545    if (url.get()) {
    536546        WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(url.get()));
    537         InjectedBundle::shared().stringBuilder()->appendLiteral(", failing URL \"");
    538         InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
    539         InjectedBundle::shared().stringBuilder()->append('"');
    540     }
    541 
    542     InjectedBundle::shared().stringBuilder()->append('>');
     547        stringBuilder.appendLiteral(", failing URL \"");
     548        stringBuilder.append(toWTFString(urlString));
     549        stringBuilder.append('"');
     550    }
     551
     552    stringBuilder.append('>');
    543553}
    544554
     
    579589    WKRetainPtr<WKBundleIntentRef> intent(AdoptWK, WKBundleIntentRequestCopyIntent(intentRequest));
    580590
    581     InjectedBundle::shared().stringBuilder()->appendLiteral("Received Web Intent: action=");
     591    StringBuilder stringBuilder;
     592    stringBuilder.appendLiteral("Received Web Intent: action=");
    582593    WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKBundleIntentCopyAction(intent.get()));
    583     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkAction.get()));
    584     InjectedBundle::shared().stringBuilder()->appendLiteral(" type=");
     594    stringBuilder.append(toWTFString(wkAction.get()));
     595    stringBuilder.appendLiteral(" type=");
    585596    WKRetainPtr<WKStringRef> wkType(AdoptWK, WKBundleIntentCopyType(intent.get()));
    586     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkType.get()));
    587     InjectedBundle::shared().stringBuilder()->append('\n');
     597    stringBuilder.append(toWTFString(wkType.get()));
     598    stringBuilder.append('\n');
    588599
    589600    const size_t numMessagePorts = WKBundleIntentMessagePortCount(intent.get());
    590601    if (numMessagePorts) {
    591         InjectedBundle::shared().stringBuilder()->appendLiteral("Have ");
    592         InjectedBundle::shared().stringBuilder()->appendNumber(numMessagePorts);
    593         InjectedBundle::shared().stringBuilder()->appendLiteral(" ports\n");
     602        stringBuilder.appendLiteral("Have ");
     603        stringBuilder.appendNumber(numMessagePorts);
     604        stringBuilder.appendLiteral(" ports\n");
    594605    }
    595606
     
    598609        WKRetainPtr<WKStringRef> wkService(AdoptWK, WKURLCopyString(wkServiceUrl.get()));
    599610        if (wkService && !WKStringIsEmpty(wkService.get())) {
    600             InjectedBundle::shared().stringBuilder()->appendLiteral("Explicit intent service: ");
    601             InjectedBundle::shared().stringBuilder()->append(toWTFString(wkService.get()));
    602             InjectedBundle::shared().stringBuilder()->append('\n');
     611            stringBuilder.appendLiteral("Explicit intent service: ");
     612            stringBuilder.append(toWTFString(wkService.get()));
     613            stringBuilder.append('\n');
    603614        }
    604615    }
     
    610621        WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkExtraKeys.get(), i));
    611622        WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(wkExtras.get(), wkKey));
    612         InjectedBundle::shared().stringBuilder()->appendLiteral("Extras[");
    613         InjectedBundle::shared().stringBuilder()->append(toWTFString(wkKey));
    614         InjectedBundle::shared().stringBuilder()->appendLiteral("] = ");
    615         InjectedBundle::shared().stringBuilder()->append(toWTFString(wkValue));
    616         InjectedBundle::shared().stringBuilder()->append('\n');
     623        stringBuilder.appendLiteral("Extras[");
     624        stringBuilder.append(toWTFString(wkKey));
     625        stringBuilder.appendLiteral("] = ");
     626        stringBuilder.append(toWTFString(wkValue));
     627        stringBuilder.append('\n');
    617628    }
    618629
     
    621632    for (size_t i = 0; i < numSuggestions; ++i) {
    622633        WKStringRef wkSuggestion = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkSuggestions.get(), i));
    623         InjectedBundle::shared().stringBuilder()->appendLiteral("Have suggestion ");
    624         InjectedBundle::shared().stringBuilder()->append(toWTFString(wkSuggestion));
    625         InjectedBundle::shared().stringBuilder()->append('\n');
    626     }
     634        stringBuilder.appendLiteral("Have suggestion ");
     635        stringBuilder.append(toWTFString(wkSuggestion));
     636        stringBuilder.append('\n');
     637    }
     638
     639    InjectedBundle::shared().outputText(stringBuilder.toString());
    627640#endif
    628641}
     
    631644{
    632645#if ENABLE(WEB_INTENTS_TAG)
    633     InjectedBundle::shared().stringBuilder()->appendLiteral("Registered Web Intent Service: action=");
     646    StringBuilder stringBuilder;
     647    stringBuilder.appendLiteral("Registered Web Intent Service: action=");
    634648    WKRetainPtr<WKStringRef> wkAction(AdoptWK, WKIntentServiceInfoCopyAction(serviceInfo));
    635     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkAction.get()));
    636     InjectedBundle::shared().stringBuilder()->appendLiteral(" type=");
     649    stringBuilder.append(toWTFString(wkAction.get()));
     650    stringBuilder.appendLiteral(" type=");
    637651    WKRetainPtr<WKStringRef> wkType(AdoptWK, WKIntentServiceInfoCopyType(serviceInfo));
    638     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkType.get()));
    639     InjectedBundle::shared().stringBuilder()->appendLiteral(" title=");
     652    stringBuilder.append(toWTFString(wkType.get()));
     653    stringBuilder.appendLiteral(" title=");
    640654    WKRetainPtr<WKStringRef> wkTitle(AdoptWK, WKIntentServiceInfoCopyTitle(serviceInfo));
    641     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkTitle.get()));
    642     InjectedBundle::shared().stringBuilder()->appendLiteral(" url=");
     655    stringBuilder.append(toWTFString(wkTitle.get()));
     656    stringBuilder.appendLiteral(" url=");
    643657    WKRetainPtr<WKURLRef> wkUrl(AdoptWK, WKIntentServiceInfoCopyHref(serviceInfo));
    644658    if (wkUrl)
    645         InjectedBundle::shared().stringBuilder()->append(toWTFString(adoptWK(WKURLCopyString(wkUrl.get()))));
    646     InjectedBundle::shared().stringBuilder()->appendLiteral(" disposition=");
     659        stringBuilder.append(toWTFString(adoptWK(WKURLCopyString(wkUrl.get()))));
     660    stringBuilder.appendLiteral(" disposition=");
    647661    WKRetainPtr<WKStringRef> wkDisposition(AdoptWK, WKIntentServiceInfoCopyDisposition(serviceInfo));
    648     InjectedBundle::shared().stringBuilder()->append(toWTFString(wkDisposition.get()));
    649     InjectedBundle::shared().stringBuilder()->append('\n');
     662    stringBuilder.append(toWTFString(wkDisposition.get()));
     663    stringBuilder.append('\n');
     664    InjectedBundle::shared().outputText(stringBuilder.toString());
    650665#endif
    651666}
     
    748763    platformDidStartProvisionalLoadForFrame(frame);
    749764
    750     if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) {
    751         dumpFrameDescriptionSuitableForTestResult(frame);
    752         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didStartProvisionalLoadForFrame\n");
    753     }
     765    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
     766        dumpLoadEvent(frame, "didStartProvisionalLoadForFrame");
    754767
    755768    if (!InjectedBundle::shared().topLoadingFrame())
    756769        InjectedBundle::shared().setTopLoadingFrame(frame);
    757770
    758     if (InjectedBundle::shared().testRunner()->shouldStopProvisionalFrameLoads()) {
    759         dumpFrameDescriptionSuitableForTestResult(frame);
    760         InjectedBundle::shared().stringBuilder()->appendLiteral(" - stopping load in didStartProvisionalLoadForFrame callback\n");
    761         WKBundleFrameStopLoading(frame);
    762     }
     771    if (InjectedBundle::shared().testRunner()->shouldStopProvisionalFrameLoads())
     772        dumpLoadEvent(frame, "stopping load in didStartProvisionalLoadForFrame callback");
    763773}
    764774
     
    771781        return;
    772782
    773     dumpFrameDescriptionSuitableForTestResult(frame);
    774     InjectedBundle::shared().stringBuilder()->appendLiteral(" - didReceiveServerRedirectForProvisionalLoadForFrame\n");
     783    dumpLoadEvent(frame, "didReceiveServerRedirectForProvisionalLoadForFrame");
    775784}
    776785
     
    780789        return;
    781790
    782     if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) {
    783         dumpFrameDescriptionSuitableForTestResult(frame);
    784         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didFailProvisionalLoadWithError\n");
    785     }
     791    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
     792        dumpLoadEvent(frame, "didFailProvisionalLoadWithError");
    786793
    787794    frameDidChangeLocation(frame);
     
    796803        return;
    797804
    798     dumpFrameDescriptionSuitableForTestResult(frame);
    799     InjectedBundle::shared().stringBuilder()->appendLiteral(" - didCommitLoadForFrame\n");
     805    dumpLoadEvent(frame, "didCommitLoadForFrame");
    800806}
    801807
     
    808814        return;
    809815
    810     InjectedBundle::shared().stringBuilder()->appendLiteral("postProgressFinishedNotification\n");
     816    InjectedBundle::shared().outputText("postProgressFinishedNotification\n");
    811817}
    812818
    813819enum FrameNamePolicy { ShouldNotIncludeFrameName, ShouldIncludeFrameName };
    814820
    815 static void dumpFrameScrollPosition(WKBundleFrameRef frame, FrameNamePolicy shouldIncludeFrameName = ShouldNotIncludeFrameName)
     821static void dumpFrameScrollPosition(WKBundleFrameRef frame, StringBuilder& stringBuilder, FrameNamePolicy shouldIncludeFrameName = ShouldNotIncludeFrameName)
    816822{
    817823    double x = numericWindowPropertyValue(frame, "pageXOffset");
    818824    double y = numericWindowPropertyValue(frame, "pageYOffset");
    819     if (fabs(x) > 0.00000001 || fabs(y) > 0.00000001) {
    820         if (shouldIncludeFrameName) {
    821             WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame));
    822             InjectedBundle::shared().stringBuilder()->appendLiteral("frame '");
    823             InjectedBundle::shared().stringBuilder()->append(toWTFString(name));
    824             InjectedBundle::shared().stringBuilder()->appendLiteral("' ");
    825         }
    826         InjectedBundle::shared().stringBuilder()->appendLiteral("scrolled to ");
    827         InjectedBundle::shared().stringBuilder()->append(WTF::String::number(x));
    828         InjectedBundle::shared().stringBuilder()->append(',');
    829         InjectedBundle::shared().stringBuilder()->append(WTF::String::number(y));
    830         InjectedBundle::shared().stringBuilder()->append('\n');
    831     }
    832 }
    833 
    834 static void dumpDescendantFrameScrollPositions(WKBundleFrameRef frame)
     825    if (fabs(x) <= 0.00000001 && fabs(y) <= 0.00000001)
     826        return;
     827
     828    if (shouldIncludeFrameName) {
     829        WKRetainPtr<WKStringRef> name(AdoptWK, WKBundleFrameCopyName(frame));
     830        stringBuilder.appendLiteral("frame '");
     831        stringBuilder.append(toWTFString(name));
     832        stringBuilder.appendLiteral("' ");
     833    }
     834    stringBuilder.appendLiteral("scrolled to ");
     835    stringBuilder.append(WTF::String::number(x));
     836    stringBuilder.append(',');
     837    stringBuilder.append(WTF::String::number(y));
     838    stringBuilder.append('\n');
     839}
     840
     841static void dumpDescendantFrameScrollPositions(WKBundleFrameRef frame, StringBuilder& stringBuilder)
    835842{
    836843    WKRetainPtr<WKArrayRef> childFrames(AdoptWK, WKBundleFrameCopyChildFrames(frame));
     
    838845    for (size_t i = 0; i < size; ++i) {
    839846        WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(WKArrayGetItemAtIndex(childFrames.get(), i));
    840         dumpFrameScrollPosition(subframe, ShouldIncludeFrameName);
    841         dumpDescendantFrameScrollPositions(subframe);
    842     }
    843 }
    844 
    845 void InjectedBundlePage::dumpAllFrameScrollPositions()
     847        dumpFrameScrollPosition(subframe, stringBuilder, ShouldIncludeFrameName);
     848        dumpDescendantFrameScrollPositions(subframe, stringBuilder);
     849    }
     850}
     851
     852void InjectedBundlePage::dumpAllFrameScrollPositions(StringBuilder& stringBuilder)
    846853{
    847854    WKBundleFrameRef frame = WKBundlePageGetMainFrame(m_page);
    848     dumpFrameScrollPosition(frame);
    849     dumpDescendantFrameScrollPositions(frame);
     855    dumpFrameScrollPosition(frame, stringBuilder);
     856    dumpDescendantFrameScrollPositions(frame, stringBuilder);
    850857}
    851858
     
    874881}
    875882
    876 static void dumpFrameText(WKBundleFrameRef frame)
     883static void dumpFrameText(WKBundleFrameRef frame, StringBuilder& stringBuilder)
    877884{
    878885    // If the frame doesn't have a document element, its inner text will be an empty string, so
     
    883890
    884891    WKRetainPtr<WKStringRef> text(AdoptWK, WKBundleFrameCopyInnerText(frame));
    885     InjectedBundle::shared().stringBuilder()->append(toWTFString(text));
    886     InjectedBundle::shared().stringBuilder()->append('\n');
    887 }
    888 
    889 static void dumpDescendantFramesText(WKBundleFrameRef frame)
     892    stringBuilder.append(toWTFString(text));
     893    stringBuilder.append('\n');
     894}
     895
     896static void dumpDescendantFramesText(WKBundleFrameRef frame, StringBuilder& stringBuilder)
    890897{
    891898    WKRetainPtr<WKArrayRef> childFrames(AdoptWK, WKBundleFrameCopyChildFrames(frame));
     
    894901        WKBundleFrameRef subframe = static_cast<WKBundleFrameRef>(WKArrayGetItemAtIndex(childFrames.get(), i));
    895902        WKRetainPtr<WKStringRef> subframeName(AdoptWK, WKBundleFrameCopyName(subframe));
    896         InjectedBundle::shared().stringBuilder()->appendLiteral("\n--------\nFrame: '");
    897         InjectedBundle::shared().stringBuilder()->append(toWTFString(subframeName));
    898         InjectedBundle::shared().stringBuilder()->appendLiteral("'\n--------\n");
    899         dumpFrameText(subframe);
    900         dumpDescendantFramesText(subframe);
    901     }
    902 }
    903 
    904 void InjectedBundlePage::dumpAllFramesText()
     903
     904        stringBuilder.appendLiteral("\n--------\nFrame: '");
     905        stringBuilder.append(toWTFString(subframeName));
     906        stringBuilder.appendLiteral("'\n--------\n");
     907
     908        dumpFrameText(subframe, stringBuilder);
     909        dumpDescendantFramesText(subframe, stringBuilder);
     910    }
     911}
     912
     913void InjectedBundlePage::dumpAllFramesText(StringBuilder& stringBuilder)
    905914{
    906915    WKBundleFrameRef frame = WKBundlePageGetMainFrame(m_page);
    907     dumpFrameText(frame);
    908     dumpDescendantFramesText(frame);
     916    dumpFrameText(frame, stringBuilder);
     917    dumpDescendantFramesText(frame, stringBuilder);
    909918}
    910919
     
    924933        InjectedBundle::shared().testRunner()->dumpAsText(false);
    925934
     935    StringBuilder stringBuilder;
     936
    926937    switch (InjectedBundle::shared().testRunner()->whatToDump()) {
    927938    case TestRunner::RenderTree: {
    928939        WKRetainPtr<WKStringRef> text(AdoptWK, WKBundlePageCopyRenderTreeExternalRepresentation(m_page));
    929         InjectedBundle::shared().stringBuilder()->append(toWTFString(text));
     940        stringBuilder.append(toWTFString(text));
    930941        break;
    931942    }
    932943    case TestRunner::MainFrameText:
    933         dumpFrameText(WKBundlePageGetMainFrame(m_page));
     944        dumpFrameText(WKBundlePageGetMainFrame(m_page), stringBuilder);
    934945        break;
    935946    case TestRunner::AllFramesText:
    936         dumpAllFramesText();
     947        dumpAllFramesText(stringBuilder);
    937948        break;
    938949    }
    939950
    940951    if (InjectedBundle::shared().testRunner()->shouldDumpAllFrameScrollPositions())
    941         dumpAllFrameScrollPositions();
     952        dumpAllFrameScrollPositions(stringBuilder);
    942953    else if (InjectedBundle::shared().testRunner()->shouldDumpMainFrameScrollPosition())
    943         dumpFrameScrollPosition(WKBundlePageGetMainFrame(m_page));
     954        dumpFrameScrollPosition(WKBundlePageGetMainFrame(m_page), stringBuilder);
    944955
    945956    if (InjectedBundle::shared().testRunner()->shouldDumpBackForwardListsForAllWindows())
    946         InjectedBundle::shared().dumpBackForwardListsForAllPages();
     957        InjectedBundle::shared().dumpBackForwardListsForAllPages(stringBuilder);
    947958
    948959    if (InjectedBundle::shared().shouldDumpPixels() && InjectedBundle::shared().testRunner()->shouldDumpPixels()) {
     
    956967    }
    957968
     969    InjectedBundle::shared().outputText(stringBuilder.toString());
    958970    InjectedBundle::shared().done();
    959971}
     
    964976        return;
    965977
     978    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
     979        dumpLoadEvent(frame, "didFinishLoadForFrame");
     980
     981    frameDidChangeLocation(frame, /*shouldDump*/ true);
     982}
     983
     984void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef)
     985{
     986    if (!InjectedBundle::shared().isTestRunning())
     987        return;
     988
     989    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
     990        dumpLoadEvent(frame, "didFailLoadWithError");
     991
     992    frameDidChangeLocation(frame);
     993}
     994
     995void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef frame)
     996{
     997    if (!InjectedBundle::shared().isTestRunning())
     998        return;
     999
     1000    StringBuilder stringBuilder;
    9661001    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) {
    967         dumpFrameDescriptionSuitableForTestResult(frame);
    968         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didFinishLoadForFrame\n");
    969     }
    970 
    971     frameDidChangeLocation(frame, /*shouldDump*/ true);
    972 }
    973 
    974 void InjectedBundlePage::didFailLoadWithErrorForFrame(WKBundleFrameRef frame, WKErrorRef)
    975 {
    976     if (!InjectedBundle::shared().isTestRunning())
    977         return;
    978 
    979     if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) {
    980         dumpFrameDescriptionSuitableForTestResult(frame);
    981         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didFailLoadWithError\n");
    982     }
    983 
    984     frameDidChangeLocation(frame);
    985 }
    986 
    987 void InjectedBundlePage::didReceiveTitleForFrame(WKStringRef title, WKBundleFrameRef frame)
    988 {
    989     if (!InjectedBundle::shared().isTestRunning())
    990         return;
    991 
    992     if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) {
    993         dumpFrameDescriptionSuitableForTestResult(frame);
    994         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didReceiveTitle: ");
    995         InjectedBundle::shared().stringBuilder()->append(toWTFString(title));
    996         InjectedBundle::shared().stringBuilder()->append('\n');
    997     }
    998 
    999     if (!InjectedBundle::shared().testRunner()->shouldDumpTitleChanges())
    1000         return;
    1001 
    1002     InjectedBundle::shared().stringBuilder()->appendLiteral("TITLE CHANGED: '");
    1003     InjectedBundle::shared().stringBuilder()->append(toWTFString(title));
    1004     InjectedBundle::shared().stringBuilder()->appendLiteral("'\n");
     1002        dumpFrameDescriptionSuitableForTestResult(frame, stringBuilder);
     1003        stringBuilder.appendLiteral(" - didReceiveTitle: ");
     1004        stringBuilder.append(toWTFString(title));
     1005        stringBuilder.append('\n');
     1006    }
     1007
     1008    if (InjectedBundle::shared().testRunner()->shouldDumpTitleChanges()) {
     1009        stringBuilder.appendLiteral("TITLE CHANGED: '");
     1010        stringBuilder.append(toWTFString(title));
     1011        stringBuilder.appendLiteral("'\n");
     1012    }
     1013
     1014    InjectedBundle::shared().outputText(stringBuilder.toString());
    10051015}
    10061016
     
    10401050        return;
    10411051
    1042     dumpFrameDescriptionSuitableForTestResult(frame);
    1043     InjectedBundle::shared().stringBuilder()->appendLiteral(" - didCancelClientRedirectForFrame\n");
     1052    dumpLoadEvent(frame, "didCancelClientRedirectForFrame");
    10441053}
    10451054
     
    10521061        return;
    10531062
    1054     dumpFrameDescriptionSuitableForTestResult(frame);
    1055     InjectedBundle::shared().stringBuilder()->appendLiteral(" - willPerformClientRedirectToURL: ");
    1056     InjectedBundle::shared().stringBuilder()->append(pathSuitableForTestResult(url));
    1057     InjectedBundle::shared().stringBuilder()->appendLiteral(" \n");
     1063    StringBuilder stringBuilder;
     1064    dumpFrameDescriptionSuitableForTestResult(frame, stringBuilder);
     1065    stringBuilder.appendLiteral(" - willPerformClientRedirectToURL: ");
     1066    stringBuilder.append(pathSuitableForTestResult(url));
     1067    stringBuilder.appendLiteral(" \n");
     1068    InjectedBundle::shared().outputText(stringBuilder.toString());
    10581069}
    10591070
     
    10671078        return;
    10681079
    1069     if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) {
    1070         dumpFrameDescriptionSuitableForTestResult(frame);
    1071         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didFinishDocumentLoadForFrame\n");
    1072     }
     1080    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
     1081        dumpLoadEvent(frame, "didFinishDocumentLoadForFrame");
    10731082
    10741083    unsigned pendingFrameUnloadEvents = WKBundleFrameGetPendingUnloadCount(frame);
    10751084    if (pendingFrameUnloadEvents) {
    1076         InjectedBundle::shared().stringBuilder()->append(frameToStr(frame));
    1077         InjectedBundle::shared().stringBuilder()->appendLiteral(" - has ");
    1078         InjectedBundle::shared().stringBuilder()->appendNumber(pendingFrameUnloadEvents);
    1079         InjectedBundle::shared().stringBuilder()->appendLiteral(" onunload handler(s)\n");
     1085        StringBuilder stringBuilder;
     1086        stringBuilder.append(frameToStr(frame));
     1087        stringBuilder.appendLiteral(" - has ");
     1088        stringBuilder.appendNumber(pendingFrameUnloadEvents);
     1089        stringBuilder.appendLiteral(" onunload handler(s)\n");
     1090        InjectedBundle::shared().outputText(stringBuilder.toString());
    10801091    }
    10811092}
     
    10861097        return;
    10871098
    1088     if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks()) {
    1089         dumpFrameDescriptionSuitableForTestResult(frame);
    1090         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didHandleOnloadEventsForFrame\n");
    1091     }
     1099    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
     1100        dumpLoadEvent(frame, "didHandleOnloadEventsForFrame");
    10921101}
    10931102
     
    10951104{
    10961105    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
    1097         InjectedBundle::shared().stringBuilder()->appendLiteral("didDisplayInsecureContent\n");
     1106        InjectedBundle::shared().outputText("didDisplayInsecureContent\n");
    10981107}
    10991108
     
    11011110{
    11021111    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
    1103         InjectedBundle::shared().stringBuilder()->appendLiteral("didRunInsecureContent\n");
     1112        InjectedBundle::shared().outputText("didRunInsecureContent\n");
    11041113}
    11051114
     
    11071116{
    11081117    if (InjectedBundle::shared().testRunner()->shouldDumpFrameLoadCallbacks())
    1109         InjectedBundle::shared().stringBuilder()->appendLiteral("didDetectXSS\n");
     1118        InjectedBundle::shared().outputText("didDetectXSS\n");
    11101119}
    11111120
     
    11381147    if (InjectedBundle::shared().isTestRunning()
    11391148        && InjectedBundle::shared().testRunner()->shouldDumpResourceLoadCallbacks()) {
    1140         dumpResourceURL(identifier);
    1141         InjectedBundle::shared().stringBuilder()->appendLiteral(" - willSendRequest ");
    1142         dumpRequestDescriptionSuitableForTestResult(request);
    1143         InjectedBundle::shared().stringBuilder()->appendLiteral(" redirectResponse ");
    1144         dumpResponseDescriptionSuitableForTestResult(response);
    1145         InjectedBundle::shared().stringBuilder()->append('\n');
     1149        StringBuilder stringBuilder;
     1150        dumpResourceURL(identifier, stringBuilder);
     1151        stringBuilder.appendLiteral(" - willSendRequest ");
     1152        dumpRequestDescriptionSuitableForTestResult(request, stringBuilder);
     1153        stringBuilder.appendLiteral(" redirectResponse ");
     1154        dumpResponseDescriptionSuitableForTestResult(response, stringBuilder);
     1155        stringBuilder.append('\n');
     1156        InjectedBundle::shared().outputText(stringBuilder.toString());
    11461157    }
    11471158
     
    11511162    WKRetainPtr<WKURLRef> redirectURL = adoptWK(WKURLResponseCopyURL(response));
    11521163    if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().testRunner()->willSendRequestReturnsNullOnRedirect() && redirectURL) {
    1153         InjectedBundle::shared().stringBuilder()->appendLiteral("Returning null for this redirect\n");
     1164        InjectedBundle::shared().outputText("Returning null for this redirect\n");
    11541165        return 0;
    11551166    }
     
    11751186        }
    11761187        if (!mainFrameIsExternal) {
    1177             InjectedBundle::shared().stringBuilder()->appendLiteral("Blocked access to external URL ");
    1178             InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
    1179             InjectedBundle::shared().stringBuilder()->append('\n');
     1188            StringBuilder stringBuilder;
     1189            stringBuilder.appendLiteral("Blocked access to external URL ");
     1190            stringBuilder.append(toWTFString(urlString));
     1191            stringBuilder.append('\n');
     1192            InjectedBundle::shared().outputText(stringBuilder.toString());
    11801193            return 0;
    11811194        }
     
    11921205
    11931206    if (InjectedBundle::shared().testRunner()->shouldDumpResourceLoadCallbacks()) {
    1194         dumpResourceURL(identifier);
    1195         InjectedBundle::shared().stringBuilder()->appendLiteral(" - didReceiveResponse ");
    1196         dumpResponseDescriptionSuitableForTestResult(response);
    1197         InjectedBundle::shared().stringBuilder()->append('\n');
     1207        StringBuilder stringBuilder;
     1208        dumpResourceURL(identifier, stringBuilder);
     1209        stringBuilder.appendLiteral(" - didReceiveResponse ");
     1210        dumpResponseDescriptionSuitableForTestResult(response, stringBuilder);
     1211        stringBuilder.append('\n');
     1212        InjectedBundle::shared().outputText(stringBuilder.toString());
    11981213    }
    11991214
     
    12061221    WKRetainPtr<WKStringRef> mimeTypeString = adoptWK(WKURLResponseCopyMIMEType(response));
    12071222
    1208     InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
    1209     InjectedBundle::shared().stringBuilder()->appendLiteral(" has MIME type ");
    1210     InjectedBundle::shared().stringBuilder()->append(toWTFString(mimeTypeString));
    1211     InjectedBundle::shared().stringBuilder()->append('\n');
     1223    StringBuilder stringBuilder;
     1224    stringBuilder.append(toWTFString(urlString));
     1225    stringBuilder.appendLiteral(" has MIME type ");
     1226    stringBuilder.append(toWTFString(mimeTypeString));
     1227    stringBuilder.append('\n');
     1228    InjectedBundle::shared().outputText(stringBuilder.toString());
    12121229}
    12131230
     
    12241241        return;
    12251242
    1226     dumpResourceURL(identifier);
    1227     InjectedBundle::shared().stringBuilder()->appendLiteral(" - didFinishLoading\n");
     1243    StringBuilder stringBuilder;
     1244    dumpResourceURL(identifier, stringBuilder);
     1245    stringBuilder.appendLiteral(" - didFinishLoading\n");
     1246    InjectedBundle::shared().outputText(stringBuilder.toString());
    12281247}
    12291248
     
    12361255        return;
    12371256
    1238     dumpResourceURL(identifier);
    1239     InjectedBundle::shared().stringBuilder()->appendLiteral(" - didFailLoadingWithError: ");
    1240 
    1241     dumpErrorDescriptionSuitableForTestResult(error);
    1242     InjectedBundle::shared().stringBuilder()->append('\n');
     1257    StringBuilder stringBuilder;
     1258    dumpResourceURL(identifier, stringBuilder);
     1259    stringBuilder.appendLiteral(" - didFailLoadingWithError: ");
     1260
     1261    dumpErrorDescriptionSuitableForTestResult(error, stringBuilder);
     1262    stringBuilder.append('\n');
     1263    InjectedBundle::shared().outputText(stringBuilder.toString());
    12431264}
    12441265
     
    12511272        return true;
    12521273
    1253     InjectedBundle::shared().stringBuilder()->appendNumber(identifier);
    1254     InjectedBundle::shared().stringBuilder()->appendLiteral(" - willCacheResponse: called\n");
     1274    StringBuilder stringBuilder;
     1275    stringBuilder.appendNumber(identifier);
     1276    stringBuilder.appendLiteral(" - willCacheResponse: called\n");
     1277    InjectedBundle::shared().outputText(stringBuilder.toString());
    12551278
    12561279    // The default behavior is the cache the response.
     
    12921315    WKRetainPtr<WKStringRef> urlScheme = adoptWK(WKURLCopyScheme(url.get()));
    12931316
    1294     InjectedBundle::shared().stringBuilder()->appendLiteral("Policy delegate: attempt to load ");
     1317    StringBuilder stringBuilder;
     1318    stringBuilder.appendLiteral("Policy delegate: attempt to load ");
    12951319    if (isLocalFileScheme(urlScheme.get())) {
    12961320        WKRetainPtr<WKStringRef> filename = adoptWK(WKURLCopyLastPathComponent(url.get()));
    1297         InjectedBundle::shared().stringBuilder()->append(toWTFString(filename));
     1321        stringBuilder.append(toWTFString(filename));
    12981322    } else {
    12991323        WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(url.get()));
    1300         InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
    1301     }
    1302     InjectedBundle::shared().stringBuilder()->appendLiteral(" with navigation type \'");
    1303     InjectedBundle::shared().stringBuilder()->append(toWTFString(NavigationTypeToString(WKBundleNavigationActionGetNavigationType(navigationAction))));
    1304     InjectedBundle::shared().stringBuilder()->appendLiteral("\'");
     1324        stringBuilder.append(toWTFString(urlString));
     1325    }
     1326    stringBuilder.appendLiteral(" with navigation type \'");
     1327    stringBuilder.append(toWTFString(NavigationTypeToString(WKBundleNavigationActionGetNavigationType(navigationAction))));
     1328    stringBuilder.appendLiteral("\'");
    13051329    WKBundleHitTestResultRef hitTestResultRef = WKBundleNavigationActionCopyHitTestResult(navigationAction);
    13061330    if (hitTestResultRef) {
    1307         InjectedBundle::shared().stringBuilder()->appendLiteral(" originating from ");
    1308         InjectedBundle::shared().stringBuilder()->append(dumpPath(m_page, m_world.get(), WKBundleHitTestResultCopyNodeHandle(hitTestResultRef)));
    1309     }
    1310 
    1311     InjectedBundle::shared().stringBuilder()->append('\n');
     1331        stringBuilder.appendLiteral(" originating from ");
     1332        stringBuilder.append(dumpPath(m_page, m_world.get(), WKBundleHitTestResultCopyNodeHandle(hitTestResultRef)));
     1333    }
     1334
     1335    stringBuilder.append('\n');
     1336    InjectedBundle::shared().outputText(stringBuilder.toString());
    13121337    InjectedBundle::shared().testRunner()->notifyDone();
    13131338
     
    13251350{
    13261351    if (WKURLResponseIsAttachment(response)) {
     1352        StringBuilder stringBuilder;
    13271353        WKRetainPtr<WKStringRef> filename = adoptWK(WKURLResponseCopySuggestedFilename(response));
    1328         InjectedBundle::shared().stringBuilder()->appendLiteral("Policy delegate: resource is an attachment, suggested file name \'");
    1329         InjectedBundle::shared().stringBuilder()->append(toWTFString(filename));
    1330         InjectedBundle::shared().stringBuilder()->appendLiteral("\'\n");
     1354        stringBuilder.appendLiteral("Policy delegate: resource is an attachment, suggested file name \'");
     1355        stringBuilder.append(toWTFString(filename));
     1356        stringBuilder.appendLiteral("\'\n");
     1357        InjectedBundle::shared().outputText(stringBuilder.toString());
    13311358    }
    13321359
     
    14071434        messageString = messageString.substring(0, fileProtocolStart) + lastFileURLPathComponent(messageString.substring(fileProtocolStart));
    14081435
    1409     InjectedBundle::shared().stringBuilder()->appendLiteral("CONSOLE MESSAGE: ");
     1436    StringBuilder stringBuilder;
     1437    stringBuilder.appendLiteral("CONSOLE MESSAGE: ");
    14101438    if (lineNumber) {
    1411         InjectedBundle::shared().stringBuilder()->appendLiteral("line ");
    1412         InjectedBundle::shared().stringBuilder()->appendNumber(lineNumber);
    1413         InjectedBundle::shared().stringBuilder()->appendLiteral(": ");
    1414     }
    1415     InjectedBundle::shared().stringBuilder()->append(messageString);
    1416     InjectedBundle::shared().stringBuilder()->append('\n');
    1417 
     1439        stringBuilder.appendLiteral("line ");
     1440        stringBuilder.appendNumber(lineNumber);
     1441        stringBuilder.appendLiteral(": ");
     1442    }
     1443    stringBuilder.append(messageString);
     1444    stringBuilder.append('\n');
     1445    InjectedBundle::shared().outputText(stringBuilder.toString());
    14181446}
    14191447
     
    14261454        return;
    14271455
    1428     InjectedBundle::shared().stringBuilder()->appendLiteral("UI DELEGATE STATUS CALLBACK: setStatusText:");
    1429     InjectedBundle::shared().stringBuilder()->append(toWTFString(statusbarText));
    1430     InjectedBundle::shared().stringBuilder()->append('\n');
     1456    StringBuilder stringBuilder;
     1457    stringBuilder.appendLiteral("UI DELEGATE STATUS CALLBACK: setStatusText:");
     1458    stringBuilder.append(toWTFString(statusbarText));
     1459    stringBuilder.append('\n');
     1460    InjectedBundle::shared().outputText(stringBuilder.toString());
    14311461}
    14321462
     
    14361466        return;
    14371467
    1438     InjectedBundle::shared().stringBuilder()->appendLiteral("ALERT: ");
    1439     InjectedBundle::shared().stringBuilder()->append(toWTFString(message));
    1440     InjectedBundle::shared().stringBuilder()->append('\n');
     1468    StringBuilder stringBuilder;
     1469    stringBuilder.appendLiteral("ALERT: ");
     1470    stringBuilder.append(toWTFString(message));
     1471    stringBuilder.append('\n');
     1472    InjectedBundle::shared().outputText(stringBuilder.toString());
    14411473}
    14421474
     
    14461478        return;
    14471479
    1448     InjectedBundle::shared().stringBuilder()->appendLiteral("CONFIRM: ");
    1449     InjectedBundle::shared().stringBuilder()->append(toWTFString(message));
    1450     InjectedBundle::shared().stringBuilder()->append('\n');
     1480    StringBuilder stringBuilder;
     1481    stringBuilder.appendLiteral("CONFIRM: ");
     1482    stringBuilder.append(toWTFString(message));
     1483    stringBuilder.append('\n');
     1484    InjectedBundle::shared().outputText(stringBuilder.toString());
    14511485}
    14521486
    14531487void InjectedBundlePage::willRunJavaScriptPrompt(WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef)
    14541488{
    1455     InjectedBundle::shared().stringBuilder()->appendLiteral("PROMPT: ");
    1456     InjectedBundle::shared().stringBuilder()->append(toWTFString(message));
    1457     InjectedBundle::shared().stringBuilder()->appendLiteral(", default text: ");
    1458     InjectedBundle::shared().stringBuilder()->append(toWTFString(defaultValue));
    1459     InjectedBundle::shared().stringBuilder()->append('\n');
     1489    StringBuilder stringBuilder;
     1490    stringBuilder.appendLiteral("PROMPT: ");
     1491    stringBuilder.append(toWTFString(message));
     1492    stringBuilder.appendLiteral(", default text: ");
     1493    stringBuilder.append(toWTFString(defaultValue));
     1494    stringBuilder.append('\n');
     1495    InjectedBundle::shared().outputText(stringBuilder.toString());
    14601496}
    14611497
     
    14691505        int64_t truncatedSpaceNeeded = (totalBytesNeeded / 10000) * 10000;
    14701506
    1471         InjectedBundle::shared().stringBuilder()->appendLiteral("UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:");
    1472         InjectedBundle::shared().stringBuilder()->append(securityOriginToStr(origin));
    1473         InjectedBundle::shared().stringBuilder()->appendLiteral(" totalSpaceNeeded:~");
    1474         InjectedBundle::shared().stringBuilder()->appendNumber(truncatedSpaceNeeded);
    1475         InjectedBundle::shared().stringBuilder()->append('\n');
     1507        StringBuilder stringBuilder;
     1508        stringBuilder.appendLiteral("UI DELEGATE APPLICATION CACHE CALLBACK: exceededApplicationCacheOriginQuotaForSecurityOrigin:");
     1509        stringBuilder.append(securityOriginToStr(origin));
     1510        stringBuilder.appendLiteral(" totalSpaceNeeded:~");
     1511        stringBuilder.appendNumber(truncatedSpaceNeeded);
     1512        stringBuilder.append('\n');
     1513        InjectedBundle::shared().outputText(stringBuilder.toString());
    14761514    }
    14771515
     
    14861524{
    14871525    if (InjectedBundle::shared().testRunner()->shouldDumpDatabaseCallbacks()) {
    1488         InjectedBundle::shared().stringBuilder()->appendLiteral("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:");
    1489         InjectedBundle::shared().stringBuilder()->append(securityOriginToStr(origin));
    1490         InjectedBundle::shared().stringBuilder()->appendLiteral(" database:");
    1491         InjectedBundle::shared().stringBuilder()->append(toWTFString(databaseName));
    1492         InjectedBundle::shared().stringBuilder()->append('\n');
     1526        StringBuilder stringBuilder;
     1527        stringBuilder.appendLiteral("UI DELEGATE DATABASE CALLBACK: exceededDatabaseQuotaForSecurityOrigin:");
     1528        stringBuilder.append(securityOriginToStr(origin));
     1529        stringBuilder.appendLiteral(" database:");
     1530        stringBuilder.append(toWTFString(databaseName));
     1531        stringBuilder.append('\n');
     1532        InjectedBundle::shared().outputText(stringBuilder.toString());
    14931533    }
    14941534
     
    15601600
    15611601    if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1562         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: shouldBeginEditingInDOMRange:");
    1563         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), range));
    1564         InjectedBundle::shared().stringBuilder()->append('\n');
     1602        StringBuilder stringBuilder;
     1603        stringBuilder.appendLiteral("EDITING DELEGATE: shouldBeginEditingInDOMRange:");
     1604        stringBuilder.append(rangeToStr(m_page, m_world.get(), range));
     1605        stringBuilder.append('\n');
     1606        InjectedBundle::shared().outputText(stringBuilder.toString());
    15651607    }
    15661608    return InjectedBundle::shared().testRunner()->shouldAllowEditing();
     
    15731615
    15741616    if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1575         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: shouldEndEditingInDOMRange:");
    1576         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), range));
    1577         InjectedBundle::shared().stringBuilder()->append('\n');
     1617        StringBuilder stringBuilder;
     1618        stringBuilder.appendLiteral("EDITING DELEGATE: shouldEndEditingInDOMRange:");
     1619        stringBuilder.append(rangeToStr(m_page, m_world.get(), range));
     1620        stringBuilder.append('\n');
     1621        InjectedBundle::shared().outputText(stringBuilder.toString());
    15781622    }
    15791623    return InjectedBundle::shared().testRunner()->shouldAllowEditing();
     
    15921636
    15931637    if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1594         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: shouldInsertNode:");
    1595         InjectedBundle::shared().stringBuilder()->append(dumpPath(m_page, m_world.get(), node));
    1596         InjectedBundle::shared().stringBuilder()->appendLiteral(" replacingDOMRange:");
    1597         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), rangeToReplace));
    1598         InjectedBundle::shared().stringBuilder()->appendLiteral(" givenAction:");
    1599         InjectedBundle::shared().stringBuilder()->append(insertactionstring[action]);
    1600         InjectedBundle::shared().stringBuilder()->append('\n');
     1638        StringBuilder stringBuilder;
     1639        stringBuilder.appendLiteral("EDITING DELEGATE: shouldInsertNode:");
     1640        stringBuilder.append(dumpPath(m_page, m_world.get(), node));
     1641        stringBuilder.appendLiteral(" replacingDOMRange:");
     1642        stringBuilder.append(rangeToStr(m_page, m_world.get(), rangeToReplace));
     1643        stringBuilder.appendLiteral(" givenAction:");
     1644        stringBuilder.append(insertactionstring[action]);
     1645        stringBuilder.append('\n');
     1646        InjectedBundle::shared().outputText(stringBuilder.toString());
    16011647    }
    16021648    return InjectedBundle::shared().testRunner()->shouldAllowEditing();
     
    16151661
    16161662    if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1617         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: shouldInsertText:");
    1618         InjectedBundle::shared().stringBuilder()->append(toWTFString(text));
    1619         InjectedBundle::shared().stringBuilder()->appendLiteral(" replacingDOMRange:");
    1620         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), rangeToReplace));
    1621         InjectedBundle::shared().stringBuilder()->appendLiteral(" givenAction:");
    1622         InjectedBundle::shared().stringBuilder()->append(insertactionstring[action]);
    1623         InjectedBundle::shared().stringBuilder()->append('\n');
     1663        StringBuilder stringBuilder;
     1664        stringBuilder.appendLiteral("EDITING DELEGATE: shouldInsertText:");
     1665        stringBuilder.append(toWTFString(text));
     1666        stringBuilder.appendLiteral(" replacingDOMRange:");
     1667        stringBuilder.append(rangeToStr(m_page, m_world.get(), rangeToReplace));
     1668        stringBuilder.appendLiteral(" givenAction:");
     1669        stringBuilder.append(insertactionstring[action]);
     1670        stringBuilder.append('\n');
     1671        InjectedBundle::shared().outputText(stringBuilder.toString());
    16241672    }
    16251673    return InjectedBundle::shared().testRunner()->shouldAllowEditing();
     
    16321680
    16331681    if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1634         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: shouldDeleteDOMRange:");
    1635         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), range));
    1636         InjectedBundle::shared().stringBuilder()->append('\n');
     1682        StringBuilder stringBuilder;
     1683        stringBuilder.appendLiteral("EDITING DELEGATE: shouldDeleteDOMRange:");
     1684        stringBuilder.append(rangeToStr(m_page, m_world.get(), range));
     1685        stringBuilder.append('\n');
     1686        InjectedBundle::shared().outputText(stringBuilder.toString());
    16371687    }
    16381688    return InjectedBundle::shared().testRunner()->shouldAllowEditing();
     
    16541704
    16551705    if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1656         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: shouldChangeSelectedDOMRange:");
    1657         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), fromRange));
    1658         InjectedBundle::shared().stringBuilder()->appendLiteral(" toDOMRange:");
    1659         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), toRange));
    1660         InjectedBundle::shared().stringBuilder()->appendLiteral(" affinity:");
    1661         InjectedBundle::shared().stringBuilder()->append(affinitystring[affinity]);
    1662         InjectedBundle::shared().stringBuilder()->appendLiteral(" stillSelecting:");
    1663         InjectedBundle::shared().stringBuilder()->append(boolstring[stillSelecting]);
    1664         InjectedBundle::shared().stringBuilder()->append('\n');
     1706        StringBuilder stringBuilder;
     1707        stringBuilder.appendLiteral("EDITING DELEGATE: shouldChangeSelectedDOMRange:");
     1708        stringBuilder.append(rangeToStr(m_page, m_world.get(), fromRange));
     1709        stringBuilder.appendLiteral(" toDOMRange:");
     1710        stringBuilder.append(rangeToStr(m_page, m_world.get(), toRange));
     1711        stringBuilder.appendLiteral(" affinity:");
     1712        stringBuilder.append(affinitystring[affinity]);
     1713        stringBuilder.appendLiteral(" stillSelecting:");
     1714        stringBuilder.append(boolstring[stillSelecting]);
     1715        stringBuilder.append('\n');
     1716        InjectedBundle::shared().outputText(stringBuilder.toString());
    16651717    }
    16661718    return InjectedBundle::shared().testRunner()->shouldAllowEditing();
     
    16731725
    16741726    if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1675         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: shouldApplyStyle:");
    1676         InjectedBundle::shared().stringBuilder()->append(styleDecToStr(style));
    1677         InjectedBundle::shared().stringBuilder()->appendLiteral(" toElementsInDOMRange:");
    1678         InjectedBundle::shared().stringBuilder()->append(rangeToStr(m_page, m_world.get(), range));
    1679         InjectedBundle::shared().stringBuilder()->append('\n');
     1727        StringBuilder stringBuilder;
     1728        stringBuilder.appendLiteral("EDITING DELEGATE: shouldApplyStyle:");
     1729        stringBuilder.append(styleDecToStr(style));
     1730        stringBuilder.appendLiteral(" toElementsInDOMRange:");
     1731        stringBuilder.append(rangeToStr(m_page, m_world.get(), range));
     1732        stringBuilder.append('\n');
     1733        InjectedBundle::shared().outputText(stringBuilder.toString());
    16801734    }
    16811735    return InjectedBundle::shared().testRunner()->shouldAllowEditing();
     
    16861740    if (!InjectedBundle::shared().isTestRunning())
    16871741        return;
    1688 
    1689     if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1690         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: webViewDidBeginEditing:");
    1691         InjectedBundle::shared().stringBuilder()->append(toWTFString(notificationName));
    1692         InjectedBundle::shared().stringBuilder()->append('\n');
    1693     }
     1742    if (!InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks())
     1743        return;
     1744
     1745    StringBuilder stringBuilder;
     1746    stringBuilder.appendLiteral("EDITING DELEGATE: webViewDidBeginEditing:");
     1747    stringBuilder.append(toWTFString(notificationName));
     1748    stringBuilder.append('\n');
     1749    InjectedBundle::shared().outputText(stringBuilder.toString());
    16941750}
    16951751
     
    16981754    if (!InjectedBundle::shared().isTestRunning())
    16991755        return;
    1700 
    1701     if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1702         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: webViewDidEndEditing:");
    1703         InjectedBundle::shared().stringBuilder()->append(toWTFString(notificationName));
    1704         InjectedBundle::shared().stringBuilder()->append('\n');
    1705     }
     1756    if (!InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks())
     1757        return;
     1758
     1759    StringBuilder stringBuilder;
     1760    stringBuilder.appendLiteral("EDITING DELEGATE: webViewDidEndEditing:");
     1761    stringBuilder.append(toWTFString(notificationName));
     1762    stringBuilder.append('\n');
     1763    InjectedBundle::shared().outputText(stringBuilder.toString());
    17061764}
    17071765
     
    17101768    if (!InjectedBundle::shared().isTestRunning())
    17111769        return;
    1712 
    1713     if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1714         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: webViewDidChange:");
    1715         InjectedBundle::shared().stringBuilder()->append(toWTFString(notificationName));
    1716         InjectedBundle::shared().stringBuilder()->append('\n');
    1717     }
     1770    if (!InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks())
     1771        return;
     1772
     1773    StringBuilder stringBuilder;
     1774    stringBuilder.appendLiteral("EDITING DELEGATE: webViewDidChange:");
     1775    stringBuilder.append(toWTFString(notificationName));
     1776    stringBuilder.append('\n');
     1777    InjectedBundle::shared().outputText(stringBuilder.toString());
    17181778}
    17191779
     
    17221782    if (!InjectedBundle::shared().isTestRunning())
    17231783        return;
    1724 
    1725     if (InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks()) {
    1726         InjectedBundle::shared().stringBuilder()->appendLiteral("EDITING DELEGATE: webViewDidChangeSelection:");
    1727         InjectedBundle::shared().stringBuilder()->append(toWTFString(notificationName));
    1728         InjectedBundle::shared().stringBuilder()->append('\n');
    1729     }
     1784    if (!InjectedBundle::shared().testRunner()->shouldDumpEditingCallbacks())
     1785        return;
     1786
     1787    StringBuilder stringBuilder;
     1788    stringBuilder.appendLiteral("EDITING DELEGATE: webViewDidChangeSelection:");
     1789    stringBuilder.append(toWTFString(notificationName));
     1790    stringBuilder.append('\n');
     1791    InjectedBundle::shared().outputText(stringBuilder.toString());
    17301792}
    17311793
     
    17341796{
    17351797    if (InjectedBundle::shared().testRunner()->shouldDumpFullScreenCallbacks())
    1736         InjectedBundle::shared().stringBuilder()->appendLiteral("supportsFullScreen() == true\n");
     1798        InjectedBundle::shared().outputText("supportsFullScreen() == true\n");
    17371799    return true;
    17381800}
     
    17411803{
    17421804    if (InjectedBundle::shared().testRunner()->shouldDumpFullScreenCallbacks())
    1743         InjectedBundle::shared().stringBuilder()->appendLiteral("enterFullScreenForElement()\n");
     1805        InjectedBundle::shared().outputText("enterFullScreenForElement()\n");
    17441806
    17451807    if (!InjectedBundle::shared().testRunner()->hasCustomFullScreenBehavior()) {
     
    17521814{
    17531815    if (InjectedBundle::shared().testRunner()->shouldDumpFullScreenCallbacks())
    1754         InjectedBundle::shared().stringBuilder()->appendLiteral("exitFullScreenForElement()\n");
     1816        InjectedBundle::shared().outputText("exitFullScreenForElement()\n");
    17551817
    17561818    if (!InjectedBundle::shared().testRunner()->hasCustomFullScreenBehavior()) {
     
    17631825{
    17641826    if (InjectedBundle::shared().testRunner()->shouldDumpFullScreenCallbacks())
    1765         InjectedBundle::shared().stringBuilder()->appendLiteral("beganEnterFullScreen()\n");
     1827        InjectedBundle::shared().outputText("beganEnterFullScreen()\n");
    17661828}
    17671829
     
    17691831{
    17701832    if (InjectedBundle::shared().testRunner()->shouldDumpFullScreenCallbacks())
    1771         InjectedBundle::shared().stringBuilder()->appendLiteral("beganExitFullScreen()\n");
     1833        InjectedBundle::shared().outputText("beganExitFullScreen()\n");
    17721834}
    17731835
     
    17751837{
    17761838    if (InjectedBundle::shared().testRunner()->shouldDumpFullScreenCallbacks())
    1777         InjectedBundle::shared().stringBuilder()->appendLiteral("closeFullScreen()\n");
     1839        InjectedBundle::shared().outputText("closeFullScreen()\n");
    17781840
    17791841    if (!InjectedBundle::shared().testRunner()->hasCustomFullScreenBehavior()) {
     
    17891851}
    17901852
    1791 static void dumpBackForwardListItem(WKBundleBackForwardListItemRef item, unsigned indent, bool isCurrentItem)
     1853static void dumpBackForwardListItem(WKBundleBackForwardListItemRef item, unsigned indent, bool isCurrentItem, StringBuilder& stringBuilder)
    17921854{
    17931855    unsigned column = 0;
    17941856    if (isCurrentItem) {
    1795         InjectedBundle::shared().stringBuilder()->appendLiteral("curr->");
     1857        stringBuilder.appendLiteral("curr->");
    17961858        column = 6;
    17971859    }
    17981860    for (unsigned i = column; i < indent; i++)
    1799         InjectedBundle::shared().stringBuilder()->append(' ');
     1861        stringBuilder.append(' ');
    18001862
    18011863    WTF::String url = toWTFString(adoptWK(WKURLCopyString(adoptWK(WKBundleBackForwardListItemCopyURL(item)).get())));
     
    18071869        else
    18081870            start += directoryName.length();
    1809         InjectedBundle::shared().stringBuilder()->appendLiteral("(file test):");
    1810         InjectedBundle::shared().stringBuilder()->append(url.substring(start));
     1871        stringBuilder.appendLiteral("(file test):");
     1872        stringBuilder.append(url.substring(start));
    18111873    } else
    1812         InjectedBundle::shared().stringBuilder()->append(url);
     1874        stringBuilder.append(url);
    18131875
    18141876    WTF::String target = toWTFString(adoptWK(WKBundleBackForwardListItemCopyTarget(item)));
    18151877    if (target.length()) {
    1816         InjectedBundle::shared().stringBuilder()->appendLiteral(" (in frame \"");
    1817         InjectedBundle::shared().stringBuilder()->append(target);
    1818         InjectedBundle::shared().stringBuilder()->appendLiteral("\")");
     1878        stringBuilder.appendLiteral(" (in frame \"");
     1879        stringBuilder.append(target);
     1880        stringBuilder.appendLiteral("\")");
    18191881    }
    18201882
    18211883    // FIXME: Need WKBackForwardListItemIsTargetItem.
    18221884    if (WKBundleBackForwardListItemIsTargetItem(item))
    1823         InjectedBundle::shared().stringBuilder()->appendLiteral("  **nav target**");
    1824 
    1825     InjectedBundle::shared().stringBuilder()->append('\n');
     1885        stringBuilder.appendLiteral("  **nav target**");
     1886
     1887    stringBuilder.append('\n');
    18261888
    18271889    if (WKRetainPtr<WKArrayRef> kids = adoptWK(WKBundleBackForwardListItemCopyChildren(item))) {
     
    18331895        stable_sort(sortedKids.begin(), sortedKids.end(), compareByTargetName);
    18341896        for (size_t i = 0; i < size; ++i)
    1835             dumpBackForwardListItem(sortedKids[i], indent + 4, false);
    1836     }
    1837 }
    1838 
    1839 void InjectedBundlePage::dumpBackForwardList()
    1840 {
    1841     InjectedBundle::shared().stringBuilder()->appendLiteral("\n============== Back Forward List ==============\n");
     1897            dumpBackForwardListItem(sortedKids[i], indent + 4, false, stringBuilder);
     1898    }
     1899}
     1900
     1901void InjectedBundlePage::dumpBackForwardList(StringBuilder& stringBuilder)
     1902{
     1903    stringBuilder.appendLiteral("\n============== Back Forward List ==============\n");
    18421904
    18431905    WKBundleBackForwardListRef list = WKBundlePageGetBackForwardList(m_page);
     
    18681930
    18691931    for (int i = itemsToPrint.size() - 1; i >= 0; i--)
    1870         dumpBackForwardListItem(itemsToPrint[i].get(), 8, i == currentItemIndex);
    1871 
    1872     InjectedBundle::shared().stringBuilder()->appendLiteral("===============================================\n");
     1932        dumpBackForwardListItem(itemsToPrint[i].get(), 8, i == currentItemIndex, stringBuilder);
     1933
     1934    stringBuilder.appendLiteral("===============================================\n");
    18731935}
    18741936
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h

    r131560 r137127  
    3030#include <WebKit2/WKBundleScriptWorld.h>
    3131#include <WebKit2/WKRetainPtr.h>
     32#include <wtf/text/WTFString.h>
    3233
    3334namespace WTR {
     
    5152    void resetAfterTest();
    5253
    53     void dumpBackForwardList();
     54    void dumpBackForwardList(WTF::StringBuilder&);
    5455
    5556private:
     
    170171    void didChangeSelection(WKStringRef notificationName);
    171172
    172     void dumpAllFramesText();
    173     void dumpAllFrameScrollPositions();
     173    void dumpAllFramesText(WTF::StringBuilder&);
     174    void dumpAllFrameScrollPositions(WTF::StringBuilder&);
    174175
    175176    void platformDidStartProvisionalLoadForFrame(WKBundleFrameRef);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r135508 r137127  
    150150{
    151151    invalidateWaitToDumpWatchdogTimer();
    152     const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
    153     InjectedBundle::shared().stringBuilder()->append(message);
    154     InjectedBundle::shared().stringBuilder()->append("\n");
     152    InjectedBundle::shared().outputText("FAIL: Timed out waiting for notifyDone to be called\n\n");
    155153    InjectedBundle::shared().done();
    156154}
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityControllerAtk.cpp

    r135267 r137127  
    5656    GOwnPtr<gchar> signalNameAndValue(signalValue ? g_strdup_printf("%s = %s", signalName, signalValue) : g_strdup(signalName));
    5757    GOwnPtr<gchar> accessibilityEventString(g_strdup_printf("Accessibility object emitted \"%s\" / Name: \"%s\" / Role: %d\n", signalNameAndValue.get(), objectName, objectRole));
    58     InjectedBundle::shared().stringBuilder()->append(accessibilityEventString.get());
     58    InjectedBundle::shared().outputText(String::fromUTF8(accessibilityEventString.get()));
    5959}
    6060
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r136004 r137127  
    3939#include <wtf/OwnArrayPtr.h>
    4040#include <wtf/PassOwnArrayPtr.h>
     41#include <wtf/PassOwnPtr.h>
    4142#include <wtf/text/CString.h>
    4243
     
    194195    updateTiledDrawingForCurrentTest(m_pathOrURL.c_str());
    195196
     197    m_textOutput.clear();
     198
    196199    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("BeginTest"));
    197200    WKRetainPtr<WKMutableDictionaryRef> beginTestMessageBody = adoptWK(WKMutableDictionaryCreate());
     
    285288void TestInvocation::dumpResults()
    286289{
    287     dump(toWTFString(m_textOutput.get()).utf8().data());
     290    dump(m_textOutput.toString().utf8().data());
    288291
    289292    if (m_dumpPixels && m_pixelResult)
     
    337340        WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);
    338341
    339         WKRetainPtr<WKStringRef> textOutputKey(AdoptWK, WKStringCreateWithUTF8CString("TextOutput"));
    340         m_textOutput = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, textOutputKey.get()));
    341 
    342342        WKRetainPtr<WKStringRef> pixelResultKey = adoptWK(WKStringCreateWithUTF8CString("PixelResult"));
    343343        m_pixelResult = static_cast<WKImageRef>(WKDictionaryGetItemForKey(messageBodyDictionary, pixelResultKey.get()));
     
    351351        return;
    352352    }
    353    
     353
     354    if (WKStringIsEqualToUTF8CString(messageName, "TextOutput")) {
     355        ASSERT(WKGetTypeID(messageBody) == WStringGetTypeID());
     356        WKStringRef textOutput = static_cast<WKStringRef>(messageBody);
     357        m_textOutput.append(toWTFString(textOutput));
     358    }
     359
    354360    if (WKStringIsEqualToUTF8CString(messageName, "BeforeUnloadReturnValue")) {
    355361        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
  • trunk/Tools/WebKitTestRunner/TestInvocation.h

    r136004 r137127  
    3030#include <WebKit2/WKRetainPtr.h>
    3131#include <wtf/Noncopyable.h>
     32#include <wtf/OwnPtr.h>
     33#include <wtf/text/StringBuilder.h>
    3234
    3335namespace WTR {
     
    6870    bool m_error;
    6971
    70     WKRetainPtr<WKStringRef> m_textOutput;
     72    StringBuilder m_textOutput;
    7173    WKRetainPtr<WKImageRef> m_pixelResult;
    7274    WKRetainPtr<WKArrayRef> m_repaintRects;
Note: See TracChangeset for help on using the changeset viewer.