Bug 455611: tweak docshell/test/navigation/NavigationUtils.js so that it works in non-Firefox apps, r=bz

This commit is contained in:
Gavin Sharp
2008-09-19 11:44:33 -04:00
parent cedfc73f89
commit c8a019f022

View File

@@ -130,8 +130,9 @@ function isInaccessible(wnd, message) {
function xpcEnumerateContentWindows(callback) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var Ci = Components.interfaces;
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
.getService(Ci.nsIWindowWatcher);
var enumerator = ww.getWindowEnumerator();
var contentWindows = [];
@@ -139,10 +140,19 @@ function xpcEnumerateContentWindows(callback) {
while (enumerator.hasMoreElements()) {
var win = enumerator.getNext();
if (typeof ChromeWindow != "undefined" && win instanceof ChromeWindow) {
if (win.gBrowser) {
var tabs = win.gBrowser.browsers;
for (var i = 0; i < tabs.length; i++)
contentWindows.push(tabs[i].docShell.document.defaultView);
var docshellTreeNode = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeNode);
var childCount = docshellTreeNode.childCount;
for (var i = 0; i < childCount; ++i) {
var childTreeNode = docshellTreeNode.getChildAt(i);
// we're only interested in content docshells
if (childTreeNode.itemType != Ci.nsIDocShellTreeItem.typeContent)
continue;
var webNav = childTreeNode.QueryInterface(Ci.nsIWebNavigation);
contentWindows.push(webNav.document.defaultView);
}
} else {
contentWindows.push(win);