aboutsummaryrefslogtreecommitdiff
path: root/test/unit/test_indexeddb.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/test_indexeddb.py')
-rw-r--r--test/unit/test_indexeddb.py46
1 files changed, 2 insertions, 44 deletions
diff --git a/test/unit/test_indexeddb.py b/test/unit/test_indexeddb.py
index 9dfbe63..0c0e7a0 100644
--- a/test/unit/test_indexeddb.py
+++ b/test/unit/test_indexeddb.py
@@ -6,7 +6,7 @@ Haketilo unit tests - IndexedDB access
# This file is part of Haketilo
#
-# Copyright (C) 2021, Wojtek Kosior <koszko@koszko.org>
+# Copyright (C) 2021,2022 Wojtek Kosior <koszko@koszko.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the CC0 1.0 Universal License as published by
@@ -25,7 +25,7 @@ from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import WebDriverException
from ..script_loader import load_script
-from .utils import sample_files, sample_files_by_hash, sample_file_ref
+from .utils import *
indexeddb_js = lambda: load_script('common/indexeddb.js')
broker_js = lambda: load_script('background/broadcast_broker.js') + ';start();'
@@ -54,48 +54,6 @@ def make_sample_mapping():
'identifier': 'helloapple'
}
-def clear_indexeddb(execute_in_page):
- execute_in_page(
- '''{
- async function delete_db() {
- if (db) {
- db.close();
- db = null;
- }
- let resolve, reject;
- const result = new Promise((...cbs) => [resolve, reject] = cbs);
- const request = indexedDB.deleteDatabase("haketilo");
- [request.onsuccess, request.onerror] = [resolve, reject];
- await result;
- }
-
- returnval(delete_db());
- }'''
- )
-
-def get_db_contents(execute_in_page):
- # Facilitate retrieving all IndexedDB contents.
- return execute_in_page(
- '''{
- async function get_database_contents()
- {
- const db = await get_db();
-
- const transaction = db.transaction(db.objectStoreNames);
- const store_names_reqs = [...db.objectStoreNames]
- .map(sn => [sn, transaction.objectStore(sn).getAll()])
-
- const promises = store_names_reqs
- .map(([_, req]) => wait_request(req));
- await Promise.all(promises);
-
- const result = {};
- store_names_reqs.forEach(([sn, req]) => result[sn] = req.result);
- return result;
- }
- returnval(get_database_contents());
- }''')
-
def mock_broadcast(execute_in_page):
execute_in_page(
'''{