diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/localstorage/test/unit/test_stringLength.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/localstorage/test/unit/test_stringLength.js')
-rw-r--r-- | dom/localstorage/test/unit/test_stringLength.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/dom/localstorage/test/unit/test_stringLength.js b/dom/localstorage/test/unit/test_stringLength.js new file mode 100644 index 0000000000..a43673682e --- /dev/null +++ b/dom/localstorage/test/unit/test_stringLength.js @@ -0,0 +1,71 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +async function testSteps() { + const principal = getPrincipal("http://example.org"); + + const data = {}; + data.key = "foobar"; + data.secondKey = "foobaz"; + data.value = { + length: 25637, + }; + data.usage = data.key.length + data.value.length; + + async function checkUsage(expectedUsage) { + info("Checking usage"); + + // This forces any pending changes to be flushed to disk. It also forces + // data to be reloaded from disk at next localStorage API call. + request = resetOrigin(principal); + await requestFinished(request); + + request = getOriginUsage(principal); + await requestFinished(request); + + is(request.result.usage, expectedUsage, "Correct usage"); + } + + info("Setting pref"); + + Services.prefs.setBoolPref("dom.storage.next_gen", true); + + info("Stage 1 - Checking usage after profile installation"); + + info("Clearing"); + + let request = clear(); + await requestFinished(request); + + info("Installing package"); + + // The profile contains storage.sqlite and webappsstore.sqlite. + installPackage("stringLength_profile"); + + await checkUsage(0); + + info("Stage 2 - Checking usage after archived data migration"); + + info("Opening database"); + + let storage = getLocalStorage(principal); + storage.open(); + + await checkUsage(data.usage); + + info("Stage 3 - Checking usage after copying the value"); + + info("Adding a second copy of the value"); + + let value = storage.getItem(data.key); + storage.setItem(data.secondKey, value); + + await checkUsage(2 * data.usage); + + info("Stage 4 - Checking length of the copied value"); + + value = storage.getItem(data.secondKey); + ok(value.length === data.value.length, "Correct string length"); +} |