// Asynchronous tests should manually call finishRepaintTest at the appropriate time.
window.testIsAsync = false;

function runRepaintTest()
{
    if (!window.testRunner || !window.internals) {
        setTimeout(repaintTest, 100);
        return;
    }

    if (window.enablePixelTesting)
        testRunner.dumpAsTextWithPixelResults();
    else
        testRunner.dumpAsText();

    if (window.testIsAsync)
        testRunner.waitUntilDone();

    if (document.body)
        document.body.offsetTop;
    else if (document.documentElement)
        document.documentElement.offsetTop;

    window.internals.startTrackingRepaints(document);

    repaintTest();

    if (!window.testIsAsync)
        finishRepaintTest();
}

function finishRepaintTest()
{
    // Force a style recalc.
    var dummy = document.body.offsetTop;

    var repaintRects = window.internals.repaintRectsAsText(document);

    internals.stopTrackingRepaints(document);

    var pre = document.createElement('pre');
    document.body.appendChild(pre);
    pre.textContent += repaintRects;

    if (window.afterTest)
        window.afterTest();

    if (window.testIsAsync)
        testRunner.notifyDone();
}

// Asynchronous tests should manually call finishRepaintTest at the appropriate time.
window.testIsAsync = false;

function runRepaintTest()
{
    if (!window.testRunner || !window.internals) {
        setTimeout(repaintTest, 100);
        return;
    }

    if (window.enablePixelTesting)
        testRunner.dumpAsTextWithPixelResults();
    else
        testRunner.dumpAsText();

    if (window.testIsAsync)
        testRunner.waitUntilDone();

    if (document.body)
        document.body.offsetTop;
    else if (document.documentElement)
        document.documentElement.offsetTop;

    window.internals.startTrackingRepaints(document);

    repaintTest();

    if (!window.testIsAsync)
        finishRepaintTest();
}

function finishRepaintTest()
{
    // Force a style recalc.
    var dummy = document.body.offsetTop;

    var repaintRects = window.internals.repaintRectsAsText(document);

    internals.stopTrackingRepaints(document);

    var pre = document.createElement('pre');
    pre.style.opacity = 0;  // appear in text dumps, but not images
    document.body.appendChild(pre);
    pre.textContent += repaintRects;

    if (window.afterTest)
        window.afterTest();

    if (window.testIsAsync)
        testRunner.notifyDone();
}

Make text based repaint output not appear in images
Make text based repaint output not appear in images

BUG=345027

Review URL: https://codereview.chromium.org/197553008

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@169165 bbb929c8-8fbe-4397-9dbb-9b2b20218538
