Skip to content

Commit fb53e92

Browse files
Merge pull request #434 from ossf/lab_support_firefox
Add Firefox support to labs
2 parents 7fd06f9 + a82d775 commit fb53e92

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

docs/labs/checker.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ function escapeHTML(unsafe) {
6666
.replace(/\'/g, "'"));
6767
}
6868

69+
/* Compute Set difference lhs \ rhs.
70+
* @lhs - Set to start with
71+
* @rhs - Set to remove from the lhs
72+
* Set difference is in Firefox nightly, but is not yet released.
73+
* So we compute it ourselves. This is equivalent to lhs.difference(rhs)
74+
*/
75+
function setDifference(lhs, rhs) {
76+
let lhsArray = Array.from(lhs);
77+
let result = lhsArray.filter((x) => {!rhs.has(x)});
78+
return new Set(result);
79+
}
80+
6981
/*
7082
* Show debug output in debug region and maybe via alert box
7183
* @debugOutput - the debug information to show
@@ -276,7 +288,7 @@ function processHints(requestedHints) {
276288

277289
// Complain about unknown fields
278290
let usedFields = new Set(Object.keys(hint));
279-
let forbiddenFields = usedFields.difference(allowedHintFields);
291+
let forbiddenFields = setDifference(usedFields, allowedHintFields);
280292
if (forbiddenFields.size != 0) {
281293
showDebugOutput(
282294
`Unknown field(s) in hint[${i}]: ` +
@@ -329,7 +341,7 @@ function processInfo(configurationInfo) {
329341
'hints', 'successes', 'failures', 'correct', 'expected',
330342
'preprocessing', 'preprocessingTests', 'debug']);
331343
let usedFields = new Set(Object.keys(info));
332-
let forbiddenFields = usedFields.difference(allowedInfoFields);
344+
let forbiddenFields = setDifference(usedFields, allowedInfoFields);
333345
if (forbiddenFields.size != 0) {
334346
showDebugOutput(
335347
`Unknown field(s) in info: ` +

0 commit comments

Comments
 (0)