OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/page/ContextMenuController.h" | 5 #include "core/page/ContextMenuController.h" |
6 | 6 |
7 #include "core/clipboard/DataTransfer.h" | 7 #include "core/clipboard/DataTransfer.h" |
8 #include "core/events/MouseEvent.h" | 8 #include "core/events/MouseEvent.h" |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 "<menuitem id=\"item10\" type=\"radio\" radiogroup=\"group\" " | 69 "<menuitem id=\"item10\" type=\"radio\" radiogroup=\"group\" " |
70 "label=\"Item10\"" | 70 "label=\"Item10\"" |
71 "onclick='if " | 71 "onclick='if " |
72 "(document.getElementById(\"item10\").hasAttribute(\"checked\"))" | 72 "(document.getElementById(\"item10\").hasAttribute(\"checked\"))" |
73 "document.title = \"Title 10 checked\"; else if " | 73 "document.title = \"Title 10 checked\"; else if " |
74 "(document.getElementById(\"item8\").hasAttribute(\"checked\"))" | 74 "(document.getElementById(\"item8\").hasAttribute(\"checked\"))" |
75 "document.title = \"Title 10 not checked and Title 8 checked\";'>" | 75 "document.title = \"Title 10 not checked and Title 8 checked\";'>" |
76 "</menu>" | 76 "</menu>" |
77 "</button>"); | 77 "</button>"); |
78 | 78 |
| 79 MouseEventInit mouseInitializer; |
| 80 mouseInitializer.setView(document().domWindow()); |
| 81 mouseInitializer.setScreenX(50); |
| 82 mouseInitializer.setScreenY(50); |
| 83 mouseInitializer.setButton(1); |
| 84 |
79 // Create right button click event and pass it to context menu controller. | 85 // Create right button click event and pass it to context menu controller. |
80 Event* event = MouseEvent::create( | 86 Event* event = |
81 EventTypeNames::click, false, false, document().domWindow(), 50, 50, 0, 0, | 87 MouseEvent::create(nullptr, EventTypeNames::click, mouseInitializer); |
82 0, 0, 0, PlatformEvent::NoModifiers, 1, 0, nullptr, TimeTicks(), | |
83 PlatformMouseEvent::RealOrIndistinguishable, String(), nullptr); | |
84 document().getElementById("button_id")->focus(); | 88 document().getElementById("button_id")->focus(); |
85 event->setTarget(document().getElementById("button_id")); | 89 event->setTarget(document().getElementById("button_id")); |
86 document().page()->contextMenuController().handleContextMenuEvent(event); | 90 document().page()->contextMenuController().handleContextMenuEvent(event); |
87 | 91 |
88 // Item 1 | 92 // Item 1 |
89 // Item 2 | 93 // Item 2 |
90 // Item 3 | 94 // Item 3 |
91 // Submenu > Item 4 | 95 // Submenu > Item 4 |
92 // Item 5 | 96 // Item 5 |
93 // Item 6 | 97 // Item 6 |
(...skipping 22 matching lines...) Expand all Loading... |
116 EXPECT_STREQ("Title 7 not checked", document().title().utf8().data()); | 120 EXPECT_STREQ("Title 7 not checked", document().title().utf8().data()); |
117 document().page()->contextMenuController().contextMenuItemSelected(&items[5]); | 121 document().page()->contextMenuController().contextMenuItemSelected(&items[5]); |
118 EXPECT_STREQ("Title 8 not checked and Title 9 checked", | 122 EXPECT_STREQ("Title 8 not checked and Title 9 checked", |
119 document().title().utf8().data()); | 123 document().title().utf8().data()); |
120 document().page()->contextMenuController().contextMenuItemSelected(&items[7]); | 124 document().page()->contextMenuController().contextMenuItemSelected(&items[7]); |
121 EXPECT_STREQ("Title 10 not checked and Title 8 checked", | 125 EXPECT_STREQ("Title 10 not checked and Title 8 checked", |
122 document().title().utf8().data()); | 126 document().title().utf8().data()); |
123 } | 127 } |
124 | 128 |
125 } // namespace blink | 129 } // namespace blink |
OLD | NEW |