From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- .../web-platform/tests/resources/test/README.md | 83 ++ .../web-platform/tests/resources/test/conftest.py | 269 ++++++ .../web-platform/tests/resources/test/harness.html | 26 + .../tests/resources/test/idl-helper.js | 24 + .../tests/resources/test/nested-testharness.js | 80 ++ .../tests/resources/test/requirements.txt | 1 + .../test/tests/functional/add_cleanup.html | 91 ++ .../test/tests/functional/add_cleanup_async.html | 85 ++ .../functional/add_cleanup_async_bad_return.html | 50 ++ .../functional/add_cleanup_async_rejection.html | 94 ++ .../add_cleanup_async_rejection_after_load.html | 52 ++ .../functional/add_cleanup_async_timeout.html | 57 ++ .../tests/functional/add_cleanup_bad_return.html | 61 ++ .../test/tests/functional/add_cleanup_count.html | 39 + .../test/tests/functional/add_cleanup_err.html | 45 + .../tests/functional/add_cleanup_err_multi.html | 52 ++ .../tests/functional/add_cleanup_sync_queue.html | 55 ++ .../test/tests/functional/api-tests-1.html | 991 +++++++++++++++++++++ .../test/tests/functional/api-tests-2.html | 62 ++ .../test/tests/functional/api-tests-3.html | 34 + .../test/tests/functional/assert-array-equals.html | 162 ++++ .../test/tests/functional/force_timeout.html | 60 ++ .../test/tests/functional/generate-callback.html | 153 ++++ .../IdlDictionary/test_partial_interface_of.html | 90 ++ .../IdlInterface/test_exposed_wildcard.html | 233 +++++ .../IdlInterface/test_immutable_prototype.html | 298 +++++++ .../IdlInterface/test_interface_mixin.html | 131 +++ .../IdlInterface/test_partial_interface_of.html | 188 ++++ .../IdlInterface/test_primary_interface_of.html | 116 +++ .../IdlInterface/test_to_json_operation.html | 177 ++++ .../idlharness/IdlNamespace/test_attribute.html | 100 +++ .../idlharness/IdlNamespace/test_operation.html | 242 +++++ .../IdlNamespace/test_partial_namespace.html | 125 +++ .../test/tests/functional/iframe-callback.html | 116 +++ .../functional/iframe-consolidate-errors.html | 50 ++ .../tests/functional/iframe-consolidate-tests.html | 85 ++ .../test/tests/functional/iframe-msg.html | 84 ++ .../test/tests/functional/log-insertion.html | 46 + .../resources/test/tests/functional/no-title.html | 146 +++ .../resources/test/tests/functional/order.html | 36 + .../test/tests/functional/promise-async.html | 172 ++++ .../test/tests/functional/promise-with-sync.html | 79 ++ .../resources/test/tests/functional/promise.html | 219 +++++ .../resources/test/tests/functional/queue.html | 130 +++ .../test/tests/functional/setup-function-worker.js | 14 + .../tests/functional/setup-worker-service.html | 86 ++ .../tests/functional/single-page-test-fail.html | 28 + .../functional/single-page-test-no-assertions.html | 25 + .../tests/functional/single-page-test-no-body.html | 26 + .../tests/functional/single-page-test-pass.html | 28 + .../resources/test/tests/functional/step_wait.html | 57 ++ .../test/tests/functional/step_wait_func.html | 49 + .../functional/task-scheduling-promise-test.html | 241 +++++ .../tests/functional/task-scheduling-test.html | 141 +++ .../functional/uncaught-exception-handle.html | 33 + .../functional/uncaught-exception-ignore.html | 35 + .../worker-dedicated-uncaught-allow.html | 45 + .../worker-dedicated-uncaught-single.html | 56 ++ .../tests/functional/worker-dedicated.sub.html | 88 ++ .../test/tests/functional/worker-error.js | 8 + .../test/tests/functional/worker-service.html | 115 +++ .../test/tests/functional/worker-shared.html | 73 ++ .../test/tests/functional/worker-uncaught-allow.js | 19 + .../tests/functional/worker-uncaught-single.js | 8 + .../resources/test/tests/functional/worker.js | 34 + .../test/tests/unit/IdlArray/is_json_type.html | 192 ++++ .../get_reverse_inheritance_stack.html | 47 + .../IdlDictionary/test_partial_dictionary.html | 39 + .../test/tests/unit/IdlInterface/constructors.html | 26 + .../IdlInterface/default_to_json_operation.html | 114 +++ .../IdlInterface/do_member_unscopable_asserts.html | 56 ++ .../unit/IdlInterface/get_interface_object.html | 22 + .../IdlInterface/get_interface_object_owner.html | 21 + .../unit/IdlInterface/get_legacy_namespace.html | 20 + .../unit/IdlInterface/get_qualified_name.html | 20 + .../get_reverse_inheritance_stack.html | 49 + .../has_default_to_json_regular_operation.html | 47 + .../has_to_json_regular_operation.html | 31 + .../IdlInterface/should_have_interface_object.html | 30 + .../test_primary_interface_of_undefined.html | 29 + .../is_to_json_regular_operation.html | 42 + .../tests/unit/IdlInterfaceMember/toString.html | 36 + .../test/tests/unit/assert_implements.html | 43 + .../tests/unit/assert_implements_optional.html | 43 + .../test/tests/unit/assert_object_equals.html | 152 ++++ .../tests/unit/async-test-return-restrictions.html | 135 +++ .../tests/resources/test/tests/unit/basic.html | 48 + .../tests/unit/exceptional-cases-timeouts.html | 120 +++ .../test/tests/unit/exceptional-cases.html | 392 ++++++++ .../resources/test/tests/unit/format-value.html | 123 +++ .../tests/resources/test/tests/unit/helpers.js | 21 + .../tests/resources/test/tests/unit/late-test.html | 54 ++ .../test/tests/unit/promise_setup-timeout.html | 28 + .../resources/test/tests/unit/promise_setup.html | 333 +++++++ .../resources/test/tests/unit/single_test.html | 94 ++ .../test/tests/unit/test-return-restrictions.html | 156 ++++ .../test/tests/unit/throwing-assertions.html | 268 ++++++ .../test/tests/unit/unpaired-surrogates.html | 143 +++ testing/web-platform/tests/resources/test/tox.ini | 13 + .../web-platform/tests/resources/test/wptserver.py | 58 ++ 100 files changed, 9743 insertions(+) create mode 100644 testing/web-platform/tests/resources/test/README.md create mode 100644 testing/web-platform/tests/resources/test/conftest.py create mode 100644 testing/web-platform/tests/resources/test/harness.html create mode 100644 testing/web-platform/tests/resources/test/idl-helper.js create mode 100644 testing/web-platform/tests/resources/test/nested-testharness.js create mode 100644 testing/web-platform/tests/resources/test/requirements.txt create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_bad_return.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection_after_load.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_timeout.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_bad_return.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_count.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err_multi.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/add_cleanup_sync_queue.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/api-tests-1.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/api-tests-2.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/api-tests-3.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/assert-array-equals.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/force_timeout.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/generate-callback.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlDictionary/test_partial_interface_of.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_exposed_wildcard.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_immutable_prototype.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_interface_mixin.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_partial_interface_of.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_primary_interface_of.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_to_json_operation.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_attribute.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_operation.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_partial_namespace.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/iframe-callback.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-errors.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-tests.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/iframe-msg.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/log-insertion.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/no-title.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/order.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/promise-async.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/promise-with-sync.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/promise.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/queue.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/setup-function-worker.js create mode 100644 testing/web-platform/tests/resources/test/tests/functional/setup-worker-service.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/single-page-test-fail.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-assertions.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-body.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/single-page-test-pass.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/step_wait.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/step_wait_func.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/task-scheduling-promise-test.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/task-scheduling-test.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-handle.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-ignore.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-allow.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-single.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-dedicated.sub.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-error.js create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-service.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-shared.html create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-allow.js create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-single.js create mode 100644 testing/web-platform/tests/resources/test/tests/functional/worker.js create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlArray/is_json_type.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/get_reverse_inheritance_stack.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/test_partial_dictionary.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/constructors.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/default_to_json_operation.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/do_member_unscopable_asserts.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object_owner.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_legacy_namespace.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_qualified_name.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_reverse_inheritance_stack.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_default_to_json_regular_operation.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_to_json_regular_operation.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/should_have_interface_object.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterface/test_primary_interface_of_undefined.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/is_to_json_regular_operation.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/toString.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/assert_implements.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/assert_implements_optional.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/assert_object_equals.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/async-test-return-restrictions.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/basic.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/exceptional-cases-timeouts.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/exceptional-cases.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/format-value.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/helpers.js create mode 100644 testing/web-platform/tests/resources/test/tests/unit/late-test.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/promise_setup-timeout.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/promise_setup.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/single_test.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/test-return-restrictions.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/throwing-assertions.html create mode 100644 testing/web-platform/tests/resources/test/tests/unit/unpaired-surrogates.html create mode 100644 testing/web-platform/tests/resources/test/tox.ini create mode 100644 testing/web-platform/tests/resources/test/wptserver.py (limited to 'testing/web-platform/tests/resources/test') diff --git a/testing/web-platform/tests/resources/test/README.md b/testing/web-platform/tests/resources/test/README.md new file mode 100644 index 0000000000..edc03ef214 --- /dev/null +++ b/testing/web-platform/tests/resources/test/README.md @@ -0,0 +1,83 @@ +# `testharness.js` test suite + +The test suite for the `testharness.js` testing framework. + +## Executing Tests + +Install the following dependencies: + +- [Python 2.7.9+](https://www.python.org/) +- [the tox Python package](https://tox.readthedocs.io/en/latest/) +- [the Mozilla Firefox web browser](https://mozilla.org/firefox) +- [the GeckoDriver server](https://github.com/mozilla/geckodriver) + +Make sure `geckodriver` can be found in your `PATH`. + +Currently, the tests should be run with the latest *Firefox Nightly*. In order to +specify the path to Firefox Nightly, use the following command-line option: + + tox -- --binary=/path/to/FirefoxNightly + +### Automated Script + +Alternatively, you may run `tools/ci/ci_resources_unittest.sh`, which only depends on +Python 2. The script will install other dependencies automatically and start `tox` with +the correct arguments. + +## Authoring Tests + +Test cases are expressed as `.html` files located within the `tests/unit/` and +`tests/functional/` sub-directories. Each test should include the +`testharness.js` library with the following markup: + + + + +This should be followed by one or more ` + +### Unit tests + +The "unit test" type allows for concisely testing the expected behavior of +assertion methods. These tests may define any number of sub-tests; the +acceptance criteria is simply that all tests executed pass. + +### Functional tests + +Thoroughly testing the behavior of the harness itself requires ensuring a +number of considerations which cannot be verified with the "unit testing" +strategy. These include: + +- Ensuring that some tests are not run +- Ensuring conditions that cause test failures +- Ensuring conditions that cause harness errors + +Functional tests allow for these details to be verified. Every functional test +must include a summary of the expected results as a JSON string within a +` diff --git a/testing/web-platform/tests/resources/test/conftest.py b/testing/web-platform/tests/resources/test/conftest.py new file mode 100644 index 0000000000..7253cac9ac --- /dev/null +++ b/testing/web-platform/tests/resources/test/conftest.py @@ -0,0 +1,269 @@ +import copy +import json +import os +import ssl +import sys +import subprocess +import urllib + +import html5lib +import py +import pytest + +from wptserver import WPTServer + +HERE = os.path.dirname(os.path.abspath(__file__)) +WPT_ROOT = os.path.normpath(os.path.join(HERE, '..', '..')) +HARNESS = os.path.join(HERE, 'harness.html') +TEST_TYPES = ('functional', 'unit') + +sys.path.insert(0, os.path.normpath(os.path.join(WPT_ROOT, "tools"))) +import localpaths + +sys.path.insert(0, os.path.normpath(os.path.join(WPT_ROOT, "tools", "webdriver"))) +import webdriver + + +def pytest_addoption(parser): + parser.addoption("--binary", action="store", default=None, help="path to browser binary") + parser.addoption("--headless", action="store_true", default=False, help="run browser in headless mode") + + +def pytest_collect_file(file_path, path, parent): + if file_path.suffix.lower() != '.html': + return + + # Tests are organized in directories by type + test_type = os.path.relpath(str(file_path), HERE) + if os.path.sep not in test_type or ".." in test_type: + # HTML files in this directory are not tests + return + test_type = test_type.split(os.path.sep)[1] + + # Handle the deprecation of Node construction in pytest6 + # https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent + if hasattr(HTMLItem, "from_parent"): + return HTMLItem.from_parent(parent, filename=str(file_path), test_type=test_type) + return HTMLItem(parent, str(file_path), test_type) + + +def pytest_configure(config): + config.proc = subprocess.Popen(["geckodriver"]) + config.add_cleanup(config.proc.kill) + + capabilities = {"alwaysMatch": {"acceptInsecureCerts": True, "moz:firefoxOptions": {}}} + if config.getoption("--binary"): + capabilities["alwaysMatch"]["moz:firefoxOptions"]["binary"] = config.getoption("--binary") + if config.getoption("--headless"): + capabilities["alwaysMatch"]["moz:firefoxOptions"]["args"] = ["--headless"] + + config.driver = webdriver.Session("localhost", 4444, + capabilities=capabilities) + config.add_cleanup(config.driver.end) + + # Although the name of the `_create_unverified_context` method suggests + # that it is not intended for external consumption, the standard library's + # documentation explicitly endorses its use: + # + # > To revert to the previous, unverified, behavior + # > ssl._create_unverified_context() can be passed to the context + # > parameter. + # + # https://docs.python.org/2/library/httplib.html#httplib.HTTPSConnection + config.ssl_context = ssl._create_unverified_context() + + config.server = WPTServer(WPT_ROOT) + config.server.start(config.ssl_context) + config.add_cleanup(config.server.stop) + + +def resolve_uri(context, uri): + if uri.startswith('/'): + base = WPT_ROOT + path = uri[1:] + else: + base = os.path.dirname(context) + path = uri + + return os.path.exists(os.path.join(base, path)) + + +def _summarize(actual): + def _scrub_stack(test_obj): + copy = dict(test_obj) + del copy['stack'] + return copy + + def _expand_status(status_obj): + for key, value in [item for item in status_obj.items()]: + # In "status" and "test" objects, the "status" value enum + # definitions are interspersed with properties for unrelated + # metadata. The following condition is a best-effort attempt to + # ignore non-enum properties. + if key != key.upper() or not isinstance(value, int): + continue + + del status_obj[key] + + if status_obj['status'] == value: + status_obj[u'status_string'] = key + + del status_obj['status'] + + return status_obj + + def _summarize_test(test_obj): + del test_obj['index'] + + assert 'phase' in test_obj + assert 'phases' in test_obj + assert 'COMPLETE' in test_obj['phases'] + assert test_obj['phase'] == test_obj['phases']['COMPLETE'] + del test_obj['phases'] + del test_obj['phase'] + + return _expand_status(_scrub_stack(test_obj)) + + def _summarize_status(status_obj): + return _expand_status(_scrub_stack(status_obj)) + + + summarized = {} + + summarized[u'summarized_status'] = _summarize_status(actual['status']) + summarized[u'summarized_tests'] = [ + _summarize_test(test) for test in actual['tests']] + summarized[u'summarized_tests'].sort(key=lambda test_obj: test_obj.get('name')) + summarized[u'summarized_asserts'] = [ + {"assert_name": assert_item["assert_name"], + "test": assert_item["test"]["name"] if assert_item["test"] else None, + "args": assert_item["args"], + "status": assert_item["status"]} for assert_item in actual["asserts"]] + summarized[u'type'] = actual['type'] + + return summarized + + +class HTMLItem(pytest.Item, pytest.Collector): + def __init__(self, parent, filename, test_type): + self.url = parent.session.config.server.url(filename) + self.type = test_type + # Some tests are reliant on the WPT servers substitution functionality, + # so tests must be retrieved from the server rather than read from the + # file system directly. + handle = urllib.request.urlopen(self.url, + context=parent.session.config.ssl_context) + try: + markup = handle.read() + finally: + handle.close() + + if test_type not in TEST_TYPES: + raise ValueError('Unrecognized test type: "%s"' % test_type) + + parsed = html5lib.parse(markup, namespaceHTMLElements=False) + name = None + self.expected = None + + for element in parsed.iter(): + if not name and element.tag == 'title': + name = element.text + continue + if element.tag == 'script': + if element.attrib.get('id') == 'expected': + try: + self.expected = json.loads(element.text) + except ValueError: + print("Failed parsing JSON in %s" % filename) + raise + + if not name: + raise ValueError('No name found in %s add a element' % filename) + elif self.type == 'functional': + if not self.expected: + raise ValueError('Functional tests must specify expected report data') + elif self.type == 'unit' and self.expected: + raise ValueError('Unit tests must not specify expected report data') + + # Ensure that distinct items have distinct fspath attributes. + # This is necessary because pytest has an internal cache keyed on it, + # and only the first test with any given fspath will be run. + # + # This cannot use super(HTMLItem, self).__init__(..) because only the + # Collector constructor takes the fspath argument. + pytest.Item.__init__(self, name, parent) + pytest.Collector.__init__(self, name, parent, fspath=py.path.local(filename)) + + + def reportinfo(self): + return self.fspath, None, self.url + + def repr_failure(self, excinfo): + return pytest.Collector.repr_failure(self, excinfo) + + def runtest(self): + if self.type == 'unit': + self._run_unit_test() + elif self.type == 'functional': + self._run_functional_test() + else: + raise NotImplementedError + + def _run_unit_test(self): + driver = self.session.config.driver + server = self.session.config.server + + driver.url = server.url(HARNESS) + + actual = driver.execute_async_script( + 'runTest("%s", "foo", arguments[0])' % self.url + ) + + summarized = _summarize(copy.deepcopy(actual)) + + print(json.dumps(summarized, indent=2)) + + assert summarized[u'summarized_status'][u'status_string'] == u'OK', summarized[u'summarized_status'][u'message'] + for test in summarized[u'summarized_tests']: + msg = "%s\n%s" % (test[u'name'], test[u'message']) + assert test[u'status_string'] == u'PASS', msg + + def _run_functional_test(self): + driver = self.session.config.driver + server = self.session.config.server + + driver.url = server.url(HARNESS) + + test_url = self.url + actual = driver.execute_async_script('runTest("%s", "foo", arguments[0])' % test_url) + + print(json.dumps(actual, indent=2)) + + summarized = _summarize(copy.deepcopy(actual)) + + print(json.dumps(summarized, indent=2)) + + # Test object ordering is not guaranteed. This weak assertion verifies + # that the indices are unique and sequential + indices = [test_obj.get('index') for test_obj in actual['tests']] + self._assert_sequence(indices) + + self.expected[u'summarized_tests'].sort(key=lambda test_obj: test_obj.get('name')) + + # Make asserts opt-in for now + if "summarized_asserts" not in self.expected: + del summarized["summarized_asserts"] + else: + # We can't be sure of the order of asserts even within the same test + # although we could also check for the failing assert being the final + # one + for obj in [summarized, self.expected]: + obj["summarized_asserts"].sort( + key=lambda x: (x["test"] or "", x["status"], x["assert_name"], tuple(x["args"]))) + + assert summarized == self.expected + + @staticmethod + def _assert_sequence(nums): + if nums and len(nums) > 0: + assert nums == list(range(1, nums[-1] + 1)) diff --git a/testing/web-platform/tests/resources/test/harness.html b/testing/web-platform/tests/resources/test/harness.html new file mode 100644 index 0000000000..5ee0f285e8 --- /dev/null +++ b/testing/web-platform/tests/resources/test/harness.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<html> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + </head> + <body> + <script> +function runTest(url, id, done) { + var child; + + function onMessage(event) { + if (!event.data || event.data.type !== 'complete') { + return; + } + + window.removeEventListener('message', onMessage); + child.close(); + done(event.data); + } + window.addEventListener('message', onMessage); + + window.child = child = window.open(url, id); +} + </script> + </body> +</html> diff --git a/testing/web-platform/tests/resources/test/idl-helper.js b/testing/web-platform/tests/resources/test/idl-helper.js new file mode 100644 index 0000000000..2b73527ff2 --- /dev/null +++ b/testing/web-platform/tests/resources/test/idl-helper.js @@ -0,0 +1,24 @@ +"use strict"; + +var typedefFrom = interfaceFrom; +var dictionaryFrom = interfaceFrom; +function interfaceFrom(i) { + var idl = new IdlArray(); + idl.add_idls(i); + for (var prop in idl.members) { + return idl.members[prop]; + } +} + +function memberFrom(m) { + var idl = new IdlArray(); + idl.add_idls('interface A { ' + m + '; };'); + return idl.members["A"].members[0]; +} + +function typeFrom(type) { + var ast = WebIDL2.parse('interface Foo { ' + type + ' a(); };'); + ast = ast[0]; // get the first fragment + ast = ast.members[0]; // get the first member + return ast.idlType; // get the type of the first field +} diff --git a/testing/web-platform/tests/resources/test/nested-testharness.js b/testing/web-platform/tests/resources/test/nested-testharness.js new file mode 100644 index 0000000000..d97c1568c7 --- /dev/null +++ b/testing/web-platform/tests/resources/test/nested-testharness.js @@ -0,0 +1,80 @@ +'use strict'; + +/** + * Execute testharness.js and one or more scripts in an iframe. Report the + * results of the execution. + * + * @param {...function|...string} bodies - a function body. If specified as a + * function object, it will be + * serialized to a string using the + * built-in + * `Function.prototype.toString` prior + * to inclusion in the generated + * iframe. + * + * @returns {Promise} eventual value describing the result of the test + * execution; the summary object has two properties: + * `harness` (a string describing the harness status) and + * `tests` (an object whose "own" property names are the + * titles of the defined sub-tests and whose associated + * values are the subtest statuses). + */ +function makeTest(...bodies) { + const closeScript = '<' + '/script>'; + let src = ` +<!DOCTYPE HTML> +<html> +<head> +<title>Document title + + + + +
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async.html new file mode 100644 index 0000000000..07ade4b93b --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async.html @@ -0,0 +1,85 @@ + + + +Test#add_cleanup with Promise-returning functions + + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_bad_return.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_bad_return.html new file mode 100644 index 0000000000..867bde2c39 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_bad_return.html @@ -0,0 +1,50 @@ + + + +Test#add_cleanup with non-thenable-returning function + + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection.html new file mode 100644 index 0000000000..e51465e7eb --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection.html @@ -0,0 +1,94 @@ + + + +Test#add_cleanup with Promise-returning functions (rejection handling) + + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection_after_load.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection_after_load.html new file mode 100644 index 0000000000..f9b2846100 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_rejection_after_load.html @@ -0,0 +1,52 @@ + + + +Test#add_cleanup with Promise-returning functions (rejection handling following "load" event) + + +

