Bug 423833 - "Show Only This Frame code uses about: url for error pages, instead of original site url" [p=johnath@mozilla.com (Johnathan Nightingale [johnath]) r=Mano a=blocking-firefox3+]
authorreed@reedloden.com
Tue, 08 Apr 2008 11:45:08 -0700
changeset 14065 7ab683b5363d0e6896e464ef594f3156d1d3663f
parent 14064 b636b03c0c3e3a8ad5b8007976e4b9f87c52cba0
child 14066 739312bd89ae9e196f0bbf169868eee291da1c11
push id11
push userbsmedberg@mozilla.com
push dateTue, 15 Apr 2008 18:11:53 +0000
treeherdermozilla-central@40e4b99f0dea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMano, blocking-firefox3
bugs423833
milestone1.9pre
Bug 423833 - "Show Only This Frame code uses about: url for error pages, instead of original site url" [p=johnath@mozilla.com (Johnathan Nightingale [johnath]) r=Mano a=blocking-firefox3+]
browser/base/content/nsContextMenu.js
browser/base/content/test/Makefile.in
browser/base/content/test/browser_bug423833.js
browser/base/content/utilityOverlay.js
--- a/browser/base/content/nsContextMenu.js
+++ b/browser/base/content/nsContextMenu.js
@@ -649,42 +649,42 @@ nsContextMenu.prototype = {
   // Open linked-to URL in a new tab.
   openLinkInTab: function() {
     openNewTabWith(this.linkURL, this.target.ownerDocument, null, null, false);
   },
 
   // Open frame in a new tab.
   openFrameInTab: function() {
     var doc = this.target.ownerDocument;
-    var frameURL = doc.documentURIObject.spec;
+    var frameURL = doc.location.href;
     var referrer = doc.referrer;
 
-    openNewTabWith(frameURL, null, null, null, false,
-                   referrer ? makeURI(referrer) : null);
+    return openNewTabWith(frameURL, null, null, null, false,
+                          referrer ? makeURI(referrer) : null);
   },
 
   // Reload clicked-in frame.
   reloadFrame: function() {
     this.target.ownerDocument.location.reload();
   },
 
   // Open clicked-in frame in its own window.
   openFrame: function() {
     var doc = this.target.ownerDocument;
-    var frameURL = doc.documentURIObject.spec;
+    var frameURL = doc.location.href;
     var referrer = doc.referrer;
 
-    openNewWindowWith(frameURL, null, null, false,
-                      referrer ? makeURI(referrer) : null);
+    return openNewWindowWith(frameURL, null, null, false,
+                             referrer ? makeURI(referrer) : null);
   },
 
   // Open clicked-in frame in the same window.
   showOnlyThisFrame: function() {
     var doc = this.target.ownerDocument;
-    var frameURL = doc.documentURIObject.spec;
+    var frameURL = doc.location.href;
 
     urlSecurityCheck(frameURL, this.browser.contentPrincipal,
                      Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
     var referrer = doc.referrer;
     this.browser.loadURI(frameURL, referrer ? makeURI(referrer) : null);
   },
 
   // View Partial Source
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -49,16 +49,17 @@ include $(topsrcdir)/config/rules.mk
 		bug395533-data.txt \
 		$(NULL)
 
 _BROWSER_FILES = browser_bug321000.js \
                  browser_bug405137.js \
                  browser_bug409481.js \
                  browser_autodiscovery.js \
                  browser_bug420160.js \
+                 browser_bug423833.js \
                  autodiscovery.html \
                  moz.png \
                  browser_getshortcutoruri.js \
     $(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
 
--- a/browser/base/content/test/browser_bug423833.js
+++ b/browser/base/content/test/browser_bug423833.js
@@ -22,23 +22,23 @@ function test() {
   var newTab = gBrowser.addTab();
   gBrowser.selectedTab = newTab;
   newBrowser = gBrowser.getBrowserForTab(newTab);
   
   newBrowser.addEventListener("load", test1Setup, true);
   newBrowser.contentWindow.location = testPage;
 }
 
-var loadCount = 0;
 function test1Setup() {
-  if(!loadCount++)
-    // Wait for both frames to load
+  
+  if(newBrowser.contentWindow.frames.length < 2 ||
+     newBrowser.contentWindow.frames[1].document.location != invalidPage)
+    // The error frame hasn't loaded yet
     return;
   
-  loadCount = 0;
   newBrowser.removeEventListener("load", test1Setup, true);
 
   var badFrame = newBrowser.contentWindow.frames[1];
   document.popupNode = badFrame.document.firstChild;
   
   var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
   var contextMenu = new nsContextMenu(contentAreaContextMenu, gBrowser);
 
@@ -60,21 +60,21 @@ function testShowOnlyThisFrame() {
   is(newBrowser.contentDocument.location.href, invalidPage, "Should navigate to page url, not about:neterror");
   
   // Go back to the frames page
   gBrowser.addEventListener("load", test2Setup, true);
   newBrowser.contentWindow.location = testPage;
 }
 
 function test2Setup() {
-  if(!loadCount++)
-    // Wait for both frames to load
+  if(newBrowser.contentWindow.frames.length < 2 ||
+     newBrowser.contentWindow.frames[1].document.location != invalidPage)
+    // The error frame hasn't loaded yet
     return;
   
-  loadCount = 0;
   gBrowser.removeEventListener("load", test2Setup, true);
   
   // Now let's do the whole thing again, but this time for "Open frame in new tab"
   newBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
   var badFrame = newBrowser.contentWindow.frames[1];
   
   document.popupNode = badFrame.document.firstChild;
   
--- a/browser/base/content/utilityOverlay.js
+++ b/browser/base/content/utilityOverlay.js
@@ -573,18 +573,18 @@ function openNewTabWith(aURL, aDocument,
   var wintype = document.documentElement.getAttribute("windowtype");
   var originCharset;
   if (wintype == "navigator:browser")
     originCharset = window.content.document.characterSet;
 
   // open link in new tab
   var referrerURI = aDocument ? aDocument.documentURIObject : aReferrer;
   var browser = top.document.getElementById("content");
-  browser.loadOneTab(aURL, referrerURI, originCharset, aPostData,
-                     loadInBackground, aAllowThirdPartyFixup || false);
+  return browser.loadOneTab(aURL, referrerURI, originCharset, aPostData,
+                            loadInBackground, aAllowThirdPartyFixup || false);
 }
 
 function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup,
                            aReferrer)
 {
   if (aDocument)
     urlSecurityCheck(aURL, aDocument.nodePrincipal);
 
@@ -593,19 +593,19 @@ function openNewWindowWith(aURL, aDocume
   // setting from the current document and use it to initialize the new browser
   // window...
   var charsetArg = null;
   var wintype = document.documentElement.getAttribute("windowtype");
   if (wintype == "navigator:browser")
     charsetArg = "charset=" + window.content.document.characterSet;
 
   var referrerURI = aDocument ? aDocument.documentURIObject : aReferrer;
-  window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
-                    aURL, charsetArg, referrerURI, aPostData,
-                    aAllowThirdPartyFixup);
+  return window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
+                           aURL, charsetArg, referrerURI, aPostData,
+                           aAllowThirdPartyFixup);
 }
 
 /**
  * isValidFeed: checks whether the given data represents a valid feed.
  *
  * @param  aData
  *         An object representing a feed with title, href and type.
  * @param  aPrincipal