dom/tests/mochitest/localstorage/test_localStorageQuotaSessionOnly2.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <html xmlns="http://www.w3.org/1999/xhtml">
michael@0 2 <head>
michael@0 3 <title>localStorage and DOM quota test</title>
michael@0 4
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="text/javascript" src="interOriginTest.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 8
michael@0 9 <script type="text/javascript">
michael@0 10
michael@0 11 var currentTest = 1;
michael@0 12
michael@0 13 function doNextTest()
michael@0 14 {
michael@0 15 slave = frame;
michael@0 16
michael@0 17 switch (currentTest)
michael@0 18 {
michael@0 19 case 1:
michael@0 20 slaveOrigin = "http://example.com";
michael@0 21 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&A&success";
michael@0 22 break;
michael@0 23
michael@0 24 // In subdomain now set another key with length 500 bytes, i.e.
michael@0 25 // allocate 501 bytes
michael@0 26 case 2:
michael@0 27 slaveOrigin = "http://example.com";
michael@0 28 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success";
michael@0 29 break;
michael@0 30
michael@0 31 // Try to set the same key value again to check we don't fail
michael@0 32 // even 1002 bytes has already been exhausted from the quota
michael@0 33 // We just change the value of an existing key.
michael@0 34 case 3:
michael@0 35 slaveOrigin = "http://example.com";
michael@0 36 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&B&success";
michael@0 37 break;
michael@0 38
michael@0 39 // Try to set the same key to a larger value that would lead to
michael@0 40 // quota reach and check that the value is still the old one
michael@0 41 case 4:
michael@0 42 slaveOrigin = "http://example.com";
michael@0 43 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add2&B&failure";
michael@0 44 break;
michael@0 45
michael@0 46 // Try to set a new 500 bytes key
michael@0 47 // and check we fail because we are over the quota
michael@0 48 case 5:
michael@0 49 slaveOrigin = "https://example.com";
michael@0 50 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&failure";
michael@0 51 break;
michael@0 52
michael@0 53 // Remove the key inherited from the non-session-only database
michael@0 54 case 6:
michael@0 55 slaveOrigin = "http://example.com";
michael@0 56 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?remove&A&success";
michael@0 57 break;
michael@0 58
michael@0 59 // Now try again to set 500 bytes key, it must succeed.
michael@0 60 case 7:
michael@0 61 slaveOrigin = "https://example.com";
michael@0 62 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&success";
michael@0 63 break;
michael@0 64
michael@0 65 case 8:
michael@0 66 // Do a clean up...
michael@0 67 slaveOrigin = "http://example.com";
michael@0 68 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear";
michael@0 69 break;
michael@0 70
michael@0 71 default:
michael@0 72 SimpleTest.finish();
michael@0 73 }
michael@0 74
michael@0 75 ++currentTest;
michael@0 76 }
michael@0 77
michael@0 78 function doStep()
michael@0 79 {
michael@0 80 }
michael@0 81
michael@0 82 SimpleTest.waitForExplicitFinish();
michael@0 83
michael@0 84 function startTest() {
michael@0 85 // Initialy setup the quota to testing value of 1024B and
michael@0 86 // set a 500 bytes key with name length 1 (allocate 501 bytes)
michael@0 87 SpecialPowers.pushPrefEnv({"set": [["dom.storage.default_quota", 1], ["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, function() {
michael@0 88 SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION, 'context': document}], doNextTest);
michael@0 89 });
michael@0 90 }
michael@0 91 </script>
michael@0 92
michael@0 93 </head>
michael@0 94
michael@0 95 <body onload="startTest();">
michael@0 96 <iframe src="" name="frame"></iframe>
michael@0 97 </body>
michael@0 98 </html>

mercurial