Promise Tests

+

This test demonstrates the use of promise_test. Assumes ECMAScript 6 +Promise support. Some failures are expected.

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_timeout.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_timeout.html new file mode 100644 index 0000000000..429536ce6e --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_async_timeout.html @@ -0,0 +1,57 @@ + + + +Test#add_cleanup with Promise-returning functions (timeout handling) + + + + +
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_bad_return.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_bad_return.html new file mode 100644 index 0000000000..3cfb28adf2 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_bad_return.html @@ -0,0 +1,61 @@ + + + +Test#add_cleanup with value-returning function + + + + +
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_count.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_count.html new file mode 100644 index 0000000000..2c9b51c6d0 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_count.html @@ -0,0 +1,39 @@ + + + +Test#add_cleanup reported count + + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err.html new file mode 100644 index 0000000000..60357c66ee --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err.html @@ -0,0 +1,45 @@ + + + +Test#add_cleanup: error + + + + +
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err_multi.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err_multi.html new file mode 100644 index 0000000000..80ba1b4959 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_err_multi.html @@ -0,0 +1,52 @@ + + + +Test#add_cleanup: multiple functions with one in error + + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_sync_queue.html b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_sync_queue.html new file mode 100644 index 0000000000..0a61503cc8 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/add_cleanup_sync_queue.html @@ -0,0 +1,55 @@ + + + +Test#add_cleanup: queuing tests + + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/api-tests-1.html b/testing/web-platform/tests/resources/test/tests/functional/api-tests-1.html new file mode 100644 index 0000000000..9de875b0f1 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/api-tests-1.html @@ -0,0 +1,991 @@ + + + +Sample HTML5 API Tests + + + +

