|
1 #!/usr/bin/env python |
|
2 |
|
3 """ |
|
4 test nonce in prefs delimeters |
|
5 see https://bugzilla.mozilla.org/show_bug.cgi?id=722804 |
|
6 """ |
|
7 |
|
8 import os |
|
9 import tempfile |
|
10 import time |
|
11 import unittest |
|
12 from mozprofile.prefs import Preferences |
|
13 from mozprofile.profile import Profile |
|
14 |
|
15 class PreferencesNonceTest(unittest.TestCase): |
|
16 |
|
17 def test_nonce(self): |
|
18 |
|
19 # make a profile with one preference |
|
20 path = tempfile.mktemp() |
|
21 profile = Profile(path, |
|
22 preferences={'foo': 'bar'}, |
|
23 restore=False) |
|
24 user_js = os.path.join(profile.profile, 'user.js') |
|
25 self.assertTrue(os.path.exists(user_js)) |
|
26 |
|
27 # ensure the preference is correct |
|
28 prefs = Preferences.read_prefs(user_js) |
|
29 self.assertEqual(dict(prefs), {'foo': 'bar'}) |
|
30 |
|
31 del profile |
|
32 |
|
33 # augment the profile with a second preference |
|
34 profile = Profile(path, |
|
35 preferences={'fleem': 'baz'}, |
|
36 restore=True) |
|
37 prefs = Preferences.read_prefs(user_js) |
|
38 self.assertEqual(dict(prefs), {'foo': 'bar', 'fleem': 'baz'}) |
|
39 |
|
40 # cleanup the profile; |
|
41 # this should remove the new preferences but not the old |
|
42 profile.cleanup() |
|
43 prefs = Preferences.read_prefs(user_js) |
|
44 self.assertEqual(dict(prefs), {'foo': 'bar'}) |
|
45 |
|
46 if __name__ == '__main__': |
|
47 unittest.main() |