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

Side by Side Diff: chrome/test/data/generic_sensor/sensor.js

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: rebase + blink reformat Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var timeOrigin;
6 var sensor;
7
8 function notifyTestDone() {
9 window.domAutomationController.send(true);
10 }
11
12 function onAmbientLightReadingChange() {
13 if (sensor.illuminance == 50 &&
14 sensor.timestamp > timeOrigin &&
15 sensor.timestamp < window.performance.now()) {
16 pass();
17 } else {
18 fail();
19 }
20 notifyTestDone();
21 }
22
23 function onSensorFailed() {
24 notifyTestDone();
25 }
26
27 function triggerSensorStart() {
28 sensor = new AmbientLightSensor();
29 timeOrigin = window.performance.now();
30 sensor.onchange =
31 onAmbientLightReadingChange;
32 sensor.onerror = onSensorFailed;
33 sensor.start();
34 }
35
36 function pass() {
37 document.getElementById('status').innerHTML = 'PASS';
38 document.location = '#pass';
39 }
40
41 function fail() {
42 document.location = '#fail';
43 }
44
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698