mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
wpt: use a custom testharness report
This commit is contained in:
@@ -1,57 +1,34 @@
|
|||||||
/* global add_completion_callback */
|
|
||||||
/* global setup */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is intended for vendors to implement code needed to integrate
|
* Prepare a report object containeing all tests results.
|
||||||
* testharness.js tests with their own test systems.
|
* https://wpt-docs.readthedocs.io/en/latest/_writing-tests/testharness-api.html#callback-api
|
||||||
*
|
|
||||||
* Typically test system integration will attach callbacks when each test has
|
|
||||||
* run, using add_result_callback(callback(test)), or when the whole test file
|
|
||||||
* has completed, using
|
|
||||||
* add_completion_callback(callback(tests, harness_status)).
|
|
||||||
*
|
|
||||||
* For more documentation about the callback functions and the
|
|
||||||
* parameters they are called with see testharness.js
|
|
||||||
*/
|
*/
|
||||||
|
var report = {
|
||||||
|
status: "",
|
||||||
|
log: "",
|
||||||
|
};
|
||||||
|
|
||||||
function dump_test_results(tests, status) {
|
add_completion_callback(function (tests, status) {
|
||||||
var results_element = document.createElement("script");
|
// report the tests global status.
|
||||||
results_element.type = "text/json";
|
// TODO the status.status is always OK even if a test fail.
|
||||||
results_element.id = "__testharness__results__";
|
// I ingore the global status for now, but I build one with the tests results.
|
||||||
var test_results = tests.map(function(x) {
|
//report.status = status.status;
|
||||||
return {name:x.name, status:x.status, message:x.message, stack:x.stack}
|
|
||||||
});
|
|
||||||
var data = {test:window.location.href,
|
|
||||||
tests:test_results,
|
|
||||||
status: status.status,
|
|
||||||
message: status.message,
|
|
||||||
stack: status.stack};
|
|
||||||
results_element.textContent = JSON.stringify(data);
|
|
||||||
|
|
||||||
// To avoid a HierarchyRequestError with XML documents, ensure that 'results_element'
|
var status = "Pass";
|
||||||
// is inserted at a location that results in a valid document.
|
// report a log with details per test.
|
||||||
var parent = document.body
|
var log = "";
|
||||||
? document.body // <body> is required in XHTML documents
|
for (var i = 0; i < tests.length; i++) {
|
||||||
: document.documentElement; // fallback for optional <body> in HTML5, SVG, etc.
|
const test = tests[i];
|
||||||
|
log += test.name+": "+test.format_status();
|
||||||
parent.appendChild(results_element);
|
if (test.message != null) {
|
||||||
}
|
log += " " + test.message;
|
||||||
|
|
||||||
add_completion_callback(dump_test_results);
|
|
||||||
|
|
||||||
/* If the parent window has a testharness_properties object,
|
|
||||||
* we use this to provide the test settings. This is used by the
|
|
||||||
* default in-browser runner to configure the timeout and the
|
|
||||||
* rendering of results
|
|
||||||
*/
|
|
||||||
try {
|
|
||||||
if (window.opener && "testharness_properties" in window.opener) {
|
|
||||||
/* If we pass the testharness_properties object as-is here without
|
|
||||||
* JSON stringifying and reparsing it, IE fails & emits the message
|
|
||||||
* "Could not complete the operation due to error 80700019".
|
|
||||||
*/
|
|
||||||
setup(JSON.parse(JSON.stringify(window.opener.testharness_properties)));
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
log += "\n";
|
||||||
}
|
|
||||||
// vim: set expandtab shiftwidth=4 tabstop=4:
|
if (test.status !== 0) {
|
||||||
|
status = test.format_status();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
report.log = log;
|
||||||
|
report.status = status;
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user