Code:   bool DoTouchScroll(const gfx::Point& point,
                     const gfx::Vector2d& distance,
                     bool wait_until_scrolled) {
    EXPECT_EQ(0, GetScrollTop());

    int scrollHeight = ExecuteScriptAndExtractInt(
        "document.documentElement.scrollHeight");
    EXPECT_EQ(1200, scrollHeight);

    scoped_refptr<FrameWatcher> frame_watcher(new FrameWatcher());
    frame_watcher->AttachTo(shell()->web_contents());

    SyntheticSmoothScrollGestureParams params;
    params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
    params.anchor = gfx::PointF(point);
    params.distances.push_back(-distance);

    runner_ = new MessageLoopRunner();

    std::unique_ptr<SyntheticSmoothScrollGesture> gesture(
        new SyntheticSmoothScrollGesture(params));
    GetWidgetHost()->QueueSyntheticGesture(
        std::move(gesture),
        base::Bind(&TouchActionBrowserTest::OnSyntheticGestureCompleted,
                   base::Unretained(this)));

    runner_->Run();
    runner_ = NULL;

     while (wait_until_scrolled &&
           frame_watcher->LastMetadata().root_scroll_offset.y() <= 0) {
       frame_watcher->WaitFrames(1);
     }
 
    int scrollTop = GetScrollTop();
    if (scrollTop == 0)
      return false;

    EXPECT_EQ(distance.y(), scrollTop);
    return true;
  }

Vulnerability Type: DoS Overflow 
CWE ID: CWE-119
Summary: Buffer overflow in OpenJPEG before r2911 in PDFium, as used in Google Chrome before 39.0.2171.65, allows remote attackers to cause a denial of service or possibly have unspecified other impact via a crafted JPEG image.
Commit Message: Drive out additional flakiness of TouchAction browser test.

It is relatively stable but it has flaked a couple of times specifically
with this:

  Actual: 44
Expected: distance.y()
Which is: 45

I presume that the failure is either we aren't waiting for the additional
frame or a subpixel scrolling problem. As a speculative fix wait for the
pixel item we are waiting to scroll for.

BUG=376668

Review-Url: https://codereview.chromium.org/2281613002
Cr-Commit-Position: refs/heads/master@{#414525}