2008-02-21 13:08:39 -08:00
|
|
|
#literal #!/usr/bin/python
|
|
|
|
#
|
2012-05-21 04:12:37 -07:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2008-02-21 13:08:39 -08:00
|
|
|
|
|
|
|
import SimpleHTTPServer
|
|
|
|
import SocketServer
|
|
|
|
import socket
|
|
|
|
import threading
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
from datetime import datetime
|
2011-02-02 07:44:00 -08:00
|
|
|
|
|
|
|
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
|
2011-02-04 19:38:52 -08:00
|
|
|
sys.path.insert(0, SCRIPT_DIR)
|
2010-01-15 09:22:54 -08:00
|
|
|
from automation import Automation
|
2010-12-06 07:37:29 -08:00
|
|
|
from automationutils import getDebuggerInfo, addCommonOptions
|
2008-02-21 13:08:39 -08:00
|
|
|
|
|
|
|
PORT = 8888
|
|
|
|
PROFILE_DIRECTORY = os.path.abspath(os.path.join(SCRIPT_DIR, "./pgoprofile"))
|
2011-06-10 17:54:01 -07:00
|
|
|
MOZ_JAR_LOG_DIR = os.path.abspath(os.getenv("JARLOG_DIR"))
|
2008-02-21 13:08:39 -08:00
|
|
|
os.chdir(SCRIPT_DIR)
|
|
|
|
|
|
|
|
class EasyServer(SocketServer.TCPServer):
|
|
|
|
allow_reuse_address = True
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2010-12-06 07:37:29 -08:00
|
|
|
from optparse import OptionParser
|
2010-01-15 09:22:54 -08:00
|
|
|
automation = Automation()
|
2010-12-06 07:37:29 -08:00
|
|
|
|
2011-07-19 11:12:51 -07:00
|
|
|
parser = OptionParser()
|
2010-12-06 07:37:29 -08:00
|
|
|
addCommonOptions(parser)
|
|
|
|
|
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
|
|
|
debuggerInfo = getDebuggerInfo(".", options.debugger, options.debuggerArgs,
|
|
|
|
options.debuggerInteractive)
|
|
|
|
|
2008-02-21 13:08:39 -08:00
|
|
|
httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
|
|
|
|
t = threading.Thread(target=httpd.serve_forever)
|
|
|
|
t.setDaemon(True) # don't hang on exit
|
|
|
|
t.start()
|
2010-03-12 13:53:37 -08:00
|
|
|
|
|
|
|
automation.setServerInfo("localhost", PORT)
|
2011-07-19 11:12:51 -07:00
|
|
|
automation.initializeProfile(PROFILE_DIRECTORY)
|
2009-10-08 11:10:47 -07:00
|
|
|
browserEnv = automation.environment()
|
2008-02-21 13:08:39 -08:00
|
|
|
browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
|
2010-08-18 10:34:07 -07:00
|
|
|
browserEnv["MOZ_JAR_LOG_DIR"] = MOZ_JAR_LOG_DIR
|
2008-02-21 13:08:39 -08:00
|
|
|
|
2009-01-13 04:34:19 -08:00
|
|
|
url = "http://localhost:%d/index.html" % PORT
|
|
|
|
appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
|
2011-07-19 11:12:51 -07:00
|
|
|
status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY, {},
|
|
|
|
debuggerInfo=debuggerInfo,
|
|
|
|
# the profiling HTML doesn't output anything,
|
|
|
|
# so let's just run this without a timeout
|
|
|
|
timeout = None)
|
|
|
|
sys.exit(status)
|