diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/localstorage/test/unit/test_uri_encoding_edge_cases.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/localstorage/test/unit/test_uri_encoding_edge_cases.js')
-rw-r--r-- | dom/localstorage/test/unit/test_uri_encoding_edge_cases.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/dom/localstorage/test/unit/test_uri_encoding_edge_cases.js b/dom/localstorage/test/unit/test_uri_encoding_edge_cases.js new file mode 100644 index 0000000000..0da4e8584d --- /dev/null +++ b/dom/localstorage/test/unit/test_uri_encoding_edge_cases.js @@ -0,0 +1,69 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/** + * This test verifies that group and origin strings for URIs with special + * characters are consistent between calling + * EnsureQuotaForOringin/EnsureOriginIsInitailized and GetQuotaObject in + * PrepareDatastoreOp, so writing to local storage won't cause a crash because + * of a null quota object. See bug 1516333. + */ + +add_task(async function testSteps() { + /** + * The edge cases are specified in this array of origins. Each edge case must + * contain two properties uri and path (origin directory path relative to the + * profile directory). + */ + const origins = [ + { + uri: "file:///test'.html", + path: "storage/default/file++++test'.html", + }, + { + uri: "file:///test>.html", + path: "storage/default/file++++test%3E.html", + }, + ]; + + info("Setting prefs"); + + Services.prefs.setBoolPref( + "dom.storage.enable_unsupported_legacy_implementation", + false + ); + + for (let origin of origins) { + const principal = getPrincipal(origin.uri); + + let originDir = getRelativeFile(origin.path); + + info("Checking the origin directory existence"); + + ok( + !originDir.exists(), + `The origin directory ${origin.path} should not exists` + ); + + info("Getting storage"); + + let storage = getLocalStorage(principal); + + info("Adding item"); + + storage.setItem("foo", "bar"); + + info("Resetting origin"); + + // This forces any pending changes to be flushed to disk (including origin + // directory creation). + let request = resetOrigin(principal); + await requestFinished(request); + + info("Checking the origin directory existence"); + + ok(originDir.exists(), `The origin directory ${origin.path} should exist`); + } +}); |