Bug 669670 - Remove workaround for getOwnPropertyDescriptor from chrome code; r=mihai.sucan,dtownsend
authorPanos Astithas <past@mozilla.com>
Fri, 08 Jul 2011 12:21:45 +0300
changeset 72430 bad86971801932432099bcbe8788b5e1eaa2e71a
parent 72429 59ae546b1da749cdecbdf15ac7e31bbe39f87fbd
child 72431 3c57112a6a6fe7442fe27761c447cd0d782c2d1e
push id20
push usermihai.sucan@gmail.com
push dateFri, 08 Jul 2011 09:29:23 +0000
treeherderfx-team@bad869718019 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmihai.sucan, dtownsend
bugs669670
milestone8.0a1
Bug 669670 - Remove workaround for getOwnPropertyDescriptor from chrome code; r=mihai.sucan,dtownsend
toolkit/components/console/hudservice/HUDService.jsm
toolkit/components/console/hudservice/PropertyPanel.jsm
--- a/toolkit/components/console/hudservice/HUDService.jsm
+++ b/toolkit/components/console/hudservice/HUDService.jsm
@@ -4032,18 +4032,16 @@ function findCompletionBeginning(aStr)
  *              matches: [ string, string, string ],
  *              matchProp: Last part of the inputValue that was used to find
  *                         the matches-strings.
  *            }
  */
 function JSPropertyProvider(aScope, aInputValue)
 {
   let obj = unwrap(aScope);
-  // Store the scope object, since obj will be modified later on.
-  let win = obj;
 
   // Analyse the aInputValue and find the beginning of the last part that
   // should be completed.
   let beginning = findCompletionBeginning(aInputValue);
 
   // There was an error analysing the string.
   if (beginning.err) {
     return null;
@@ -4072,17 +4070,17 @@ function JSPropertyProvider(aScope, aInp
       // If obj is undefined or null, then there is no chance to run completion
       // on it. Exit here.
       if (typeof obj === "undefined" || obj === null) {
         return null;
       }
 
       // Check if prop is a getter function on obj. Functions can change other
       // stuff so we can't execute them to get the next object. Stop here.
-      if (isNonNativeGetter(win, obj, prop)) {
+      if (isNonNativeGetter(obj, prop)) {
         return null;
       }
       try {
         obj = obj[prop];
       }
       catch (ex) {
         return null;
       }
--- a/toolkit/components/console/hudservice/PropertyPanel.jsm
+++ b/toolkit/components/console/hudservice/PropertyPanel.jsm
@@ -158,36 +158,33 @@ function isNativeFunction(aFunction)
 {
   return typeof aFunction == "function" && !("prototype" in aFunction);
 }
 
 /**
  * Tells if the given property of the provided object is a non-native getter or
  * not.
  *
- * @param object aScope
- *        Scope to use for the check.
- *
  * @param object aObject
  *        The object that contains the property.
  *
  * @param string aProp
  *        The property you want to check if it is a getter or not.
  *
  * @return boolean
  *         True if the given property is a getter, false otherwise.
  */
-function isNonNativeGetter(aScope, aObject, aProp) {
+function isNonNativeGetter(aObject, aProp) {
   if (typeof aObject != "object") {
     return false;
   }
   let desc;
   while (aObject) {
     try {
-      if (desc = aScope.Object.getOwnPropertyDescriptor(aObject, aProp)) {
+      if (desc = Object.getOwnPropertyDescriptor(aObject, aProp)) {
         break;
       }
     }
     catch (ex) {
       // Native getters throw here. See bug 520882.
       if (ex.name == "NS_ERROR_XPC_BAD_CONVERT_JS" ||
           ex.name == "NS_ERROR_XPC_BAD_OP_ON_WN_PROTO") {
         return false;
@@ -218,21 +215,18 @@ function namesAndValuesOf(aObject)
   let isDOMDocument = aObject instanceof Ci.nsIDOMDocument;
 
   for (var propName in aObject) {
     // See bug 632275: skip deprecated width and height properties.
     if (isDOMDocument && (propName == "width" || propName == "height")) {
       continue;
     }
 
-    // Also skip non-native getters. Pass the content window so that
-    // getOwnPropertyDescriptor can work later on.
-    let chromeWindow = Services.wm.getMostRecentWindow("navigator:browser");
-    let contentWindow = chromeWindow.gBrowser.selectedBrowser.contentWindow;
-    if (isNonNativeGetter(contentWindow.wrappedJSObject, aObject, propName)) {
+    // Also skip non-native getters.
+    if (isNonNativeGetter(aObject, propName)) {
       value = ""; // Value is never displayed.
       presentable = {type: TYPE_OTHER, display: "Getter"};
     }
     else {
       try {
         value = aObject[propName];
         presentable = presentableValueFor(value);
       }