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

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

mercurial