Bug 1513681 - part5 : remove event 'AudibleAutoplayMediaOccurred'. r=jaws
authorAlastor Wu <alwu@mozilla.com>
Fri, 04 Jan 2019 19:04:39 +0000
changeset 452625 86afca3f41ac522e120c22cc1b4c55ab86c83fe5
parent 452624 9378c3b5ad2dc2d50774b6dc93164dda712da17d
child 452626 fedf648d3785496798d361b31c9bdd144e2b5897
push id35317
push userrgurzau@mozilla.com
push dateSat, 05 Jan 2019 12:34:37 +0000
treeherdermozilla-central@689de183c761 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1513681
milestone66.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 1513681 - part5 : remove event 'AudibleAutoplayMediaOccurred'. r=jaws This event is used for shield-study which has finished, so we could remove it. Differential Revision: https://phabricator.services.mozilla.com/D14810
browser/base/content/tabbrowser.js
dom/base/Document.cpp
toolkit/actors/AutoplayChild.jsm
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_autoplay_audibleMediaOccurred.js
toolkit/content/widgets/browser.xml
toolkit/modules/ActorManagerParent.jsm
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -4758,26 +4758,16 @@ window._gBrowser = {
         tab.removeAttribute("activemedia-blocked");
         this._tabAttrModified(tab, ["activemedia-blocked"]);
         let hist = Services.telemetry.getHistogramById("TAB_AUDIO_INDICATOR_USED");
         hist.add(2 /* unblockByVisitingTab */ );
         tab.finishMediaBlockTimer();
       }
     });
 