Sample HTML5 API Tests

+
+ + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/api-tests-2.html b/testing/web-platform/tests/resources/test/tests/functional/api-tests-2.html new file mode 100644 index 0000000000..9af94f61ac --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/api-tests-2.html @@ -0,0 +1,62 @@ + + + +Sample HTML5 API Tests + + +

Sample HTML5 API Tests

+

There should be two results

+
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/api-tests-3.html b/testing/web-platform/tests/resources/test/tests/functional/api-tests-3.html new file mode 100644 index 0000000000..991fc6da67 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/api-tests-3.html @@ -0,0 +1,34 @@ + + + +Sample HTML5 API Tests + + + + +

Sample HTML5 API Tests

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/assert-array-equals.html b/testing/web-platform/tests/resources/test/tests/functional/assert-array-equals.html new file mode 100644 index 0000000000..b6460a4868 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/assert-array-equals.html @@ -0,0 +1,162 @@ + +assert_array_equals + + +
+ + diff --git a/testing/web-platform/tests/resources/test/tests/functional/force_timeout.html b/testing/web-platform/tests/resources/test/tests/functional/force_timeout.html new file mode 100644 index 0000000000..2058fdb862 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/force_timeout.html @@ -0,0 +1,60 @@ + + + +Test#force_timeout + + +

