test_originEndsWithDot.js (1999B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 loadScript("dom/quota/test/common/file.js"); 7 8 async function testSteps() { 9 // First, ensure the origin can be initialized and used by a client that uses 10 // SQLite databases. 11 12 // Todo: consider using simpleDB once it supports using storage for SQLite. 13 info("Testing SQLite database with an origin that ends with a dot"); 14 15 const principal = getPrincipal("https://example.com."); 16 let request = indexedDB.openForPrincipal(principal, "myIndexedDB"); 17 await openDBRequestUpgradeNeeded(request); 18 19 info("Testing simple operations"); 20 21 const database = request.result; 22 23 const objectStore = database.createObjectStore("Blobs", {}); 24 25 objectStore.add(getNullBlob(200), 42); 26 27 await openDBRequestSucceeded(request); 28 29 database.close(); 30 31 info("Reseting"); 32 33 request = reset(); 34 await requestFinished(request); 35 36 let idbDB = getRelativeFile( 37 "storage/default/https+++example.com./idb/2320029346mByDIdnedxe.sqlite" 38 ); 39 ok(idbDB.exists(), "IDB database was created successfully"); 40 41 // Second, ensure storage initialization works fine with the origin. 42 43 info("Testing storage initialization and temporary storage initialization"); 44 45 request = init(); 46 await requestFinished(request); 47 48 request = initTemporaryStorage(); 49 await requestFinished(request); 50 51 // Third, ensure QMS APIs that touch the client directory for the origin work 52 // fine. 53 54 info("Testing getUsageForPrincipal"); 55 56 request = getOriginUsage(principal); 57 await requestFinished(request); 58 59 ok( 60 request.result instanceof Ci.nsIQuotaOriginUsageResult, 61 "The result is nsIQuotaOriginUsageResult instance" 62 ); 63 Assert.greater(request.result.usage, 0, "Total usage is not empty"); 64 Assert.greater(request.result.fileUsage, 0, "File usage is not empty"); 65 66 info("Testing clearStoragesForPrincipal"); 67 68 request = clearOrigin(principal, "default"); 69 await requestFinished(request); 70 }