Bug 1258154 - Minor test cleanups for function inspection in console; r=jlongster
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 30 Mar 2016 18:30:06 -0700
changeset 291353 712a70746d183ee33e00bc06efd48de25b7332a7
parent 291352 85199a7b852fe6729f5708f56a31e6a368ddc009
child 291354 6d91363a7eac7343ded2da66d19b3ca01b6d0776
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlongster
bugs1258154
milestone48.0a1
Bug 1258154 - Minor test cleanups for function inspection in console; r=jlongster MozReview-Commit-ID: KkmC0uxHmPk
devtools/client/webconsole/test/browser_console_variables_view.js
devtools/client/webconsole/test/browser_webconsole_bug_1050691_click_function_to_source.js
--- a/devtools/client/webconsole/test/browser_console_variables_view.js
+++ b/devtools/client/webconsole/test/browser_console_variables_view.js
@@ -5,29 +5,28 @@
 
 // Check that variables view works as expected in the web console.
 
 "use strict";
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/test-eval-in-stackframe.html";
 
-var gWebConsole, gJSTerm, gVariablesView;
+var hud, gVariablesView;
 
-var hud;
+registerCleanupFunction(function() {
+  hud = gVariablesView = null;
+});
 
 add_task(function* () {
   yield loadTab(TEST_URI);
 
   hud = yield openConsole();
 
-  gWebConsole = hud;
-  gJSTerm = hud.jsterm;
-
-  let msg = yield gJSTerm.execute("(function foo(){})");
+  let msg = yield hud.jsterm.execute("(function foo(){})");
 
   ok(msg, "output message found");
   ok(msg.textContent.includes("function foo()"),
                               "message text check");
 
   executeSoon(() => {
     EventUtils.synthesizeMouse(msg.querySelector("a"), 2, 2, {}, hud.iframeWindow);
   });
@@ -37,29 +36,29 @@ add_task(function* () {
 
   yield findVariableViewProperties(varView, [{
     name: "name",
     value: "foo",
   }], { webconsole: hud });
 });
 
 add_task(function* () {
-  let msg = yield gJSTerm.execute("fooObj");
+  let msg = yield hud.jsterm.execute("fooObj");
 
   ok(msg, "output message found");
   ok(msg.textContent.includes('{ testProp: "testValue" }'),
                               "message text check");
 
   let anchor = msg.querySelector("a");
   ok(anchor, "object link found");
 
-  let fetched = gJSTerm.once("variablesview-fetched");
+  let fetched = hud.jsterm.once("variablesview-fetched");
 
   // executeSoon
-  EventUtils.synthesizeMouse(anchor, 2, 2, {}, gWebConsole.iframeWindow);
+  EventUtils.synthesizeMouse(anchor, 2, 2, {}, hud.iframeWindow);
 
   let view = yield fetched;
 
   let results = yield onFooObjFetch(view);
 
   let vView = yield onTestPropFound(results);
   let results2 = yield onFooObjFetchAfterUpdate(vView);
 
@@ -68,84 +67,82 @@ add_task(function* () {
 
   let vView3 = yield onRenamedTestPropFound(results3);
   let results4 = yield onPropUpdateError(vView3);
 
   yield onRenamedTestPropFoundAgain(results4);
 
   let prop = results4[0].matchedProp;
   yield testPropDelete(prop);
-
-  gWebConsole = gJSTerm = gVariablesView = null;
 });
 
 function onFooObjFetch(aVar) {
   gVariablesView = aVar._variablesView;
   ok(gVariablesView, "variables view object");
 
   return findVariableViewProperties(aVar, [
     { name: "testProp", value: "testValue" },
-  ], { webconsole: gWebConsole });
+  ], { webconsole: hud });
 }
 
 function onTestPropFound(aResults) {
   let prop = aResults[0].matchedProp;
   ok(prop, "matched the |testProp| property in the variables view");
 
   is("testValue", aResults[0].value,
      "|fooObj.testProp| value is correct");
 
   // Check that property value updates work and that jsterm functions can be
   // used.
   return updateVariablesViewProperty({
     property: prop,
     field: "value",
     string: "document.title + window.location + $('p')",
-    webconsole: gWebConsole
+    webconsole: hud
   });
 }
 
 function onFooObjFetchAfterUpdate(aVar) {
   info("onFooObjFetchAfterUpdate");
   let expectedValue = content.document.title + content.location +
                       "[object HTMLParagraphElement]";
 
   return findVariableViewProperties(aVar, [
     { name: "testProp", value: expectedValue },
-  ], { webconsole: gWebConsole });
+  ], { webconsole: hud });
 }
 
 function onUpdatedTestPropFound(aResults) {
   let prop = aResults[0].matchedProp;
   ok(prop, "matched the updated |testProp| property value");
 
   is(content.wrappedJSObject.fooObj.testProp, aResults[0].value,
      "|fooObj.testProp| value has been updated");
 
   // Check that property name updates work.
   return updateVariablesViewProperty({
     property: prop,
     field: "name",
     string: "testUpdatedProp",
-    webconsole: gWebConsole
+    webconsole: hud
   });
 }
 
 function* onFooObjFetchAfterPropRename(aVar) {
   info("onFooObjFetchAfterPropRename");
 
   let expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
     let para = content.wrappedJSObject.document.querySelector("p");
     return content.document.title + content.location + para;
   });
 
   // Check that the new value is in the variables view.
   return findVariableViewProperties(aVar, [
     { name: "testUpdatedProp", value: expectedValue },
-  ], { webconsole: gWebConsole });
+  ], { webconsole: hud });
 }
 
 function onRenamedTestPropFound(aResults) {
   let prop = aResults[0].matchedProp;
   ok(prop, "matched the renamed |testProp| property");
 
   ok(!content.wrappedJSObject.fooObj.testProp,
      "|fooObj.testProp| has been deleted");
@@ -153,40 +150,40 @@ function onRenamedTestPropFound(aResults
      "|fooObj.testUpdatedProp| is correct");
 
   // Check that property value updates that cause exceptions are reported in
   // the web console output.
   return updateVariablesViewProperty({
     property: prop,
     field: "value",
     string: "foobarzFailure()",
-    webconsole: gWebConsole
+    webconsole: hud
   });
 }
 
 function* onPropUpdateError(aVar) {
   info("onPropUpdateError");
 
   let expectedValue = yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function* () {
     let para = content.wrappedJSObject.document.querySelector("p");
     return content.document.title + content.location + para;
   });
 
   // Make sure the property did not change.
   return findVariableViewProperties(aVar, [
     { name: "testUpdatedProp", value: expectedValue },
-  ], { webconsole: gWebConsole });
+  ], { webconsole: hud });
 }
 
 function onRenamedTestPropFoundAgain(aResults) {
   let prop = aResults[0].matchedProp;
   ok(prop, "matched the renamed |testProp| property again");
 
   return waitForMessages({
-    webconsole: gWebConsole,
+    webconsole: hud,
     messages: [{
       name: "exception in property update reported in the web console output",
       text: "foobarzFailure",
       category: CATEGORY_OUTPUT,
       severity: SEVERITY_ERROR,
     }],
   });
 }
--- a/devtools/client/webconsole/test/browser_webconsole_bug_1050691_click_function_to_source.js
+++ b/devtools/client/webconsole/test/browser_webconsole_bug_1050691_click_function_to_source.js
@@ -32,17 +32,19 @@ function* testWithDebuggerOpen(hud, debu
 }
 
 function synthesizeClick(clickable, hud) {
   EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
 }
 
 var printFunction = Task.async(function* (hud) {
   hud.jsterm.clearOutput();
-  content.wrappedJSObject.foo();
+  ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
+    content.wrappedJSObject.foo();
+  });
   let [result] = yield waitForMessages({
     webconsole: hud,
     messages: [{
       category: CATEGORY_WEBDEV,
       severity: SEVERITY_LOG,
     }],
   });
   let msg = [...result.matched][0];