tools/test-harness/jssh-driver/test_layout_engine.py

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rwxr-xr-x

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 #!/usr/bin/env python
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 import unittest
     6 import sys, os
     7 import re, glob
     8 import difflib
    10 this_dir = os.path.abspath(os.path.dirname(__file__))
    11 data_dir = os.path.join(this_dir, 'data')
    13 from jssh_driver import JsshTester
    15 class LayoutEngineTests(unittest.TestCase):
    17     def setUp(self):
    18         self.tester = JsshTester("localhost")
    19         self.get_files_from_data_dir()
    21     def get_files_from_data_dir(self):
    22         self.html_files = glob.glob("%s/*.html" % data_dir)
    23         print self.html_files
    24         self.golden_images = [re.sub("\.html$", "_inner_html.txt", filename) for filename in self.html_files]
    25         print self.golden_images
    27     def test_inner_html(self):
    28         self.failUnless(len(self.html_files) == len(self.golden_images))
    29         failures = 0
    30         for file, golden_image in zip(self.html_files, self.golden_images):
    31             local_url = "file:///" + file
    32             local_url = re.sub(r"\\", "/", local_url)
    33             print local_url
    34             inner_html = self.tester.get_innerHTML_from_URL(local_url)
    35             golden_inner_html = open(golden_image).read()
    36             if inner_html != golden_inner_html:
    37                 failures += 1
    38         self.failUnless(failures == 0)
    40 def main():
    41     unittest.main()
    43 if __name__ == '__main__':
    44     main()

mercurial