mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision ddfc95cf0493ae147a4f6a4d7be8eff1a0c23098
This commit is contained in:
parent
1f6a864ab5
commit
7e6290451f
832 changed files with 16026 additions and 2649 deletions
|
@ -143,6 +143,25 @@ function runGenericSensorTests(sensorType) {
|
|||
assert_false(sensor.activated);
|
||||
}, `${sensorType.name}: no exception is thrown when calling stop() on already stopped sensor`);
|
||||
|
||||
promise_test(async t => {
|
||||
const sensor = new sensorType();
|
||||
const sensorWatcher = new EventWatcher(t, sensor, ["reading", "error"]);
|
||||
sensor.start();
|
||||
|
||||
await sensorWatcher.wait_for("reading");
|
||||
assert_true(sensor.hasReading);
|
||||
const timestamp = sensor.timestamp;
|
||||
sensor.stop();
|
||||
assert_false(sensor.hasReading);
|
||||
|
||||
sensor.start();
|
||||
await sensorWatcher.wait_for("reading");
|
||||
assert_true(sensor.hasReading);
|
||||
assert_greater_than(timestamp, 0);
|
||||
assert_greater_than(sensor.timestamp, timestamp);
|
||||
sensor.stop();
|
||||
}, `${sensorType.name}: Test that fresh reading is fetched on start()`);
|
||||
|
||||
promise_test(async t => {
|
||||
const sensor = new sensorType();
|
||||
const sensorWatcher = new EventWatcher(t, sensor, ["reading", "error"]);
|
||||
|
@ -159,8 +178,69 @@ function runGenericSensorTests(sensorType) {
|
|||
|
||||
win.close();
|
||||
sensor.stop();
|
||||
assert_array_equals(cachedSensor1, cachedSensor2);
|
||||
assert_object_equals(cachedSensor1, cachedSensor2);
|
||||
}, `${sensorType.name}: sensor readings can not be fired on the background tab`);
|
||||
|
||||
promise_test(async t => {
|
||||
const fastSensor = new sensorType({frequency: 30});
|
||||
const slowSensor = new sensorType({frequency: 5});
|
||||
slowSensor.start();
|
||||
|
||||
const fastCounter = await new Promise((resolve, reject) => {
|
||||
let fastCounter = 0;
|
||||
let slowCounter = 0;
|
||||
|
||||
fastSensor.onreading = () => {
|
||||
fastCounter++;
|
||||
}
|
||||
slowSensor.onreading = () => {
|
||||
slowCounter++;
|
||||
if (slowCounter == 1) {
|
||||
fastSensor.start();
|
||||
} else if (slowCounter == 3) {
|
||||
fastSensor.stop();
|
||||
slowSensor.stop();
|
||||
resolve(fastCounter);
|
||||
}
|
||||
}
|
||||
fastSensor.onerror = reject;
|
||||
slowSensor.onerror = reject;
|
||||
});
|
||||
assert_greater_than(fastCounter, 2,
|
||||
"Fast sensor overtakes the slow one");
|
||||
}, `${sensorType.name}: frequency hint works`);
|
||||
|
||||
promise_test(async t => {
|
||||
// Create a focused editbox inside a cross-origin iframe,
|
||||
// sensor notification must suspend.
|
||||
const iframeSrc = 'data:text/html;charset=utf-8,<html><body>'
|
||||
+ '<input type="text" autofocus></body></html>';
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.src = encodeURI(iframeSrc);
|
||||
|
||||
const sensor = new sensorType();
|
||||
const sensorWatcher = new EventWatcher(t, sensor, ["reading", "error"]);
|
||||
sensor.start();
|
||||
|
||||
await sensorWatcher.wait_for("reading");
|
||||
assert_reading_not_null(sensor);
|
||||
const cachedTimestamp = sensor.timestamp;
|
||||
const cachedSensor1 = reading_to_array(sensor);
|
||||
|
||||
const iframeWatcher = new EventWatcher(t, iframe, "load");
|
||||
document.body.appendChild(iframe);
|
||||
await iframeWatcher.wait_for("load");
|
||||
const cachedSensor2 = reading_to_array(sensor);
|
||||
assert_array_equals(cachedSensor1, cachedSensor2);
|
||||
|
||||
iframe.remove();
|
||||
await sensorWatcher.wait_for("reading");
|
||||
const cachedSensor3 = reading_to_array(sensor);
|
||||
assert_greater_than(sensor.timestamp, cachedTimestamp);
|
||||
|
||||
sensor.stop();
|
||||
}, `${sensorType.name}: sensor receives suspend / resume notifications when\
|
||||
cross-origin subframe is focused`);
|
||||
}
|
||||
|
||||
function runGenericSensorInsecureContext(sensorType) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue