2008-02-21 21:08:39 +00:00
|
|
|
#literal #!/usr/bin/python
|
|
|
|
#
|
2012-05-21 11:12:37 +00: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 21:08:39 +00:00
|
|
|
|
|
|
|
import SimpleHTTPServer
|
|
|
|
import SocketServer
|
|
|
|
import socket
|
|
|
|
import threading
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
from datetime import datetime
|
2011-02-02 15:44:00 +00:00
|
|
|
|
|
|
|
SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
|
2011-02-05 03:38:52 +00:00
|
|
|
sys.path.insert(0, SCRIPT_DIR)
|
2010-01-15 17:22:54 +00:00
|
|
|
from automation import Automation
|
2010-12-06 15:37:29 +00:00
|
|
|
from automationutils import getDebuggerInfo, addCommonOptions
|
2008-02-21 21:08:39 +00:00
|
|
|
|
|
|
|
PORT = 8888
|
|
|
|
PROFILE_DIRECTORY = os.path.abspath(os.path.join(SCRIPT_DIR, "./pgoprofile"))
|
2011-06-11 00:54:01 +00:00
|
|
|
MOZ_JAR_LOG_DIR = os.path.abspath(os.getenv("JARLOG_DIR"))
|
2008-02-21 21:08:39 +00:00
|
|
|
os.chdir(SCRIPT_DIR)
|
|
|
|
|
|
|
|
class EasyServer(SocketServer.TCPServer):
|
|
|
|
allow_reuse_address = True
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2010-12-06 15:37:29 +00:00
|
|
|
from optparse import OptionParser
|
2010-01-15 17:22:54 +00:00
|
|
|
automation = Automation()
|
2010-12-06 15:37:29 +00:00
|
|
|
|
2011-07-19 18:12:51 +00:00
|
|
|
parser = OptionParser()
|
2010-12-06 15:37:29 +00:00
|
|
|
addCommonOptions(parser)
|
|
|
|
|
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
|
|
|
debuggerInfo = getDebuggerInfo(".", options.debugger, options.debuggerArgs,
|
|
|
|
options.debuggerInteractive)
|
|
|
|
|
2008-02-21 21:08:39 +00: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 21:53:37 +00:00
|
|
|
|
|
|
|
automation.setServerInfo("localhost", PORT)
|
2011-07-19 18:12:51 +00:00
|
|
|
automation.initializeProfile(PROFILE_DIRECTORY)
|
2009-10-08 18:10:47 +00:00
|
|
|
browserEnv = automation.environment()
|
2008-02-21 21:08:39 +00:00
|
|
|
browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
|
2010-08-18 17:34:07 +00:00
|
|
|
browserEnv["MOZ_JAR_LOG_DIR"] = MOZ_JAR_LOG_DIR
|
2008-02-21 21:08:39 +00:00
|
|
|
|
2009-01-13 12:34:19 +00:00
|
|
|
url = "http://localhost:%d/index.html" % PORT
|
|
|
|
appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
|
2011-07-19 18:12:51 +00: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)
|