Test#force_timeout

+
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/generate-callback.html b/testing/web-platform/tests/resources/test/tests/functional/generate-callback.html new file mode 100644 index 0000000000..11d41743b3 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/generate-callback.html @@ -0,0 +1,153 @@ + + + +Sample for using generate_tests to create a series of tests that share the same callback. + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlDictionary/test_partial_interface_of.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlDictionary/test_partial_interface_of.html new file mode 100644 index 0000000000..05e6e0b1e0 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlDictionary/test_partial_interface_of.html @@ -0,0 +1,90 @@ + + + + + + + idlharness: Partial dictionary + + + + + + + + +

Verify the series of sub-tests that are executed for "partial" dictionary objects.

+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_exposed_wildcard.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_exposed_wildcard.html new file mode 100644 index 0000000000..addc0eb4fc --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_exposed_wildcard.html @@ -0,0 +1,233 @@ + + + + + idlharness: Exposed=* + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_immutable_prototype.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_immutable_prototype.html new file mode 100644 index 0000000000..5fe05915b0 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_immutable_prototype.html @@ -0,0 +1,298 @@ + + + + + idlharness: Immutable prototypes + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_interface_mixin.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_interface_mixin.html new file mode 100644 index 0000000000..be2844e698 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_interface_mixin.html @@ -0,0 +1,131 @@ + + + + + + idlharness: interface mixins + + + + + + + +

