Bug 458579 - Feed tab missing in page info; r=gavin.sharp
authorNatch <highmind63@gmail.com>
Wed, 29 Oct 2008 04:37:44 +0100
changeset 21034 5373680e5d49f189960bf521b629934e6b3b229a
parent 21033 cb300cc32f233c2042123b800c577683be811896
child 21035 ed7f8c9bd8194701e9fe8db8c3bb337204c1d40a
push idunknown
push userunknown
push dateunknown
reviewersgavin
bugs458579
milestone1.9.1b2pre
Bug 458579 - Feed tab missing in page info; r=gavin.sharp
browser/base/content/browser.js
browser/base/content/pageinfo/pageInfo.js
browser/base/content/test/Makefile.in
browser/base/content/test/browser_feed_tab.js
browser/base/content/test/feed_tab.html
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1935,21 +1935,21 @@ function BrowserViewSourceOfDocument(aDo
   top.gViewSourceUtils.viewSource(webNav.currentURI.spec, pageCookie, aDocument);
 }
 
 // doc - document to use for source, or null for this window's document
 // initialTab - name of the initial tab to display, or null for the first tab
 function BrowserPageInfo(doc, initialTab)
 {
   var args = {doc: doc, initialTab: initialTab};
-  toOpenDialogByTypeAndUrl("Browser:page-info",
-                           doc ? doc.location : window.content.document.location,
-                           "chrome://browser/content/pageinfo/pageInfo.xul",
-                           "chrome,toolbar,dialog=no,resizable",
-                           args);
+  return toOpenDialogByTypeAndUrl("Browser:page-info",
+                                  doc ? doc.location : window.content.document.location,
+                                  "chrome://browser/content/pageinfo/pageInfo.xul",
+                                  "chrome,toolbar,dialog=no,resizable",
+                                  args);
 }
 
 #ifdef DEBUG
 // Initialize the LeakDetector class.
 function LeakDetector(verbose)
 {
   this.verbose = verbose;
 }
@@ -3060,19 +3060,19 @@ function toOpenDialogByTypeAndUrl(inType
     if (currentWindow.document.documentElement.getAttribute("relatedUrl") == relatedUrl) {
     	currentWindow.focus();
     	return;
     }
   }
 
   // We didn't find a matching window, so open a new one.
   if (features)
-    window.openDialog(windowUri, "_blank", features, extraArgument);
-  else
-    window.openDialog(windowUri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", extraArgument);
+    return window.openDialog(windowUri, "_blank", features, extraArgument);
+
+  return window.openDialog(windowUri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", extraArgument);
 }
 
 function OpenBrowserWindow()
 {
   var charsetArg = new String();
   var handler = Components.classes["@mozilla.org/browser/clh;1"]
                           .getService(Components.interfaces.nsIBrowserHandler);
   var defaultArgs = handler.defaultArgs;
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -308,16 +308,19 @@ function onLoadPageInfo()
   if ("arguments" in window && window.arguments.length >= 1 &&
        window.arguments[0] && window.arguments[0].initialTab)
     initialTab = window.arguments[0].initialTab;
   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);
 }
 
 function loadPageInfo()
 {
   var titleFormat = gWindow != gWindow.top ? "pageInfo.frame.title"
                                            : "pageInfo.page.title";
   document.title = gBundle.getFormattedString(titleFormat, [gDocument.location]);
 
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -65,16 +65,18 @@ include $(topsrcdir)/config/rules.mk
                  discovery.html \
                  moz.png \
                  browser_getshortcutoruri.js \
                  browser_page_style_menu.js \
                  page_style_sample.html \
                  browser_ctrlTab.js \
                  browser_selectTabAtIndex.js \
                  browser_gestureSupport.js \
+                 browser_feed_tab.js \
+                 feed_tab.html \
     $(NULL)
 
 ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
 _BROWSER_FILES += browser_customize.js \
     $(NULL)
 endif
 
 libs:: $(_TEST_FILES)
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_feed_tab.js
@@ -0,0 +1,54 @@
+function test() {
+  waitForExplicitFinish();
+
+  var pageInfo, obs;
+  var gTestPage = gBrowser.addTab();
+  gBrowser.selectedTab = gTestPage;
+  gTestPage.linkedBrowser.addEventListener("load", handleLoad, true);
+  content.location =
+    "http://localhost:8888/browser/browser/base/content/test/feed_tab.html";
+  gTestPage.focus();
+
+  var observer = {
+    observe: function(win, topic, data) {
+      if (topic != "page-info-dialog-loaded")
+        return;
+
+      obs.removeObserver(observer, "page-info-dialog-loaded");
+      handlePageInfo();
+    }
+  };
+
+  function handleLoad() {
+
+    pageInfo = BrowserPageInfo();
+    obs = Components.classes["@mozilla.org/observer-service;1"]
+            .getService(Components.interfaces.nsIObserverService);
+    obs.addObserver(observer, "page-info-dialog-loaded", false);
+  }
+
+  function handlePageInfo() {
+    function $(aId) { return pageInfo.document.getElementById(aId) };
+    var feedTab = $("feedTab");
+    var feedListbox = $("feedListbox");
+
+    ok(feedListbox, "Feed list is null (feeds tab is broken)");
+
+    var feedRowsNum = feedListbox.getRowCount();
+
+    ok(feedRowsNum == 3, "Number of feeds listed: " +
+                         feedRowsNum + ", should be 3");
+
+
+    for (var i = 0; i < feedRowsNum; i++) {
+      let feedItem = feedListbox.getItemAtIndex(i);
+      ok(feedItem.getAttribute("name") == (i+1), 
+         "Name given: " + feedItem.getAttribute("name") + ", should be " + (i+1));
+    }
+
+    pageInfo.close();
+    gTestPage.focus();
+    gBrowser.removeCurrentTab();
+    finish();
+  }
+}
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/feed_tab.html
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=458579
+-->
+  <head>
+    <title>Test for page info feeds tab</title>
+
+    <!-- Straight up standard -->
+    <link rel="alternate" type="application/atom+xml" title="1" href="/1.atom" />
+    <link rel="alternate" type="application/rss+xml" title="2" href="/2.rss" />
+    <link rel="feed" title="3" href="/3.xml" />
+
+  </head>
+  <body>
+  </body>
+</html>