# 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/. import json import os import pathlib import re import signal import tempfile import threading
from mozdevice import ADBDevice from mozlog import get_proxy_logger from mozprocess import ProcessHandler
from mozperftest.layers import Layer from mozperftest.utils import (
ON_TRY,
download_file,
get_output_dir,
get_pretty_app_name,
install_package,
)
LOG = get_proxy_logger(component="proxy")
HERE = os.path.dirname(__file__)
def __call__(self, line):
line = line.strip() ifnot line: return
line = line.decode("utf-8", errors="replace") try:
data = json.loads(line) except ValueError:
self.process_output(line) return
if isinstance(data, dict) and"action"in data: # Retrieve the port number for the proxy server from the logs of # our subprocess.
m = re.match(r"Proxy running on port (\d+)", data.get("message", "")) if m:
self.port = int(m.group(1))
self.port_event.set()
LOG.log_raw(data) else:
self.process_output(json.dumps(data))
def finished(self):
self.port_event.set()
def process_output(self, line): if self.proc isNone:
LOG.process_output(line) else:
LOG.process_output(self.proc.pid, line)
arguments = { "mode": { "type": str, "choices": ["record", "playback"], "help": "Proxy server mode. Use `playback` to replay from the provided file(s). " "Use `record` to generate a new recording at the path specified by `--file`. " "playback - replay from provided file. " "record - generate a new recording at the specified path.",
}, "file": { "type": str, "nargs": "+", "help": "The playback files to replay, or the file that a recording will be saved to. " "For playback, it can be any combination of the following: zip file, manifest file, " "or a URL to zip/manifest file. " "For recording, it's a zip fle.",
}, "perftest-page": { "type": str, "default": None, "help": "This option can be used to specify a single test to record rather than " "having to continuously modify the pageload_sites.json. This flag should only be " "used by the perftest team and selects items from " "`testing/performance/pageload_sites.json` based on the name field. Note that " "the login fields won't be checked with a request such as this (i.e. it overrides " "those settings).",
}, "deterministic": { "action": "store_true", "default": False, "help": "If set, the deterministic JS script will be injected into the pages.",
},
}
if metadata.flavor == "mobile-browser":
command.extend(["--tool=%s" % "mitmproxy-android"])
command.extend(["--binary=android"])
command.extend(
[f"--app={get_pretty_app_name(self.get_arg('android-app-name'))}"]
) else:
command.extend(["--tool=%s" % "mitmproxy"]) # XXX See bug 1712337, we need a single point where we can get the binary used from # this is required to make it work localy
binary = self.get_arg("browsertime-binary") if binary isNone:
binary = self.mach_cmd.get_binary_path()
command.extend(["--binary=%s" % binary])
if self.get_arg("mode") == "record":
output = self.get_arg("output") if output isNone:
output = pathlib.Path(self.mach_cmd.topsrcdir, "artifacts")
results_dir = get_output_dir(output)
# Wait until we've retrieved the proxy server's port number so we can # configure the browser properly.
port = self.output_handler.wait_for_port() if port isNone: raise ValueError("Unable to retrieve the port number from mozproxy")
self.info("Received port number %s from mozproxy" % port)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.