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 33232 92f2f9d3268c
parent 33231 1025d59f7259
child 33233 992cb1d8b84f
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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}`);