Bug 1347154 - Set correct csp for icon fetching. r=marcosc
authorDale Harvey <dale@arandomurl.com>
Fri, 17 Mar 2017 10:55:59 +0000
changeset 398704 8c14b29f17888289af432ce9ea53558cce1137c6
parent 398703 156ee3ddc81024e455385e9ba0b3bcbb2b9c89a6
child 398705 a13dc6642789e1ced2fa069f52fe685099099ea2
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarcosc
bugs1347154
milestone55.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 1347154 - Set correct csp for icon fetching. r=marcosc
dom/manifest/ManifestIcons.jsm
--- a/dom/manifest/ManifestIcons.jsm
+++ b/dom/manifest/ManifestIcons.jsm
@@ -63,20 +63,20 @@ async function getIcon(aWindow, icons, e
   return fetchIcon(aWindow, icons[index].src).catch(err => {
     // Remove all icons with the failed source, the same source
     // may have been used for multiple sizes
     icons = icons.filter(x => x.src !== icons[index].src);
     return getIcon(aWindow, icons, expectedSize);
   });
 }
 
-function fetchIcon(aWindow, src) {
-  const manifestURL = new aWindow.URL(src);
-  const request = new aWindow.Request(manifestURL, {mode: "cors"});
-  request.overrideContentPolicyType(Ci.nsIContentPolicy.TYPE_WEB_MANIFEST);
+async function fetchIcon(aWindow, src) {
+  const iconURL = new aWindow.URL(src, aWindow.location);
+  const request = new aWindow.Request(iconURL, {mode: "cors"});
+  request.overrideContentPolicyType(Ci.nsIContentPolicy.TYPE_IMAGE);
   return aWindow.fetch(request)
     .then(response => response.blob())
     .then(blob => new Promise((resolve, reject) => {
       var reader = new FileReader();
       reader.onloadend = () => resolve(reader.result);
       reader.onerror = reject;
       reader.readAsDataURL(blob);
     }));