Ensure compositing test preference overrides are reset between tests

Layouttests in the compositing/ directory override the default
preferences to enable accelerated 2d canvas and enable mock
scrollbars[1]. These preferences were not reset properly so tests
following the compositing test could run with the compositing overrides.

This patch forces preferences to be reset before every test.

This flakiness was observable on the bots where tests would flakily
fail with incorrect scrollbars:
http://test-results.appspot.com/dashboards/flakiness_dashboard.html#tests=compositing%2Flayers-inside-overflow-scroll.html&showExpectations=true

To reproduce this bug reliably, run:
run-webkit-tests compositing/animation/state-at-end-event-transform-layer.html fast/canvas/canvas-render-layer.html --additional-driver-flag=--enable-slimming-paint-v2 --child-processes=1
which will fail. Running the tests individually passes.

[1] https://cs.chromium.org/chromium/src/content/shell/browser/layout_test/blink_test_controller.cc?l=369

BUG=633707,627798,634685

Review-Url: https://codereview.chromium.org/2208603004
Cr-Commit-Position: refs/heads/master@{#410485}
diff --git a/content/shell/browser/layout_test/blink_test_controller.cc b/content/shell/browser/layout_test/blink_test_controller.cc
index eb1a913..9aca502c 100644
--- a/content/shell/browser/layout_test/blink_test_controller.cc
+++ b/content/shell/browser/layout_test/blink_test_controller.cc
@@ -278,8 +278,8 @@
   accumulated_layout_test_runtime_flags_changes_.Clear();
   ShellBrowserContext* browser_context =
       ShellContentBrowserClient::Get()->browser_context();
-  if (test_url.spec().find("compositing/") != std::string::npos)
-    is_compositing_test_ = true;
+  is_compositing_test_ =
+      test_url.spec().find("compositing/") != std::string::npos;
   initial_size_ = Shell::GetShellDefaultSize();
   // The W3C SVG layout tests use a different size than the other layout tests.
   if (test_url.spec().find("W3C-SVG-1.1") != std::string::npos)
@@ -311,6 +311,13 @@
         ->WasResized();
     RenderViewHost* render_view_host =
         main_window_->web_contents()->GetRenderViewHost();
+
+    // Compositing tests override the default preferences (see
+    // BlinkTestController::OverrideWebkitPrefs) so we force them to be
+    // calculated again to ensure is_compositing_test_ changes are picked up.
+    default_prefs_ = render_view_host->GetWebkitPreferences();
+    OverrideWebkitPrefs(&default_prefs_);
+
     render_view_host->UpdateWebkitPreferences(default_prefs_);
     HandleNewRenderFrameHost(render_view_host->GetMainFrame());
 
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index d50b9e6..ab7ec73 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -1343,16 +1343,26 @@
 
 crbug.com/627782 [ Win ] svg/filters/filter-source-position.svg [ Pass Failure ]
 
-crbug.com/627798 editing/spelling/inline-spelling-markers-hidpi-composited.html [ Pass Failure ]
-crbug.com/627798 fast/repaint/line-flow-with-floats-9.html [ Pass Failure ]
-crbug.com/627798 fast/repaint/nested-fixed-iframe-scrolled.html [ Pass Failure ]
-crbug.com/627798 fast/repaint/repaint-during-scroll-with-zoom.html [ Pass Failure ]
-crbug.com/627798 fast/repaint/resize-scrollable-iframe.html [ Pass Failure ]
-crbug.com/627798 fast/repaint/text-match-document-change.html [ Pass Failure ]
-crbug.com/627798 fast/forms/fieldset/fieldset-align.html [ Pass Failure ]
-crbug.com/627798 fast/forms/select/listbox-clip.html [ Pass Failure ]
-crbug.com/627798 fast/block/positioning/auto/007.html [ Pass Failure ]
-crbug.com/627798 compositing/overflow/update-widget-positions-on-nested-frames-and-scrollers.html [ Pass Failure ]
+crbug.com/627798 editing/spelling/inline-spelling-markers-hidpi-composited.html [ NeedsRebaseline ]
+crbug.com/627798 fast/repaint/line-flow-with-floats-9.html [ NeedsRebaseline ]
+crbug.com/627798 fast/repaint/nested-fixed-iframe-scrolled.html [ NeedsRebaseline ]
+crbug.com/627798 fast/repaint/repaint-during-scroll-with-zoom.html [ NeedsRebaseline ]
+crbug.com/627798 fast/repaint/resize-scrollable-iframe.html [ NeedsRebaseline ]
+crbug.com/627798 fast/repaint/text-match-document-change.html [ NeedsRebaseline ]
+crbug.com/627798 fast/forms/fieldset/fieldset-align.html [ NeedsRebaseline ]
+crbug.com/627798 fast/forms/select/listbox-clip.html [ NeedsRebaseline ]
+crbug.com/627798 fast/block/positioning/auto/007.html [ NeedsRebaseline ]
+crbug.com/627798 compositing/overflow/update-widget-positions-on-nested-frames-and-scrollers.html [ NeedsRebaseline ]
+
+crbug.com/633707 compositing/geometry/video-fixed-scrolling.html [ NeedsRebaseline ]
+crbug.com/633707 compositing/layers-inside-overflow-scroll.html [ NeedsRebaseline ]
+crbug.com/633707 compositing/overflow/scroll-ancestor-update.html [ NeedsRebaseline ]
+crbug.com/633707 compositing/self-painting-layers.html [ NeedsRebaseline ]
+crbug.com/633707 [ Win ] fast/forms/select-popup/popup-menu-appearance-zoom090.html [ NeedsRebaseline ]
+crbug.com/633707 [ Win ] fast/forms/select-popup/popup-menu-appearance-rtl.html [ NeedsRebaseline ]
+crbug.com/633707 [ Win ] fast/forms/select-popup/popup-menu-appearance-rtl-default.html [ NeedsRebaseline ]
+crbug.com/633707 [ Win ] fast/forms/select-popup/popup-menu-appearance-many.html [ NeedsRebaseline ]
+crbug.com/633707 [ Win ] fast/forms/select-popup/popup-menu-appearance-long.html [ NeedsRebaseline ]
 
 # Very slight rendering changes caused by Skia rect clipping change.
 crbug.com/627844 virtual/gpu/fast/canvas/canvas-createImageBitmap-colorClamping.html [ Pass Failure ]
@@ -1386,5 +1396,3 @@
 crbug.com/490015 virtual/stable/http/tests/navigation/beacon-blob-with-non-simple-type.html [ Skip ]
 # This test fails with the stable release mode.
 crbug.com/490015 virtual/stable/http/tests/navigation/same-and-different-back.html [ Skip ]
-
-crbug.com/634685 compositing/overflow/scroll-ancestor-update.html [ Pass Failure ]
diff --git a/third_party/WebKit/LayoutTests/platform/mac/compositing/geometry/video-fixed-scrolling-expected.png b/third_party/WebKit/LayoutTests/platform/mac/compositing/geometry/video-fixed-scrolling-expected.png
index 70a933b..5859a58 100644
--- a/third_party/WebKit/LayoutTests/platform/mac/compositing/geometry/video-fixed-scrolling-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/mac/compositing/geometry/video-fixed-scrolling-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/compositing/layers-inside-overflow-scroll-expected.png b/third_party/WebKit/LayoutTests/platform/mac/compositing/layers-inside-overflow-scroll-expected.png
index 2237757a..d8665b9 100644
--- a/third_party/WebKit/LayoutTests/platform/mac/compositing/layers-inside-overflow-scroll-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/mac/compositing/layers-inside-overflow-scroll-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/compositing/overflow/scroll-ancestor-update-expected.png b/third_party/WebKit/LayoutTests/platform/mac/compositing/overflow/scroll-ancestor-update-expected.png
index 32fe593..97472d4 100644
--- a/third_party/WebKit/LayoutTests/platform/mac/compositing/overflow/scroll-ancestor-update-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/mac/compositing/overflow/scroll-ancestor-update-expected.png
Binary files differ
diff --git a/third_party/WebKit/LayoutTests/platform/mac/compositing/self-painting-layers-expected.png b/third_party/WebKit/LayoutTests/platform/mac/compositing/self-painting-layers-expected.png
index 4cff73c..714a686 100644
--- a/third_party/WebKit/LayoutTests/platform/mac/compositing/self-painting-layers-expected.png
+++ b/third_party/WebKit/LayoutTests/platform/mac/compositing/self-painting-layers-expected.png
Binary files differ