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

Side by Side Diff: content/browser/renderer_host/input/non_blocking_event_browsertest.cc

Issue 1895303007: Non passive touch end or touch cancel listeners should not block scroll. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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 | « cc/trees/layer_tree_impl.cc ('k') | content/renderer/gpu/render_widget_compositor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <utility> 5 #include <utility>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 "</style>" 50 "</style>"
51 "<div class=spacer></div>" 51 "<div class=spacer></div>"
52 "<script>" 52 "<script>"
53 " document.addEventListener('wheel', function(e) { while(true) {} }, " 53 " document.addEventListener('wheel', function(e) { while(true) {} }, "
54 "{'passive': true});" 54 "{'passive': true});"
55 " document.addEventListener('touchstart', function(e) { while(true) {} }, " 55 " document.addEventListener('touchstart', function(e) { while(true) {} }, "
56 "{'passive': true});" 56 "{'passive': true});"
57 " document.title='ready';" 57 " document.title='ready';"
58 "</script>"; 58 "</script>";
59 59
60 const char kPassiveTouchStartBlockingTouchEndDataURL[] =
61 "data:text/html;charset=utf-8,"
62 "<!DOCTYPE html>"
63 "<meta name='viewport' content='width=device-width'/>"
64 "<style>"
65 "html, body {"
66 " margin: 0;"
67 "}"
68 ".spacer { height: 10000px; }"
69 "</style>"
70 "<div class=spacer></div>"
71 "<script>"
72 " document.addEventListener('touchstart', function(e) { while(true) {} }, "
73 "{'passive': true});"
74 " document.addEventListener('touchend', function(e) { while(true) {} });"
75 " document.title='ready';"
76 "</script>";
77
60 } // namespace 78 } // namespace
61 79
62 namespace content { 80 namespace content {
63 81
64 class NonBlockingEventBrowserTest : public ContentBrowserTest { 82 class NonBlockingEventBrowserTest : public ContentBrowserTest {
65 public: 83 public:
66 NonBlockingEventBrowserTest() {} 84 NonBlockingEventBrowserTest() {}
67 ~NonBlockingEventBrowserTest() override {} 85 ~NonBlockingEventBrowserTest() override {}
68 86
69 RenderWidgetHostImpl* GetWidgetHost() { 87 RenderWidgetHostImpl* GetWidgetHost() {
70 return RenderWidgetHostImpl::From( 88 return RenderWidgetHostImpl::From(
71 shell()->web_contents()->GetRenderViewHost()->GetWidget()); 89 shell()->web_contents()->GetRenderViewHost()->GetWidget());
72 } 90 }
73 91
74 void OnSyntheticGestureCompleted(SyntheticGesture::Result result) { 92 void OnSyntheticGestureCompleted(SyntheticGesture::Result result) {
75 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); 93 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
76 } 94 }
77 95
78 protected: 96 protected:
79 void LoadURL() { 97 void LoadURL(const char* page_data) {
80 const GURL data_url(kNonBlockingEventDataURL); 98 const GURL data_url(page_data);
81 NavigateToURL(shell(), data_url); 99 NavigateToURL(shell(), data_url);
82 100
83 RenderWidgetHostImpl* host = GetWidgetHost(); 101 RenderWidgetHostImpl* host = GetWidgetHost();
84 host->GetView()->SetSize(gfx::Size(400, 400)); 102 host->GetView()->SetSize(gfx::Size(400, 400));
85 103
86 base::string16 ready_title(base::ASCIIToUTF16("ready")); 104 base::string16 ready_title(base::ASCIIToUTF16("ready"));
87 TitleWatcher watcher(shell()->web_contents(), ready_title); 105 TitleWatcher watcher(shell()->web_contents(), ready_title);
88 ignore_result(watcher.WaitAndGetTitle()); 106 ignore_result(watcher.WaitAndGetTitle());
89 107
90 MainThreadFrameObserver main_thread_sync(host); 108 MainThreadFrameObserver main_thread_sync(host);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // main thread was in a busy loop. 179 // main thread was in a busy loop.
162 while (frame_watcher->LastMetadata().root_scroll_offset.y() <= 0) 180 while (frame_watcher->LastMetadata().root_scroll_offset.y() <= 0)
163 frame_watcher->WaitFrames(1); 181 frame_watcher->WaitFrames(1);
164 } 182 }
165 183
166 private: 184 private:
167 DISALLOW_COPY_AND_ASSIGN(NonBlockingEventBrowserTest); 185 DISALLOW_COPY_AND_ASSIGN(NonBlockingEventBrowserTest);
168 }; 186 };
169 187
170 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MouseWheel) { 188 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MouseWheel) {
171 LoadURL(); 189 LoadURL(kNonBlockingEventDataURL);
172 DoWheelScroll(); 190 DoWheelScroll();
173 } 191 }
174 192
175 // Disabled on MacOS because it doesn't support touch input. 193 // Disabled on MacOS because it doesn't support touch input.
176 #if defined(OS_MACOSX) 194 #if defined(OS_MACOSX)
177 #define MAYBE_TouchStart DISABLED_TouchStart 195 #define MAYBE_TouchStart DISABLED_TouchStart
178 #else 196 #else
179 #define MAYBE_TouchStart TouchStart 197 #define MAYBE_TouchStart TouchStart
180 #endif 198 #endif
181 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MAYBE_TouchStart) { 199 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest, MAYBE_TouchStart) {
182 LoadURL(); 200 LoadURL(kNonBlockingEventDataURL);
183 DoTouchScroll(); 201 DoTouchScroll();
184 } 202 }
185 203
204 // Disabled on MacOS because it doesn't support touch input.
205 #if defined(OS_MACOSX)
206 #define MAYBE_PassiveTouchStartBlockingTouchEnd \
207 DISABLED_PassiveTouchStartBlockingTouchEnd
208 #else
209 #define MAYBE_PassiveTouchStartBlockingTouchEnd \
210 PassiveTouchStartBlockingTouchEnd
211 #endif
212 IN_PROC_BROWSER_TEST_F(NonBlockingEventBrowserTest,
213 MAYBE_PassiveTouchStartBlockingTouchEnd) {
214 LoadURL(kPassiveTouchStartBlockingTouchEndDataURL);
215 DoTouchScroll();
216 }
217
186 } // namespace content 218 } // namespace content
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | content/renderer/gpu/render_widget_compositor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698