| 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" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 document().frame()->eventHandler().dragDataTransferLocationForTesting()); | 230 document().frame()->eventHandler().dragDataTransferLocationForTesting()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 // Regression test for http://crbug.com/641403 to verify we use up-to-date | 233 // Regression test for http://crbug.com/641403 to verify we use up-to-date |
| 234 // layout tree for dispatching "contextmenu" event. | 234 // layout tree for dispatching "contextmenu" event. |
| 235 TEST_F(EventHandlerTest, sendContextMenuEventWithHover) { | 235 TEST_F(EventHandlerTest, sendContextMenuEventWithHover) { |
| 236 setHtmlInnerHTML( | 236 setHtmlInnerHTML( |
| 237 "<style>*:hover { color: red; }</style>" | 237 "<style>*:hover { color: red; }</style>" |
| 238 "<div>foo</div>"); | 238 "<div>foo</div>"); |
| 239 document().settings()->setScriptEnabled(true); | 239 document().settings()->setScriptEnabled(true); |
| 240 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION); | 240 Element* script = document().createElement("script"); |
| 241 script->setInnerHTML( | 241 script->setInnerHTML( |
| 242 "document.addEventListener('contextmenu', event => " | 242 "document.addEventListener('contextmenu', event => " |
| 243 "event.preventDefault());", | 243 "event.preventDefault());", |
| 244 ASSERT_NO_EXCEPTION); | 244 ASSERT_NO_EXCEPTION); |
| 245 document().body()->appendChild(script); | 245 document().body()->appendChild(script); |
| 246 document().updateStyleAndLayout(); | 246 document().updateStyleAndLayout(); |
| 247 document().frame()->selection().setSelection( | 247 document().frame()->selection().setSelection( |
| 248 SelectionInDOMTree::Builder() | 248 SelectionInDOMTree::Builder() |
| 249 .collapse(Position(document().body(), 0)) | 249 .collapse(Position(document().body(), 0)) |
| 250 .build()); | 250 .build()); |
| 251 PlatformMouseEvent mouseDownEvent( | 251 PlatformMouseEvent mouseDownEvent( |
| 252 IntPoint(0, 0), IntPoint(100, 200), WebPointerProperties::Button::Right, | 252 IntPoint(0, 0), IntPoint(100, 200), WebPointerProperties::Button::Right, |
| 253 PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::RightButtonDown, | 253 PlatformEvent::MousePressed, 1, PlatformEvent::Modifiers::RightButtonDown, |
| 254 WTF::monotonicallyIncreasingTime()); | 254 WTF::monotonicallyIncreasingTime()); |
| 255 EXPECT_EQ( | 255 EXPECT_EQ( |
| 256 WebInputEventResult::HandledApplication, | 256 WebInputEventResult::HandledApplication, |
| 257 document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent)); | 257 document().frame()->eventHandler().sendContextMenuEvent(mouseDownEvent)); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace blink | 260 } // namespace blink |
| OLD | NEW |