Bug 1249106 - Fail tests when React propType errors are logged. r=jyrans
authorLin Clark <lclark@mozilla.com>
Wed, 09 Mar 2016 21:50:42 -0800
changeset 311803 12637684d990bb6daa08fa7049f66af21c6706a5
parent 311802 fd53c862d17a3a2ab146ec2f4c8b1e1c31d5198e
child 311804 e36c64327f7af7ad8dbc9433d780cdd67e9e14a0
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjyrans
bugs1249106
milestone48.0a1
Bug 1249106 - Fail tests when React propType errors are logged. r=jyrans MozReview-Commit-ID: HlTDuMhsyX6
devtools/client/framework/test/shared-head.js
--- a/devtools/client/framework/test/shared-head.js
+++ b/devtools/client/framework/test/shared-head.js
@@ -35,16 +35,36 @@ const URL_ROOT_SSL = CHROME_URL_ROOT.rep
                                              "https://example.com/");
 
 // All test are asynchronous
 waitForExplicitFinish();
 
 // Uncomment this pref to dump all devtools emitted events to the console.
 // Services.prefs.setBoolPref("devtools.dump.emit", true);
 
+/**
+ * Watch console messages for failed propType definitions in React components.
+ */
+const ConsoleObserver = {
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
+
+  observe: function(subject, topic, data) {
+    var message = subject.wrappedJSObject.arguments[0];
+
+    if (/Failed propType/.test(message)) {
+      ok(false, message);
+    }
+  }
+};
+
+Services.obs.addObserver(ConsoleObserver, "console-api-log-event", false);
+registerCleanupFunction(() => {
+  Services.obs.removeObserver(ConsoleObserver, "console-api-log-event");
+});
+
 function getFrameScript() {
   let mm = gBrowser.selectedBrowser.messageManager;
   let frameURL = "chrome://devtools/content/shared/frame-script-utils.js";
   mm.loadFrameScript(frameURL, false);
   SimpleTest.registerCleanupFunction(() => {
     mm = null;
   });
   return mm;