Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 4 | |
michael@0 | 5 | import unittest |
michael@0 | 6 | import xml.dom.minidom |
michael@0 | 7 | import os.path |
michael@0 | 8 | |
michael@0 | 9 | from cuddlefish import rdf, packaging |
michael@0 | 10 | |
michael@0 | 11 | parent = os.path.dirname |
michael@0 | 12 | test_dir = parent(os.path.abspath(__file__)) |
michael@0 | 13 | template_dir = os.path.join(parent(test_dir), "../../app-extension") |
michael@0 | 14 | |
michael@0 | 15 | class RDFTests(unittest.TestCase): |
michael@0 | 16 | def testBug567660(self): |
michael@0 | 17 | obj = rdf.RDF() |
michael@0 | 18 | data = u'\u2026'.encode('utf-8') |
michael@0 | 19 | x = '<?xml version="1.0" encoding="utf-8"?><blah>%s</blah>' % data |
michael@0 | 20 | obj.dom = xml.dom.minidom.parseString(x) |
michael@0 | 21 | self.assertEqual(obj.dom.documentElement.firstChild.nodeValue, |
michael@0 | 22 | u'\u2026') |
michael@0 | 23 | self.assertEqual(str(obj).replace("\n",""), x.replace("\n","")) |
michael@0 | 24 | |
michael@0 | 25 | def failUnlessIn(self, substring, s, msg=""): |
michael@0 | 26 | if substring not in s: |
michael@0 | 27 | self.fail("(%s) substring '%s' not in string '%s'" |
michael@0 | 28 | % (msg, substring, s)) |
michael@0 | 29 | |
michael@0 | 30 | def testUnpack(self): |
michael@0 | 31 | basedir = os.path.join(test_dir, "bug-715340-files") |
michael@0 | 32 | for n in ["pkg-1-pack", "pkg-2-unpack", "pkg-3-pack"]: |
michael@0 | 33 | cfg = packaging.get_config_in_dir(os.path.join(basedir, n)) |
michael@0 | 34 | m = rdf.gen_manifest(template_dir, cfg, jid="JID") |
michael@0 | 35 | if n.endswith("-pack"): |
michael@0 | 36 | # these ones should remain packed |
michael@0 | 37 | self.failUnlessEqual(m.get("em:unpack"), "false") |
michael@0 | 38 | self.failUnlessIn("<em:unpack>false</em:unpack>", str(m), n) |
michael@0 | 39 | else: |
michael@0 | 40 | # and these should be unpacked |
michael@0 | 41 | self.failUnlessEqual(m.get("em:unpack"), "true") |
michael@0 | 42 | self.failUnlessIn("<em:unpack>true</em:unpack>", str(m), n) |
michael@0 | 43 | |
michael@0 | 44 | def testTitle(self): |
michael@0 | 45 | basedir = os.path.join(test_dir, 'bug-906359-files') |
michael@0 | 46 | for n in ['title', 'fullName', 'none']: |
michael@0 | 47 | cfg = packaging.get_config_in_dir(os.path.join(basedir, n)) |
michael@0 | 48 | m = rdf.gen_manifest(template_dir, cfg, jid='JID') |
michael@0 | 49 | self.failUnlessEqual(m.get('em:name'), 'a long ' + n) |
michael@0 | 50 | self.failUnlessIn('<em:name>a long ' + n + '</em:name>', str(m), n) |
michael@0 | 51 | |
michael@0 | 52 | |
michael@0 | 53 | if __name__ == '__main__': |
michael@0 | 54 | unittest.main() |