bug 1523104: remote: display error message and a stack in mochitest; r=ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Fri, 22 Feb 2019 04:15:58 -0800
changeset 521104 e3b2b601748c
parent 521103 cce704488a62
child 521105 c26cc4c7f021
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1523104
milestone67.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 1523104: remote: display error message and a stack in mochitest; r=ato
remote/test/browser/browser_cdp.js
--- a/remote/test/browser/browser_cdp.js
+++ b/remote/test/browser/browser_cdp.js
@@ -5,16 +5,30 @@
 
 /* global getCDP */
 
 // Test very basic CDP features.
 
 const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
 
 add_task(async function() {
+  try {
+    await testCDP();
+  } catch (e) {
+    // Display better error message with the server side stacktrace
+    // if an error happened on the server side:
+    if (e.response) {
+      throw new Error("CDP Exception:\n" + e.response + "\n");
+    } else {
+      throw e;
+    }
+  }
+});
+
+async function testCDP() {
   // Open a test page, to prevent debugging the random default page
   const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URI);
 
   // Start the CDP server
   const RemoteAgent = Cc["@mozilla.org/remote/agent"].getService(Ci.nsISupports).wrappedJSObject;
   RemoteAgent.tabs.start();
   RemoteAgent.listen(Services.io.newURI("http://localhost:9222"));
 
@@ -57,9 +71,9 @@ add_task(async function() {
   ok(true, "The new page is done loading");
 
   await client.close();
   ok(true, "The client is closed");
 
   BrowserTestUtils.removeTab(tab);
 
   await RemoteAgent.close();
-});
+}