Bug 1476701 - notify observer when audible autoplay occurred. r=cpearce,jaws

In our autoplay shield-study, we want to collect the information which could tell us how many website
contains audible autoplay media, but there is no way to get this information on current API desigin.

Therefore, I would like to send a new notification when autoplay occurred.

The extension code could get the information by following way,
```
Services.obs.addObserver((subject, topic, data) => {
    // DO SOMETHING
}, "AudibleAutoplayMediaOccurred");
```

MozReview-Commit-ID: 4bSYcxDZOGK
This commit is contained in:
alwu
2018-07-25 09:08:44 -07:00
parent f474a291b9
commit c96fe8806b
6 changed files with 51 additions and 6 deletions

View File

@@ -4431,6 +4431,16 @@ window._gBrowser = {
tab.finishMediaBlockTimer();
}
});
this.addEventListener("AudibleAutoplayMediaOccurred", (event) => {
let browser = event.originalTarget;
let tab = this.getTabForBrowser(browser);
if (!tab) {
return;
}
Services.obs.notifyObservers(tab, "AudibleAutoplayMediaOccurred");
});
},
};