Bug 1339543 part 2 eKeyPress event should have edit commands for all editor types when it's dispatched to a remote process r=smaug

When eKeyPress event is dispatched from TabParent to a remote process, it
should store edit command for all editor types.  Then, copied
WidgetKeyboardEvent in the remote process doesn't need to request the edit
commands when its ExecuteEditCommands() is called.

Note that this patch also changes a automated test, browser_bug1316330.js,
that uses nsIDOMWindowUtils.dispatchDOMEventViaPresShell() to dispatch
repeated keyboard events in the tab.  However, it should use synthesizeKey()
to emulate everything of native keyboard events and the API can dispatch
repeated keyboard events too.  (And the test has a bug.  It tries to wait 0.5
sec when every keydown or keypress event.  However, it fails since startTime
is never initialized.  This patch fixes this bug too.)

MozReview-Commit-ID: IYhyxqH3Ch8
This commit is contained in:
Masayuki Nakano
2017-05-19 17:24:20 +09:00
parent d4365ad2e8
commit db7735d2b2
9 changed files with 110 additions and 76 deletions

View File

@@ -342,9 +342,14 @@ PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus)
MOZ_ASSERT(!mChild || mChild->mWindowType == eWindowType_popup,
"Unexpected event dispatch!");
MOZ_ASSERT(!aEvent->AsKeyboardEvent() ||
aEvent->mFlags.mIsSynthesizedForTests ||
aEvent->AsKeyboardEvent()->AreAllEditCommandsInitialized(),
"Non-sysnthesized keyboard events should have edit commands for all types "
"before dispatched");
AutoCacheNativeKeyCommands autoCache(this);
if ((aEvent->mFlags.mIsSynthesizedForTests ||
aEvent->mFlags.mIsSuppressedOrDelayed) && !mNativeKeyCommandsValid) {
if (aEvent->mFlags.mIsSynthesizedForTests && !mNativeKeyCommandsValid) {
WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
if (keyEvent) {
mTabChild->RequestNativeKeyBindings(&autoCache, keyEvent);