Bug 1382833 - Add regression test for CPOWs in the Browser Console;r=jimb
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 26 Jul 2017 11:22:59 -0700
changeset 419860 020aa7f3789c1d1330d1b24c9eaf06b70041ea12
parent 419859 90c5dd7af31d37a88d50240156c2e83aaea7fd76
child 419861 8a8f5e718ddd212b9a43291493f4e0496b6d33dd
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs1382833
milestone56.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 1382833 - Add regression test for CPOWs in the Browser Console;r=jimb MozReview-Commit-ID: 6OEnLdOpg4Q
devtools/client/webconsole/test/browser_console.js
--- a/devtools/client/webconsole/test/browser_console.js
+++ b/devtools/client/webconsole/test/browser_console.js
@@ -12,35 +12,35 @@ const TEST_URI = "http://example.com/bro
 const TEST_FILE = "chrome://mochitests/content/browser/devtools/client/" +
                   "webconsole/test/test-cu-reporterror.js";
 
 const TEST_XHR_ERROR_URI = `http://example.com/404.html?${Date.now()}`;
 
 const TEST_IMAGE = "http://example.com/browser/devtools/client/webconsole/" +
                    "test/test-image.png";
 
-"use strict";
+const {ObjectClient} = require("devtools/shared/client/main");
 
 add_task(function* () {
   yield loadTab(TEST_URI);
 
   let opened = waitForConsole();
 
   let hud = HUDService.getBrowserConsole();
   ok(!hud, "browser console is not open");
   info("wait for the browser console to open with ctrl-shift-j");
   EventUtils.synthesizeKey("j", { accelKey: true, shiftKey: true }, window);
 
   hud = yield opened;
   ok(hud, "browser console opened");
-
-  yield consoleOpened(hud);
+  yield testMessages(hud);
+  yield testCPOWInspection(hud);
 });
 
-function consoleOpened(hud) {
+function testMessages(hud) {
   hud.jsterm.clearOutput(true);
 
   expectUncaughtException();
   executeSoon(() => {
     foobarExceptionBug587757();
   });
 
   // Add a message from a chrome window.
@@ -154,16 +154,38 @@ function consoleOpened(hud) {
         category: CATEGORY_NETWORK,
         severity: SEVERITY_INFO,
         isXhr: true,
       },
     ],
   });
 }
 
+function* testCPOWInspection(hud) {
+  // Directly request evaluation to get an actor for the selected browser.
+  // Note that this doesn't actually render a message, and instead allows us
+  // us to assert that inspecting an object doesn't throw in the server.
+  // This would be done in a mochitest-chrome suite, but that doesn't run in
+  // e10s, so it's harder to get ahold of a CPOW.
+  let cpowEval = yield hud.jsterm.requestEvaluation("gBrowser.selectedBrowser");
+  info("Creating an ObjectClient with: " + cpowEval.result.actor);
+
+  let objectClient = new ObjectClient(hud.jsterm.hud.proxy.client, {
+    actor: cpowEval.result.actor,
+  });
+
+  // Before the fix for Bug 1382833, this wouldn't resolve due to a CPOW error
+  // in the ObjectActor.
+  let prototypeAndProperties = yield objectClient.getPrototypeAndProperties();
+
+  // Just a sanity check to make sure a valid packet came back
+  is(prototypeAndProperties.prototype.class, "XBL prototype JSClass",
+    "Looks like a valid response");
+}
+
 function waitForConsole() {
   let deferred = promise.defer();
 
   Services.obs.addObserver(function observer(aSubject) {
     Services.obs.removeObserver(observer, "web-console-created");
     aSubject.QueryInterface(Ci.nsISupportsString);
 
     let hud = HUDService.getBrowserConsole();