| 816 | |
| 817 | const pool = []; |
| 818 | function initGlobals(attribute, type) { |
| 819 | if (useFastMode) { |
| 820 | // Note: this is not giving correct results for warnings. |
| 821 | // But it's much faster. |
| 822 | if (pool[0]) { |
| 823 | return pool[0].globals; |
| 824 | } |
| 825 | } else { |
| 826 | document.title = `${attribute.name} (${type.name})`; |
| 827 | } |
| 828 | |
| 829 | // Creating globals for every single test is too slow. |
| 830 | // However caching them between runs won't work for the same attribute names |
| 831 | // because warnings will be deduplicated. As a result, we only share globals |
| 832 | // between different attribute names. |
| 833 | for (let i = 0; i < pool.length; i++) { |
| 834 | if (!pool[i].testedAttributes.has(attribute.name)) { |
| 835 | pool[i].testedAttributes.add(attribute.name); |
| 836 | return pool[i].globals; |
| 837 | } |
| 838 | } |
| 839 | |
| 840 | let globals = {}; |
| 841 | Object.keys(sources).forEach((name, i) => { |
| 842 | eval.call(window, codesByIndex[i]); // eslint-disable-line |
| 843 | globals[name] = window[name.replace(/Stable|Next/g, '')]; |
| 844 | }); |
| 845 | |
| 846 | // Cache for future use (for different attributes). |
| 847 | pool.push({ |
| 848 | globals, |
| 849 | testedAttributes: new Set([attribute.name]), |
| 850 | }); |
| 851 | |
| 852 | return globals; |
| 853 | } |
| 854 | |
| 855 | const {table, rowPatternHashes} = await prepareState(initGlobals); |
| 856 | document.title = 'Ready'; |