Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 """The test case itsself, and associated stuff"""
7 import string
9 class BaseTest:
10 def __init__(self):
11 self.res = -1
12 self.reason = None
14 def parse_config(self, config):
15 self.files = []
17 for line in config.readlines():
18 line = string.strip(line)
19 self.files.append({'file': line, 'read': 0})
21 baseName = 'index'
23 def verify_request(self, req):
24 """Check that the request is valid.
26 Also needs to update any internal 'read' stuff"""
28 ## XXXXX
29 ## This needs to be done using exceptions, maybe
30 ## XXXXX
32 for i in self.files:
33 if i['file'] == req.fname:
34 if i['read'] == 1:
35 self.res = 0
36 self.reason = "File %s was read twice" % (req.fname)
37 return 0
38 i['read'] = 1
39 break
40 elif i['read'] == 0:
41 self.res = 0
42 self.reason = "File %s requested, expected %s" % (req.fname, i['file'])
43 return 0
45 ### Simplistic for now...
46 res = req.headers.getheader('Host')
48 return res
50 def result(self):
51 if self.res == -1:
52 for i in self.files:
53 if i['read'] == 0:
54 self.res = 0
55 self.reason = "%s not read" % (i['file'])
56 return self.res, self.reason
57 self.res = 1
59 return self.res, self.reason
61 tester = BaseTest