summaryrefslogtreecommitdiffstats
path: root/testing/raptor/browsertime/indexeddb_getkeyrange.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/raptor/browsertime/indexeddb_getkeyrange.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/raptor/browsertime/indexeddb_getkeyrange.js')
-rw-r--r--testing/raptor/browsertime/indexeddb_getkeyrange.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/raptor/browsertime/indexeddb_getkeyrange.js b/testing/raptor/browsertime/indexeddb_getkeyrange.js
new file mode 100644
index 0000000000..100ac20e2a
--- /dev/null
+++ b/testing/raptor/browsertime/indexeddb_getkeyrange.js
@@ -0,0 +1,69 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* eslint-env node */
+
+module.exports = async function (context, commands) {
+ context.log.info("Starting a indexedDB getkeyrange");
+
+ const test_url = context.options.browsertime.url;
+ let page_cycles = context.options.browsertime.page_cycles;
+ let page_cycle_delay = context.options.browsertime.page_cycle_delay;
+ let post_startup_delay = context.options.browsertime.post_startup_delay;
+
+ context.log.info(
+ "Waiting for %d ms (post_startup_delay)",
+ post_startup_delay
+ );
+ await commands.wait.byTime(post_startup_delay);
+
+ await commands.navigate(test_url);
+
+ for (let count = 0; count < page_cycles; count++) {
+ context.log.info("Cycle %d, waiting for %d ms", count, page_cycle_delay);
+ await commands.wait.byTime(page_cycle_delay);
+
+ context.log.info("Cycle %d, starting the measure", count);
+ await await commands.measure.start();
+ await commands.js.run(`
+ const notifyDone = arguments[arguments.length - 1];
+ async function resPromise() {
+ return new Promise((resolve, reject) => {
+ const results = {};
+ const request = indexedDB.open('get-keyrange', 1);
+
+ request.onsuccess = () => {
+ const db = request.result;
+ const start = Date.now();
+ const keyRange = IDBKeyRange.bound(0, 99);
+ const transaction = db.transaction('entries', 'readonly');
+ const store = transaction.objectStore('entries');
+ const index = store.index('index');
+ const getAllRequest = index.getAll(keyRange);
+ getAllRequest.onsuccess = () => {
+ const items = getAllRequest.result;
+ items.forEach((item) => {
+ results[item.key] = item;
+ });
+ const end = Date.now();
+ db.close();
+ resolve(end - start);
+ };
+ getAllRequest.onerror = () => {
+ reject(getAllRequest.error);
+ };
+ };
+
+ });
+ }
+ resPromise().then(() => {
+ notifyDone();
+ });
+ `);
+ await commands.measure.stop();
+ }
+
+ context.log.info("IndexedDB getkeyrange ended.");
+ return true;
+};