Bug 778732 - Change JSTerm's $ helper function from getElementById to querySelector; r=msucan
authorRob Campbell <rcampbell@mozilla.com>
Thu, 02 Aug 2012 12:53:00 +0300
changeset 101315 6ad33e8a2fb8
parent 101314 45146b1667de
child 101316 98216d5724de
push id23229
push userrcampbell@mozilla.com
push date2012-08-03 21:14 +0000
Treeherderresults
reviewersmsucan
bugs778732
milestone17.0a1
Bug 778732 - Change JSTerm's $ helper function from getElementById to querySelector; r=msucan
browser/devtools/webconsole/HUDService-content.js
browser/devtools/webconsole/test/browser_webconsole_jsterm.js
--- a/browser/devtools/webconsole/HUDService-content.js
+++ b/browser/devtools/webconsole/HUDService-content.js
@@ -518,21 +518,21 @@ let Manager = {
 function JSTermHelper(aJSTerm)
 {
   /**
    * Find a node by ID.
    *
    * @param string aId
    *        The ID of the element you want.
    * @return nsIDOMNode or null
-   *         The result of calling document.getElementById(aId).
+   *         The result of calling document.querySelector(aSelector).
    */
-  aJSTerm.sandbox.$ = function JSTH_$(aId)
+  aJSTerm.sandbox.$ = function JSTH_$(aSelector)
   {
-    return aJSTerm.window.document.getElementById(aId);
+    return aJSTerm.window.document.querySelector(aSelector);
   };
 
   /**
    * Find the nodes matching a CSS selector.
    *
    * @param string aSelector
    *        A string that is passed to window.document.querySelectorAll.
    * @return nsIDOMNodeList
--- a/browser/devtools/webconsole/test/browser_webconsole_jsterm.js
+++ b/browser/devtools/webconsole/test/browser_webconsole_jsterm.js
@@ -47,17 +47,17 @@ function checkResult(msg, desc, lines) {
   });
 }
 
 function testJSTerm(hud)
 {
   jsterm = hud.jsterm;
 
   jsterm.clearOutput();
-  jsterm.execute("'id=' + $('header').getAttribute('id')");
+  jsterm.execute("'id=' + $('#header').getAttribute('id')");
   checkResult('"id=header"', "$() worked", 1);
   yield;
 
   jsterm.clearOutput();
   jsterm.execute("headerQuery = $$('h1')");
   jsterm.execute("'length=' + headerQuery.length");
   checkResult('"length=1"', "$$() worked", 2);
   yield;