Bug 464222 - Get relative links to resolve in parser view selection. r=dolske
authorJames Kitchener <jkitch.bug@gmail.com>
Thu, 20 Feb 2014 08:43:54 -0500
changeset 169666 3ad497d0c250107285f2032000524a8afcbea7b8
parent 169665 08ed6226573d05aba4148a9359cca20c3a8e32e4
child 169667 776b40c41bd9681e61da13416552b4ff88b1c1d4
push id40022
push userryanvm@gmail.com
push dateThu, 20 Feb 2014 13:43:46 +0000
treeherdermozilla-inbound@739971fe2acf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs464222
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 464222 - Get relative links to resolve in parser view selection. r=dolske
toolkit/components/viewsource/content/viewPartialSource.js
toolkit/components/viewsource/test/browser/browser.ini
toolkit/components/viewsource/test/browser/browser_bug464222.js
toolkit/components/viewsource/test/browser/file_bug464222.html
--- a/toolkit/components/viewsource/content/viewPartialSource.js
+++ b/toolkit/components/viewsource/content/viewPartialSource.js
@@ -168,21 +168,22 @@ function viewPartialSourceForSelection(s
   // the load is aynchronous and so we will wait until the view-source DOM is done
   // before drawing the selection.
   if (canDrawSelection) {
     window.document.getElementById("content").addEventListener("load", drawSelection, true);
   }
 
   // all our content is held by the data:URI and URIs are internally stored as utf-8 (see nsIURI.idl)
   var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
-  getWebNavigation().loadURI((isHTML ?
-                              "view-source:data:text/html;charset=utf-8," :
-                              "view-source:data:application/xml;charset=utf-8,")
-                             + encodeURIComponent(tmpNode.innerHTML),
-                             loadFlags, null, null, null);
+  getWebNavigation().loadURIWithBase((isHTML ?
+                                      "view-source:data:text/html;charset=utf-8," :
+                                      "view-source:data:application/xml;charset=utf-8,")
+                                     + encodeURIComponent(tmpNode.innerHTML),
+                                     loadFlags, null, null, null,
+                                     Services.io.newURI(doc.baseURI, null, null));
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // helper to get a path like FIXptr, but with an array instead of the "tumbler" notation
 // see FIXptr: http://lists.w3.org/Archives/Public/www-xml-linking-comments/2001AprJun/att-0074/01-NOTE-FIXptr-20010425.htm
 function getPath(ancestor, node)
 {
   var n = node;
--- a/toolkit/components/viewsource/test/browser/browser.ini
+++ b/toolkit/components/viewsource/test/browser/browser.ini
@@ -1,9 +1,11 @@
 [DEFAULT]
 support-files = head.js
+  file_bug464222.html
 
+[browser_bug464222.js]
 [browser_bug699356.js]
 [browser_bug713810.js]
 [browser_contextmenu.js]
 [browser_gotoline.js]
 [browser_viewsourceprefs.js]
 [browser_viewsourceprefs_nonhtml.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/components/viewsource/test/browser/browser_bug464222.js
@@ -0,0 +1,14 @@
+const source = "http://example.com/browser/toolkit/components/viewsource/test/browser/file_bug464222.html";
+
+function test() {
+  waitForExplicitFinish();
+  testSelection();
+}
+
+function testSelection() {
+  openDocumentSelect(source, "a", function(aWindow) {
+    let aTags = aWindow.gBrowser.contentDocument.querySelectorAll("a[href]");
+    is(aTags[0].href, "view-source:" + source, "Relative links broken?");
+    closeViewSourceWindow(aWindow, finish);
+  });
+}
new file mode 100644
--- /dev/null
+++ b/toolkit/components/viewsource/test/browser/file_bug464222.html
@@ -0,0 +1,1 @@
+<a href="file_bug464222.html">I'm a link</a>
\ No newline at end of file