Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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://test1.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://test1.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://test1.example.com";
43 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add2&B&failure";
44 break;
46 // In a different subdomain 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://test2.example.com";
50 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&failure";
51 break;
53 // Remove from the second subdomain the second key, it must not fail
54 // This should release the allocated space of the quota assigned to
55 // example.com.
56 case 6:
57 slaveOrigin = "http://test1.example.com";
58 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?remove&B&success";
59 break;
61 // Now try again to set 500 bytes key, it must succeed.
62 case 7:
63 slaveOrigin = "https://test2.example.com";
64 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?add&C&success";
65 break;
67 case 8:
68 // Do a clean up...
69 slaveOrigin = "http://example.com";
70 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear";
71 break;
73 case 9:
74 // Do a clean up...
75 slaveOrigin = "http://test1.example.com";
76 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear";
77 break;
79 case 10:
80 // Do a clean up...
81 slaveOrigin = "https://test2.example.com";
82 slave.location = slaveOrigin + slavePath + "frameQuotaSessionOnly.html?clear";
83 break;
85 default:
86 SimpleTest.finish();
87 }
89 ++currentTest;
90 }
92 function doStep()
93 {
94 }
96 SimpleTest.waitForExplicitFinish();
98 function startTest() {
99 SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION, 'context': document}], function() {
100 // Initialy setup the quota to testing value of 1024B and
101 // set a 500 bytes key with name length 1 (allocate 501 bytes)
102 SpecialPowers.pushPrefEnv({"set": [["dom.storage.default_quota", 1], ["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, doNextTest);
103 });
104 }
105 </script>
107 </head>
109 <body onload="startTest();">
110 <iframe src="" name="frame"></iframe>
111 </body>
112 </html>