Bug 1514993 - Resolve overlays' script/stylesheet references relative to the overlay; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 31 Dec 2018 12:17:45 +1300
changeset 34086 92f2f9d3268cf833b2860a0cdf5a443e6e5562d8
parent 34085 1025d59f72597772038884ab12a4e1fc648213c5
child 34087 992cb1d8b84f15a340dc72c3a7f61eb4da31e945
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersFallen
bugs1514993
Bug 1514993 - Resolve overlays' script/stylesheet references relative to the overlay; r=Fallen
common/src/Overlays.jsm
--- a/common/src/Overlays.jsm
+++ b/common/src/Overlays.jsm
@@ -114,17 +114,17 @@ class Overlays {
       }
 
       // Load css processing instructions from the overlay
       let stylesheets = doc.evaluate("/processing-instruction('xml-stylesheet')", doc, null, 7, null);
       for (let i = 0, len = stylesheets.snapshotLength; i < len; ++i) {
         let node = stylesheets.snapshotItem(i);
         let match = node.nodeValue.match(/href=["']([^"']*)["']/);
         if (match) {
-          unloadedSheets.push(match[1]);
+          unloadedSheets.push(new URL(match[1], node.baseURI).href);
         }
       }
 
       // Prepare loading further nested xul overlays from the overlay
       unloadedOverlays.push(...this._collectOverlays(doc));
 
       // Prepare loading further nested xul overlays from the registry
       for (let overlayUrl of this.overlayProvider.overlay.get(url, false)) {
@@ -466,17 +466,17 @@ class Overlays {
           deferredLoad.push({ listener, useCapture });
           return null;
         }
         return oldAddEventListener.call(this, type, listener, useCapture, ...args);
       };
     }
 
     if (node.hasAttribute("src")) {
-      let url = node.getAttribute("src");
+      let url = new URL(node.getAttribute("src"), node.baseURI).href;
       oconsole.debug(`Loading script ${url} into ${this.window.location}`);
       try {
         Services.scriptloader.loadSubScript(url, this.window);
       } catch (ex) {
         Cu.reportError(ex);
       }
     } else if (node.textContent) {
       oconsole.debug(`Loading eval'd script into ${this.window.location}`);