Verify the series of sub-tests that are executed for "interface mixin" objects.

+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_partial_interface_of.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_partial_interface_of.html new file mode 100644 index 0000000000..671196cc5d --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_partial_interface_of.html @@ -0,0 +1,188 @@ + + + + + + + idlharness: Partial interface + + + + + + + + +

Verify the series of sub-tests that are executed for "partial" interface objects.

+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_primary_interface_of.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_primary_interface_of.html new file mode 100644 index 0000000000..309de60bb7 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_primary_interface_of.html @@ -0,0 +1,116 @@ + + + + + idlharness: Primary interface + + + + + + +

Verify the series of sub-tests that are executed for "tested" interface +objects but skipped for "untested" interface objects.

+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_to_json_operation.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_to_json_operation.html new file mode 100644 index 0000000000..bbc502a313 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlInterface/test_to_json_operation.html @@ -0,0 +1,177 @@ + + + + + IdlInterface.prototype.test_to_json_operation() + + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_attribute.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_attribute.html new file mode 100644 index 0000000000..2c94061fc1 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_attribute.html @@ -0,0 +1,100 @@ + + + + + idlharness: namespace attribute + + + + + + +

Verify the series of sub-tests that are executed for namespace attributes.

+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_operation.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_operation.html new file mode 100644 index 0000000000..da70c8fa31 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_operation.html @@ -0,0 +1,242 @@ + + + + + idlharness: namespace operation + + + + + + +

Verify the series of sub-tests that are executed for namespace operations.

+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_partial_namespace.html b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_partial_namespace.html new file mode 100644 index 0000000000..eabdcd10a9 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/idlharness/IdlNamespace/test_partial_namespace.html @@ -0,0 +1,125 @@ + + + + + + idlharness: Partial namespace + + + + + + + +

Verify the series of sub-tests that are executed for "partial" namespace objects.

+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/iframe-callback.html b/testing/web-platform/tests/resources/test/tests/functional/iframe-callback.html new file mode 100644 index 0000000000..f49d0aa6b8 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/iframe-callback.html @@ -0,0 +1,116 @@ + + + +Example with iframe that notifies containing document via callbacks + + + + +

Callbacks From Tests Running In An IFRAME

+

A test is run inside an iframe with a same origin document. The +containing document should receive callbacks as the tests progress inside the +iframe. A single passing test is expected in the summary below. +

+ + + +
+
+ + diff --git a/testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-errors.html b/testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-errors.html new file mode 100644 index 0000000000..ef9b8702ec --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-errors.html @@ -0,0 +1,50 @@ + + + +Example with iframe that consolidates errors via fetch_tests_from_window + + + + + +

Fetching Tests From a Child Context

+

This test demonstrates the use of fetch_tests_from_window to pull +tests from an iframe into the primary document.

+

The test suite is expected to fail due to an unhandled exception in the +child context.

+
+ + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-tests.html b/testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-tests.html new file mode 100644 index 0000000000..246dddee11 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/iframe-consolidate-tests.html @@ -0,0 +1,85 @@ + + + +Example with iframe that consolidates tests via fetch_tests_from_window + + + + + +

Fetching Tests From a Child Context

+

This test demonstrates the use of fetch_tests_from_window to pull +tests from an iframe into the primary document.

+

The test suite will not complete until tests in the child context have finished +executing

+
+ + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/iframe-msg.html b/testing/web-platform/tests/resources/test/tests/functional/iframe-msg.html new file mode 100644 index 0000000000..283a5d98cc --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/iframe-msg.html @@ -0,0 +1,84 @@ + + + +Example with iframe that notifies containing document via cross document messaging + + + + +

Notifications From Tests Running In An IFRAME

+

A test is run inside an iframe with a same origin document. The +containing document should receive messages via postMessage/ +onmessage as the tests progress inside the iframe. A single +passing test is expected in the summary below. +

+
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/log-insertion.html b/testing/web-platform/tests/resources/test/tests/functional/log-insertion.html new file mode 100644 index 0000000000..9a63c3dbde --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/log-insertion.html @@ -0,0 +1,46 @@ + +Log insertion + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/no-title.html b/testing/web-platform/tests/resources/test/tests/functional/no-title.html new file mode 100644 index 0000000000..a337e4e5f5 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/no-title.html @@ -0,0 +1,146 @@ + + + +Tests with no title + + + + +

Tests with no title

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/order.html b/testing/web-platform/tests/resources/test/tests/functional/order.html new file mode 100644 index 0000000000..686383861a --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/order.html @@ -0,0 +1,36 @@ + + + +Ordering + + + +
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/promise-async.html b/testing/web-platform/tests/resources/test/tests/functional/promise-async.html new file mode 100644 index 0000000000..fa82665cf0 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/promise-async.html @@ -0,0 +1,172 @@ + + + +Async Tests and Promises + + +

Async Tests and Promises

+

This test assumes ECMAScript 6 Promise support. Some failures are expected.

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/promise-with-sync.html b/testing/web-platform/tests/resources/test/tests/functional/promise-with-sync.html new file mode 100644 index 0000000000..e8e680a9c7 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/promise-with-sync.html @@ -0,0 +1,79 @@ + + + +Promise Tests and Synchronous Tests + + +

Promise Tests

+

This test demonstrates the use of promise_test alongside synchronous tests.

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/promise.html b/testing/web-platform/tests/resources/test/tests/functional/promise.html new file mode 100644 index 0000000000..f35feb0e21 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/promise.html @@ -0,0 +1,219 @@ + + + +Promise Tests + + +

Promise Tests

+

This test demonstrates the use of promise_test. Assumes ECMAScript 6 +Promise support. Some failures are expected.

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/queue.html b/testing/web-platform/tests/resources/test/tests/functional/queue.html new file mode 100644 index 0000000000..0c721286ec --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/queue.html @@ -0,0 +1,130 @@ + + + +Test queuing synchronous tests + + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/setup-function-worker.js b/testing/web-platform/tests/resources/test/tests/functional/setup-function-worker.js new file mode 100644 index 0000000000..82c1456aa6 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/setup-function-worker.js @@ -0,0 +1,14 @@ +importScripts("/resources/testharness.js"); + +// Regression test for https://github.com/web-platform-tests/wpt/issues/27299, +// where we broke the ability for a setup function in a worker to contain an +// assertion (even a passing one). +setup(function() { + assert_true(true, "True is true"); +}); + +// We must define at least one test for the harness, though it is not what we +// are testing here. +test(function() { + assert_false(false, "False is false"); +}, 'Worker test'); diff --git a/testing/web-platform/tests/resources/test/tests/functional/setup-worker-service.html b/testing/web-platform/tests/resources/test/tests/functional/setup-worker-service.html new file mode 100644 index 0000000000..9f24adac2d --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/setup-worker-service.html @@ -0,0 +1,86 @@ + + + +Setup function in a service worker + + + + +

