Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: content/test/data/generic_sensor/ambient_light_sensor_test.html

Issue 2434563005: [sensors] Add a browser test to sanity check ambient light sensor. (Closed)
Patch Set: Fix nits found by Reilly Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/BUILD.gn ('k') | device/generic_sensor/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/generic_sensor/ambient_light_sensor_test.html
diff --git a/content/test/data/generic_sensor/ambient_light_sensor_test.html b/content/test/data/generic_sensor/ambient_light_sensor_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..346bfc14b22ca04dd1421a2c0c5c74ca3793869d
--- /dev/null
+++ b/content/test/data/generic_sensor/ambient_light_sensor_test.html
@@ -0,0 +1,38 @@
+<html>
+ <head>
+ <title>AmbientLight Generic Sensor test</title>
+ <script type="text/javascript">
+ var timeOrigin;
+ function onAmbientLightReadingChange(event) {
+ if (event.reading.illuminance == 50 &&
+ event.reading.timeStamp > timeOrigin &&
+ event.reading.timeStamp < window.performance.now()) {
+ pass();
+ } else {
+ fail();
+ }
+ }
+
+ function start() {
+ var sensor = new AmbientLightSensor();
+ timeOrigin = window.performance.now();
+ sensor.onchange = function(e) {
+ onAmbientLightReadingChange(e);
+ };
+ sensor.start();
+ }
+
+ function pass() {
+ document.getElementById('status').innerHTML = 'PASS';
+ document.location = '#pass';
+ }
+
+ function fail() {
+ document.location = '#fail';
+ }
+ </script>
+ </head>
+ <body onLoad="start()">
+ <div id="status">FAIL</div>
+ </body>
+</html>
« no previous file with comments | « content/test/BUILD.gn ('k') | device/generic_sensor/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698