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 #!/usr/bin/env python
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 # You can obtain one at http://mozilla.org/MPL/2.0/.
7 import mozfile
8 import os
9 import shutil
10 import sqlite3
11 import tempfile
12 import unittest
13 from mozprofile.permissions import Permissions
15 class PermissionsTest(unittest.TestCase):
17 locations = """http://mochi.test:8888 primary,privileged
18 http://127.0.0.1:80 noxul
19 http://127.0.0.1:8888 privileged
20 """
22 def setUp(self):
23 self.profile_dir = tempfile.mkdtemp()
24 self.locations_file = mozfile.NamedTemporaryFile()
25 self.locations_file.write(self.locations)
26 self.locations_file.flush()
28 def tearDown(self):
29 if self.profile_dir:
30 shutil.rmtree(self.profile_dir)
31 if self.locations_file:
32 self.locations_file.close()
34 def test_schema_version(self):
35 perms = Permissions(self.profile_dir, self.locations_file.name)
36 perms_db_filename = os.path.join(self.profile_dir, 'permissions.sqlite')
37 perms.write_db(self.locations_file)
39 stmt = 'PRAGMA user_version;'
41 con = sqlite3.connect(perms_db_filename)
42 cur = con.cursor()
43 cur.execute(stmt)
44 entries = cur.fetchall()
46 schema_version = entries[0][0]
47 self.assertEqual(schema_version, 2)
49 if __name__ == '__main__':
50 unittest.main()