-    this.addEventListener("AudibleAutoplayMediaOccurred", (event) => {
-      let browser = event.originalTarget;
-      let tab = this.getTabForBrowser(browser);
-      if (!tab) {
-        return;
-      }
-
-      Services.obs.notifyObservers(tab, "AudibleAutoplayMediaOccurred");
-    });
-
     this.addEventListener("GloballyAutoplayBlocked", (event) => {
       let browser = event.originalTarget;
       let tab = this.getTabForBrowser(browser);
       if (!tab) {
         return;
       }
 
       SitePermissions.set(event.detail.url, "autoplay-media",
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -11753,22 +11753,16 @@ void Document::MaybeNotifyAutoplayBlocke
 }
 
 void Document::SetDocTreeHadAudibleMedia() {
   Document* topLevelDoc = GetTopLevelContentDocument();
   if (!topLevelDoc) {
     return;
   }
 
-  if (!topLevelDoc->mDocTreeHadAudibleMedia) {
-    RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
-        topLevelDoc, NS_LITERAL_STRING("AudibleAutoplayMediaOccurred"),
-        CanBubble::eYes, ChromeOnlyDispatch::eYes);
-    asyncDispatcher->PostDOMEvent();
-  }
   topLevelDoc->mDocTreeHadAudibleMedia = true;
 }
 
 void Document::SetDocTreeHadPlayRevoked() {
   Document* topLevelDoc = GetTopLevelContentDocument();
   if (topLevelDoc) {
     topLevelDoc->mDocTreeHadPlayRevoked = true;
   }
--- a/toolkit/actors/AutoplayChild.jsm
+++ b/toolkit/actors/AutoplayChild.jsm
@@ -5,18 +5,11 @@
 "use strict";
 
 var EXPORTED_SYMBOLS = ["AutoplayChild"];
 
 ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
 
 class AutoplayChild extends ActorChild {
   handleEvent(event) {
-    if (event.type == "AudibleAutoplayMediaOccurred") {
-      this.mm.sendAsyncMessage("AudibleAutoplayMediaOccurred");
-      return;
-    }
-    if (event.type == "GloballyAutoplayBlocked") {
-      this.mm.sendAsyncMessage("GloballyAutoplayBlocked");
-      return;
-    }
+    this.mm.sendAsyncMessage("GloballyAutoplayBlocked");
   }
 }
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -25,17 +25,16 @@ support-files =
   silentAudioTrack.webm
   doggy.png
   firebird.png
 
 [browser_audioCompeting.js]
 tags = audiochannel
 [browser_audioCompeting_onlyForActiveAgent.js]
 tags = audiochannel
-[browser_autoplay_audibleMediaOccurred.js]
 [browser_autoplay_policy_iframe_hierarchy.js]
 support-files =
   file_autoplay_three_layers_frame1.html
   file_autoplay_three_layers_frame2.html
   file_autoplay_two_layers_frame1.html
   file_autoplay_two_layers_frame2.html
   file_video.html
   gizmo.mp4
deleted file mode 100644
--- a/toolkit/content/tests/browser/browser_autoplay_audibleMediaOccurred.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * This test is used to test whether the topic 'AudibleAutoplayMediaOccurred'
- * is sent correctly when the autoplay audible media tries to start.
- */
-"use strict";
-
-const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_mediaPlayback.html";
-
-add_task(async function testAudibleAutoplayMedia() {
-  info("- open new tab  -");
-  let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser,
-                                                        "about:blank");
-  let browser = tab.linkedBrowser;
-
-  // start observing the topic before loading the page to ensure we can get it.
-  let audibleAutoplayOccurred = TestUtils.topicObserved("AudibleAutoplayMediaOccurred");
-  browser.loadURI(PAGE, {
-    triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
-  });
-
-  await BrowserTestUtils.browserLoaded(browser);
-  await audibleAutoplayOccurred;
-  ok(true, "Got the topic 'AudibleAutoplayMediaOccurred'.");
-
-  info("- remove tab -");
-  BrowserTestUtils.removeTab(tab);
-});
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -757,26 +757,16 @@
           <![CDATA[
             let event = document.createEvent("Events");
             event.initEvent("DOMAudioPlaybackStopped", true, false);
             this.dispatchEvent(event);
           ]]>
         </body>
       </method>
 
-      <method name="notifyAudibleAutoplayMediaOccurred">
-        <body>
-          <![CDATA[
-            let event = document.createEvent("Events");
-            event.initEvent("AudibleAutoplayMediaOccurred", true, false);
-            this.dispatchEvent(event);
-          ]]>
-        </body>
-      </method>
-
       <method name="notifyGloballyAutoplayBlocked">
         <body>
           <![CDATA[
             let event = document.createEvent("CustomEvent");
             event.initCustomEvent("GloballyAutoplayBlocked", true, false,
               {
                 url: this.documentURI,
               });
@@ -1116,17 +1106,16 @@
             this.messageManager.addMessageListener("PopupBlocking:UpdateBlockedPopups", this);
             this.messageManager.addMessageListener("Autoscroll:Start", this);
             this.messageManager.addMessageListener("Autoscroll:Cancel", this);
             this.messageManager.addMessageListener("AudioPlayback:Start", this);
             this.messageManager.addMessageListener("AudioPlayback:Stop", this);
             this.messageManager.addMessageListener("AudioPlayback:ActiveMediaBlockStart", this);
             this.messageManager.addMessageListener("AudioPlayback:ActiveMediaBlockStop", this);
             this.messageManager.addMessageListener("UnselectedTabHover:Toggle", this);
-            this.messageManager.addMessageListener("AudibleAutoplayMediaOccurred", this);
             this.messageManager.addMessageListener("GloballyAutoplayBlocked", this);
 
             if (this.hasAttribute("selectmenulist")) {
               this.messageManager.addMessageListener("Forms:ShowDropDown", this);
               this.messageManager.addMessageListener("Forms:HideDropDown", this);
             }
 
           }
@@ -1259,19 +1248,16 @@
             case "AudioPlayback:ActiveMediaBlockStop":
               this.activeMediaBlockStopped();
               break;
             case "UnselectedTabHover:Toggle":
               this._shouldSendUnselectedTabHover = data.enable ?
                 ++this._unselectedTabHoverMessageListenerCount > 0 :
                 --this._unselectedTabHoverMessageListenerCount == 0;
               break;
-            case "AudibleAutoplayMediaOccurred":
-              this.notifyAudibleAutoplayMediaOccurred();
-              break;
             case "GloballyAutoplayBlocked":
               this.notifyGloballyAutoplayBlocked();
               break;
             case "Forms:ShowDropDown": {
               if (!this._selectParentHelper) {
                 this._selectParentHelper =
                   ChromeUtils.import("resource://gre/modules/SelectParentHelper.jsm", {}).SelectParentHelper;
               }
--- a/toolkit/modules/ActorManagerParent.jsm
+++ b/toolkit/modules/ActorManagerParent.jsm
@@ -113,17 +113,16 @@ let ACTORS = {
       ],
     },
   },
 
   Autoplay: {
     child: {
       module: "resource://gre/actors/AutoplayChild.jsm",
       events: {
-        "AudibleAutoplayMediaOccurred": {},
         "GloballyAutoplayBlocked": {},
       },
     },
   },
 
   Browser: {
     child: {
       module: "resource://gre/actors/BrowserChild.jsm",