Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
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://test1.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://test1.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://test1.example.com"; |
michael@0 | 43 | slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add2&B&failure"; |
michael@0 | 44 | break; |
michael@0 | 45 | |
michael@0 | 46 | // In a different subdomain 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://test2.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 from the second subdomain the second key, it must not fail |
michael@0 | 54 | // This should release the allocated space of the quota assigned to |
michael@0 | 55 | // example.com. |
michael@0 | 56 | case 6: |
michael@0 | 57 | slaveOrigin = "http://test1.example.com"; |
michael@0 | 58 | slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?remove&B&success"; |
michael@0 | 59 | break; |
michael@0 | 60 | |
michael@0 | 61 | // Now try again to set 500 bytes key, it must succeed. |
michael@0 | 62 | case 7: |
michael@0 | 63 | slaveOrigin = "https://test2.example.com"; |
michael@0 | 64 | slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&success"; |
michael@0 | 65 | break; |
michael@0 | 66 | |
michael@0 | 67 | case 8: |
michael@0 | 68 | // Do a clean up... |
michael@0 | 69 | slaveOrigin = "http://example.com"; |
michael@0 | 70 | slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear"; |
michael@0 | 71 | break; |
michael@0 | 72 | |
michael@0 | 73 | case 9: |
michael@0 | 74 | // Do a clean up... |
michael@0 | 75 | slaveOrigin = "http://test1.example.com"; |
michael@0 | 76 | slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear"; |
michael@0 | 77 | break; |
michael@0 | 78 | |
michael@0 | 79 | case 10: |
michael@0 | 80 | // Do a clean up... |
michael@0 | 81 | slaveOrigin = "https://test2.example.com"; |
michael@0 | 82 | slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear"; |
michael@0 | 83 | break; |
michael@0 | 84 | |
michael@0 | 85 | default: |
michael@0 | 86 | SimpleTest.finish(); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | ++currentTest; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | function doStep() |
michael@0 | 93 | { |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 97 | |
michael@0 | 98 | function startTest() { |
michael@0 | 99 | SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION, 'context': document}], function() { |
michael@0 | 100 | // Initialy setup the quota to testing value of 1024B and |
michael@0 | 101 | // set a 500 bytes key with name length 1 (allocate 501 bytes) |
michael@0 | 102 | SpecialPowers.pushPrefEnv({"set": [["dom.storage.default_quota", 1], ["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, doNextTest); |
michael@0 | 103 | }); |
michael@0 | 104 | } |
michael@0 | 105 | </script> |
michael@0 | 106 | |
michael@0 | 107 | </head> |
michael@0 | 108 | |
michael@0 | 109 | <body onload="startTest();"> |
michael@0 | 110 | <iframe src="" name="frame"></iframe> |
michael@0 | 111 | </body> |
michael@0 | 112 | </html> |