Bug 1573829 - Port |Bug 524092 - "View Image Info" command is not carried out if "Page Info" window is already opened| to SeaMonkey. r=frg a=frg
authorIan Neal <iann_cvs@blueyonder.co.uk>
Fri, 23 Aug 2019 01:16:14 +0200
changeset 32282 4c7254e896da4a576e86382325eb5e58f897ce00
parent 32281 e7a66da1bb691167abcda43af1d35ad75796541b
child 32283 75fdb3e8faeddcaee43ecf5a013d67b5bc7647fc
push id211
push userfrgrahl@gmx.net
push dateThu, 22 Aug 2019 23:17:49 +0000
treeherdercomm-esr60@75fdb3e8faed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg, frg
bugs1573829, 524092
Bug 1573829 - Port |Bug 524092 - "View Image Info" command is not carried out if "Page Info" window is already opened| to SeaMonkey. r=frg a=frg
suite/browser/pageinfo/pageInfo.js
--- a/suite/browser/pageinfo/pageInfo.js
+++ b/suite/browser/pageinfo/pageInfo.js
@@ -299,51 +299,35 @@ function onLoadPageInfo()
                   "linkStylesheet", "linkRev", "linkX", "linkScript",
                   "linkScriptInline", "yes"];
   strNames.forEach(function(n) { gStrings[n] = gBundle.getString(n); });
 
   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];
+  if (!args || !args.doc) {
+    gWindow = window.opener.gBrowser.selectedBrowser.contentWindowAsCPOW;
     gDocument = gWindow.document;
   }
 
   // init views
   function initView(treeid, view)
   {
     document.getElementById(treeid).view = view;
   }
 
   initView("imagetree", gImageView);
   initView("formtree", gFormView);
   initView("formpreview", gFieldView);
   initView("linktree", gLinkView);
   initPermission();
 
-  // set gImageElement if present
-  if ("arguments" in window && window.arguments.length >= 1 &&
-      window.arguments[0].imageElement)
-    gImageElement = window.arguments[0].imageElement;
-
-  // build the content
-  loadPageInfo();
-
   /* Select the requested tab, if the name is specified */
-  var initialTab = (args && args.initialTab) || "generalTab";
-  showTab(initialTab);
+  loadTab(args);
   Services.obs.notifyObservers(window, "page-info-dialog-loaded");
 }
 
 function loadPageInfo()
 {
   var titleFormat = gWindow != gWindow.top ? "pageInfo.frame.title"
                                            : "pageInfo.page.title";
   document.title = gBundle.getFormattedString(titleFormat, [gDocument.location]);
@@ -382,26 +366,19 @@ function resetPageInfo(args)
   /* Reset Feeds Tab */
   var feedListbox = document.getElementById("feedListbox");
   while (feedListbox.hasChildNodes())
     feedListbox.lastChild.remove();
 
   /* Call registered overlay reset functions */
   onResetRegistry.forEach(function(func) { func(); });
 
-  if (args && args.doc) {
-    gDocument = args.doc;
-    gWindow = gDocument.defaultView;
-  }
+  /* Rebuild the data */
+  loadTab(args);
 
-  /* Rebuild the data */
-  loadPageInfo();
-
-  if (args && args.initialTab)
-    showTab(args.initialTab);
   Services.obs.notifyObservers(window, "page-info-dialog-reset");
 }
 
 function onUnloadPageInfo()
 {
   // Remove the observer, only if there is at least 1 image.
   if (gImageView.data.length != 0) {
     Services.obs.removeObserver(imagePermissionObserver, "perm-changed");
@@ -433,16 +410,34 @@ function showTab(id)
   var tabbox = document.getElementById("tabbox");
   var selectedTab = document.getElementById(id) ||
                     document.getElementById(id + "Tab") || // Firefox compatibility sillyness
                     document.getElementById("generalTab");
   tabbox.selectedTab = selectedTab;
   selectedTab.focus();
 }
 
+function loadTab(args)
+{
+  if (args && args.doc) {
+    gDocument = args.doc;
+    gWindow = gDocument.defaultView;
+  }
+
+  // set gImageElement if present
+  gImageElement = args && args.imageElement;
+
+  /* Load the page info */
+  loadPageInfo();
+
+  /* Select the requested tab, if the name is specified */
+  var initialTab = (args && args.initialTab) || "generalTab";
+  showTab(initialTab);
+}
+
 function onClickMore()
 {
   showTab("securityTab");
 }
 
 function openCacheEntry(key, cb)
 {
   var checkCacheListener = {