Bug 525190 - Refactor the way pageInfo.js handles arguments. r=db48x
authorDão Gottwald <dao@mozilla.com>
Sat, 31 Oct 2009 01:50:57 +0100
changeset 34431 61d1e7b9f1f521b13c7376adaaf39d4d71a519fb
parent 34430 d1c5512a35868af10b893d6d84dd366c55e2a03e
child 34432 a0e997531921b6478c2b26b26c3b08a167a269d2
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdb48x
bugs525190
milestone1.9.3a1pre
Bug 525190 - Refactor the way pageInfo.js handles arguments. r=db48x
browser/base/content/pageinfo/pageInfo.js
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -274,46 +274,44 @@ function onLoadPageInfo()
   gStrings.notSet = gBundle.getString("notset");
   gStrings.mediaImg = gBundle.getString("mediaImg");
   gStrings.mediaBGImg = gBundle.getString("mediaBGImg");
   gStrings.mediaObject = gBundle.getString("mediaObject");
   gStrings.mediaEmbed = gBundle.getString("mediaEmbed");
   gStrings.mediaLink = gBundle.getString("mediaLink");
   gStrings.mediaInput = gBundle.getString("mediaInput");
 
-  if ("arguments" in window && window.arguments.length >= 1 &&
-       window.arguments[0] && window.arguments[0].doc) {
-    gDocument = window.arguments[0].doc;
+  var args = "arguments" in window &&
+             window.arguments.length >= 1 &&
+             window.arguments[0];
+
+  if (args && args.doc) {
+    gDocument = args.doc;
     gWindow = gDocument.defaultView;
   }
   else {
     if ("gBrowser" in window.opener)
       gWindow = window.opener.gBrowser.contentWindow;
     else
       gWindow = window.opener.frames[0];
     gDocument = gWindow.document;
   }
 
   // init media view
   var imageTree = document.getElementById("imagetree");
   imageTree.view = gImageView;
 
   // set gImageElement if present
-  if ("arguments" in window && window.arguments.length >= 1 &&
-      window.arguments[0].imageElement)
-    gImageElement = window.arguments[0].imageElement;
+  gImageElement = args && args.imageElement;
 
   // build the content
   loadPageInfo();
 
   /* Select the requested tab, if the name is specified */
-  var initialTab = "generalTab";
-  if ("arguments" in window && window.arguments.length >= 1 &&
-       window.arguments[0] && window.arguments[0].initialTab)
-    initialTab = window.arguments[0].initialTab;
+  var initialTab = (args && args.initialTab) || "generalTab";
   var radioGroup = document.getElementById("viewGroup");
   initialTab = document.getElementById(initialTab) || document.getElementById("generalTab");
   radioGroup.selectedItem = initialTab;
   radioGroup.selectedItem.doCommand();
   radioGroup.focus();
   Components.classes["@mozilla.org/observer-service;1"]
             .getService(Components.interfaces.nsIObserverService)
             .notifyObservers(window, "page-info-dialog-loaded", null);