Bug 1227885 - Improve stubbing of audio requests to avoid intermittent console warnings and also improve caught errors output. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Fri, 27 Nov 2015 11:53:30 +0000
changeset 308602 556ab9e3521ba6b53393e09a203b06c811a8ec7b
parent 308601 bb512bf5a0669afa0d8158daf906a4223f4ba6ce
child 308603 c52cc48aea1ea85a331012dfecf7f9cc837b7136
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1227885
milestone45.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 1227885 - Improve stubbing of audio requests to avoid intermittent console warnings and also improve caught errors output. r=mikedeboer
browser/components/loop/test/shared/loop_mocha_utils.js
browser/components/loop/test/standalone/standaloneRoomViews_test.js
--- a/browser/components/loop/test/shared/loop_mocha_utils.js
+++ b/browser/components/loop/test/shared/loop_mocha_utils.js
@@ -253,17 +253,21 @@ var LoopMochaUtils = (function(global, _
         throw new Error();
       } catch (e) {
         gCaughtIssues.push([args, e.stack]);
       }
       consoleWarn.apply(console, args);
     };
     console.error = function() {
       var args = Array.slice(arguments);
-      gCaughtIssues.push(args);
+      try {
+        throw new Error();
+      } catch (e) {
+        gCaughtIssues.push([args, e.stack]);
+      }
       consoleError.apply(console, args);
     };
   }
 
   /**
    * Adds tests to check no warnings nor errors have occurred since trapErrors
    * was called.
    */
--- a/browser/components/loop/test/standalone/standaloneRoomViews_test.js
+++ b/browser/components/loop/test/standalone/standaloneRoomViews_test.js
@@ -15,17 +15,17 @@ describe("loop.standaloneRoomViews", fun
   var sharedActions = loop.shared.actions;
   var sharedUtils = loop.shared.utils;
   var fixtures = document.querySelector("#fixtures");
 
   var sandbox, dispatcher, activeRoomStore, dispatch;
   var clock, fakeWindow, view;
 
   beforeEach(function() {
-    sandbox = sinon.sandbox.create();
+    sandbox = LoopMochaUtils.createSandbox();
     dispatcher = new loop.Dispatcher();
     dispatch = sandbox.stub(dispatcher, "dispatch");
     activeRoomStore = new loop.store.ActiveRoomStore(dispatcher, {
       mozLoop: {},
       sdkDriver: {}
     });
     var textChatStore = new loop.store.TextChatStore(dispatcher, {
       sdkDriver: {}
@@ -54,16 +54,21 @@ describe("loop.standaloneRoomViews", fun
           return args.terms_of_use_url + " " + args.privacy_notice_url;
         default:
           return key;
       }
     });
 
     // Prevents audio request errors in the test console.
     sandbox.useFakeXMLHttpRequest();
+    sandbox.stub(sharedUtils, "isDesktop").returns(true);
+    LoopMochaUtils.stubLoopRequest({
+      GetDoNotDisturb: sinon.stub().returns(true),
+      GetLoopPref: sinon.stub()
+    });
   });
 
   afterEach(function() {
     loop.shared.mixins.setRootObject(window);
     sandbox.restore();
     clock.restore();
     React.unmountComponentAtNode(fixtures);
     view = null;