mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -1,12 +1,15 @@
|
|||
let unreached = event => {
|
||||
assert_unreached(event.error.name + ":" + event.error.message);
|
||||
assert_unreached(event.error.name + ": " + event.error.message);
|
||||
};
|
||||
|
||||
let properties = {
|
||||
'AmbientLightSensor' : ['timestamp', 'illuminance'],
|
||||
'Accelerometer' : ['timestamp', 'x', 'y', 'z'],
|
||||
'Gyroscope' : ['timestamp', 'x', 'y', 'z'],
|
||||
'Magnetometer' : ['timestamp', 'x', 'y', 'z']
|
||||
'AmbientLightSensor' : ['timestamp', 'illuminance'],
|
||||
'Accelerometer' : ['timestamp', 'x', 'y', 'z'],
|
||||
'LinearAccelerationSensor' : ['timestamp', 'x', 'y', 'z'],
|
||||
'Gyroscope' : ['timestamp', 'x', 'y', 'z'],
|
||||
'Magnetometer' : ['timestamp', 'x', 'y', 'z'],
|
||||
'AbsoluteOrientationSensor' : ['timestamp', 'quaternion'],
|
||||
'RelativeOrientationSensor' : ['timestamp', 'quaternion']
|
||||
};
|
||||
|
||||
function assert_reading_not_null(sensor) {
|
||||
|
@ -35,14 +38,14 @@ function reading_to_array(sensor) {
|
|||
function runGenericSensorTests(sensorType) {
|
||||
async_test(t => {
|
||||
let sensor = new sensorType();
|
||||
sensor.onchange = t.step_func_done(() => {
|
||||
sensor.onreading = t.step_func_done(() => {
|
||||
assert_reading_not_null(sensor);
|
||||
sensor.stop();
|
||||
assert_reading_null(sensor);
|
||||
});
|
||||
sensor.onerror = t.step_func_done(unreached);
|
||||
sensor.start();
|
||||
}, "Test that 'onchange' is called and sensor reading is valid");
|
||||
}, `${sensorType.name}: Test that 'onreading' is called and sensor reading is valid`);
|
||||
|
||||
async_test(t => {
|
||||
let sensor1 = new sensorType();
|
||||
|
@ -64,7 +67,7 @@ function runGenericSensorTests(sensorType) {
|
|||
sensor2.onerror = t.step_func_done(unreached);
|
||||
sensor1.start();
|
||||
sensor2.start();
|
||||
}, "sensor reading is correct");
|
||||
}, `${sensorType.name}: sensor reading is correct`);
|
||||
|
||||
async_test(t => {
|
||||
let sensor = new sensorType();
|
||||
|
@ -75,27 +78,27 @@ function runGenericSensorTests(sensorType) {
|
|||
sensor.onerror = t.step_func_done(unreached);
|
||||
sensor.start();
|
||||
t.step_timeout(() => {
|
||||
sensor.onchange = t.step_func_done(() => {
|
||||
sensor.onreading = t.step_func_done(() => {
|
||||
//sensor.timestamp changes.
|
||||
let cachedTimeStamp2 = sensor.timestamp;
|
||||
assert_greater_than(cachedTimeStamp2, cachedTimeStamp1);
|
||||
sensor.stop();
|
||||
});
|
||||
}, 1000);
|
||||
}, "sensor timestamp is updated when time passes");
|
||||
}, `${sensorType.name}: sensor timestamp is updated when time passes`);
|
||||
|
||||
async_test(t => {
|
||||
let sensor = new sensorType();
|
||||
sensor.onerror = t.step_func_done(unreached);
|
||||
assert_false(sensor.activated);
|
||||
sensor.onchange = t.step_func_done(() => {
|
||||
sensor.onreading = t.step_func_done(() => {
|
||||
assert_true(sensor.activated);
|
||||
sensor.stop();
|
||||
assert_false(sensor.activated);
|
||||
});
|
||||
sensor.start();
|
||||
assert_false(sensor.activated);
|
||||
}, "Test that sensor can be successfully created and its states are correct.");
|
||||
}, `${sensorType.name}: Test that sensor can be successfully created and its states are correct.`);
|
||||
|
||||
test(() => {
|
||||
let sensor, start_return;
|
||||
|
@ -104,7 +107,7 @@ function runGenericSensorTests(sensorType) {
|
|||
start_return = sensor.start();
|
||||
assert_equals(start_return, undefined);
|
||||
sensor.stop();
|
||||
}, "sensor.start() returns undefined");
|
||||
}, `${sensorType.name}: sensor.start() returns undefined`);
|
||||
|
||||
test(() => {
|
||||
try {
|
||||
|
@ -117,7 +120,7 @@ function runGenericSensorTests(sensorType) {
|
|||
} catch (e) {
|
||||
assert_unreached(e.name + ": " + e.message);
|
||||
}
|
||||
}, "no exception is thrown when calling start() on already started sensor");
|
||||
}, `${sensorType.name}: no exception is thrown when calling start() on already started sensor`);
|
||||
|
||||
test(() => {
|
||||
let sensor, stop_return;
|
||||
|
@ -126,7 +129,7 @@ function runGenericSensorTests(sensorType) {
|
|||
sensor.start();
|
||||
stop_return = sensor.stop();
|
||||
assert_equals(stop_return, undefined);
|
||||
}, "sensor.stop() returns undefined");
|
||||
}, `${sensorType.name}: sensor.stop() returns undefined`);
|
||||
|
||||
test(() => {
|
||||
try {
|
||||
|
@ -139,14 +142,34 @@ function runGenericSensorTests(sensorType) {
|
|||
} catch (e) {
|
||||
assert_unreached(e.name + ": " + e.message);
|
||||
}
|
||||
}, "no exception is thrown when calling stop() on already stopped sensor");
|
||||
}, `${sensorType.name}: no exception is thrown when calling stop() on already stopped sensor`);
|
||||
|
||||
async_test(t => {
|
||||
window.onmessage = t.step_func(e => {
|
||||
assert_equals(e.data, "SecurityError");
|
||||
t.done();
|
||||
promise_test(() => {
|
||||
return new Promise((resolve,reject) => {
|
||||
let iframe = document.createElement('iframe');
|
||||
iframe.srcdoc = '<script>' +
|
||||
' window.onmessage = message => {' +
|
||||
' if (message.data === "LOADED") {' +
|
||||
' try {' +
|
||||
' new ' + sensorType.name + '();' +
|
||||
' parent.postMessage("FAIL", "*");' +
|
||||
' } catch (e) {' +
|
||||
' parent.postMessage(e.name, "*");' +
|
||||
' }' +
|
||||
' }' +
|
||||
' };' +
|
||||
'<\/script>';
|
||||
iframe.onload = () => iframe.contentWindow.postMessage('LOADED', '*');
|
||||
document.body.appendChild(iframe);
|
||||
window.onmessage = message => {
|
||||
if (message.data == 'SecurityError') {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, "throw a 'SecurityError' when firing sensor readings within iframes");
|
||||
}, `${sensorType.name}: throw a 'SecurityError' when constructing sensor object within iframe`);
|
||||
|
||||
async_test(t => {
|
||||
let sensor = new sensorType();
|
||||
|
@ -164,13 +187,13 @@ function runGenericSensorTests(sensorType) {
|
|||
});
|
||||
sensor.onerror = t.step_func_done(unreached);
|
||||
sensor.start();
|
||||
}, "sensor readings can not be fired on the background tab");
|
||||
}, `${sensorType.name}: sensor readings can not be fired on the background tab`);
|
||||
}
|
||||
|
||||
function runGenericSensorInsecureContext(sensorType) {
|
||||
test(() => {
|
||||
assert_throws('SecurityError', () => { new sensorType(); });
|
||||
}, "throw a 'SecurityError' when construct sensor in an insecure context");
|
||||
}, `${sensorType.name}: throw a 'SecurityError' when construct sensor in an insecure context`);
|
||||
}
|
||||
|
||||
function runGenericSensorOnerror(sensorType) {
|
||||
|
@ -182,5 +205,5 @@ function runGenericSensorOnerror(sensorType) {
|
|||
assert_equals(event.error.name, 'NotReadableError');
|
||||
});
|
||||
sensor.start();
|
||||
}, "'onerror' event is fired when sensor is not supported");
|
||||
}, `${sensorType.name}: 'onerror' event is fired when sensor is not supported`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue