Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | #!/usr/bin/python |
michael@0 | 2 | # |
michael@0 | 3 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 6 | |
michael@0 | 7 | from mozprofile import FirefoxProfile, Profile, Preferences |
michael@0 | 8 | from mozprofile.permissions import ServerLocations |
michael@0 | 9 | from mozrunner import FirefoxRunner, CLI |
michael@0 | 10 | from mozhttpd import MozHttpd |
michael@0 | 11 | import json |
michael@0 | 12 | import socket |
michael@0 | 13 | import threading |
michael@0 | 14 | import os |
michael@0 | 15 | import sys |
michael@0 | 16 | import shutil |
michael@0 | 17 | import tempfile |
michael@0 | 18 | from datetime import datetime |
michael@0 | 19 | from mozbuild.base import MozbuildObject |
michael@0 | 20 | from buildconfig import substs |
michael@0 | 21 | |
michael@0 | 22 | PORT = 8888 |
michael@0 | 23 | |
michael@0 | 24 | if __name__ == '__main__': |
michael@0 | 25 | cli = CLI() |
michael@0 | 26 | debug_args, interactive = cli.debugger_arguments() |
michael@0 | 27 | |
michael@0 | 28 | build = MozbuildObject.from_environment() |
michael@0 | 29 | httpd = MozHttpd(port=PORT, |
michael@0 | 30 | docroot=os.path.join(build.topsrcdir, "build", "pgo")) |
michael@0 | 31 | httpd.start(block=False) |
michael@0 | 32 | |
michael@0 | 33 | locations = ServerLocations() |
michael@0 | 34 | locations.add_host(host='127.0.0.1', |
michael@0 | 35 | port=PORT, |
michael@0 | 36 | options='primary,privileged') |
michael@0 | 37 | |
michael@0 | 38 | #TODO: mozfile.TemporaryDirectory |
michael@0 | 39 | profilePath = tempfile.mkdtemp() |
michael@0 | 40 | try: |
michael@0 | 41 | #TODO: refactor this into mozprofile |
michael@0 | 42 | prefpath = os.path.join(build.topsrcdir, "testing", "profiles", "prefs_general.js") |
michael@0 | 43 | prefs = {} |
michael@0 | 44 | prefs.update(Preferences.read_prefs(prefpath)) |
michael@0 | 45 | interpolation = { "server": "%s:%d" % httpd.httpd.server_address, |
michael@0 | 46 | "OOP": "false"} |
michael@0 | 47 | prefs = json.loads(json.dumps(prefs) % interpolation) |
michael@0 | 48 | for pref in prefs: |
michael@0 | 49 | prefs[pref] = Preferences.cast(prefs[pref]) |
michael@0 | 50 | profile = FirefoxProfile(profile=profilePath, |
michael@0 | 51 | preferences=prefs, |
michael@0 | 52 | addons=[os.path.join(build.distdir, 'xpi-stage', 'quitter')], |
michael@0 | 53 | locations=locations) |
michael@0 | 54 | |
michael@0 | 55 | env = os.environ.copy() |
michael@0 | 56 | env["MOZ_CRASHREPORTER_NO_REPORT"] = "1" |
michael@0 | 57 | env["XPCOM_DEBUG_BREAK"] = "warn" |
michael@0 | 58 | |
michael@0 | 59 | # For VC12, make sure we can find the right bitness of pgort120.dll |
michael@0 | 60 | if "VS120COMNTOOLS" in env and not substs["HAVE_64BIT_OS"]: |
michael@0 | 61 | vc12dir = os.path.abspath(os.path.join(env["VS120COMNTOOLS"], |
michael@0 | 62 | "../../VC/bin")) |
michael@0 | 63 | if os.path.exists(vc12dir): |
michael@0 | 64 | env["PATH"] = vc12dir + ";" + env["PATH"] |
michael@0 | 65 | |
michael@0 | 66 | jarlog = os.getenv("JARLOG_FILE") |
michael@0 | 67 | if jarlog: |
michael@0 | 68 | env["MOZ_JAR_LOG_FILE"] = os.path.abspath(jarlog) |
michael@0 | 69 | print "jarlog: %s" % env["MOZ_JAR_LOG_FILE"] |
michael@0 | 70 | |
michael@0 | 71 | cmdargs = ["http://localhost:%d/index.html" % PORT] |
michael@0 | 72 | runner = FirefoxRunner(profile=profile, |
michael@0 | 73 | binary=build.get_binary_path(where="staged-package"), |
michael@0 | 74 | cmdargs=cmdargs, |
michael@0 | 75 | env=env) |
michael@0 | 76 | runner.start(debug_args=debug_args, interactive=interactive) |
michael@0 | 77 | runner.wait() |
michael@0 | 78 | httpd.stop() |
michael@0 | 79 | finally: |
michael@0 | 80 | shutil.rmtree(profilePath) |