diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties
index aa7e88f683d0..c6fa4b06641c 100644
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -250,6 +250,8 @@ ManifestInvalidType=Expected the %1$S’s %2$S member to be a %3$S.
ManifestInvalidCSSColor=%1$S: %2$S is not a valid CSS color.
# LOCALIZATION NOTE: %1$S is the name of the property whose value is invalid. %2$S is the (invalid) value of the property. E.g. "lang: 42 is not a valid language code."
ManifestLangIsInvalid=%1$S: %2$S is not a valid language code.
+# LOCALIZATION NOTE: %1$S is the name of the parent property whose value is invalid (e.g., "icons"). %2$S is the index of the image object that is invalid (from 0). %3$S is the name of actual member that is invalid. %4$S is the invalid value. E.g. "icons item at index 2 is invalid. The src member is an invalid URL http://:Invalid"
+ManifestImageURLIsInvalid=%1$S item at index %2$S is invalid. The %3$S member is an invalid URL %4$S
PatternAttributeCompileFailure=Unable to check because the pattern is not a valid regexp: %S
# LOCALIZATION NOTE: Do not translate "postMessage" or DOMWindow. %S values are origins, like https://domain.com:port
TargetPrincipalDoesNotMatch=Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘%S’) does not match the recipient window’s origin (‘%S’).
diff --git a/dom/manifest/ImageObjectProcessor.jsm b/dom/manifest/ImageObjectProcessor.jsm
index 6428885f9087..b9b0961987fb 100644
--- a/dom/manifest/ImageObjectProcessor.jsm
+++ b/dom/manifest/ImageObjectProcessor.jsm
@@ -28,9 +28,10 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]);
-function ImageObjectProcessor(aConsole, aExtractor) {
- this.console = aConsole;
+function ImageObjectProcessor(aErrors, aExtractor, aBundle) {
+ this.errors = aErrors;
this.extractor = aExtractor;
+ this.domBundle = aBundle;
}
// Static getters
@@ -59,13 +60,13 @@ ImageObjectProcessor.prototype.process = function(
expectedType: "array",
trim: false,
};
- const extractor = this.extractor;
+ const { domBundle, extractor, errors } = this;
const images = [];
const value = extractor.extractValue(spec);
if (Array.isArray(value)) {
// Filter out images whose "src" is not useful.
value
- .filter(item => !!processSrcMember(item, aBaseURL))
+ .filter((item, index) => !!processSrcMember(item, aBaseURL, index))
.map(toImageObject)
.forEach(image => images.push(image));
}
@@ -100,9 +101,9 @@ ImageObjectProcessor.prototype.process = function(
return value || undefined;
}
- function processSrcMember(aImage, aBaseURL) {
+ function processSrcMember(aImage, aBaseURL, index) {
const spec = {
- objectName: "image",
+ objectName: aMemberName,
object: aImage,
property: "src",
expectedType: "string",
@@ -113,7 +114,13 @@ ImageObjectProcessor.prototype.process = function(
if (value && value.length) {
try {
url = new URL(value, aBaseURL).href;
- } catch (e) {}
+ } catch (e) {
+ const warn = domBundle.formatStringFromName(
+ "ManifestImageURLIsInvalid",
+ [aMemberName, index, "src", value]
+ );
+ errors.push({ warn });
+ }
}
return url;
}
diff --git a/dom/manifest/ManifestObtainer.jsm b/dom/manifest/ManifestObtainer.jsm
index 794dc2102623..edcc9b01acca 100644
--- a/dom/manifest/ManifestObtainer.jsm
+++ b/dom/manifest/ManifestObtainer.jsm
@@ -57,15 +57,18 @@ var ManifestObtainer = {
},
/**
* Public interface for obtaining a web manifest from a XUL browser.
- * @param {Window} The content Window from which to extract the manifest.
+ * @param {Window} aContent A content Window from which to extract the manifest.
+ * @param {Object} aOptions
+ * @param {Boolean} aOptions.checkConformance If spec conformance messages should be collected.
* @return {Promise