| OLD | NEW |
| 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/input/EventHandler.h" | 5 #include "core/input/EventHandler.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/Range.h" | 8 #include "core/dom/Range.h" |
| 9 #include "core/editing/Editor.h" | 9 #include "core/editing/Editor.h" |
| 10 #include "core/editing/FrameSelection.h" | 10 #include "core/editing/FrameSelection.h" |
| 11 #include "core/frame/FrameView.h" | 11 #include "core/frame/FrameView.h" |
| 12 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
| 13 #include "core/frame/Settings.h" |
| 13 #include "core/page/AutoscrollController.h" | 14 #include "core/page/AutoscrollController.h" |
| 14 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
| 15 #include "core/testing/DummyPageHolder.h" | 16 #include "core/testing/DummyPageHolder.h" |
| 16 #include "platform/PlatformMouseEvent.h" | 17 #include "platform/PlatformMouseEvent.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include <memory> | 19 #include <memory> |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 class EventHandlerTest : public ::testing::Test { | 23 class EventHandlerTest : public ::testing::Test { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 WebPointerProperties::Button::Left, | 234 WebPointerProperties::Button::Left, |
| 234 PlatformEvent::MouseMoved, | 235 PlatformEvent::MouseMoved, |
| 235 1, | 236 1, |
| 236 PlatformEvent::Modifiers::LeftButtonDown, | 237 PlatformEvent::Modifiers::LeftButtonDown, |
| 237 WTF::monotonicallyIncreasingTime()); | 238 WTF::monotonicallyIncreasingTime()); |
| 238 document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent); | 239 document().frame()->eventHandler().handleMouseMoveEvent(mouseMoveEvent); |
| 239 | 240 |
| 240 EXPECT_EQ(IntPoint(45, 44), document().frame()->eventHandler().dragDataTrans
ferLocationForTesting()); | 241 EXPECT_EQ(IntPoint(45, 44), document().frame()->eventHandler().dragDataTrans
ferLocationForTesting()); |
| 241 } | 242 } |
| 242 | 243 |
| 244 // Regression test for http://crbug.com/641403 to verify we use up-to-date |
| 245 // layout tree for dispatching "contextmenu" event. |
| 246 TEST_F(EventHandlerTest, sendContextMenuEventWithHover) |
| 247 { |
| 248 setHtmlInnerHTML( |
| 249 "<style>*:hover { color: red; }</style>" |
| 250 "<div>foo</div>"); |
| 251 document().settings()->setScriptEnabled(true); |
| 252 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION); |
| 253 script->setInnerHTML( |
| 254 "document.addEventListener('contextmenu', event => event.preventDefault(
));", |
| 255 ASSERT_NO_EXCEPTION); |
| 256 document().body()->appendChild(script); |
| 257 document().frame()->selection().setSelection( |
| 258 VisibleSelection(Position(document().body(), 0))); |
| 259 PlatformMouseEvent mouseDownEvent( |
| 260 IntPoint(0, 0), |
| 261 IntPoint(100, 200), |
| 262 WebPointerProperties::Button::Right, |
| 263 PlatformEvent::MousePressed, |
| 264 1, |
| 265 PlatformEvent::Modifiers::RightButtonDown, |
| 266 WTF::monotonicallyIncreasingTime()); |
| 267 EXPECT_EQ(WebInputEventResult::HandledApplication, |
| 268 document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent))
; |
| 269 } |
| 270 |
| 243 } // namespace blink | 271 } // namespace blink |
| OLD | NEW |