From ac8ac5642362ce3247b2f4bc7047f66f26a76897 Mon Sep 17 00:00:00 2001 From: Natch Date: Wed, 29 Oct 2008 04:37:44 +0100 Subject: [PATCH] Bug 458579 - Feed tab missing in page info; r=gavin.sharp --- browser/base/content/browser.js | 16 +++--- browser/base/content/pageinfo/pageInfo.js | 3 ++ browser/base/content/test/Makefile.in | 2 + browser/base/content/test/browser_feed_tab.js | 54 +++++++++++++++++++ browser/base/content/test/feed_tab.html | 17 ++++++ 5 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 browser/base/content/test/browser_feed_tab.js create mode 100644 browser/base/content/test/feed_tab.html diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 78661c750ee..6b6404f55c3 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1940,11 +1940,11 @@ function BrowserViewSourceOfDocument(aDocument) 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 @@ -3065,9 +3065,9 @@ function toOpenDialogByTypeAndUrl(inType, relatedUrl, windowUri, features, extra // 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() diff --git a/browser/base/content/pageinfo/pageInfo.js b/browser/base/content/pageinfo/pageInfo.js index f8ef5f448d9..e9b74697fe6 100644 --- a/browser/base/content/pageinfo/pageInfo.js +++ b/browser/base/content/pageinfo/pageInfo.js @@ -313,6 +313,9 @@ function onLoadPageInfo() 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() diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index 4a75b5c9c00..d30b8e1b548 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -70,6 +70,8 @@ _BROWSER_FILES = browser_bug321000.js \ browser_ctrlTab.js \ browser_selectTabAtIndex.js \ browser_gestureSupport.js \ + browser_feed_tab.js \ + feed_tab.html \ $(NULL) ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) diff --git a/browser/base/content/test/browser_feed_tab.js b/browser/base/content/test/browser_feed_tab.js new file mode 100644 index 00000000000..bd201ea7a9e --- /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(); + } +} diff --git a/browser/base/content/test/feed_tab.html b/browser/base/content/test/feed_tab.html new file mode 100644 index 00000000000..50903f48b61 --- /dev/null +++ b/browser/base/content/test/feed_tab.html @@ -0,0 +1,17 @@ + + + + + Test for page info feeds tab + + + + + + + + + +