Commit c4801e2a authored by Eric Eastwood's avatar Eric Eastwood

Fix up off index when reading canvas and something failed

parent 02ce3133
...@@ -74,6 +74,7 @@ function testUnicodeSupportMap(testMap) { ...@@ -74,6 +74,7 @@ function testUnicodeSupportMap(testMap) {
.reduce((list, testKey) => list.concat(testMap[testKey]), []).length; .reduce((list, testKey) => list.concat(testMap[testKey]), []).length;
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
(window.gl || window).testEmojiUnicodeSupportMapCanvas = canvas;
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
canvas.width = (2 * fontSize); canvas.width = (2 * fontSize);
canvas.height = (numTestEntries * fontSize); canvas.height = (numTestEntries * fontSize);
...@@ -95,7 +96,9 @@ function testUnicodeSupportMap(testMap) { ...@@ -95,7 +96,9 @@ function testUnicodeSupportMap(testMap) {
let readIndex = 0; let readIndex = 0;
testMapKeys.forEach((testKey) => { testMapKeys.forEach((testKey) => {
const testEntry = testMap[testKey]; const testEntry = testMap[testKey];
const isTestSatisfied = [].concat(testEntry).every(() => { // This needs to be a `reduce` instead of `every` because we need to
// keep the `readIndex` in sync from the writes by running all entries
const isTestSatisfied = [].concat(testEntry).reduce((isSatisfied) => {
// Sample along the vertical-middle for a couple of characters // Sample along the vertical-middle for a couple of characters
const imageData = ctx.getImageData( const imageData = ctx.getImageData(
0, 0,
...@@ -121,8 +124,8 @@ function testUnicodeSupportMap(testMap) { ...@@ -121,8 +124,8 @@ function testUnicodeSupportMap(testMap) {
} }
readIndex += 1; readIndex += 1;
return isValidEmoji; return isSatisfied && isValidEmoji;
}); }, true);
resultMap[testKey] = isTestSatisfied; resultMap[testKey] = isTestSatisfied;
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment