Bug 1339543 part 3 PuppetWidget should stop getting all edit commands before dispatching keyboard events which are synthesized for tests r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 17 May 2017 15:34:11 +0900
changeset 359317 a950fbfa6d8cb1c3287a5ed14b4b09d497057224
parent 359316 198e58f7052f48338f8c10c08c6b6713bae8bafb
child 359318 b75c111837a802ceb953dba50a3c5a193d53ca22
push id90494
push userkwierso@gmail.com
push dateFri, 19 May 2017 22:19:13 +0000
treeherdermozilla-inbound@cd9b1ab819e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1339543
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1339543 part 3 PuppetWidget should stop getting all edit commands before dispatching keyboard events which are synthesized for tests r=smaug Synthesized keyboard events in child process doesn't have edit commands when it's being dispatched. With the old design, PuppetWidget needed to store all edit commands for dispatching keyboard event but it's not necessary now because WidgetKeyboardEvent will get only necessary edit commands when WidgetKeyboardEvent::ExecuteEditCommands() is called. So, PuppetWidget should stop calling TabChild::RequestNativeKeyBindings() before dispatching keyboard events. This patch changes browser_audioTabIcon.js which becomes permanent orange with this change. MozReview-Commit-ID: 1eK1mUahRMO
browser/base/content/test/general/browser_audioTabIcon.js
widget/PuppetWidget.cpp
--- a/browser/base/content/test/general/browser_audioTabIcon.js
+++ b/browser/base/content/test/general/browser_audioTabIcon.js
@@ -2,17 +2,17 @@ const PAGE = "https://example.com/browse
 const TABATTR_REMOVAL_PREFNAME = "browser.tabs.delayHidingAudioPlayingIconMS";
 const INITIAL_TABATTR_REMOVAL_DELAY_MS = Services.prefs.getIntPref(TABATTR_REMOVAL_PREFNAME);
 
 async function wait_for_tab_playing_event(tab, expectPlaying) {
   if (tab.soundPlaying == expectPlaying) {
     ok(true, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
     return true;
   }
-  return await BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
+  return BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
     if (event.detail.changed.includes("soundplaying")) {
       is(tab.hasAttribute("soundplaying"), expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
       is(tab.soundPlaying, expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
       return true;
     }
     return false;
   });
 }
@@ -48,18 +48,16 @@ async function pause(tab, options) {
     // Use 10s to remove possibility of race condition with attr removal.
     Services.prefs.setIntPref(TABATTR_REMOVAL_PREFNAME, 10000);
   }
 
   try {
     let browser = tab.linkedBrowser;
     let awaitDOMAudioPlaybackStopped =
       BrowserTestUtils.waitForEvent(browser, "DOMAudioPlaybackStopped", "DOMAudioPlaybackStopped event should get fired after pause");
-    let awaitTabPausedAttrModified =
-      wait_for_tab_playing_event(tab, false);
     await ContentTask.spawn(browser, {}, async function() {
       let audio = content.document.querySelector("audio");
       audio.pause();
     });
 
     // If the tab has already be muted, it means the tab won't have soundplaying,
     // so we don't need to check this attribute.
     if (browser.audioMuted) {
@@ -68,17 +66,17 @@ async function pause(tab, options) {
 
     if (extendedDelay) {
       ok(tab.hasAttribute("soundplaying"), "The tab should still have the soundplaying attribute immediately after pausing");
 
       await awaitDOMAudioPlaybackStopped;
       ok(tab.hasAttribute("soundplaying"), "The tab should still have the soundplaying attribute immediately after DOMAudioPlaybackStopped");
     }
 
-    await awaitTabPausedAttrModified;
+    await wait_for_tab_playing_event(tab, false);
     ok(!tab.hasAttribute("soundplaying"), "The tab should not have the soundplaying attribute after the timeout has resolved");
   } finally {
     // Make sure other tests don't timeout if an exception gets thrown above.
     // Need to use setIntPref instead of clearUserPref because prefs_general.js
     // overrides the default value to help this and other tests run faster.
     Services.prefs.setIntPref(TABATTR_REMOVAL_PREFNAME, INITIAL_TABATTR_REMOVAL_DELAY_MS);
   }
 }
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -343,24 +343,16 @@ PuppetWidget::DispatchEvent(WidgetGUIEve
              "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 && !mNativeKeyCommandsValid) {
-    WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
-    if (keyEvent) {
-      mTabChild->RequestNativeKeyBindings(&autoCache, keyEvent);
-    }
-  }
-
   if (aEvent->mClass == eCompositionEventClass) {
     // Store the latest native IME context of parent process's widget or
     // TextEventDispatcher if it's in this process.
     WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
 #ifdef DEBUG
     if (mNativeIMEContext.IsValid() &&
         mNativeIMEContext != compositionEvent->mNativeIMEContext) {
       RefPtr<TextComposition> composition =