Bug 1041155 - The browser_wa_properties-view-media-nodes.js test doesn't wait for the audio device to be actually closed, r=paul.
authorFlorian Quèze <florian@queze.net>
Sat, 19 Jul 2014 20:08:28 +0200
changeset 217099 7e65e2b5bcdd366673d57531f3b12e3d148f7906
parent 217098 cabc7efd2c1fdefa9abed927ef3aff42ee46a499
child 217100 5cc2ca22144333a62e4135346e1e099ce31410b4
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul
bugs1041155
milestone33.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 1041155 - The browser_wa_properties-view-media-nodes.js test doesn't wait for the audio device to be actually closed, r=paul.
browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
--- a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
@@ -3,16 +3,40 @@
 
 /**
  * Tests that params view correctly displays all properties for nodes
  * correctly, with default values and correct types.
  */
 
 let MEDIA_PERMISSION = "media.navigator.permission.disabled";
 
+function waitForDeviceClosed() {
+  info("Checking that getUserMedia streams are no longer in use.");
+
+  let temp = {};
+  Cu.import("resource:///modules/webrtcUI.jsm", temp);
+  let webrtcUI = temp.webrtcUI;
+
+  if (!webrtcUI.showGlobalIndicator)
+    return Promise.resolve();
+
+  let deferred = Promise.defer();
+
+  const TOPIC = "recording-device-events";
+  Services.obs.addObserver(function deviceEventsObserver() {
+    info("Observing " + TOPIC);
+    if (!webrtcUI.showGlobalIndicator) {
+      Services.obs.removeObserver(deviceEventsObserver, TOPIC);
+      deferred.resolve();
+    }
+  }, TOPIC, false);
+
+  return deferred.promise;
+}
+
 function spawnTest() {
   let [target, debuggee, panel] = yield initWebAudioEditor(MEDIA_NODES_URL);
   let { panelWin } = panel;
   let { gFront, $, $$, EVENTS, WebAudioInspectorView } = panelWin;
   let gVars = WebAudioInspectorView._propsView;
 
   // Auto enable getUserMedia
   let mediaPermissionPref = Services.prefs.getBoolPref(MEDIA_PERMISSION);
@@ -36,10 +60,13 @@ function spawnTest() {
     yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
     checkVariableView(gVars, 0, NODE_DEFAULT_VALUES[types[i]], types[i]);
   }
 
   // Reset permissions on getUserMedia
   Services.prefs.setBoolPref(MEDIA_PERMISSION, mediaPermissionPref);
 
   yield teardown(panel);
+
+  yield waitForDeviceClosed();
+
   finish();
 }