Lines Matching defs:test
9 // default timeout is 10 seconds, test can override if needed
24 * TestEnvironment is an abstraction for the environment in which the test
25 * harness is used. Each implementation of a test environment has to provide
33 * // Invoked after setup() has been called to notify the test environment
34 * // of changes to the test harness properties.
37 * // Should return a new unique default test name.
40 * // Should return the test harness timeout duration in milliseconds.
46 * A test environment with a DOM. The global object is 'window'. By default
47 * test results are displayed in a table. Any parent windows receive
48 * callbacks or messages via postMessage() when test events occur. See
68 function(test) {
69 this_obj._dispatch("test_state_callback", [test],
71 test: test.structured_clone()});
74 function (test) {
76 this_obj._dispatch("result_callback", [test],
78 test: test.structured_clone()});
82 var cloned_tests = map(tests, function(test) {
83 return test.structured_clone();
175 add_test_state_callback(function(test) {
179 add_result_callback(function (test) {
236 * Workers accumulate test results. One or more clients can connect and
291 function(test) {
294 test: test.structured_clone()
298 function(test) {
301 test: test.structured_clone()
309 function(test) {
310 return test.structured_clone();
443 * Signal to the test environment that the tests are ready and the on-loaded
447 * event for us to use to set up the test environment; so, instead, this method
455 throw new Error("Tried to start a shadow realm test environment after it has already started");
539 * Object) so we don't have a nice `instanceof` test to use; instead, we
541 * on the global object. that was set by the test harness when it
579 if (arrow !== null && !/[\u000A\u000D\u2028\u2029]/.test(func_code)) {
603 * @param {Test} test - The test currnetly being run.
609 * Create a synchronous test
612 * immediately. If it returns without error, the test status is
614 * any other exception, the test status is set to ``FAIL``
619 function test(func, name, properties)
623 tests.status.message = '`test` invoked after `promise_setup`';
632 '" passed a function to `test` that returned a value.';
651 * Create an asynchronous test
654 * to call immediately with the test name as an argument (if any),
655 * or name of the test.
656 * @param {String} name - Test name (if a test function was
659 * @returns {Test} An object representing the ongoing test.
705 * Create a promise test.
708 * object. If the promise is fulfilled the test passes, if it's
709 * rejected the test fails, otherwise the test passes.
712 * promise. The test is automatically marked as complete once the
724 var test = new Test(test_name, properties);
725 test._is_promise_test = true;
733 var promise = test.step(func, test, test);
735 test.step(function() {
737 "test body must return a 'thenable' object (received ${value})",
740 "test body must return a 'thenable' object (received an object with no `then` method)",
751 add_test_done_callback(test, resolve);
754 .catch(test.step_func(
763 test.done();
797 * @param {Test} test - the `Test` to use for the assertion.
804 function promise_rejects_js(test, constructor, promise, description) {
806 .then(test.unreached_func("Should have rejected: " + description))
828 * @param {Test} test - the `Test` to use for the assertion.
843 function promise_rejects_dom(test, type, promiseOrConstructor, descriptionOrPromise, maybeDescription) {
858 .then(test.unreached_func("Should have rejected: " + description))
868 * @param {Test} test - the `Test` to use for the assertion.
875 function promise_rejects_exactly(test, exception, promise, description) {
877 .then(test.unreached_func("Should have rejected: " + description))
887 * This can make it a lot easier to test a very specific series of events,
896 * @param {Test} test - The `Test` to use for the assertion.
900 * test to be set to `TIMEOUT` once fulfilled.
903 function EventWatcher(test, watchedNode, eventTypes, timeoutPromise)
915 var eventHandler = test.step_func(function(evt) {
977 var timeout = test.step_func(function() {
1015 test._add_cleanup(stop_watching);
1023 * @property {bool} single_test - Use the single-page-test
1027 * status of the test rather than the status of the harness.
1034 * @property hide_test_state - hide the test state output while
1035 * the test is running; This is helpful when the output of the test state
1036 * may interfere the test results.
1040 * by a test runner that providees its own timeout mechanism.
1042 * per-test timeouts. This should only be set by a test runner.
1046 * SVG test loaded in an HTML wrapper
1126 * Mark test loading as complete.
1133 * For single page tests this marks the test as complete and sets its status.
1134 * For other tests, this marks test loading as complete, but doesn't affect ongoing tests.
1150 // file is test files never have asynchronous cleanup logic,
1160 * This is deprecated because it runs all the tests outside of the test functions
1161 * and as a result any test throwing an exception will result in no tests being
1162 * run. In almost all cases, you should simply call test within the loop you would
1168 * array, a test is generated with name `testName` and test function equivalent to
1175 test(function()
1204 * test step. The actual wait time is ``timeout`` x
1215 expose(test, 'test');
1316 * use in assertion messages, test names, and debugging
1675 * @param {Array} actual - Array of test values.
1903 assert(expected.test(actual),
1945 * @param {string} property_name - Property name to test.
2283 // New style exception: also test the name property.
2408 * @param {object} condition The truthy value to test
2426 * @param {object} condition The truthy value to test
2440 * :js:func:`test`, :js:func:`async_test` or :js:func:`promise_test` functions.
2449 throw new Error("Tried to create a test with file_is_test");
2451 /** The test name. */
2457 /** The test status code.*/
2468 /** A message indicating the reason for test failure. */
2491 * Enum of possible test statuses.
2550 * Run a single step of an ongoing test.
2568 //If we don't get a result before the harness times out that will be a test timeout
2608 * Wrap a function so that it runs as a step of the current test.
2611 * test step.
2617 * // Mark the test as complete.
2643 * Wrap a function so that it runs as a step of the current test,
2644 * and automatically marks the test as complete if the function
2673 * Return a function that automatically sets the current test to
2688 * Run a function as a step of the test after a given timeout.
2691 * account for the expected execution speed of the current test
2692 * environment. For example ``test.step_timeout(f, 2000)`` with a
2697 * as they provide better test performance.
2699 * @param {Function} func - Function to run as a test
2702 * test step. The actual wait time is ``timeout`` x
2719 * to reduce intermittents without compromising test execution
2761 * to reduce intermittents without compromising test execution speed
2804 * intermittents without compromising test execution speed
2841 * Schedule a function to be run after the test result is known, regardless
2845 * influence the result of the test, but if an exception is thrown, the
2846 * test harness will report an error.
2875 * Manually set the test status to ``TIMEOUT``.
2886 * Manually set the test status to ``TIMEOUT``.
2895 * Mark the test as complete.
2897 * This sets the test status to ``PASS`` if no other status was
2899 * test steps will be ignored.
2901 * After setting the test status any test cleanup functions will
2927 function add_test_done_callback(test, callback)
2929 if (test.phase === test.phases.COMPLETE) {
2934 test._done_callbacks.push(callback);
2998 * test. Any test may return the value `undefined`. Tests created with
3001 function is_valid_cleanup_result(test, result) {
3006 if (test._is_promise_test) {
3013 function cleanup_done(test, errors, bad_value_count) {
3015 var total = test._user_defined_cleanup_count;
3019 tests.status.message = "Test named '" + test.name +
3031 var type = test._is_promise_test ?
3040 test.phase = test.phases.COMPLETE;
3041 tests.result(test);
3042 forEach(test._done_callbacks,
3046 test._done_callbacks.length = 0;
3053 * on the local document. This allows listeners (test result reporting
3100 * test status in the parent realm). The `cleanup` method delegates to
3130 * A RemoteContext listens for test events from a remote test context, such
3186 // started and the remote test's `allow_uncaught_exception` property
3215 var remote_test = this.tests[data.test.index];
3217 remote_test = new RemoteTest(data.test);
3218 this.tests[data.test.index] = remote_test;
3220 remote_test.update_state_from(data.test);
3225 var remote_test = this.tests[data.test.index];
3226 remote_test.update_state_from(data.test);
3241 record.test = assert.test != null ? this.tests[assert.test.index] : null;
3337 * @param {Test} test - The test which ran the assert.
3341 function AssertRecord(test, assert_name, args = []) {
3345 this.test = test;
3356 test: this.test ? this.test.structured_clone() : null,
3483 throw new Error("Tried to set file as test after creating a test");
3487 // Create the test, which will add it to the list of tests
3515 function(test) {
3516 // No more than one test is expected to be in the
3518 if (test.phase === test.phases.CLEANING) {
3519 test_in_cleanup = test;
3522 test.phase = test.phases.COMPLETE;
3525 // Timeouts that occur while a test is in the "cleanup" phase
3527 // invalidates the overall test execution, so the timeout should be
3533 "test named \"" + test_in_cleanup.name + "\".";
3551 Tests.prototype.push = function(test)
3557 test.index = this.tests.push(test);
3558 this.notify_test_state(test);
3561 Tests.prototype.notify_test_state = function(test) {
3565 callback(test, this_obj);
3591 Tests.prototype.result = function(test)
3599 this.notify_result(test);
3602 Tests.prototype.notify_result = function(test) {
3608 callback(test, this_obj);
3626 function(test) {
3627 return test.phase < test.phases.COMPLETE;
3631 * To preserve legacy behavior, overall test completion must be
3640 function(test, testDone)
3642 if (test.phase === test.phases.INITIAL) {
3643 test.phase = test.phases.COMPLETE;
3646 add_test_done_callback(test, testDone);
3647 test.cleanup();
3673 function(test) {
3674 if (test.phase === test.phases.INITIAL) {
3675 test.phase = test.phases.COMPLETE;
3689 function(test)
3691 if (test.name in names && duplicates.indexOf(test.name) === -1) {
3692 duplicates.push(test.name);
3694 names[test.name] = true;
3719 function (test)
3721 var sanitized = sanitize_unpaired_surrogates(test.name);
3723 if (test.name !== sanitized) {
3724 test.name = sanitized;
3725 delete test._structured_clone;
3742 // Test names are presumed to be unique within test files--this
3749 duplicates.length + ' duplicate test name' +
3808 * Get test results from a worker and include them in the current test.
3830 * into the current document as if they were all part of the same test file.
3834 * :js:func:`test`, :js:func:`async_test`, and :js:func:`promise_test` in
3845 * Get test results from a shadow realm and include them in the current test.
3847 * @param {ShadowRealm} realm - A shadow realm also running the test harness
3863 * Begin running tests in this shadow realm test harness.
3868 * @param {Function} postMessage - A function to send test updates to the
3908 * Add a callback that's triggered when a test state changes.
3918 * Add a callback that's triggered when a test result is received.
3993 //If output is disabled in testharnessreport.js the test shouldn't be
4113 function(test) {
4114 var status = test.format_status();
4202 // large test suites (tens of thousands of tests).
4221 function get_assertion(test)
4223 if (test.properties.hasOwnProperty("assert")) {
4224 if (Array.isArray(test.properties.assert)) {
4225 return test.properties.assert.join(' ');
4227 return test.properties.assert;
4234 if (!asserts_run_by_test.has(assert.test)) {
4235 asserts_run_by_test.set(assert.test, []);
4237 asserts_run_by_test.get(assert.test).push(assert);
4240 function get_asserts_output(test) {
4241 var asserts = asserts_run_by_test.get(test);
4286 var test = tests[i];
4288 status_class(test.format_status()) +
4291 status_class(test.format_status()) +
4293 test.format_status() +
4295 escape_html(test.name) +
4297 (assertions ? escape_html(get_assertion(test)) + "</td><td>" : "") +
4298 escape_html(test.message ? tests[i].message : " ") +
4302 if (!(test instanceof RemoteTest)) {
4303 html += "<details><summary>Asserts run</summary>" + get_asserts_output(test) + "</details>"
4533 while (!re.test(lines[i]) && i < lines.length) {
4537 // Then skip the top frames originating from testharness.js to begin the stack at the test code.
4538 while (re.test(lines[i]) && i < lines.length) {
4752 var test = tests.tests[0];
4753 if (test.phase >= test.phases.HAS_RESULT) {
4756 var status = optional_unsupported ? test.PRECONDITION_FAILED : test.FAIL;
4757 test.set_status(status, message, stack);
4758 test.phase = test.phases.HAS_RESULT;
4766 // Do not transition to the "complete" phase if the test has been
4767 // configured to allow uncaught exceptions. This gives the test an