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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2074423004: [InputEvent] Dispatch 'input' event for ContentEditable and typing on Input element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tkent's review Created 4 years, 5 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 // 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/editing/InputMethodController.h" 5 #include "core/editing/InputMethodController.h"
6 6
7 #include "core/dom/Element.h" 7 #include "core/dom/Element.h"
8 #include "core/dom/Range.h" 8 #include "core/dom/Range.h"
9 #include "core/editing/FrameSelection.h" 9 #include "core/editing/FrameSelection.h"
10 #include "core/events/MouseEvent.h" 10 #include "core/events/MouseEvent.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 EXPECT_EQ(24u, controller().getSelectionOffsets().end()); 349 EXPECT_EQ(24u, controller().getSelectionOffsets().end());
350 } 350 }
351 351
352 TEST_F(InputMethodControllerTest, CompositionFireBeforeInput) 352 TEST_F(InputMethodControllerTest, CompositionFireBeforeInput)
353 { 353 {
354 document().settings()->setScriptEnabled(true); 354 document().settings()->setScriptEnabled(true);
355 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru e'></div>", "sample"); 355 Element* editable = insertHTMLElement("<div id='sample' contentEditable='tru e'></div>", "sample");
356 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION); 356 Element* script = document().createElement("script", ASSERT_NO_EXCEPTION);
357 script->setInnerHTML( 357 script->setInnerHTML(
358 "document.getElementById('sample').addEventListener('beforeinput', funct ion(event) {" 358 "document.getElementById('sample').addEventListener('beforeinput', funct ion(event) {"
359 " document.title = `beforeinput.isComposing:${event.isComposing}`;" 359 " document.title = `beforeinput.isComposing:${event.isComposing};`;"
360 "});"
361 "document.getElementById('sample').addEventListener('input', function(ev ent) {"
362 " document.title += `input.isComposing:${event.isComposing};`;"
360 "});", 363 "});",
361 ASSERT_NO_EXCEPTION); 364 ASSERT_NO_EXCEPTION);
362 document().body()->appendChild(script, ASSERT_NO_EXCEPTION); 365 document().body()->appendChild(script, ASSERT_NO_EXCEPTION);
363 document().view()->updateAllLifecyclePhases(); 366 document().view()->updateAllLifecyclePhases();
364 367
365 // Simulate composition in the |contentEditable|. 368 // Simulate composition in the |contentEditable|.
366 Vector<CompositionUnderline> underlines; 369 Vector<CompositionUnderline> underlines;
367 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 370 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
368 editable->focus(); 371 editable->focus();
369 372
370 document().setTitle(emptyString()); 373 document().setTitle(emptyString());
371 controller().setComposition("foo", underlines, 0, 3); 374 controller().setComposition("foo", underlines, 0, 3);
372 EXPECT_STREQ("beforeinput.isComposing:true", document().title().utf8().data( )); 375 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen t().title().utf8().data());
373 376
374 document().setTitle(emptyString()); 377 document().setTitle(emptyString());
375 controller().confirmComposition(); 378 controller().confirmComposition();
376 // Last 'beforeinput' should also be inside composition scope. 379 // Last 'beforeinput' should also be inside composition scope.
377 EXPECT_STREQ("beforeinput.isComposing:true", document().title().utf8().data( )); 380 EXPECT_STREQ("beforeinput.isComposing:true;input.isComposing:true;", documen t().title().utf8().data());
chongz 2016/06/23 00:32:06 Testing |isComposing|
378 } 381 }
379 382
380 } // namespace blink 383 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | third_party/WebKit/Source/core/editing/commands/TypingCommand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698