| Index: chrome/test/data/generic_sensor/sensor.js
|
| diff --git a/chrome/test/data/generic_sensor/sensor.js b/chrome/test/data/generic_sensor/sensor.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d75578d12d0292ad889c0796e21f6c21983aa1c1
|
| --- /dev/null
|
| +++ b/chrome/test/data/generic_sensor/sensor.js
|
| @@ -0,0 +1,44 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +var timeOrigin;
|
| +var sensor;
|
| +
|
| +function notifyTestDone() {
|
| + window.domAutomationController.send(true);
|
| +}
|
| +
|
| +function onAmbientLightReadingChange() {
|
| + if (sensor.illuminance == 50 &&
|
| + sensor.timestamp > timeOrigin &&
|
| + sensor.timestamp < window.performance.now()) {
|
| + pass();
|
| + } else {
|
| + fail();
|
| + }
|
| + notifyTestDone();
|
| +}
|
| +
|
| +function onSensorFailed() {
|
| + notifyTestDone();
|
| +}
|
| +
|
| +function triggerSensorStart() {
|
| + sensor = new AmbientLightSensor();
|
| + timeOrigin = window.performance.now();
|
| + sensor.onchange =
|
| + onAmbientLightReadingChange;
|
| + sensor.onerror = onSensorFailed;
|
| + sensor.start();
|
| +}
|
| +
|
| +function pass() {
|
| + document.getElementById('status').innerHTML = 'PASS';
|
| + document.location = '#pass';
|
| +}
|
| +
|
| +function fail() {
|
| + document.location = '#fail';
|
| +}
|
| +
|
|
|