Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameViewTest.cpp

Issue 2720823002: Fix crash in FrameView::updateLayersAndCompositingAfterScrollIfNeeded (Closed)
Patch Set: Re-enabled RLS in test, use layoutViewportScrollableArea Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/FrameView.h" 5 #include "core/frame/FrameView.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
11 #include "core/html/HTMLElement.h" 11 #include "core/html/HTMLElement.h"
12 #include "core/layout/LayoutBoxModelObject.h" 12 #include "core/layout/LayoutBoxModelObject.h"
13 #include "core/layout/LayoutObject.h" 13 #include "core/layout/LayoutObject.h"
14 #include "core/loader/EmptyClients.h" 14 #include "core/loader/EmptyClients.h"
15 #include "core/page/Page.h" 15 #include "core/page/Page.h"
16 #include "core/paint/PaintLayer.h"
16 #include "core/testing/DummyPageHolder.h" 17 #include "core/testing/DummyPageHolder.h"
17 #include "platform/RuntimeEnabledFeatures.h" 18 #include "platform/RuntimeEnabledFeatures.h"
18 #include "platform/geometry/IntSize.h" 19 #include "platform/geometry/IntSize.h"
19 #include "platform/graphics/paint/PaintArtifact.h" 20 #include "platform/graphics/paint/PaintArtifact.h"
20 #include "platform/heap/Handle.h" 21 #include "platform/heap/Handle.h"
21 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 22 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
22 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 using testing::_; 26 using testing::_;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 // NoOverflowInIncrementVisuallyNonEmptyPixelCount tests fail if the number of 134 // NoOverflowInIncrementVisuallyNonEmptyPixelCount tests fail if the number of
134 // pixels is calculated in 32-bit integer, because 65536 * 65536 would become 0 135 // pixels is calculated in 32-bit integer, because 65536 * 65536 would become 0
135 // if it was calculated in 32-bit and thus it would be considered as empty. 136 // if it was calculated in 32-bit and thus it would be considered as empty.
136 TEST_P(FrameViewTest, NoOverflowInIncrementVisuallyNonEmptyPixelCount) { 137 TEST_P(FrameViewTest, NoOverflowInIncrementVisuallyNonEmptyPixelCount) {
137 EXPECT_FALSE(document().view()->isVisuallyNonEmpty()); 138 EXPECT_FALSE(document().view()->isVisuallyNonEmpty());
138 document().view()->incrementVisuallyNonEmptyPixelCount(IntSize(65536, 65536)); 139 document().view()->incrementVisuallyNonEmptyPixelCount(IntSize(65536, 65536));
139 EXPECT_TRUE(document().view()->isVisuallyNonEmpty()); 140 EXPECT_TRUE(document().view()->isVisuallyNonEmpty());
140 } 141 }
141 142
143 // This test addresses http://crbug.com/696173, in which a call to
144 // FrameView::updateLayersAndCompositingAfterScrollIfNeeded during layout caused
145 // a crash as the code was incorrectly assuming that the ancestor overflow layer
146 // would always be valid.
147 TEST_P(FrameViewTest, ViewportConstrainedObjectsHandledCorrectlyDuringLayout) {
148 document().body()->setInnerHTML(
149 "<style>.container { height: 200%; }"
150 "#sticky { position: sticky; top: 0; height: 50px; }</style>"
151 "<div class='container'><div id='sticky'></div></div>");
152 document().view()->updateAllLifecyclePhases();
153
154 LayoutBoxModelObject* sticky = toLayoutBoxModelObject(
155 document().getElementById("sticky")->layoutObject());
156
157 // Deliberately invalidate the ancestor overflow layer. This approximates
158 // http://crbug.com/696173, in which the ancestor overflow layer can be null
159 // during layout.
160 sticky->layer()->updateAncestorOverflowLayer(nullptr);
161
162 // This call should not crash.
163 document().view()->layoutViewportScrollableArea()->setScrollOffset(
164 ScrollOffset(0, 100), ProgrammaticScroll);
165 }
166
142 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) { 167 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) {
143 // When using root layer scrolling there is no concept of viewport constrained 168 // When using root layer scrolling there is no concept of viewport constrained
144 // objects, so skip this test. 169 // objects, so skip this test.
145 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 170 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
146 return; 171 return;
147 172
148 document().body()->setInnerHTML( 173 document().body()->setInnerHTML(
149 "<style>.container { height: 200%; }" 174 "<style>.container { height: 200%; }"
150 "#sticky { position: sticky; top: 0; height: 50px; }</style>" 175 "#sticky { position: sticky; top: 0; height: 50px; }</style>"
151 "<div class='container'><div id='sticky'></div></div>"); 176 "<div class='container'><div id='sticky'></div></div>");
(...skipping 17 matching lines...) Expand all
169 // And making it sticky again should put it back in that list. 194 // And making it sticky again should put it back in that list.
170 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, ""); 195 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, "");
171 document().view()->updateAllLifecyclePhases(); 196 document().view()->updateAllLifecyclePhases();
172 197
173 EXPECT_TRUE( 198 EXPECT_TRUE(
174 document().view()->viewportConstrainedObjects()->contains(sticky)); 199 document().view()->viewportConstrainedObjects()->contains(sticky));
175 } 200 }
176 201
177 } // namespace 202 } // namespace
178 } // namespace blink 203 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698