OLD | NEW |
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 Loading... |
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/FetchRequest.h" | 94 #include "platform/loader/fetch/FetchRequest.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 "public/platform/Platform.h" | 109 #include "public/platform/Platform.h" |
109 #include "public/platform/WebCache.h" | 110 #include "public/platform/WebCache.h" |
110 #include "public/platform/WebCachePolicy.h" | 111 #include "public/platform/WebCachePolicy.h" |
111 #include "public/platform/WebClipboard.h" | 112 #include "public/platform/WebClipboard.h" |
112 #include "public/platform/WebFloatRect.h" | 113 #include "public/platform/WebFloatRect.h" |
| 114 #include "public/platform/WebKeyboardEvent.h" |
113 #include "public/platform/WebMockClipboard.h" | 115 #include "public/platform/WebMockClipboard.h" |
114 #include "public/platform/WebSecurityOrigin.h" | 116 #include "public/platform/WebSecurityOrigin.h" |
115 #include "public/platform/WebThread.h" | 117 #include "public/platform/WebThread.h" |
116 #include "public/platform/WebURL.h" | 118 #include "public/platform/WebURL.h" |
117 #include "public/platform/WebURLLoaderClient.h" | 119 #include "public/platform/WebURLLoaderClient.h" |
118 #include "public/platform/WebURLLoaderMockFactory.h" | 120 #include "public/platform/WebURLLoaderMockFactory.h" |
119 #include "public/platform/WebURLResponse.h" | 121 #include "public/platform/WebURLResponse.h" |
120 #include "public/web/WebConsoleMessage.h" | 122 #include "public/web/WebConsoleMessage.h" |
121 #include "public/web/WebContextMenuData.h" | 123 #include "public/web/WebContextMenuData.h" |
122 #include "public/web/WebDataSource.h" | 124 #include "public/web/WebDataSource.h" |
(...skipping 4135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 webViewHelper.initializeAndLoad( | 4260 webViewHelper.initializeAndLoad( |
4259 m_baseURL + "iframe_clear_focused_node_test.html", true); | 4261 m_baseURL + "iframe_clear_focused_node_test.html", true); |
4260 | 4262 |
4261 // Clear the focused node. | 4263 // Clear the focused node. |
4262 webViewHelper.webView()->clearFocusedElement(); | 4264 webViewHelper.webView()->clearFocusedElement(); |
4263 | 4265 |
4264 // Now retrieve the FocusedNode and test it should be null. | 4266 // Now retrieve the FocusedNode and test it should be null. |
4265 EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); | 4267 EXPECT_EQ(0, webViewHelper.webView()->focusedElement()); |
4266 } | 4268 } |
4267 | 4269 |
| 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 |
4268 // Implementation of WebFrameClient that tracks the v8 contexts that are created | 4326 // Implementation of WebFrameClient that tracks the v8 contexts that are created |
4269 // and destroyed for verification. | 4327 // and destroyed for verification. |
4270 class ContextLifetimeTestWebFrameClient | 4328 class ContextLifetimeTestWebFrameClient |
4271 : public FrameTestHelpers::TestWebFrameClient { | 4329 : public FrameTestHelpers::TestWebFrameClient { |
4272 public: | 4330 public: |
4273 struct Notification { | 4331 struct Notification { |
4274 public: | 4332 public: |
4275 Notification(WebLocalFrame* frame, | 4333 Notification(WebLocalFrame* frame, |
4276 v8::Local<v8::Context> context, | 4334 v8::Local<v8::Context> context, |
4277 int worldId) | 4335 int worldId) |
(...skipping 7231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11509 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); | 11567 EXPECT_FALSE(testSelectAll("<textarea></textarea>")); |
11510 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); | 11568 EXPECT_TRUE(testSelectAll("<textarea>nonempty</textarea>")); |
11511 EXPECT_FALSE(testSelectAll("<input>")); | 11569 EXPECT_FALSE(testSelectAll("<input>")); |
11512 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); | 11570 EXPECT_TRUE(testSelectAll("<input value='nonempty'>")); |
11513 // TODO(amaralp): Empty contenteditable should not have select all enabled. | 11571 // TODO(amaralp): Empty contenteditable should not have select all enabled. |
11514 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); | 11572 EXPECT_TRUE(testSelectAll("<div contenteditable></div>")); |
11515 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); | 11573 EXPECT_TRUE(testSelectAll("<div contenteditable>nonempty</div>")); |
11516 } | 11574 } |
11517 | 11575 |
11518 } // namespace blink | 11576 } // namespace blink |
OLD | NEW |