diff options
Diffstat (limited to 'test/test-database.js')
-rw-r--r-- | test/test-database.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/test-database.js b/test/test-database.js index 44f409dd..35f22523 100644 --- a/test/test-database.js +++ b/test/test-database.js @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2020 Alex Yatskov <alex@foosoft.net> + * Author: Alex Yatskov <alex@foosoft.net> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + const fs = require('fs'); const url = require('url'); const path = require('path'); @@ -72,7 +90,7 @@ class XMLHttpRequest { const {JsonSchema} = yomichanTest.requireScript('ext/bg/js/json-schema.js', ['JsonSchema']); const {dictFieldSplit, dictTagSanitize} = yomichanTest.requireScript('ext/bg/js/dictionary.js', ['dictFieldSplit', 'dictTagSanitize']); -const {stringReverse, hasOwn} = yomichanTest.requireScript('ext/mixed/js/core.js', ['stringReverse', 'hasOwn'], {chrome}); +const {stringReverse} = yomichanTest.requireScript('ext/mixed/js/core.js', ['stringReverse'], {chrome}); const {requestJson} = yomichanTest.requireScript('ext/bg/js/request.js', ['requestJson'], {XMLHttpRequest}); const databaseGlobals = { @@ -80,7 +98,6 @@ const databaseGlobals = { JsonSchema, requestJson, stringReverse, - hasOwn, dictFieldSplit, dictTagSanitize, indexedDB: global.indexedDB, @@ -109,7 +126,8 @@ function countKanjiWithCharacter(kanji, character) { function clearDatabase(timeout) { return new Promise((resolve, reject) => { - const timer = setTimeout(() => { + let timer = setTimeout(() => { + timer = null; reject(new Error(`clearDatabase failed to resolve after ${timeout}ms`)); }, timeout); @@ -122,7 +140,9 @@ function clearDatabase(timeout) { request.onsuccess = () => resolve2(); }); } - clearTimeout(timer); + if (timer !== null) { + clearTimeout(timer); + } resolve(); })(); }); |