Bug 1363253 - Ignore events specific to preview window also when decrementing. r=florian
authorAndreas Pehrson <pehrsons@gmail.com>
Thu, 11 May 2017 15:07:17 +0200
changeset 358593 e7c7370fdd5457cd71bacc6e452a9d928fde8083
parent 358592 4e4b275723774ef9260ea40bc6a80d0bd01ab3b4
child 358594 374e39d641907cd65c518eac835db72e09aba5c3
push id90353
push userryanvm@gmail.com
push dateWed, 17 May 2017 00:10:47 +0000
treeherdermozilla-inbound@41958333867b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1363253
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 1363253 - Ignore events specific to preview window also when decrementing. r=florian MozReview-Commit-ID: 8pjSBUI7ZkZ
browser/base/content/test/webrtc/get_user_media_content_script.js
--- a/browser/base/content/test/webrtc/get_user_media_content_script.js
+++ b/browser/base/content/test/webrtc/get_user_media_content_script.js
@@ -13,29 +13,37 @@ const kObservedTopics = [
   "getUserMedia:revoke",
   "getUserMedia:response:deny",
   "getUserMedia:request",
   "recording-device-events",
   "recording-window-ended"
 ];
 
 var gObservedTopics = {};
-function observer(aSubject, aTopic, aData) {
+
+function ignoreEvent(aSubject, aTopic, aData) {
   // With e10s disabled, our content script receives notifications for the
   // preview displayed in our screen sharing permission prompt; ignore them.
   const kBrowserURL = "chrome://browser/content/browser.xul";
   const nsIPropertyBag = Components.interfaces.nsIPropertyBag;
   if (aTopic == "recording-device-events" &&
       aSubject.QueryInterface(nsIPropertyBag).getProperty("requestURL") == kBrowserURL) {
-    return;
+    return true;
   }
   if (aTopic == "recording-window-ended") {
     let win = Services.wm.getOuterWindowWithId(aData).top;
     if (win.document.documentURI == kBrowserURL)
-      return;
+      return true;
+  }
+  return false;
+}
+
+function observer(aSubject, aTopic, aData) {
+  if (ignoreEvent(aSubject, aTopic, aData)) {
+    return;
   }
 
   if (!(aTopic in gObservedTopics))
     gObservedTopics[aTopic] = 1;
   else
     ++gObservedTopics[aTopic];
 }
 
@@ -85,17 +93,26 @@ function _getMediaCaptureState() {
 }
 
 addMessageListener("Test:GetMediaCaptureState", data => {
   sendAsyncMessage("Test:MediaCaptureState", _getMediaCaptureState());
 });
 
 addMessageListener("Test:WaitForObserverCall", ({data}) => {
   let topic = data;
-  Services.obs.addObserver(function obs() {
+  Services.obs.addObserver(function obs(aSubject, aTopic, aData) {
+    if (aTopic != topic) {
+      is(aTopic, topic, "Wrong topic observed");
+      return;
+    }
+
+    if (ignoreEvent(aSubject, aTopic, aData)) {
+      return;
+    }
+
     sendAsyncMessage("Test:ObserverCalled", topic);
     Services.obs.removeObserver(obs, topic);
 
     if (kObservedTopics.indexOf(topic) != -1) {
       if (!(topic in gObservedTopics))
         gObservedTopics[topic] = -1;
       else
         --gObservedTopics[topic];