Setup function in a service worker

+

This test assumes that the browser supports ServiceWorkers. +

+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/single-page-test-fail.html b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-fail.html new file mode 100644 index 0000000000..8bbd530c48 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-fail.html @@ -0,0 +1,28 @@ + +Example with file_is_test (should fail) + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-assertions.html b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-assertions.html new file mode 100644 index 0000000000..9b39d2a02c --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-assertions.html @@ -0,0 +1,25 @@ + +Example single page test with no asserts + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-body.html b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-body.html new file mode 100644 index 0000000000..cb018f4dae --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-no-body.html @@ -0,0 +1,26 @@ + +Example single page test with no body + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/single-page-test-pass.html b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-pass.html new file mode 100644 index 0000000000..e143e22f3c --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/single-page-test-pass.html @@ -0,0 +1,28 @@ + +Example with file_is_test + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/step_wait.html b/testing/web-platform/tests/resources/test/tests/functional/step_wait.html new file mode 100644 index 0000000000..ae3442c759 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/step_wait.html @@ -0,0 +1,57 @@ + +Tests for step_wait + + +
+ + diff --git a/testing/web-platform/tests/resources/test/tests/functional/step_wait_func.html b/testing/web-platform/tests/resources/test/tests/functional/step_wait_func.html new file mode 100644 index 0000000000..9fed18a3e2 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/step_wait_func.html @@ -0,0 +1,49 @@ + +Tests for step_wait_func and step_wait_func_done + + +
+ + diff --git a/testing/web-platform/tests/resources/test/tests/functional/task-scheduling-promise-test.html b/testing/web-platform/tests/resources/test/tests/functional/task-scheduling-promise-test.html new file mode 100644 index 0000000000..9d8e5c11cc --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/task-scheduling-promise-test.html @@ -0,0 +1,241 @@ + +testharness.js - task scheduling + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/task-scheduling-test.html b/testing/web-platform/tests/resources/test/tests/functional/task-scheduling-test.html new file mode 100644 index 0000000000..035844448d --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/task-scheduling-test.html @@ -0,0 +1,141 @@ + +testharness.js - task scheduling + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-handle.html b/testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-handle.html new file mode 100644 index 0000000000..764b0c4055 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-handle.html @@ -0,0 +1,33 @@ + + + +Harness Handling Uncaught Exception + + + + +

Harness Handling Uncaught Exception

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-ignore.html b/testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-ignore.html new file mode 100644 index 0000000000..6bd0ddbb0d --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/uncaught-exception-ignore.html @@ -0,0 +1,35 @@ + + + +Harness Ignoring Uncaught Exception + + + + +

Harness Ignoring Uncaught Exception

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-allow.html b/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-allow.html new file mode 100644 index 0000000000..ba28d4914f --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-allow.html @@ -0,0 +1,45 @@ + + + +Dedicated Worker Tests - Allowed Uncaught Exception + + + + +

Dedicated Web Worker Tests - Allowed Uncaught Exception

+

Demonstrates running testharness based tests inside a dedicated web worker. +

The test harness is expected to pass despite an uncaught exception in a worker because that worker is configured to allow uncaught exceptions.

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-single.html b/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-single.html new file mode 100644 index 0000000000..486e067114 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated-uncaught-single.html @@ -0,0 +1,56 @@ + + + +Dedicated Worker Tests - Uncaught Exception in Single-Page Test + + + + +

Dedicated Web Worker Tests - Uncaught Exception in Single-Page Test

+

Demonstrates running testharness based tests inside a dedicated web worker. +

The test harness is expected to pass despite an uncaught exception in a worker because that worker is a single-page test.

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated.sub.html b/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated.sub.html new file mode 100644 index 0000000000..efd703c760 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-dedicated.sub.html @@ -0,0 +1,88 @@ + + + +Dedicated Worker Tests + + + + +

Dedicated Web Worker Tests

+

Demonstrates running testharness based tests inside a dedicated web worker. +

The test harness is expected to fail due to an uncaught exception in one worker.

+
+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-error.js b/testing/web-platform/tests/resources/test/tests/functional/worker-error.js new file mode 100644 index 0000000000..7b89602f04 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-error.js @@ -0,0 +1,8 @@ +importScripts("/resources/testharness.js"); + +// The following sub-test ensures that the worker is not interpreted as a +// single-page test. The subsequent uncaught exception should therefore be +// interpreted as a harness error rather than a single-page test failure. +test(function() {}, "worker test that completes successfully before exception"); + +throw new Error("This failure is expected."); diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-service.html b/testing/web-platform/tests/resources/test/tests/functional/worker-service.html new file mode 100644 index 0000000000..2e07746e62 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-service.html @@ -0,0 +1,115 @@ + + + +Example with a service worker + + + + +

Service Worker Tests

+

Demonstrates running testharness based tests inside a service worker. +

The test harness should time out due to one of the tests inside the worker timing out. +

This test assumes that the browser supports ServiceWorkers. +

+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-shared.html b/testing/web-platform/tests/resources/test/tests/functional/worker-shared.html new file mode 100644 index 0000000000..e26f17dec2 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-shared.html @@ -0,0 +1,73 @@ + + + +Example with a shared worker + + + + +

Shared Web Worker Tests

+

Demonstrates running testharness based tests inside a shared worker. +

The test harness should time out due to one of the tests in the worker timing out. +

This test assumes that the browser supports shared web workers. +

+ + + + diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-allow.js b/testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-allow.js new file mode 100644 index 0000000000..6925d59349 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-allow.js @@ -0,0 +1,19 @@ +importScripts("/resources/testharness.js"); + +setup({allow_uncaught_exception:true}); + +async_test(function(t) { + onerror = function() { + // Further delay the test's completion to ensure that the worker's + // `onerror` handler does not influence results in the parent context. + setTimeout(function() { + t.done(); + }, 0); + }; + + setTimeout(function() { + throw new Error("This error is expected."); + }, 0); +}, 'onerror event is triggered'); + +done(); diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-single.js b/testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-single.js new file mode 100644 index 0000000000..c04542b2f5 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker-uncaught-single.js @@ -0,0 +1,8 @@ +importScripts("/resources/testharness.js"); + +setup({ single_test: true }); + +// Because this script enables the `single_test` configuration option, it +// should be interpreted as a single-page test, and the uncaught exception +// should be reported as a test failure (harness status: OK). +throw new Error("This failure is expected."); diff --git a/testing/web-platform/tests/resources/test/tests/functional/worker.js b/testing/web-platform/tests/resources/test/tests/functional/worker.js new file mode 100644 index 0000000000..a923bc2d89 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/functional/worker.js @@ -0,0 +1,34 @@ +importScripts("/resources/testharness.js"); + +test( + function(test) { + assert_true(true, "True is true"); + }, + "Worker test that completes successfully"); + +test( + function(test) { + assert_true(false, "Failing test"); + }, + "Worker test that fails ('FAIL')"); + +async_test( + function(test) { + assert_true(true, "True is true"); + }, + "Worker test that times out ('TIMEOUT')"); + +async_test("Worker test that doesn't run ('NOT RUN')"); + +async_test( + function(test) { + self.setTimeout( + function() { + test.done(); + }, + 0); + }, + "Worker async_test that completes successfully"); + +// An explicit done() is required for dedicated and shared web workers. +done(); diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlArray/is_json_type.html b/testing/web-platform/tests/resources/test/tests/unit/IdlArray/is_json_type.html new file mode 100644 index 0000000000..18e83a8e89 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlArray/is_json_type.html @@ -0,0 +1,192 @@ + + + +IdlArray.prototype.is_json_type() + + +
+ + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/get_reverse_inheritance_stack.html b/testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/get_reverse_inheritance_stack.html new file mode 100644 index 0000000000..418bcdec92 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/get_reverse_inheritance_stack.html @@ -0,0 +1,47 @@ + + + +IdlDictionary.prototype.get_reverse_inheritance_stack() + + +
+ + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/test_partial_dictionary.html b/testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/test_partial_dictionary.html new file mode 100644 index 0000000000..d6137f6895 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlDictionary/test_partial_dictionary.html @@ -0,0 +1,39 @@ + + + + + + idlharness: partial dictionaries + + + + + + + + +
+dictionary A {};
+partial dictionary A {
+  boolean B;
+};
+partial dictionary A {
+  boolean C;
+};
+
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/constructors.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/constructors.html new file mode 100644 index 0000000000..e9ee3f8680 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/constructors.html @@ -0,0 +1,26 @@ + +IdlInterface.prototype.constructors() +
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/default_to_json_operation.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/default_to_json_operation.html new file mode 100644 index 0000000000..5ade7d0d28 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/default_to_json_operation.html @@ -0,0 +1,114 @@ + + + +IdlDictionary.prototype.default_to_json_operation() + + +
+ + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/do_member_unscopable_asserts.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/do_member_unscopable_asserts.html new file mode 100644 index 0000000000..90142efe6b --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/do_member_unscopable_asserts.html @@ -0,0 +1,56 @@ + + + +IdlDictionary.prototype.do_member_unscopable_asserts() + + +
+ + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object.html new file mode 100644 index 0000000000..a3d901a752 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object.html @@ -0,0 +1,22 @@ + +IdlInterface.prototype.get_interface_object() +
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object_owner.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object_owner.html new file mode 100644 index 0000000000..51ab2067bc --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_interface_object_owner.html @@ -0,0 +1,21 @@ + +IdlInterface.prototype.get_interface_object_owner() +
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_legacy_namespace.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_legacy_namespace.html new file mode 100644 index 0000000000..e2d42bb09e --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_legacy_namespace.html @@ -0,0 +1,20 @@ + +IdlInterface.prototype.get_legacy_namespace() +
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_qualified_name.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_qualified_name.html new file mode 100644 index 0000000000..677a31b5e7 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_qualified_name.html @@ -0,0 +1,20 @@ + +IdlInterface.prototype.get_qualified_name() +
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_reverse_inheritance_stack.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_reverse_inheritance_stack.html new file mode 100644 index 0000000000..0c066baabb --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/get_reverse_inheritance_stack.html @@ -0,0 +1,49 @@ + + + +IdlInterface.prototype.get_reverse_inheritance_stack() + + +
+ + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_default_to_json_regular_operation.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_default_to_json_regular_operation.html new file mode 100644 index 0000000000..b47262b72b --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_default_to_json_regular_operation.html @@ -0,0 +1,47 @@ + + + +IdlInterface.prototype.has_default_to_json_regular_operation() + + +
+ + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_to_json_regular_operation.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_to_json_regular_operation.html new file mode 100644 index 0000000000..a1a641bd97 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/has_to_json_regular_operation.html @@ -0,0 +1,31 @@ + + + +IdlInterface.prototype.has_to_json_regular_operation() + + +
+ + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/should_have_interface_object.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/should_have_interface_object.html new file mode 100644 index 0000000000..3ce945751d --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/should_have_interface_object.html @@ -0,0 +1,30 @@ + +IdlInterface.prototype.should_have_interface_object() +
+ + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/test_primary_interface_of_undefined.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/test_primary_interface_of_undefined.html new file mode 100644 index 0000000000..0031558ad4 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterface/test_primary_interface_of_undefined.html @@ -0,0 +1,29 @@ + + + + + idlharness test_primary_interface_of_undefined + + + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/is_to_json_regular_operation.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/is_to_json_regular_operation.html new file mode 100644 index 0000000000..b3f402dd08 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/is_to_json_regular_operation.html @@ -0,0 +1,42 @@ + + + +IdlInterfaceMember.prototype.is_to_json_regular_operation() + + +
+ + + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/toString.html b/testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/toString.html new file mode 100644 index 0000000000..054dbb1ccb --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/IdlInterfaceMember/toString.html @@ -0,0 +1,36 @@ + + + +IdlInterfaceMember.prototype.toString() + + +
+ + + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/assert_implements.html b/testing/web-platform/tests/resources/test/tests/unit/assert_implements.html new file mode 100644 index 0000000000..6e35f38502 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/assert_implements.html @@ -0,0 +1,43 @@ + + + + + + +assert_implements unittests + diff --git a/testing/web-platform/tests/resources/test/tests/unit/assert_implements_optional.html b/testing/web-platform/tests/resources/test/tests/unit/assert_implements_optional.html new file mode 100644 index 0000000000..4f23e203c5 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/assert_implements_optional.html @@ -0,0 +1,43 @@ + + + + + + +assert_implements_optional unittests + diff --git a/testing/web-platform/tests/resources/test/tests/unit/assert_object_equals.html b/testing/web-platform/tests/resources/test/tests/unit/assert_object_equals.html new file mode 100644 index 0000000000..313d77b977 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/assert_object_equals.html @@ -0,0 +1,152 @@ + + + + + + +Assertion functions + diff --git a/testing/web-platform/tests/resources/test/tests/unit/async-test-return-restrictions.html b/testing/web-platform/tests/resources/test/tests/unit/async-test-return-restrictions.html new file mode 100644 index 0000000000..0fde2e2422 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/async-test-return-restrictions.html @@ -0,0 +1,135 @@ + + + + + + Restrictions on return value from `async_test` + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/basic.html b/testing/web-platform/tests/resources/test/tests/unit/basic.html new file mode 100644 index 0000000000..d52082f2e0 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/basic.html @@ -0,0 +1,48 @@ + + + +idlharness basic + + +
+ + + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/exceptional-cases-timeouts.html b/testing/web-platform/tests/resources/test/tests/unit/exceptional-cases-timeouts.html new file mode 100644 index 0000000000..760ac7154f --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/exceptional-cases-timeouts.html @@ -0,0 +1,120 @@ + + + + + + + Exceptional cases - timeouts + + +

+ The tests in this file are executed in parallel to avoid exceeding the "long" + timeout duration. +

+ + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/exceptional-cases.html b/testing/web-platform/tests/resources/test/tests/unit/exceptional-cases.html new file mode 100644 index 0000000000..4054d0311d --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/exceptional-cases.html @@ -0,0 +1,392 @@ + + + + + + + Exceptional cases + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/format-value.html b/testing/web-platform/tests/resources/test/tests/unit/format-value.html new file mode 100644 index 0000000000..13d01b81f3 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/format-value.html @@ -0,0 +1,123 @@ + + + + format_value utility function + + + +
+ + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/helpers.js b/testing/web-platform/tests/resources/test/tests/unit/helpers.js new file mode 100644 index 0000000000..ca378a27c9 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/helpers.js @@ -0,0 +1,21 @@ +// Helper for testing assertion failure cases for a testharness.js API +// +// The `assert_throws_*` functions cannot be used for this purpose because they +// always fail in response to AssertionError exceptions, even when this is +// expressed as the expected error. +function test_failure(fn, name) { + test(function() { + try { + fn(); + } catch (err) { + if (err instanceof AssertionError) { + return; + } + throw new AssertionError('Expected an AssertionError, but' + err); + } + throw new AssertionError( + 'Expected an AssertionError, but no error was thrown' + ); + }, name); +} + diff --git a/testing/web-platform/tests/resources/test/tests/unit/late-test.html b/testing/web-platform/tests/resources/test/tests/unit/late-test.html new file mode 100644 index 0000000000..693d7e3c81 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/late-test.html @@ -0,0 +1,54 @@ + + + +Test declared after harness completion + + +
+ + +

This test simulates an automated test running scenario, where the test +results emitted by testharness.js may be interpreted after some delay. It is +intended to demonstrate that in such cases, any additional tests which are +executed during that delay are not included in the dataset.

+ +

Although these "late" tests are likely an indication of a mistake in test +design, they cannot be detected deterministically, so in the interest of +stability, they should be silently tolerated.

+ + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/promise_setup-timeout.html b/testing/web-platform/tests/resources/test/tests/unit/promise_setup-timeout.html new file mode 100644 index 0000000000..c4947feef4 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/promise_setup-timeout.html @@ -0,0 +1,28 @@ + + + + + + + + promise_setup - timeout + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/promise_setup.html b/testing/web-platform/tests/resources/test/tests/unit/promise_setup.html new file mode 100644 index 0000000000..2abb10a476 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/promise_setup.html @@ -0,0 +1,333 @@ + + + + + + + promise_setup + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/single_test.html b/testing/web-platform/tests/resources/test/tests/unit/single_test.html new file mode 100644 index 0000000000..ff766e66ce --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/single_test.html @@ -0,0 +1,94 @@ + + + + + + + + single_test + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/test-return-restrictions.html b/testing/web-platform/tests/resources/test/tests/unit/test-return-restrictions.html new file mode 100644 index 0000000000..0295c5214d --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/test-return-restrictions.html @@ -0,0 +1,156 @@ + + + + + + Restrictions on return value from `test` + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/throwing-assertions.html b/testing/web-platform/tests/resources/test/tests/unit/throwing-assertions.html new file mode 100644 index 0000000000..a36a56043c --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/throwing-assertions.html @@ -0,0 +1,268 @@ + + + + + + + Test the methods that make assertions about exceptions + + + + + diff --git a/testing/web-platform/tests/resources/test/tests/unit/unpaired-surrogates.html b/testing/web-platform/tests/resources/test/tests/unit/unpaired-surrogates.html new file mode 100644 index 0000000000..b232111326 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tests/unit/unpaired-surrogates.html @@ -0,0 +1,143 @@ + + + + + + Restrictions on return value from `test` + + + + + diff --git a/testing/web-platform/tests/resources/test/tox.ini b/testing/web-platform/tests/resources/test/tox.ini new file mode 100644 index 0000000000..cc07e3b028 --- /dev/null +++ b/testing/web-platform/tests/resources/test/tox.ini @@ -0,0 +1,13 @@ +[tox] +envlist = py36,py37,py38,py39,py310 +skipsdist=True + +[testenv] +passenv=DISPLAY # Necessary for the spawned GeckoDriver process to connect to + # the appropriate display. + +deps = + -r{toxinidir}/../../tools/requirements_pytest.txt + -r{toxinidir}/requirements.txt + +commands = pytest -vv {posargs} diff --git a/testing/web-platform/tests/resources/test/wptserver.py b/testing/web-platform/tests/resources/test/wptserver.py new file mode 100644 index 0000000000..1f913dd96d --- /dev/null +++ b/testing/web-platform/tests/resources/test/wptserver.py @@ -0,0 +1,58 @@ +import logging +import os +import subprocess +import time +import sys +import urllib + + +class WPTServer(object): + def __init__(self, wpt_root): + self.logger = logging.getLogger() + self.wpt_root = wpt_root + + # This is a terrible hack to get the default config of wptserve. + sys.path.insert(0, os.path.join(wpt_root, "tools")) + from serve.serve import build_config + with build_config(self.logger) as config: + self.host = config["browser_host"] + self.http_port = config["ports"]["http"][0] + self.https_port = config["ports"]["https"][0] + + self.base_url = 'http://%s:%s' % (self.host, self.http_port) + self.https_base_url = 'https://%s:%s' % (self.host, self.https_port) + + def start(self, ssl_context): + self.devnull = open(os.devnull, 'w') + wptserve_cmd = [os.path.join(self.wpt_root, 'wpt'), 'serve'] + if sys.executable: + wptserve_cmd[0:0] = [sys.executable] + self.logger.info('Executing %s' % ' '.join(wptserve_cmd)) + self.proc = subprocess.Popen( + wptserve_cmd, + stderr=self.devnull, + cwd=self.wpt_root) + + for retry in range(5): + # Exponential backoff. + time.sleep(2 ** retry) + exit_code = self.proc.poll() + if exit_code != None: + logging.warning('Command "%s" exited with %s', ' '.join(wptserve_cmd), exit_code) + break + try: + urllib.request.urlopen(self.base_url, timeout=1) + urllib.request.urlopen(self.https_base_url, timeout=1, context=ssl_context) + return + except urllib.error.URLError: + pass + + raise Exception('Could not start wptserve on %s' % self.base_url) + + def stop(self): + self.proc.terminate() + self.proc.wait() + self.devnull.close() + + def url(self, abs_path): + return self.https_base_url + '/' + os.path.relpath(abs_path, self.wpt_root) -- cgit v1.2.3