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>slave for sessionStorage test</title>
5 <script type="text/javascript" src="interOriginFrame.js"></script>
6 <script type="text/javascript">
8 const DOM_QUOTA_REACHED = 2152924150;
10 function checkException(func, exc)
11 {
12 var exceptionThrew = false;
13 try {
14 func();
15 }
16 catch (ex) {
17 exceptionThrew = true;
18 is(ex.result, exc, "Expected "+exc+" exception");
19 }
20 ok(exceptionThrew, "Exception "+exc+" threw at "+location);
21 }
23 function doStep()
24 {
25 var query = location.search.substring(1);
26 var queries = query.split("&");
28 var operation = queries[0];
29 var keyName = queries[1];
30 var result = queries[2];
32 switch (result)
33 {
34 case "success":
35 switch (operation)
36 {
37 case "add":
38 // Store 500 bytes long string must succeed
39 localStorage.setItem(keyName, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
40 is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "500 bytes key "+keyName+" stored");
41 break;
43 case "remove":
44 localStorage.removeItem(keyName);
45 is(localStorage.getItem(keyName), null, "Key "+keyName+" removed");
46 break;
48 case "checkclean":
49 is(localStorage.getItem(keyName), null, "Key "+keyName+" not present");
50 break;
52 case "checknotclean":
53 is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "Key "+keyName+" is present");
54 break;
55 }
57 break;
59 case "failure":
60 switch (operation)
61 {
62 case "add":
63 // Attempt to store 500 bytes long string that doens't
64 // fit the quota, have to throw DOM_QUOTA_REACHED exception
65 checkException(function() {
66 localStorage.setItem(keyName, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
67 }, DOM_QUOTA_REACHED);
68 is(localStorage.getItem(keyName), null, "500 bytes key "+keyName+" is NOT stored");
69 break;
71 case "add2":
72 // Attempt to change a key value to reach the DOM quota and
73 // check it fails and the old key value is still present.
74 checkException(function() {
75 localStorage.setItem(keyName, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
76 }, DOM_QUOTA_REACHED);
77 is(localStorage.getItem(keyName), "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "Key "+keyName+" left unchanged");
78 break;
79 }
81 break;
83 case "":
84 default:
85 switch (operation)
86 {
87 case "clear":
88 localStorage.clear();
89 break;
90 }
92 break;
93 }
95 // Just inform the master we are finished now
96 postMsg("done");
97 return false;
98 }
100 function startTest() {
101 SpecialPowers.pushPermissions([{'type': 'cookie', 'allow': SpecialPowers.Ci.nsICookiePermission.ACCESS_SESSION, 'context': document}], function() {
102 postMsg('frame loaded');
103 });
104 }
105 </script>
107 </head>
109 <body onload="startTest();">
110 </body>
111 </html>