build/leaktest.py.in

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #literal #!/usr/bin/python
     2 #
     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
     5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7 import SimpleHTTPServer
     8 import SocketServer
     9 import threading
    10 import os
    11 import sys
    12 import logging
    13 from getopt import getopt
    14 from automation import Automation
    16 PORT = 8888
    17 SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
    18 PROFILE_DIRECTORY = os.path.abspath(os.path.join(SCRIPT_DIR, "./leakprofile"))
    19 os.chdir(SCRIPT_DIR)
    21 class EasyServer(SocketServer.TCPServer):
    22     allow_reuse_address = True
    24 if __name__ == '__main__':
    25     automation = Automation()
    26     DIST_BIN = os.path.join(SCRIPT_DIR, automation.DIST_BIN)
    27     opts, extraArgs = getopt(sys.argv[1:], 'l:')
    28     if len(opts) > 0:
    29         try:
    30             automation.log.addHandler(logging.FileHandler(opts[0][1], "w"))
    31         except:
    32             automation.log.info("Unable to open logfile " + opts[0][1] + \
    33                                 "ONLY logging to stdout.")
    35     httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
    36     t = threading.Thread(target=httpd.serve_forever)
    37     t.setDaemon(True)
    38     t.start()
    40     automation.setServerInfo("localhost", PORT)
    42     # keep a profile reference so that it is not cleaned up immediately via __del__
    43     profile = automation.initializeProfile(PROFILE_DIRECTORY)
    45     browserEnv = automation.environment()
    47     if not "XPCOM_DEBUG_BREAK" in browserEnv:
    48         browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
    49     url = "http://localhost:%d/bloatcycle.html" % PORT
    50     appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
    51     status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY,
    52                                extraArgs, timeout=1800)
    53     sys.exit(status)

mercurial