mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Bug 1573786 - ManifestProcessor should throw error when parsing invalid JSON r=marcosc
Differential Revision: https://phabricator.services.mozilla.com/D42627 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7249733689
commit
5ac210ec83
@ -93,7 +93,9 @@ var ManifestProcessor = {
|
||||
let rawManifest = {};
|
||||
try {
|
||||
rawManifest = JSON.parse(jsonText);
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
errors.push({ type: "json", error: e.message });
|
||||
}
|
||||
if (rawManifest === null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -19,11 +19,15 @@ var invalidJson = ["", ` \t \n ${whiteSpace} `, "{", "{[[}"];
|
||||
invalidJson.forEach((testString) => {
|
||||
var expected = `Expect to recover from invalid JSON: ${testString}`;
|
||||
data.jsonText = testString;
|
||||
data.checkConformance = true;
|
||||
var result = processor.process(data);
|
||||
SimpleTest.is(result.start_url, docURL.href, expected);
|
||||
SimpleTest.ok(
|
||||
[...result.moz_validation].find(x => x.error && x.type === "json"),
|
||||
"A JSON error message is included");
|
||||
});
|
||||
|
||||
var validButUnhelpful = ["1", 1, "", "[{}]"];
|
||||
var validButUnhelpful = ["1", 1, "[{}]"];
|
||||
validButUnhelpful.forEach((testString) => {
|
||||
var expected = `Expect to recover from valid JSON: ${testString}`;
|
||||
data.jsonText = testString;
|
||||
|
Loading…
x
Reference in New Issue
Block a user