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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2616623002: Do not send redundant selectionchange-events (decouple focus) (Closed)
Patch Set: Rebase Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #include "core/loader/FrameLoadRequest.h" 79 #include "core/loader/FrameLoadRequest.h"
80 #include "core/loader/ThreadableLoader.h" 80 #include "core/loader/ThreadableLoader.h"
81 #include "core/page/Page.h" 81 #include "core/page/Page.h"
82 #include "core/page/ScopedPageSuspender.h" 82 #include "core/page/ScopedPageSuspender.h"
83 #include "core/paint/PaintLayer.h" 83 #include "core/paint/PaintLayer.h"
84 #include "core/testing/NullExecutionContext.h" 84 #include "core/testing/NullExecutionContext.h"
85 #include "modules/mediastream/MediaStream.h" 85 #include "modules/mediastream/MediaStream.h"
86 #include "modules/mediastream/MediaStreamRegistry.h" 86 #include "modules/mediastream/MediaStreamRegistry.h"
87 #include "platform/Cursor.h" 87 #include "platform/Cursor.h"
88 #include "platform/DragImage.h" 88 #include "platform/DragImage.h"
89 #include "platform/KeyboardCodes.h"
89 #include "platform/PlatformResourceLoader.h" 90 #include "platform/PlatformResourceLoader.h"
90 #include "platform/RuntimeEnabledFeatures.h" 91 #include "platform/RuntimeEnabledFeatures.h"
91 #include "platform/UserGestureIndicator.h" 92 #include "platform/UserGestureIndicator.h"
92 #include "platform/geometry/FloatRect.h" 93 #include "platform/geometry/FloatRect.h"
93 #include "platform/loader/fetch/FetchParameters.h" 94 #include "platform/loader/fetch/FetchParameters.h"
94 #include "platform/loader/fetch/MemoryCache.h" 95 #include "platform/loader/fetch/MemoryCache.h"
95 #include "platform/loader/fetch/ResourceError.h" 96 #include "platform/loader/fetch/ResourceError.h"
96 #include "platform/loader/fetch/ResourceFetcher.h" 97 #include "platform/loader/fetch/ResourceFetcher.h"
97 #include "platform/scroll/Scrollbar.h" 98 #include "platform/scroll/Scrollbar.h"
98 #include "platform/scroll/ScrollbarTestSuite.h" 99 #include "platform/scroll/ScrollbarTestSuite.h"
99 #include "platform/scroll/ScrollbarTheme.h" 100 #include "platform/scroll/ScrollbarTheme.h"
100 #include "platform/scroll/ScrollbarThemeMock.h" 101 #include "platform/scroll/ScrollbarThemeMock.h"
101 #include "platform/scroll/ScrollbarThemeOverlayMock.h" 102 #include "platform/scroll/ScrollbarThemeOverlayMock.h"
102 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 103 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
103 #include "platform/testing/URLTestHelpers.h" 104 #include "platform/testing/URLTestHelpers.h"
104 #include "platform/testing/UnitTestHelpers.h" 105 #include "platform/testing/UnitTestHelpers.h"
105 #include "platform/weborigin/KURLHash.h" 106 #include "platform/weborigin/KURLHash.h"
106 #include "platform/weborigin/SchemeRegistry.h" 107 #include "platform/weborigin/SchemeRegistry.h"
107 #include "platform/weborigin/SecurityOrigin.h" 108 #include "platform/weborigin/SecurityOrigin.h"
108 #include "platform/wtf/Forward.h" 109 #include "platform/wtf/Forward.h"
109 #include "platform/wtf/PtrUtil.h" 110 #include "platform/wtf/PtrUtil.h"
110 #include "platform/wtf/dtoa/utils.h" 111 #include "platform/wtf/dtoa/utils.h"
111 #include "public/platform/Platform.h" 112 #include "public/platform/Platform.h"
112 #include "public/platform/WebCache.h" 113 #include "public/platform/WebCache.h"
113 #include "public/platform/WebCachePolicy.h" 114 #include "public/platform/WebCachePolicy.h"
114 #include "public/platform/WebClipboard.h" 115 #include "public/platform/WebClipboard.h"
115 #include "public/platform/WebFloatRect.h" 116 #include "public/platform/WebFloatRect.h"
117 #include "public/platform/WebKeyboardEvent.h"
116 #include "public/platform/WebMockClipboard.h" 118 #include "public/platform/WebMockClipboard.h"
117 #include "public/platform/WebSecurityOrigin.h" 119 #include "public/platform/WebSecurityOrigin.h"
118 #include "public/platform/WebThread.h" 120 #include "public/platform/WebThread.h"
119 #include "public/platform/WebURL.h" 121 #include "public/platform/WebURL.h"
120 #include "public/platform/WebURLLoaderClient.h" 122 #include "public/platform/WebURLLoaderClient.h"
121 #include "public/platform/WebURLLoaderMockFactory.h" 123 #include "public/platform/WebURLLoaderMockFactory.h"
122 #include "public/platform/WebURLResponse.h" 124 #include "public/platform/WebURLResponse.h"
123 #include "public/web/WebConsoleMessage.h" 125 #include "public/web/WebConsoleMessage.h"
124 #include "public/web/WebContextMenuData.h" 126 #include "public/web/WebContextMenuData.h"
125 #include "public/web/WebDataSource.h" 127 #include "public/web/WebDataSource.h"
(...skipping 4234 matching lines...) Expand 10 before | Expand all | Expand 10 after
4360 web_view_helper.InitializeAndLoad( 4362 web_view_helper.InitializeAndLoad(
4361 base_url_ + "iframe_clear_focused_node_test.html", true); 4363 base_url_ + "iframe_clear_focused_node_test.html", true);
4362 4364
4363 // Clear the focused node. 4365 // Clear the focused node.
4364 web_view_helper.WebView()->ClearFocusedElement(); 4366 web_view_helper.WebView()->ClearFocusedElement();
4365 4367
4366 // Now retrieve the FocusedNode and test it should be null. 4368 // Now retrieve the FocusedNode and test it should be null.
4367 EXPECT_EQ(0, web_view_helper.WebView()->FocusedElement()); 4369 EXPECT_EQ(0, web_view_helper.WebView()->FocusedElement());
4368 } 4370 }
4369 4371
4372 class ChangedSelectionCounter : public FrameTestHelpers::TestWebFrameClient {
4373 public:
4374 ChangedSelectionCounter() : call_count_(0) {}
4375 void DidChangeSelection(bool isSelectionEmpty) { ++call_count_; }
4376 int Count() const { return call_count_; }
4377 void Reset() { call_count_ = 0; }
4378
4379 private:
4380 int call_count_;
4381 };
4382
4383 TEST_P(ParameterizedWebFrameTest, TabKeyCursorMoveTriggersOneSelectionChange) {
4384 ChangedSelectionCounter counter;
4385 FrameTestHelpers::WebViewHelper web_view_helper;
4386 RegisterMockedHttpURLLoad("editable_elements.html");
4387 WebViewImpl* web_view = web_view_helper.InitializeAndLoad(
4388 base_url_ + "editable_elements.html", true, &counter);
4389
4390 WebKeyboardEvent tab_down(WebInputEvent::kKeyDown,
4391 WebInputEvent::kNoModifiers,
4392 WebInputEvent::kTimeStampForTesting);
4393 WebKeyboardEvent tab_up(WebInputEvent::kKeyUp, WebInputEvent::kNoModifiers,
4394 WebInputEvent::kTimeStampForTesting);
4395 tab_down.dom_key = Platform::Current()->DomKeyEnumFromString("\t");
4396 tab_up.dom_key = Platform::Current()->DomKeyEnumFromString("\t");
4397 tab_down.windows_key_code = VKEY_TAB;
4398 tab_up.windows_key_code = VKEY_TAB;
4399
4400 // Move to the next text-field: 1 cursor change.
4401 counter.Reset();
4402 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_down));
4403 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_up));
4404 EXPECT_EQ(1, counter.Count());
4405
4406 // Move to another text-field: 1 cursor change.
4407 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_down));
4408 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_up));
4409 EXPECT_EQ(2, counter.Count());
4410
4411 // Move to a number-field: 1 cursor change.
4412 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_down));
4413 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_up));
4414 EXPECT_EQ(3, counter.Count());
4415
4416 // Move to an editable element: 1 cursor change.
4417 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_down));
4418 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_up));
4419 EXPECT_EQ(4, counter.Count());
4420
4421 // Move to a non-editable element: 0 cursor changes.
4422 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_down));
4423 web_view->HandleInputEvent(WebCoalescedInputEvent(tab_up));
4424 EXPECT_EQ(4, counter.Count());
4425 }
4426
4370 // Implementation of WebFrameClient that tracks the v8 contexts that are created 4427 // Implementation of WebFrameClient that tracks the v8 contexts that are created
4371 // and destroyed for verification. 4428 // and destroyed for verification.
4372 class ContextLifetimeTestWebFrameClient 4429 class ContextLifetimeTestWebFrameClient
4373 : public FrameTestHelpers::TestWebFrameClient { 4430 : public FrameTestHelpers::TestWebFrameClient {
4374 public: 4431 public:
4375 struct Notification { 4432 struct Notification {
4376 public: 4433 public:
4377 Notification(WebLocalFrame* frame, 4434 Notification(WebLocalFrame* frame,
4378 v8::Local<v8::Context> context, 4435 v8::Local<v8::Context> context,
4379 int world_id) 4436 int world_id)
(...skipping 7562 matching lines...) Expand 10 before | Expand all | Expand 10 after
11942 11999
11943 // Failing the original child frame navigation and trying to render fallback 12000 // Failing the original child frame navigation and trying to render fallback
11944 // content shouldn't crash. It should return NoLoadInProgress. This is so the 12001 // content shouldn't crash. It should return NoLoadInProgress. This is so the
11945 // caller won't attempt to replace the correctly empty frame with an error 12002 // caller won't attempt to replace the correctly empty frame with an error
11946 // page. 12003 // page.
11947 EXPECT_EQ(WebLocalFrame::NoLoadInProgress, 12004 EXPECT_EQ(WebLocalFrame::NoLoadInProgress,
11948 child->MaybeRenderFallbackContent(WebURLError())); 12005 child->MaybeRenderFallbackContent(WebURLError()));
11949 } 12006 }
11950 12007
11951 } // namespace blink 12008 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698