def test_webkitgtk_certificate_domain_list(product): def domain_is_inside_certificate_list_cert(domain_to_find, webkitgtk_certificate_list, cert_file): for domain in webkitgtk_certificate_list: if domain["host"] == domain_to_find and domain[ "certificateFile"] == cert_file: return True return False if product not in ["epiphany", "webkit", "webkitgtk_minibrowser"]: pytest.skip("%s doesn't support certificate_domain_list" % product) (check_args, target_browser_cls, get_browser_kwargs, executor_classes, get_executor_kwargs, env_options, get_env_extras, run_info_extras) = products.load_product({}, product) cert_file = "/home/user/wpt/tools/certs/cacert.pem" valid_domains_test = [ "a.example.org", "b.example.org", "example.org", "a.example.net", "b.example.net", "example.net" ] invalid_domains_test = [ "x.example.org", "y.example.org", "example.it", "x.example.net", "y.example.net", "z.example.net" ] kwargs = {} kwargs["timeout_multiplier"] = 1 kwargs["debug_info"] = None kwargs["host_cert_path"] = cert_file kwargs["webkit_port"] = "gtk" kwargs["binary"] = None kwargs["webdriver_binary"] = None kwargs["pause_after_test"] = False kwargs["pause_on_unexpected"] = False kwargs["debug_test"] = False with ConfigBuilder(browser_host="example.net", alternate_hosts={"alt": "example.org"}, subdomains={"a", "b"}, not_subdomains={"x", "y"}) as env_config: executor_args = get_executor_kwargs(None, None, env_config, None, None, **kwargs) assert ('capabilities' in executor_args) assert ('webkitgtk:browserOptions' in executor_args['capabilities']) assert ('certificates' in executor_args['capabilities']['webkitgtk:browserOptions']) cert_list = executor_args['capabilities']['webkitgtk:browserOptions'][ 'certificates'] for valid_domain in valid_domains_test: assert (domain_is_inside_certificate_list_cert( valid_domain, cert_list, cert_file)) assert (not domain_is_inside_certificate_list_cert( valid_domain, cert_list, cert_file + ".backup_non_existent")) for invalid_domain in invalid_domains_test: assert (not domain_is_inside_certificate_list_cert( invalid_domain, cert_list, cert_file)) assert (not domain_is_inside_certificate_list_cert( invalid_domain, cert_list, cert_file + ".backup_non_existent"))
def test_server_start_config(product): (check_args, target_browser_cls, get_browser_kwargs, executor_classes, get_executor_kwargs, env_options, get_env_extras, run_info_extras) = products.load_product({}, product) env_extras = get_env_extras() with mock.patch.object(environment.serve, "start") as start: with environment.TestEnvironment(test_paths, sslutils.environments["none"](None), False, None, env_options, env_extras) as test_environment: start.assert_called_once() args = start.call_args config = args[0][0] if "host" in env_options: assert config["host"] == env_options["host"] assert isinstance(config["bind_address"], bool)
def test_server_start_config(product): (check_args, target_browser_cls, get_browser_kwargs, executor_classes, get_executor_kwargs, env_options, get_env_extras, run_info_extras) = products.load_product({}, product) env_extras = get_env_extras() with mock.patch.object(environment.serve, "start") as start: with environment.TestEnvironment(test_paths, sslutils.environments["none"](None), False, None, env_options, env_extras): start.assert_called_once() args = start.call_args config = args[0][0] if "server_host" in env_options: assert config["server_host"] == env_options["server_host"] else: assert config["server_host"] == config["browser_host"] assert isinstance(config["bind_address"], bool)
def load_wpt_tests(xul_tester, requested_paths, excluded_paths, update_manifest=True): """Return a list of `RefTestCase` objects for the jsshell testharness.js tests filtered by the given paths and debug-ness.""" repo_root = abspath(os.path.join(here, "..", "..", "..")) wp = os.path.join(repo_root, "testing", "web-platform") wpt = os.path.join(wp, "tests") sys_paths = [ "python/mozterm", "python/mozboot", "testing/mozbase/mozcrash", "testing/mozbase/mozdevice", "testing/mozbase/mozfile", "testing/mozbase/mozinfo", "testing/mozbase/mozleak", "testing/mozbase/mozlog", "testing/mozbase/mozprocess", "testing/mozbase/mozprofile", "testing/mozbase/mozrunner", "testing/mozbase/mozversion", "testing/web-platform/", "testing/web-platform/tests/tools", "testing/web-platform/tests/tools/third_party/html5lib", "testing/web-platform/tests/tools/third_party/webencodings", "testing/web-platform/tests/tools/wptrunner", "testing/web-platform/tests/tools/wptserve", "third_party/python/requests", ] abs_sys_paths = [os.path.join(repo_root, path) for path in sys_paths] failed = False for path in abs_sys_paths: if not os.path.isdir(path): failed = True print("Could not add '%s' to the path") if failed: return [] sys.path[0:0] = abs_sys_paths import manifestupdate from wptrunner import products, testloader, wptcommandline, wpttest, wptlogging manifest_root = tempfile.gettempdir() path_split = os.path.dirname(xul_tester.js_bin).split(os.path.sep) if path_split[-2:] == ["dist", "bin"]: maybe_root = os.path.join(*path_split[:-2]) if os.path.exists(os.path.join(maybe_root, "_tests")): # Assume this is a gecko objdir. manifest_root = maybe_root logger = wptlogging.setup({}, {}) test_manifests = manifestupdate.run(repo_root, manifest_root, logger, update=update_manifest) kwargs = vars(wptcommandline.create_parser().parse_args([])) kwargs.update({ "config": os.path.join(manifest_root, "_tests", "web-platform", "wptrunner.local.ini"), "gecko_e10s": False, "verify": False, "wasm": xul_tester.test("wasmIsSupported()"), }) wptcommandline.set_from_config(kwargs) def filter_jsshell_tests(it): for item_type, path, tests in it: tests = set(item for item in tests if item.jsshell) if tests: yield item_type, path, tests run_info_extras = products.load_product(kwargs["config"], "firefox")[-1](**kwargs) run_info = wpttest.get_run_info(kwargs["test_paths"]["/"]["metadata_path"], "firefox", debug=xul_tester.test("isDebugBuild"), extras=run_info_extras) release_or_beta = xul_tester.test("getBuildConfiguration().release_or_beta") run_info["release_or_beta"] = release_or_beta run_info["nightly_build"] = not release_or_beta path_filter = testloader.TestFilter(test_manifests, include=requested_paths, exclude=excluded_paths) loader = testloader.TestLoader(test_manifests, ["testharness"], run_info, manifest_filters=[path_filter, filter_jsshell_tests]) extra_helper_paths = [ os.path.join(here, "web-platform-test-shims.js"), os.path.join(wpt, "resources", "testharness.js"), os.path.join(here, "testharnessreport.js"), ] def resolve(test_path, script): if script.startswith("/"): return os.path.join(wpt, script[1:]) return os.path.join(wpt, os.path.dirname(test_path), script) tests = [] for test in loader.tests["testharness"]: test_path = os.path.relpath(test.path, wpt) scripts = [resolve(test_path, s) for s in test.scripts] extra_helper_paths_for_test = extra_helper_paths + scripts # We must create at least one test with the default options, along with # one test for each option given in a test-also annotation. options = [None] for m in test.itermeta(): if m.has_key("test-also"): # NOQA: W601 options += m.get("test-also").split() for option in options: test_case = RefTestCase( wpt, test_path, extra_helper_paths=extra_helper_paths_for_test[:], wpt=test ) if option: test_case.options.append(option) tests.append(test_case) return tests
def test_load_all_products(product): """test every product either loads or throws ImportError""" try: products.load_product({}, product) except ImportError: pass
def test_load_active_product(product): """test we can successfully load the product of the current testenv""" products.load_product({}, product)
def load_wpt_tests(xul_tester, requested_paths, excluded_paths): """Return a list of `RefTestCase` objects for the jsshell testharness.js tests filtered by the given paths and debug-ness.""" repo_root = abspath(os.path.join(here, "..", "..", "..")) wp = os.path.join(repo_root, "testing", "web-platform") wpt = os.path.join(wp, "tests") sys_paths = [ "python/mozterm", "python/mozboot", "testing/mozbase/mozcrash", "testing/mozbase/mozdevice", "testing/mozbase/mozfile", "testing/mozbase/mozinfo", "testing/mozbase/mozleak", "testing/mozbase/mozlog", "testing/mozbase/mozprocess", "testing/mozbase/mozprofile", "testing/mozbase/mozrunner", "testing/web-platform/", "testing/web-platform/tests/tools", "testing/web-platform/tests/tools/third_party/html5lib", "testing/web-platform/tests/tools/third_party/webencodings", "testing/web-platform/tests/tools/wptrunner", "testing/web-platform/tests/tools/wptserve", "third_party/python/requests", ] abs_sys_paths = [os.path.join(repo_root, path) for path in sys_paths] failed = False for path in abs_sys_paths: if not os.path.isdir(path): failed = True print("Could not add '%s' to the path") if failed: return [] sys.path[0:0] = abs_sys_paths import manifestupdate from wptrunner import products, testloader, wptcommandline, wpttest, wptlogging manifest_root = tempfile.gettempdir() path_split = os.path.dirname(xul_tester.js_bin).split(os.path.sep) if path_split[-2:] == ["dist", "bin"]: maybe_root = os.path.join(*path_split[:-2]) if os.path.exists(os.path.join(maybe_root, "_tests")): # Assume this is a gecko objdir. manifest_root = maybe_root logger = wptlogging.setup({}, {}) manifestupdate.run(repo_root, manifest_root, logger) kwargs = vars(wptcommandline.create_parser().parse_args([])) kwargs.update({ "config": os.path.join(manifest_root, "_tests", "web-platform", "wptrunner.local.ini"), "gecko_e10s": False, "verify": False, "wasm": xul_tester.test("wasmIsSupported()"), }) wptcommandline.set_from_config(kwargs) test_paths = kwargs["test_paths"] def filter_jsshell_tests(it): for test in it: if test[1].get("jsshell"): yield test test_manifests = testloader.ManifestLoader(test_paths, types=["testharness"], meta_filters=[filter_jsshell_tests]).load() run_info_extras = products.load_product(kwargs["config"], "firefox")[-1](**kwargs) run_info = wpttest.get_run_info(kwargs["test_paths"]["/"]["metadata_path"], "firefox", debug=xul_tester.test("isDebugBuild"), extras=run_info_extras) path_filter = testloader.TestFilter(test_manifests, include=requested_paths, exclude=excluded_paths) loader = testloader.TestLoader(test_manifests, ["testharness"], run_info, manifest_filters=[path_filter]) extra_helper_paths = [ os.path.join(here, "web-platform-test-shims.js"), os.path.join(wpt, "resources", "testharness.js"), os.path.join(here, "testharnessreport.js"), ] def resolve(test_path, script): if script.startswith("/"): return os.path.join(wpt, script[1:]) return os.path.join(wpt, os.path.dirname(test_path), script) return [ RefTestCase( wpt, test_path, extra_helper_paths=extra_helper_paths + [resolve(test_path, s) for s in test.scripts], wpt=test ) for test_path, test in ( (os.path.relpath(test.path, wpt), test) for test in loader.tests["testharness"] ) ]
def load_wpt_tests(xul_tester, requested_paths, excluded_paths): """Return a list of `RefTestCase` objects for the jsshell testharness.js tests filtered by the given paths and debug-ness.""" repo_root = abspath(os.path.join(here, "..", "..", "..")) wp = os.path.join(repo_root, "testing", "web-platform") wpt = os.path.join(wp, "tests") sys_paths = [ "python/mozterm", "python/mozboot", "testing/mozbase/mozcrash", "testing/mozbase/mozdevice", "testing/mozbase/mozfile", "testing/mozbase/mozinfo", "testing/mozbase/mozleak", "testing/mozbase/mozlog", "testing/mozbase/mozprocess", "testing/mozbase/mozprofile", "testing/mozbase/mozrunner", "testing/web-platform/", "testing/web-platform/tests/tools", "testing/web-platform/tests/tools/third_party/html5lib", "testing/web-platform/tests/tools/third_party/webencodings", "testing/web-platform/tests/tools/wptrunner", "testing/web-platform/tests/tools/wptserve", "third_party/python/requests", ] abs_sys_paths = [os.path.join(repo_root, path) for path in sys_paths] failed = False for path in abs_sys_paths: if not os.path.isdir(path): failed = True print("Could not add '%s' to the path") if failed: return [] sys.path[0:0] = abs_sys_paths import manifestupdate from wptrunner import products, testloader, wptcommandline, wpttest, wptlogging manifest_root = tempfile.gettempdir() path_split = os.path.dirname(xul_tester.js_bin).split(os.path.sep) if path_split[-2:] == ["dist", "bin"]: maybe_root = os.path.join(*path_split[:-2]) if os.path.exists(os.path.join(maybe_root, "_tests")): # Assume this is a gecko objdir. manifest_root = maybe_root logger = wptlogging.setup({}, {}) manifestupdate.run(repo_root, manifest_root, logger) kwargs = vars(wptcommandline.create_parser().parse_args([])) kwargs.update({ "config": os.path.join(manifest_root, "_tests", "web-platform", "wptrunner.local.ini"), "gecko_e10s": False, "verify": False, "wasm": xul_tester.test("wasmIsSupported()"), }) wptcommandline.set_from_config(kwargs) test_paths = kwargs["test_paths"] def filter_jsshell_tests(it): for test in it: if test[1].get("jsshell"): yield test test_manifests = testloader.ManifestLoader(test_paths, types=["testharness"], meta_filters=[filter_jsshell_tests]).load() run_info_extras = products.load_product(kwargs["config"], "firefox")[-1](**kwargs) run_info = wpttest.get_run_info(kwargs["test_paths"]["/"]["metadata_path"], "firefox", debug=xul_tester.test("isDebugBuild"), extras=run_info_extras) path_filter = testloader.TestFilter(test_manifests, include=requested_paths, exclude=excluded_paths) loader = testloader.TestLoader(test_manifests, ["testharness"], run_info, manifest_filters=[path_filter]) extra_helper_paths = [ os.path.join(here, "web-platform-test-shims.js"), os.path.join(wpt, "resources", "testharness.js"), os.path.join(here, "testharnessreport.js"), ] def resolve(test_path, script): if script.startswith("/"): return os.path.join(wpt, script[1:]) return os.path.join(wpt, os.path.dirname(test_path), script) return [ RefTestCase( wpt, test_path, extra_helper_paths=extra_helper_paths + [resolve(test_path, s) for s in test.scripts], wpt=test ) for test_path, test in ( (os.path.relpath(test.path, wpt), test) for test in loader.tests["testharness"] ) ]
def load_wpt_tests(requested_paths, excluded_paths, debug, wasm): """Return a list of `RefTestCase` objects for the jsshell testharness.js tests filtered by the given paths and debug-ness.""" repo_root = abspath(os.path.join(here, "..", "..", "..")) wp = os.path.join(repo_root, "testing", "web-platform") wpt = os.path.join(wp, "tests") sys_paths = [ "python/mozterm", "testing/mozbase/mozcrash", "testing/mozbase/mozdevice", "testing/mozbase/mozfile", "testing/mozbase/mozinfo", "testing/mozbase/mozleak", "testing/mozbase/mozlog", "testing/mozbase/mozprocess", "testing/mozbase/mozprofile", "testing/mozbase/mozrunner", "testing/web-platform/tests/tools", "testing/web-platform/tests/tools/third_party/html5lib", "testing/web-platform/tests/tools/third_party/webencodings", "testing/web-platform/tests/tools/wptrunner", "testing/web-platform/tests/tools/wptserve", ] abs_sys_paths = [os.path.join(repo_root, path) for path in sys_paths] failed = False for path in abs_sys_paths: if not os.path.isdir(path): failed = True print("Could not add '%s' to the path") if failed: return [] sys.path[0:0] = abs_sys_paths from wptrunner import products, testloader, wptcommandline, wpttest, wptlogging wptlogging.setup({}, {}) kwargs = { "config": None, "tests_root": wpt, "metadata_root": os.path.join(wp, "meta"), "gecko_e10s": False, "verify": False, "wasm": wasm, } wptcommandline.set_from_config(kwargs) test_paths = kwargs["test_paths"] def filter_jsshell_tests(it): for test in it: if test[1].get("jsshell"): yield test test_manifests = testloader.ManifestLoader(test_paths, types=["testharness"], meta_filters=[ filter_jsshell_tests ]).load() run_info_extras = products.load_product(kwargs["config"], "firefox")[-1](**kwargs) run_info = wpttest.get_run_info(kwargs["metadata_root"], "firefox", debug=debug, extras=run_info_extras) path_filter = testloader.TestFilter(test_manifests, include=requested_paths, exclude=excluded_paths) loader = testloader.TestLoader(test_manifests, ["testharness"], run_info, manifest_filters=[path_filter]) extra_helper_paths = [ os.path.join(wpt, "resources", "testharness.js"), os.path.join(here, "testharnessreport.js"), ] def resolve(test_path, script): if script.startswith("/"): return os.path.join(wpt, script[1:]) return os.path.join(wpt, os.path.dirname(test_path), script) return [ RefTestCase(wpt, test_path, extra_helper_paths=extra_helper_paths + [resolve(test_path, s) for s in test.scripts], wpt=test) for test_path, test in ((os.path.relpath(test.path, wpt), test) for test in loader.tests["testharness"]) ]