diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /testing/web-platform/tests/resources | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/resources')
7 files changed, 117 insertions, 122 deletions
diff --git a/testing/web-platform/tests/resources/chromium/mock-pressure-service.js b/testing/web-platform/tests/resources/chromium/mock-pressure-service.js index bd0e32c567..016c6d97e7 100644 --- a/testing/web-platform/tests/resources/chromium/mock-pressure-service.js +++ b/testing/web-platform/tests/resources/chromium/mock-pressure-service.js @@ -65,26 +65,20 @@ class MockPressureService { if (this.pressureServiceReadingTimerId_ != null) this.stopPlatformCollector(); - // The following code for calculating the timestamp was taken from - // https://source.chromium.org/chromium/chromium/src/+/main:third_party/ - // blink/web_tests/http/tests/resources/ - // geolocation-mock.js;l=131;drc=37a9b6c03b9bda9fcd62fc0e5e8016c278abd31f - - // The new Date().getTime() returns the number of milliseconds since the - // UNIX epoch (1970-01-01 00::00:00 UTC), while |internalValue| of the - // device.mojom.PressureUpdate represents the value of microseconds since - // the Windows FILETIME epoch (1601-01-01 00:00:00 UTC). So add the delta - // when sets the |internalValue|. See more info in //base/time/time.h. - const windowsEpoch = Date.UTC(1601, 0, 1, 0, 0, 0, 0); - const unixEpoch = Date.UTC(1970, 0, 1, 0, 0, 0, 0); - // |epochDeltaInMs| equals to base::Time::kTimeTToMicrosecondsOffset. - const epochDeltaInMs = unixEpoch - windowsEpoch; - this.pressureServiceReadingTimerId_ = self.setInterval(() => { if (this.pressureUpdate_ === null || this.observers_.length === 0) return; + + // Because we cannot retrieve directly the timeOrigin internal in + // TimeTicks from Chromium, we need to create a timestamp that + // would help to test basic functionality. + // by multiplying performance.timeOrigin by 10 we make sure that the + // origin is higher than the internal time origin in TimeTicks. + // performance.now() allows us to have an increase matching the TimeTicks + // that would be read from the platform collector. this.pressureUpdate_.timestamp = { - internalValue: BigInt((new Date().getTime() + epochDeltaInMs) * 1000) + internalValue: + Math.round((performance.timeOrigin * 10) + performance.now()) * 1000 }; for (let observer of this.observers_) observer.onPressureUpdated(this.pressureUpdate_); diff --git a/testing/web-platform/tests/resources/idlharness.js b/testing/web-platform/tests/resources/idlharness.js index 8f741b09b2..4cf19234af 100644 --- a/testing/web-platform/tests/resources/idlharness.js +++ b/testing/web-platform/tests/resources/idlharness.js @@ -566,6 +566,7 @@ IdlArray.prototype.is_json_type = function(type) case "Uint8ClampedArray": case "BigInt64Array": case "BigUint64Array": + case "Float16Array": case "Float32Array": case "Float64Array": case "ArrayBuffer": 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 index 18e83a8e89..caea20067f 100644 --- 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 @@ -39,6 +39,7 @@ assert_false(idl.is_json_type(typeFrom("Uint8ClampedArray"))); assert_false(idl.is_json_type(typeFrom("BigInt64Array"))); assert_false(idl.is_json_type(typeFrom("BigUint64Array"))); + assert_false(idl.is_json_type(typeFrom("Float16Array"))); assert_false(idl.is_json_type(typeFrom("Float32Array"))); assert_false(idl.is_json_type(typeFrom("Float64Array"))); assert_false(idl.is_json_type(typeFrom("ArrayBuffer"))); diff --git a/testing/web-platform/tests/resources/test/tox.ini b/testing/web-platform/tests/resources/test/tox.ini index 12013a1a70..49603ef64b 100644 --- a/testing/web-platform/tests/resources/test/tox.ini +++ b/testing/web-platform/tests/resources/test/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py37,py38,py39,py310,py311 +envlist = py38,py39,py310,py311 skipsdist=True [testenv] diff --git a/testing/web-platform/tests/resources/testdriver.js b/testing/web-platform/tests/resources/testdriver.js index 20140b2fc0..2d1a89690c 100644 --- a/testing/web-platform/tests/resources/testdriver.js +++ b/testing/web-platform/tests/resources/testdriver.js @@ -1023,6 +1023,49 @@ */ get_virtual_sensor_information: function(sensor_type, context=null) { return window.test_driver_internal.get_virtual_sensor_information(sensor_type, context); + }, + + /** + * Overrides device posture set by hardware. + * + * Matches the `Set device posture + * <https://w3c.github.io/device-posture/#set-device-posture>`_ + * WebDriver command. + * + * @param {String} posture - A `DevicePostureType + * <https://w3c.github.io/device-posture/#dom-deviceposturetype>`_ + * either "continuous" or "folded". + * @param {WindowProxy} [context=null] - Browsing context in which to + * run the call, or null for the + * current browsing context. + * + * @returns {Promise} Fulfilled when device posture is set. + * Rejected in case the WebDriver command errors out + * (including if a device posture of the given type + * does not exist). + */ + set_device_posture: function(posture, context=null) { + return window.test_driver_internal.set_device_posture(posture, context); + }, + + /** + * Removes device posture override and returns device posture control + * back to hardware. + * + * Matches the `Clear device posture + * <https://w3c.github.io/device-posture/#clear-device-posture>`_ + * WebDriver command. + * + * @param {WindowProxy} [context=null] - Browsing context in which to + * run the call, or null for the + * current browsing context. + * + * @returns {Promise} Fulfilled after the device posture override has + * been removed. Rejected in case the WebDriver + * command errors out. + */ + clear_device_posture: function(context=null) { + return window.test_driver_internal.clear_device_posture(context); } }; @@ -1203,6 +1246,14 @@ async get_virtual_sensor_information(sensor_type, context=null) { throw new Error("get_virtual_sensor_information() is not implemented by testdriver-vendor.js"); + }, + + async set_device_posture(posture, context=null) { + throw new Error("set_device_posture() is not implemented by testdriver-vendor.js"); + }, + + async clear_device_posture(context=null) { + throw new Error("clear_device_posture() is not implemented by testdriver-vendor.js"); } }; })(); diff --git a/testing/web-platform/tests/resources/testharness.js b/testing/web-platform/tests/resources/testharness.js index 1a6a4bb341..c5c375e172 100644 --- a/testing/web-platform/tests/resources/testharness.js +++ b/testing/web-platform/tests/resources/testharness.js @@ -4194,11 +4194,7 @@ status ], ], - ["button", - {"onclick": "let evt = new Event('__test_restart'); " + - "let canceled = !window.dispatchEvent(evt);" + - "if (!canceled) { location.reload() }"}, - "Rerun"] + ["button", {"id":"rerun"}, "Rerun"] ]]; if (harness_status.status === harness_status.ERROR) { @@ -4230,6 +4226,13 @@ log.appendChild(render(summary_template, {num_tests:tests.length}, output_document)); + output_document.getElementById("rerun").addEventListener("click", + function() { + let evt = new Event('__test_restart'); + let canceled = !window.dispatchEvent(evt); + if (!canceled) { location.reload(); } + }); + forEach(output_document.querySelectorAll("section#summary label"), function(element) { @@ -4254,18 +4257,6 @@ }); }); - // This use of innerHTML plus manual escaping is not recommended in - // general, but is necessary here for performance. Using textContent - // on each individual <td> adds tens of seconds of execution time for - // large test suites (tens of thousands of tests). - function escape_html(s) - { - return s.replace(/\&/g, "&") - .replace(/</g, "<") - .replace(/"/g, """) - .replace(/'/g, "'"); - } - function has_assertions() { for (var i = 0; i < tests.length; i++) { @@ -4296,81 +4287,63 @@ }); function get_asserts_output(test) { + const asserts_output = render( + ["details", {}, + ["summary", {}, "Asserts run"], + ["table", {}, ""] ]); + var asserts = asserts_run_by_test.get(test); if (!asserts) { - return "No asserts ran"; + asserts_output.querySelector("summary").insertAdjacentText("afterend", "No asserts ran"); + return asserts_output; } - rv = "<table>"; - rv += asserts.map(assert => { - var output_fn = "<strong>" + escape_html(assert.assert_name) + "</strong>("; - var prefix_len = output_fn.length; - var output_args = assert.args; - var output_len = output_args.reduce((prev, current) => prev+current, prefix_len); - if (output_len[output_len.length - 1] > 50) { - output_args = output_args.map((x, i) => - (i > 0 ? " ".repeat(prefix_len) : "" )+ x + (i < output_args.length - 1 ? ",\n" : "")); - } else { - output_args = output_args.map((x, i) => x + (i < output_args.length - 1 ? ", " : "")); - } - output_fn += escape_html(output_args.join("")); - output_fn += ')'; - var output_location; + + const table = asserts_output.querySelector("table"); + for (const assert of asserts) { + const status_class_name = status_class(Test.prototype.status_formats[assert.status]); + var output_fn = "(" + assert.args.join(", ") + ")"; if (assert.stack) { - output_location = assert.stack.split("\n", 1)[0].replace(/@?\w+:\/\/[^ "\/]+(?::\d+)?/g, " "); + output_fn += "\n"; + output_fn += assert.stack.split("\n", 1)[0].replace(/@?\w+:\/\/[^ "\/]+(?::\d+)?/g, " "); } - return "<tr class='overall-" + - status_class(Test.prototype.status_formats[assert.status]) + "'>" + - "<td class='" + - status_class(Test.prototype.status_formats[assert.status]) + "'>" + - Test.prototype.status_formats[assert.status] + "</td>" + - "<td><pre>" + - output_fn + - (output_location ? "\n" + escape_html(output_location) : "") + - "</pre></td></tr>"; + table.appendChild(render( + ["tr", {"class":"overall-" + status_class_name}, + ["td", {"class":status_class_name}, Test.prototype.status_formats[assert.status]], + ["td", {}, ["pre", {}, ["strong", {}, assert.assert_name], output_fn]] ])); } - ).join("\n"); - rv += "</table>"; - return rv; + return asserts_output; } - log.appendChild(document.createElementNS(xhtml_ns, "section")); var assertions = has_assertions(); - var html = "<h2>Details</h2><table id='results' " + (assertions ? "class='assertions'" : "" ) + ">" + - "<thead><tr><th>Result</th><th>Test Name</th>" + - (assertions ? "<th>Assertion</th>" : "") + - "<th>Message</th></tr></thead>" + - "<tbody>"; - for (var i = 0; i < tests.length; i++) { - var test = tests[i]; - html += '<tr class="overall-' + - status_class(test.format_status()) + - '">' + - '<td class="' + - status_class(test.format_status()) + - '">' + - test.format_status() + - "</td><td>" + - escape_html(test.name) + - "</td><td>" + - (assertions ? escape_html(get_assertion(test)) + "</td><td>" : "") + - escape_html(test.message ? tests[i].message : " ") + - (tests[i].stack ? "<pre>" + - escape_html(tests[i].stack) + - "</pre>": ""); + const section = render( + ["section", {}, + ["h2", {}, "Details"], + ["table", {"id":"results", "class":(assertions ? "assertions" : "")}, + ["thead", {}, + ["tr", {}, + ["th", {}, "Result"], + ["th", {}, "Test Name"], + (assertions ? ["th", {}, "Assertion"] : ""), + ["th", {}, "Message" ]]], + ["tbody", {}]]]); + + const tbody = section.querySelector("tbody"); + for (const test of tests) { + const status = test.format_status(); + const status_class_name = status_class(status); + tbody.appendChild(render( + ["tr", {"class":"overall-" + status_class_name}, + ["td", {"class":status_class_name}, status], + ["td", {}, test.name], + (assertions ? ["td", {}, get_assertion(test)] : ""), + ["td", {}, + test.message ?? "", + ["pre", {}, test.stack ?? ""]]])); if (!(test instanceof RemoteTest)) { - html += "<details><summary>Asserts run</summary>" + get_asserts_output(test) + "</details>" + tbody.lastChild.lastChild.appendChild(get_asserts_output(test)); } - html += "</td></tr>"; - } - html += "</tbody></table>"; - try { - log.lastChild.innerHTML = html; - } catch (e) { - log.appendChild(document.createElementNS(xhtml_ns, "p")) - .textContent = "Setting innerHTML for the log threw an exception."; - log.appendChild(document.createElementNS(xhtml_ns, "pre")) - .textContent = html; } + log.appendChild(section); }; /* diff --git a/testing/web-platform/tests/resources/testharnessreport.js b/testing/web-platform/tests/resources/testharnessreport.js index e5cb40fe0e..405a2d8b06 100644 --- a/testing/web-platform/tests/resources/testharnessreport.js +++ b/testing/web-platform/tests/resources/testharnessreport.js @@ -14,31 +14,6 @@ * parameters they are called with see testharness.js */ -function dump_test_results(tests, status) { - var results_element = document.createElement("script"); - results_element.type = "text/json"; - results_element.id = "__testharness__results__"; - var test_results = tests.map(function(x) { - 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' - // is inserted at a location that results in a valid document. - var parent = document.body - ? document.body // <body> is required in XHTML documents - : document.documentElement; // fallback for optional <body> in HTML5, SVG, etc. - - parent.appendChild(results_element); -} - -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 |