Bug 1191959 - Make sure that pinned tabs are still clickable after unuting a tab that is not playing; r=jaws
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 06 Aug 2015 22:29:06 -0400
changeset 288395 f58ce99d0d99256512a5e5f7f648a98b9d4b5da7
parent 288394 6fb2fb69fe674e2b776a427f4f3e36f235aa3a55
child 288396 e14cb4eb7c0bdd00b20ab6ff212e5f72158b12a9
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1191959
milestone42.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 1191959 - Make sure that pinned tabs are still clickable after unuting a tab that is not playing; r=jaws This bug happens becuase when toggleMuteAudio() is called from the click handler for the tab, we remove the muted attribute during unmuting, which makes the element display:none. Therefore, when the mouse pointer leaves that region, there is no element to receive the mouseout event and as a result, the _overPlayingIcon variable stays true, which means we stop tab switching in the mousedown handler.
browser/base/content/tabbrowser.xml
browser/base/content/test/general/browser_audioTabIcon.js
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -5971,16 +5971,17 @@
         }
 
         let anonid = event.originalTarget.getAttribute("anonid");
         let iconVisible = this.hasAttribute("soundplaying") ||
                           this.hasAttribute("muted");
         if ((anonid == "soundplaying-icon") ||
             ((anonid == "overlay-icon") && iconVisible)) {
           this.toggleMuteAudio();
+          this._overPlayingIcon = false;
         }
       ]]>
       </handler>
     </handlers>
   </binding>
 
   <binding id="tabbrowser-alltabs-popup"
            extends="chrome://global/content/bindings/popup.xml#popup">
--- a/browser/base/content/test/general/browser_audioTabIcon.js
+++ b/browser/base/content/test/general/browser_audioTabIcon.js
@@ -154,16 +154,68 @@ function* test_browser_swapping(tab, bro
 
     yield BrowserTestUtils.withNewTab({
       gBrowser,
       url: "about:blank",
     }, newBrowser => test_swapped_browser(tab, newBrowser, false));
   });
 }
 
+function* test_click_on_pinned_tab_after_mute() {
+  function* test_on_browser(browser) {
+    let tab = gBrowser.getTabForBrowser(browser);
+
+    gBrowser.selectedTab = originallySelectedTab;
+    isnot(tab, gBrowser.selectedTab, "Sanity check, the tab should not be selected!");
+
+    // Steps to reproduce the bug:
+    //   Pin the tab.
+    gBrowser.pinTab(tab);
+
+    //   Start playbak.
+    yield ContentTask.spawn(browser, {}, function* () {
+      let audio = content.document.querySelector("audio");
+      audio.play();
+    });
+
+    //   Wait for playback to start.
+    yield wait_for_tab_playing_event(tab, true);
+
+    //   Mute the tab.
+    let icon = document.getAnonymousElementByAttribute(tab, "anonid", "overlay-icon");
+    yield test_mute_tab(tab, icon, true);
+
+    //   Stop playback
+    yield ContentTask.spawn(browser, {}, function* () {
+      let audio = content.document.querySelector("audio");
+      audio.pause();
+    });
+
+    // Unmute tab.
+    yield test_mute_tab(tab, icon, false);
+
+    // Now click on the tab.
+    let image = document.getAnonymousElementByAttribute(tab, "anonid", "tab-icon-image");
+    EventUtils.synthesizeMouseAtCenter(image, {button: 0});
+
+    is(tab, gBrowser.selectedTab, "Tab switch should be successful");
+
+    // Cleanup.
+    gBrowser.unpinTab(tab);
+    gBrowser.selectedTab = originallySelectedTab;
+  }
+
+  let originallySelectedTab = gBrowser.selectedTab;
+
+  yield BrowserTestUtils.withNewTab({
+    gBrowser,
+    url: PAGE
+  }, test_on_browser);
+}
+
 function* test_on_browser(browser) {
   let tab = gBrowser.getTabForBrowser(browser);
 
   // Test the icon in a normal tab.
   yield test_playing_icon_on_tab(tab, browser, false);
 
   gBrowser.pinTab(tab);
 
@@ -175,16 +227,18 @@ function* test_on_browser(browser) {
   // Retest with another browser in the foreground tab
   if (gBrowser.selectedBrowser.currentURI.spec == PAGE) {
     yield BrowserTestUtils.withNewTab({
       gBrowser,
       url: "data:text/html,test"
     }, () => test_on_browser(browser));
   } else {
     yield test_browser_swapping(tab, browser);
+
+    yield test_click_on_pinned_tab_after_mute();
   }
 }
 
 add_task(function*() {
   yield new Promise((resolve) => {
     SpecialPowers.pushPrefEnv({"set": [
                                 ["media.useAudioChannelService", true],
                                 ["browser.tabs.showAudioPlayingIcon", true],