From f2a33ff9cbc6d19943f1c7fbddd1f23d23975577 Mon Sep 17 00:00:00 2001 From: Andras Becsi Date: Wed, 11 Dec 2013 21:33:03 +0100 Subject: Update Chromium to branch 1650 (31.0.1650.63) Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f Reviewed-by: Jocelyn Turcotte --- .../tools/browser_tester/browser_tester.py | 26 ++++++++++++-- .../tools/browser_tester/browserdata/nacltest.js | 11 ++++++ .../browsertester/browserlauncher.py | 17 +++++---- .../browser_tester/browsertester/browserprocess.py | 8 ++++- .../tools/browser_tester/browsertester/server.py | 42 ++++++++++++++++++++-- 5 files changed, 92 insertions(+), 12 deletions(-) (limited to 'chromium/ppapi/native_client/tools/browser_tester') diff --git a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py index 513a091605c..0fef6ea6713 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browser_tester.py @@ -47,6 +47,12 @@ def BuildArgParser(): metavar='DIRNAME', help='Add directory DIRNAME to be served from the HTTP ' 'server to be made visible under the root.') + parser.add_option('--output_dir', dest='output_dir', action='store', + type='string', default=None, + metavar='DIRNAME', + help='Set directory DIRNAME to be the output directory ' + 'when POSTing data to the server. NOTE: if this flag is ' + 'not set, POSTs will fail.') parser.add_option('--test_arg', dest='test_args', action='append', type='string', nargs=2, default=[], metavar='KEY VALUE', @@ -73,6 +79,10 @@ def BuildArgParser(): parser.add_option('--ppapi_plugin', dest='ppapi_plugin', action='store', type='string', default=None, help='Use the browser plugin located here.') + parser.add_option('--ppapi_plugin_mimetype', dest='ppapi_plugin_mimetype', + action='store', type='string', default='application/x-nacl', + help='Associate this mimetype with the browser plugin. ' + 'Unused if --ppapi_plugin is not specified.') parser.add_option('--sel_ldr', dest='sel_ldr', action='store', type='string', default=None, help='Use the sel_ldr located here.') @@ -138,6 +148,10 @@ def BuildArgParser(): parser.add_option('--enable_crash_reporter', dest='enable_crash_reporter', action='store_true', default=False, help='Force crash reporting on.') + parser.add_option('--enable_sockets', dest='enable_sockets', + action='store_true', default=False, + help='Pass --allow-nacl-socket-api= to Chrome, where ' + ' is the name of the browser tester\'s web server.') return parser @@ -235,14 +249,15 @@ def RunTestsOnce(url, options): options.allow_404, options.bandwidth, listener, - options.serving_dirs) + options.serving_dirs, + options.output_dir) browser = browsertester.browserlauncher.ChromeLauncher(options) full_url = 'http://%s:%d/%s' % (host, port, url) if len(options.test_args) > 0: full_url += '?' + urllib.urlencode(options.test_args) - browser.Run(full_url, port) + browser.Run(full_url, host, port) server.TestingBegun(0.125) # In Python 2.5, server.handle_request may block indefinitely. Serving pages @@ -308,6 +323,13 @@ def RunTestsOnce(url, options): DumpNetLog(browser.NetLogName()) except Exception: listener.ever_failed = 1 + # Try to let the browser clean itself up normally before killing it. + sys.stdout.write('##################### Terminating the browser\n') + browser.WaitForProcessDeath() + if browser.IsRunning(): + sys.stdout.write('##################### TERM failed, KILLING\n') + # Always call Cleanup; it kills the process, but also removes the + # user-data-dir. browser.Cleanup() # We avoid calling server.server_close() here because it causes # the HTTP server thread to exit uncleanly with an EBADF error, diff --git a/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js b/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js index 6917d5a03de..59a1340075d 100644 --- a/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js +++ b/chromium/ppapi/native_client/tools/browser_tester/browserdata/nacltest.js @@ -466,6 +466,17 @@ function embed_name(embed) { } +// Write data to the filesystem. This will only work if the browser_tester was +// initialized with --output_dir. +function outputFile(name, data, onload, onerror) { + var xhr = new XMLHttpRequest(); + xhr.onload = onload; + xhr.onerror = onerror; + xhr.open('POST', name, true); + xhr.send(data); +} + + // Webkit Bug Workaround // THIS SHOULD BE REMOVED WHEN Webkit IS FIXED // http://code.google.com/p/nativeclient/issues/detail?id=2428 diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py index 256a1cb37f9..67ea29125e9 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserlauncher.py @@ -9,6 +9,7 @@ import shutil import sys import tempfile import time +import urlparse import browserprocess @@ -105,7 +106,7 @@ class BrowserLauncher(object): def CreateProfile(self): raise NotImplementedError - def MakeCmd(self, url): + def MakeCmd(self, url, host, port): raise NotImplementedError def CreateToolLogDir(self): @@ -205,12 +206,12 @@ class BrowserLauncher(object): def GetReturnCode(self): return self.browser_process.GetReturnCode() - def Run(self, url, port): + def Run(self, url, host, port): self.binary = EscapeSpaces(self.FindBinary()) self.profile = self.CreateProfile() if self.options.tool is not None: self.tool_log_dir = self.CreateToolLogDir() - cmd = self.MakeCmd(url, port) + cmd = self.MakeCmd(url, host, port) self.Launch(cmd, MakeEnv(self.options)) @@ -262,7 +263,7 @@ class ChromeLauncher(BrowserLauncher): def NetLogName(self): return os.path.join(self.profile, 'netlog.json') - def MakeCmd(self, url, port): + def MakeCmd(self, url, host, port): cmd = [self.binary, # Note that we do not use "--enable-logging" here because # it actually turns off logging to the Buildbot logs on @@ -279,6 +280,7 @@ class ChromeLauncher(BrowserLauncher): '--no-default-browser-check', '--log-level=1', '--safebrowsing-disable-auto-update', + '--disable-default-apps', # Suppress metrics reporting. This prevents misconfigured bots, # people testing at their desktop, etc from poisoning the UMA data. '--metrics-recording-only', @@ -302,8 +304,9 @@ class ChromeLauncher(BrowserLauncher): if disable_sandbox: cmd.append('--no-sandbox') else: - cmd.append('--register-pepper-plugins=%s;application/x-nacl' - % self.options.ppapi_plugin) + cmd.append('--register-pepper-plugins=%s;%s' + % (self.options.ppapi_plugin, + self.options.ppapi_plugin_mimetype)) cmd.append('--no-sandbox') if self.options.browser_extensions: cmd.append('--load-extension=%s' % @@ -335,6 +338,8 @@ class ChromeLauncher(BrowserLauncher): '--log-file=%s/log.%%p' % (self.tool_log_dir,)] + cmd elif self.options.tool != None: raise LaunchFailure('Invalid tool name "%s"' % (self.options.tool,)) + if self.options.enable_sockets: + cmd.append('--allow-nacl-socket-api=%s' % host) cmd.extend(self.options.browser_flags) cmd.append(url) return cmd diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py index bca17340774..e10e6b5336f 100755 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/browserprocess.py @@ -21,7 +21,13 @@ class BrowserProcessBase(object): return self.handle.poll() is None def Wait(self, wait_steps, sleep_time): - self.term() + try: + self.term() + except Exception: + # Terminating the handle can raise an exception. There is likely no point + # in waiting if the termination didn't succeed. + return + i = 0 # subprocess.wait() doesn't have a timeout, unfortunately. while self.IsRunning() and i < wait_steps: diff --git a/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py b/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py index d1f9375b96e..971d0d6fc5e 100644 --- a/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py +++ b/chromium/ppapi/native_client/tools/browser_tester/browsertester/server.py @@ -124,8 +124,43 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): self.end_headers() data = self.rfile.read(int(self.headers.getheader('content-length'))) self.wfile.write(data) + elif self.server.output_dir is not None: + # Try to write the file to disk. + path = self.NormalizePath(path) + output_path = os.path.join(self.server.output_dir, path) + try: + outfile = open(output_path, 'w') + except IOError: + error_message = 'File not found: %r' % output_path + self.server.listener.ServerError(error_message) + self.send_error(404, error_message) + return + + try: + data = self.rfile.read(int(self.headers.getheader('content-length'))) + outfile.write(data) + except IOError, e: + outfile.close() + try: + os.remove(output_path) + except OSError: + # Oh, well. + pass + error_message = 'Can\'t write file: %r\n' % output_path + error_message += 'Exception:\n%s' % str(e) + self.server.listener.ServerError(error_message) + self.send_error(500, error_message) + return + + outfile.close() + + # Send a success response. + self.send_response(200) + self.end_headers() else: - self.send_error(404, 'File not found') + error_message = 'File not found: %r' % path + self.server.listener.ServerError(error_message) + self.send_error(404, error_message) self.server.ResetTimeout() @@ -214,8 +249,8 @@ class RequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): class Server(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): def Configure( - self, file_mapping, redirect_mapping, extensions_mapping, allow_404, - bandwidth, listener, serving_dirs=[]): + self, file_mapping, redirect_mapping, extensions_mapping, allow_404, + bandwidth, listener, serving_dirs=[], output_dir=None): self.file_mapping = file_mapping self.redirect_mapping = redirect_mapping self.extensions_mapping.update(extensions_mapping) @@ -224,6 +259,7 @@ class Server(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer): self.listener = listener self.rpc_lock = threading.Lock() self.serving_dirs = serving_dirs + self.output_dir = output_dir def TestingBegun(self, timeout): self.test_in_progress = True -- cgit v1.2.1