https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 9b6e516d529b526e06447d171dc2937f646bbe89 authored by Bear Travis on 11 July 2014, 21:52:43 UTC
Adding basic tests for the CSS.supports API as part of the CSS Conditional Rules Module L3.
Tip revision: 9b6e516
AmbientLightSensor_onchange.https.html
<!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>
<div id="log"></div>
<script>

async_test(t => {
  let sensor = new AmbientLightSensor();
  sensor.start();

  sensor.onchange = t.step_func_done(() => {
    assert_greater_than_equal(sensor.reading.illuminance, 0);
    assert_equals(sensor.state, "activated");
    sensor.stop();
  });

  sensor.onerror = t.step_func_done(event => {
    assert_unreached(event.error.name + ":" + event.error.message);
  });
}, "event change fired");

</script>
back to top