mirror of
https://github.com/servo/servo.git
synced 2025-09-06 21:18:20 +01:00
Update web-platform-tests to revision 3b3585e368841b77caea8576fa56cef91c3fbdf0
This commit is contained in:
parent
d00639c55f
commit
3b4f0ec0bb
541 changed files with 14609 additions and 3288 deletions
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>AmbientLightSensor Test: Sensor readings must only be available in the top-level browsing context</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com">
|
||||
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<iframe src="support-iframe.html" id="frame" style="display:none">
|
||||
</iframe>
|
||||
<script>
|
||||
|
||||
async_test(function (t) {
|
||||
document.getElementById('frame').onload = t.step_func_done(function(event) {
|
||||
var iframe = document.getElementById('frame').contentWindow;
|
||||
let reading = iframe.document.getElementById('reading').value;
|
||||
assert_equals(reading, "null");
|
||||
});
|
||||
}, "sensor readings can not be fired within iframes");
|
||||
|
||||
test(function() {
|
||||
let sensor = new AmbientLightSensor();
|
||||
sensor.start();
|
||||
var win = window.open('', '_blank');
|
||||
let reading = String(sensor.reading);
|
||||
win.close();
|
||||
sensor.stop();
|
||||
assert_equals(reading, "null");
|
||||
}, "sensor readings can not be fired on the background tab");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>AmbientLightSensor Test: onchange</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com">
|
||||
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<h2>Description</h2>
|
||||
<p>
|
||||
This test validates that the "onchange" event can be invoked when changing the ambient light illuminance of the device.
|
||||
</p>
|
||||
|
||||
<h2>Precondition</h2>
|
||||
<ol>
|
||||
<li>
|
||||
Change the ambient light illuminance of the device.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<script>
|
||||
|
||||
async_test(function(t) {
|
||||
let sensor = new AmbientLightSensor();
|
||||
sensor.start();
|
||||
|
||||
sensor.onchange = t.step_func_done(function(event) {
|
||||
sensor.stop();
|
||||
});
|
||||
|
||||
sensor.onerror = t.step_func_done(function(event) {
|
||||
assert_unreached(event.error.name + ":" + event.error.message);
|
||||
});
|
||||
}, "event change fired");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>AmbientLightSensor Test: onstatechange</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com">
|
||||
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var sensor;
|
||||
setup(function() {
|
||||
sensor = new AmbientLightSensor();
|
||||
});
|
||||
|
||||
test(function() {
|
||||
assert_equals(sensor.state, "idle");
|
||||
}, "The default sensor.state is 'idle'.");
|
||||
|
||||
async_test(function(t) {
|
||||
sensor.onstatechange = t.step_func_done(function(event) {
|
||||
assert_equals(sensor.state, "activating");
|
||||
});
|
||||
sensor.onerror = t.step_func_done(function(event) {
|
||||
assert_unreached(event.error.name + ":" + event.error.message);
|
||||
});
|
||||
sensor.start();
|
||||
}, "The sensor.state changes to 'activating' after sensor.start().");
|
||||
|
||||
async_test(function(t) {
|
||||
sensor.onstatechange = t.step_func_done(function(event) {
|
||||
assert_equals(sensor.state, "idle");
|
||||
});
|
||||
sensor.onerror = t.step_func_done(function(event) {
|
||||
assert_unreached(event.error.name + ":" + event.error.message);
|
||||
});
|
||||
sensor.stop();
|
||||
}, "The sensor.state changes to 'idle' after sensor.stop().");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>AmbientLightSensor Test: start()</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com">
|
||||
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var sensor, start_return;
|
||||
|
||||
setup(function() {
|
||||
sensor = new AmbientLightSensor();
|
||||
start_return = sensor.start();
|
||||
});
|
||||
|
||||
test(function() {
|
||||
assert_equals(String(sensor.reading), "[object AmbientLightSensorReading]");
|
||||
}, "the sensor.reading is AmbientLightSensorReading after executing start() method");
|
||||
|
||||
test(function() {
|
||||
assert_throws("InvalidStateError", function() { sensor.start(); }, "start() twice");
|
||||
}, "throw an InvalidStateError exception when state is neither idle nor errored");
|
||||
|
||||
//TODO: The permission is not ready.
|
||||
|
||||
test(function() {
|
||||
assert_equals(start_return, undefined);
|
||||
}, "the sensor.start() return undefined");
|
||||
|
||||
</script>
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>AmbientLightSensor Test: stop()</title>
|
||||
<link rel="author" title="Intel" href="http://www.intel.com">
|
||||
<link rel="help" href="https://www.w3.org/TR/ambient-light/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
|
||||
var sensor, stop_return;
|
||||
setup(function() {
|
||||
sensor = new AmbientLightSensor();
|
||||
sensor.start();
|
||||
stop_return = sensor.stop();
|
||||
});
|
||||
|
||||
test(function() {
|
||||
assert_equals(String(sensor.reading), "null");
|
||||
}, "the sensor.reading is null after executing stop() method");
|
||||
|
||||
test(function() {
|
||||
assert_throws("InvalidStateError", function() { sensor.stop(); }, "stop() twice");
|
||||
}, "throw an InvalidStateError exception when state is either idle or errored");
|
||||
|
||||
test(function() {
|
||||
assert_equals(stop_return, undefined);
|
||||
}, "the sensor.stop() returns undefined");
|
||||
|
||||
</script>
|
|
@ -98,7 +98,7 @@ dictionary AmbientLightSensorReadingInit {
|
|||
idl_array.add_objects({
|
||||
AmbientLightSensor: ['new AmbientLightSensor();'],
|
||||
AmbientLightSensorReading: ['new AmbientLightSensorReading({ illuminance: 750 });'],
|
||||
SensorReadingEvent: ['new SensorReadingEvent({ reading: new AmbientLightSensorReading({ illuminance: 750 }) });']
|
||||
SensorReadingEvent: ['new SensorReadingEvent("reading", { reading: new AmbientLightSensorReading({ illuminance: 750 }) });']
|
||||
});
|
||||
|
||||
idl_array.test();
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset="utf-8">
|
||||
<input type="text" id="reading" />
|
||||
<script>
|
||||
|
||||
let sensor = new AmbientLightSensor();
|
||||
sensor.start();
|
||||
document.getElementById("reading").value = String(sensor.reading);
|
||||
sensor.stop();
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue