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

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

Issue 2784653002: Revert of Do not send redundant selectionchange-events (Closed)
Patch Set: 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"
90 #include "platform/PlatformResourceLoader.h" 89 #include "platform/PlatformResourceLoader.h"
91 #include "platform/RuntimeEnabledFeatures.h" 90 #include "platform/RuntimeEnabledFeatures.h"
92 #include "platform/UserGestureIndicator.h" 91 #include "platform/UserGestureIndicator.h"
93 #include "platform/geometry/FloatRect.h" 92 #include "platform/geometry/FloatRect.h"
94 #include "platform/loader/fetch/FetchRequest.h" 93 #include "platform/loader/fetch/FetchRequest.h"
95 #include "platform/loader/fetch/MemoryCache.h" 94 #include "platform/loader/fetch/MemoryCache.h"
96 #include "platform/loader/fetch/ResourceError.h" 95 #include "platform/loader/fetch/ResourceError.h"
97 #include "platform/loader/fetch/ResourceFetcher.h" 96 #include "platform/loader/fetch/ResourceFetcher.h"
98 #include "platform/scroll/Scrollbar.h" 97 #include "platform/scroll/Scrollbar.h"
99 #include "platform/scroll/ScrollbarTestSuite.h" 98 #include "platform/scroll/ScrollbarTestSuite.h"
100 #include "platform/scroll/ScrollbarTheme.h" 99 #include "platform/scroll/ScrollbarTheme.h"
101 #include "platform/scroll/ScrollbarThemeMock.h" 100 #include "platform/scroll/ScrollbarThemeMock.h"
102 #include "platform/scroll/ScrollbarThemeOverlayMock.h" 101 #include "platform/scroll/ScrollbarThemeOverlayMock.h"
103 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 102 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
104 #include "platform/testing/URLTestHelpers.h" 103 #include "platform/testing/URLTestHelpers.h"
105 #include "platform/testing/UnitTestHelpers.h" 104 #include "platform/testing/UnitTestHelpers.h"
106 #include "platform/weborigin/KURLHash.h" 105 #include "platform/weborigin/KURLHash.h"
107 #include "platform/weborigin/SchemeRegistry.h" 106 #include "platform/weborigin/SchemeRegistry.h"
108 #include "platform/weborigin/SecurityOrigin.h" 107 #include "platform/weborigin/SecurityOrigin.h"
109 #include "public/platform/Platform.h" 108 #include "public/platform/Platform.h"
110 #include "public/platform/WebCache.h" 109 #include "public/platform/WebCache.h"
111 #include "public/platform/WebCachePolicy.h" 110 #include "public/platform/WebCachePolicy.h"
112 #include "public/platform/WebClipboard.h" 111 #include "public/platform/WebClipboard.h"
113 #include "public/platform/WebFloatRect.h" 112 #include "public/platform/WebFloatRect.h"
114 #include "public/platform/WebKeyboardEvent.h"
115 #include "public/platform/WebMockClipboard.h" 113 #include "public/platform/WebMockClipboard.h"
116 #include "public/platform/WebSecurityOrigin.h" 114 #include "public/platform/WebSecurityOrigin.h"
117 #include "public/platform/WebThread.h" 115 #include "public/platform/WebThread.h"
118 #include "public/platform/WebURL.h" 116 #include "public/platform/WebURL.h"
119 #include "public/platform/WebURLLoaderClient.h" 117 #include "public/platform/WebURLLoaderClient.h"
120 #include "public/platform/WebURLLoaderMockFactory.h" 118 #include "public/platform/WebURLLoaderMockFactory.h"
121 #include "public/platform/WebURLResponse.h" 119 #include "public/platform/WebURLResponse.h"
122 #include "public/web/WebConsoleMessage.h" 120 #include "public/web/WebConsoleMessage.h"
123 #include "public/web/WebContextMenuData.h" 121 #include "public/web/WebContextMenuData.h"
124 #include "public/web/WebDataSource.h" 122 #include "public/web/WebDataSource.h"
(...skipping 4135 matching lines...) Expand 10 before | Expand all | Expand 10 after
4260 webViewHelper.initializeAndLoad( 4258 webViewHelper.initializeAndLoad(
4261 m_baseURL + "iframe_clear_focused_node_test.html", true); 4259 m_baseURL + "iframe_clear_focused_node_test.html", true);
4262 4260
4263 // Clear the focused node. 4261 // Clear the focused node.
4264 webViewHelper.webView()->clearFocusedElement(); 4262 webViewHelper.webView()->clearFocusedElement();
4265 4263
4266 // Now retrieve the FocusedNode and test it should be null. 4264 // Now retrieve the FocusedNode and test it should be null.
4267 EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); 4265 EXPECT_EQ(0, webViewHelper.webView()->focusedElement());
4268 } 4266 }
4269 4267
4270 class ChangedSelectionCounter : public FrameTestHelpers::TestWebFrameClient {
4271 public:
4272 ChangedSelectionCounter() : m_callCount(0) {}
4273 void didChangeSelection(bool isSelectionEmpty) { ++m_callCount; }
4274 int count() const { return m_callCount; }
4275 void reset() { m_callCount = 0; }
4276
4277 private:
4278 int m_callCount;
4279 };
4280
4281 TEST_P(ParameterizedWebFrameTest, TabKeyCursorMoveTriggersOneSelectionChange) {
4282 ChangedSelectionCounter counter;
4283 FrameTestHelpers::WebViewHelper webViewHelper;
4284 registerMockedHttpURLLoad("editable_elements.html");
4285 WebViewImpl* webView = webViewHelper.initializeAndLoad(
4286 m_baseURL + "editable_elements.html", true, &counter);
4287
4288 WebKeyboardEvent tabDownEvent(WebInputEvent::KeyDown,
4289 WebInputEvent::NoModifiers,
4290 WebInputEvent::TimeStampForTesting);
4291 WebKeyboardEvent tabUpEvent(WebInputEvent::KeyUp, WebInputEvent::NoModifiers,
4292 WebInputEvent::TimeStampForTesting);
4293 tabDownEvent.domKey = Platform::current()->domKeyEnumFromString("\t");
4294 tabUpEvent.domKey = Platform::current()->domKeyEnumFromString("\t");
4295 tabDownEvent.windowsKeyCode = VKEY_TAB;
4296 tabUpEvent.windowsKeyCode = VKEY_TAB;
4297
4298 // Move to the next text-field: 1 cursor change.
4299 counter.reset();
4300 webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent));
4301 webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent));
4302 EXPECT_EQ(1, counter.count());
4303
4304 // Move to another text-field: 1 cursor change.
4305 webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent));
4306 webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent));
4307 EXPECT_EQ(2, counter.count());
4308
4309 // Move to a number-field: 1 cursor change.
4310 webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent));
4311 webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent));
4312 EXPECT_EQ(3, counter.count());
4313
4314 // Move to an editable element: 1 cursor change.
4315 webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent));
4316 webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent));
4317 EXPECT_EQ(4, counter.count());
4318
4319 // Move to a non-editable element: 0 cursor changes.
4320 // TODO(editing-dev): Once we've fixed crbug.com/692898 test this too:
4321 // webView->handleInputEvent(WebCoalescedInputEvent(tabDownEvent));
4322 // webView->handleInputEvent(WebCoalescedInputEvent(tabUpEvent));
4323 // EXPECT_EQ(4, counter.count());
4324 }
4325
4326 // Implementation of WebFrameClient that tracks the v8 contexts that are created 4268 // Implementation of WebFrameClient that tracks the v8 contexts that are created
4327 // and destroyed for verification. 4269 // and destroyed for verification.
4328 class ContextLifetimeTestWebFrameClient 4270 class ContextLifetimeTestWebFrameClient
4329 : public FrameTestHelpers::TestWebFrameClient { 4271 : public FrameTestHelpers::TestWebFrameClient {
4330 public: 4272 public:
4331 struct Notification { 4273 struct Notification {
4332 public: 4274 public:
4333 Notification(WebLocalFrame* frame, 4275 Notification(WebLocalFrame* frame,
4334 v8::Local<v8::Context> context, 4276 v8::Local<v8::Context> context,
4335 int worldId) 4277 int worldId)
(...skipping 7164 matching lines...) Expand 10 before | Expand all | Expand 10 after
11500 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); 11442 EXPECT_FALSE(testSelectAll("<textarea></textarea>"));
11501 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); 11443 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>"));
11502 EXPECT_FALSE(testSelectAll("<input>")); 11444 EXPECT_FALSE(testSelectAll("<input>"));
11503 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); 11445 EXPECT_TRUE(testSelectAll("<input value='nonempty'>"));
11504 // TODO(amaralp): Empty contenteditable should not have select all enabled. 11446 // TODO(amaralp): Empty contenteditable should not have select all enabled.
11505 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); 11447 EXPECT_TRUE(testSelectAll("<div contenteditable></div>"));
11506 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); 11448 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>"));
11507 } 11449 }
11508 11450
11509 } // namespace blink 11451 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698