diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/localstorage/frameQuotaSessionOnly.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/localstorage/frameQuotaSessionOnly.html')
-rw-r--r-- | dom/tests/mochitest/localstorage/frameQuotaSessionOnly.html | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/dom/tests/mochitest/localstorage/frameQuotaSessionOnly.html b/dom/tests/mochitest/localstorage/frameQuotaSessionOnly.html new file mode 100644 index 000000000..a6f69b176 --- /dev/null +++ b/dom/tests/mochitest/localstorage/frameQuotaSessionOnly.html @@ -0,0 +1,111 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>slave for sessionStorage test</title> + +<script type="text/javascript" src="interOriginFrame.js"></script> +<script type="text/javascript"> + +const DOM_QUOTA_REACHED = 2152924150; + +function checkException(func, exc) +{ + var exceptionThrew = false; + try { + func(); + } + catch (ex) { + exceptionThrew = true; + is(ex.result, exc, "Expected "+exc+" exception"); + } + ok(exceptionThrew, "Exception "+exc+" threw at "+location); +} + +function doStep() +{ + var query = location.search.substring(1); + var queries = query.split("&"); + + var operation = queries[0]; + var keyName = queries[1]; + var result = queries[2]; + + switch (result) + { + case "success": + switch (operation) + { + case "add": + // Store 500 bytes long string must succeed + localStorage.setItem(keyName, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); + is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "500 bytes key "+keyName+" stored"); + break; + + case "remove": + localStorage.removeItem(keyName); + is(localStorage.getItem(keyName), null, "Key "+keyName+" removed"); + break; + + case "checkclean": + is(localStorage.getItem(keyName), null, "Key "+keyName+" not present"); + break; + + case "checknotclean": + is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "Key "+keyName+" is present"); + break; + } + + break; + + case "failure": + switch (operation) + { + case "add": + // Attempt to store 500 bytes long string that doens't + // fit the quota, have to throw DOM_QUOTA_REACHED exception + checkException(function() { + localStorage.setItem(keyName, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); + }, DOM_QUOTA_REACHED); + is(localStorage.getItem(keyName), null, "500 bytes key "+keyName+" is NOT stored"); + break; + + case "add2": + // Attempt to change a key value to reach the DOM quota and + // check it fails and the old key value is still present. + checkException(function() { + localStorage.setItem(keyName, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"); + }, DOM_QUOTA_REACHED); + is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "Key "+keyName+" left unchanged"); + break; + } + + break; + + case "": + default: + switch (operation) + { + case "clear": + localStorage.clear(); + break; + } + + break; + } + + // Just inform the master we are finished now + postMsg("done"); + return false; +} + +function startTest() { + SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION, 'context': document}], function() { + postMsg('frame loaded'); + }); +} +</script> + +</head> + +<body onload="startTest();"> +</body> +</html> |