-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.html
1950 lines (1826 loc) · 118 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html><html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<title>Ambient Light Sensor</title>
<meta content="ED" name="w3c-status">
<link href="https://www.w3.org/StyleSheets/TR/2021/W3C-ED" rel="stylesheet">
<meta content="Bikeshed version 82ce88815, updated Thu Sep 7 16:33:55 2023 -0700" name="generator">
<link href="https://www.w3.org/TR/ambient-light/" rel="canonical">
<meta content="96e67a1f5977f0056f4a48ef240c0314cc2bf8b8" name="document-revision">
<style>/* Boilerplate: style-autolinks */
.css.css, .property.property, .descriptor.descriptor {
color: var(--a-normal-text);
font-size: inherit;
font-family: inherit;
}
.css::before, .property::before, .descriptor::before {
content: "‘";
}
.css::after, .property::after, .descriptor::after {
content: "’";
}
.property, .descriptor {
/* Don't wrap property and descriptor names */
white-space: nowrap;
}
.type { /* CSS value <type> */
font-style: italic;
}
pre .property::before, pre .property::after {
content: "";
}
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {
content: "‘";
}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {
content: "’";
}
[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after {
content: "";
}
[data-link-type=element],
[data-link-type=element-attr] {
font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
font-size: .9em;
}
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after { content: ">" }
[data-link-type=biblio] {
white-space: pre;
}
@media (prefers-color-scheme: dark) {
:root {
--selflink-text: black;
--selflink-bg: silver;
--selflink-hover-text: white;
}
}
</style>
<style>/* Boilerplate: style-colors */
/* Any --*-text not paired with a --*-bg is assumed to have a transparent bg */
:root {
color-scheme: light dark;
--text: black;
--bg: white;
--unofficial-watermark: url(https://www.w3.org/StyleSheets/TR/2016/logos/UD-watermark);
--logo-bg: #1a5e9a;
--logo-active-bg: #c00;
--logo-text: white;
--tocnav-normal-text: #707070;
--tocnav-normal-bg: var(--bg);
--tocnav-hover-text: var(--tocnav-normal-text);
--tocnav-hover-bg: #f8f8f8;
--tocnav-active-text: #c00;
--tocnav-active-bg: var(--tocnav-normal-bg);
--tocsidebar-text: var(--text);
--tocsidebar-bg: #f7f8f9;
--tocsidebar-shadow: rgba(0,0,0,.1);
--tocsidebar-heading-text: hsla(203,20%,40%,.7);
--toclink-text: var(--text);
--toclink-underline: #3980b5;
--toclink-visited-text: var(--toclink-text);
--toclink-visited-underline: #054572;
--heading-text: #005a9c;
--hr-text: var(--text);
--algo-border: #def;
--del-text: red;
--del-bg: transparent;
--ins-text: #080;
--ins-bg: transparent;
--a-normal-text: #034575;
--a-normal-underline: #bbb;
--a-visited-text: var(--a-normal-text);
--a-visited-underline: #707070;
--a-hover-bg: rgba(75%, 75%, 75%, .25);
--a-active-text: #c00;
--a-active-underline: #c00;
--blockquote-border: silver;
--blockquote-bg: transparent;
--blockquote-text: currentcolor;
--issue-border: #e05252;
--issue-bg: #fbe9e9;
--issue-text: var(--text);
--issueheading-text: #831616;
--example-border: #e0cb52;
--example-bg: #fcfaee;
--example-text: var(--text);
--exampleheading-text: #574b0f;
--note-border: #52e052;
--note-bg: #e9fbe9;
--note-text: var(--text);
--noteheading-text: hsl(120, 70%, 30%);
--notesummary-underline: silver;
--assertion-border: #aaa;
--assertion-bg: #eee;
--assertion-text: black;
--advisement-border: orange;
--advisement-bg: #fec;
--advisement-text: var(--text);
--advisementheading-text: #b35f00;
--warning-border: red;
--warning-bg: hsla(40,100%,50%,0.95);
--warning-text: var(--text);
--amendment-border: #330099;
--amendment-bg: #F5F0FF;
--amendment-text: var(--text);
--amendmentheading-text: #220066;
--def-border: #8ccbf2;
--def-bg: #def;
--def-text: var(--text);
--defrow-border: #bbd7e9;
--datacell-border: silver;
--indexinfo-text: #707070;
--indextable-hover-text: black;
--indextable-hover-bg: #f7f8f9;
--outdatedspec-bg: rgba(0, 0, 0, .5);
--outdatedspec-text: black;
--outdated-bg: maroon;
--outdated-text: white;
--outdated-shadow: red;
--editedrec-bg: darkorange;
}
@media (prefers-color-scheme: dark) {
:root {
--text: #ddd;
--bg: black;
--unofficial-watermark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cg fill='%23100808' transform='translate(200 200) rotate(-45) translate(-200 -200)' stroke='%23100808' stroke-width='3'%3E%3Ctext x='50%25' y='220' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EUNOFFICIAL%3C/text%3E%3Ctext x='50%25' y='305' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EDRAFT%3C/text%3E%3C/g%3E%3C/svg%3E");
--logo-bg: #1a5e9a;
--logo-active-bg: #c00;
--logo-text: white;
--tocnav-normal-text: #999;
--tocnav-normal-bg: var(--bg);
--tocnav-hover-text: var(--tocnav-normal-text);
--tocnav-hover-bg: #080808;
--tocnav-active-text: #f44;
--tocnav-active-bg: var(--tocnav-normal-bg);
--tocsidebar-text: var(--text);
--tocsidebar-bg: #080808;
--tocsidebar-shadow: rgba(255,255,255,.1);
--tocsidebar-heading-text: hsla(203,20%,40%,.7);
--toclink-text: var(--text);
--toclink-underline: #6af;
--toclink-visited-text: var(--toclink-text);
--toclink-visited-underline: #054572;
--heading-text: #8af;
--hr-text: var(--text);
--algo-border: #456;
--del-text: #f44;
--del-bg: transparent;
--ins-text: #4a4;
--ins-bg: transparent;
--a-normal-text: #6af;
--a-normal-underline: #555;
--a-visited-text: var(--a-normal-text);
--a-visited-underline: var(--a-normal-underline);
--a-hover-bg: rgba(25%, 25%, 25%, .2);
--a-active-text: #f44;
--a-active-underline: var(--a-active-text);
--borderedblock-bg: rgba(255, 255, 255, .05);
--blockquote-border: silver;
--blockquote-bg: var(--borderedblock-bg);
--blockquote-text: currentcolor;
--issue-border: #e05252;
--issue-bg: var(--borderedblock-bg);
--issue-text: var(--text);
--issueheading-text: hsl(0deg, 70%, 70%);
--example-border: hsl(50deg, 90%, 60%);
--example-bg: var(--borderedblock-bg);
--example-text: var(--text);
--exampleheading-text: hsl(50deg, 70%, 70%);
--note-border: hsl(120deg, 100%, 35%);
--note-bg: var(--borderedblock-bg);
--note-text: var(--text);
--noteheading-text: hsl(120, 70%, 70%);
--notesummary-underline: silver;
--assertion-border: #444;
--assertion-bg: var(--borderedblock-bg);
--assertion-text: var(--text);
--advisement-border: orange;
--advisement-bg: #222218;
--advisement-text: var(--text);
--advisementheading-text: #f84;
--warning-border: red;
--warning-bg: hsla(40,100%,20%,0.95);
--warning-text: var(--text);
--amendment-border: #330099;
--amendment-bg: #080010;
--amendment-text: var(--text);
--amendmentheading-text: #cc00ff;
--def-border: #8ccbf2;
--def-bg: #080818;
--def-text: var(--text);
--defrow-border: #136;
--datacell-border: silver;
--indexinfo-text: #aaa;
--indextable-hover-text: var(--text);
--indextable-hover-bg: #181818;
--outdatedspec-bg: rgba(255, 255, 255, .5);
--outdatedspec-text: black;
--outdated-bg: maroon;
--outdated-text: white;
--outdated-shadow: red;
--editedrec-bg: darkorange;
}
/* In case a transparent-bg image doesn't expect to be on a dark bg,
which is quite common in practice... */
img { background: white; }
}
</style>
<style>/* Boilerplate: style-counters */
body {
counter-reset: example figure issue;
}
.issue {
counter-increment: issue;
}
.issue:not(.no-marker)::before {
content: "Issue " counter(issue);
}
.example {
counter-increment: example;
}
.example:not(.no-marker)::before {
content: "Example " counter(example);
}
.invalid.example:not(.no-marker)::before,
.illegal.example:not(.no-marker)::before {
content: "Invalid Example" counter(example);
}
figcaption {
counter-increment: figure;
}
figcaption:not(.no-marker)::before {
content: "Figure " counter(figure) " ";
}
</style>
<style>/* Boilerplate: style-dfn-panel */
:root {
--dfnpanel-bg: #ddd;
--dfnpanel-text: var(--text);
}
@media (prefers-color-scheme: dark) {
:root {
--dfnpanel-bg: #222;
--dfnpanel-text: var(--text);
}
}
.dfn-panel {
position: absolute;
z-index: 35;
width: 20em;
width: 300px;
height: auto;
max-height: 500px;
overflow: auto;
padding: 0.5em 0.75em;
font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
background: var(--dfnpanel-bg);
color: var(--dfnpanel-text);
border: outset 0.2em;
white-space: normal; /* in case it's moved into a pre */
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: var(--dfnpanel-text); }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0 0 0 1em; list-style: none; }
.dfn-panel li a {
white-space: pre;
display: inline-block;
max-width: calc(300px - 1.5em - 1em);
overflow: hidden;
text-overflow: ellipsis;
}
.dfn-panel.activated {
display: inline-block;
position: fixed;
left: .5em;
bottom: 2em;
margin: 0 auto;
max-width: calc(100vw - 1.5em - .4em - .5em);
max-height: 30vh;
}
.dfn-paneled[role="button"] { cursor: pointer; }
</style>
<style>/* Boilerplate: style-dfn-panel */
:root {
--dfnpanel-bg: #ddd;
--dfnpanel-text: var(--text);
}
@media (prefers-color-scheme: dark) {
:root {
--dfnpanel-bg: #222;
--dfnpanel-text: var(--text);
}
}
.dfn-panel {
position: absolute;
z-index: 35;
width: 20em;
width: 300px;
height: auto;
max-height: 500px;
overflow: auto;
padding: 0.5em 0.75em;
font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
background: var(--dfnpanel-bg);
color: var(--dfnpanel-text);
border: outset 0.2em;
white-space: normal; /* in case it's moved into a pre */
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: var(--dfnpanel-text); }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0 0 0 1em; list-style: none; }
.dfn-panel li a {
white-space: pre;
display: inline-block;
max-width: calc(300px - 1.5em - 1em);
overflow: hidden;
text-overflow: ellipsis;
}
.dfn-panel.activated {
display: inline-block;
position: fixed;
left: .5em;
bottom: 2em;
margin: 0 auto;
max-width: calc(100vw - 1.5em - .4em - .5em);
max-height: 30vh;
}
.dfn-paneled[role="button"] { cursor: pointer; }
</style>
<style>/* Boilerplate: style-issues */
a[href].issue-return {
float: right;
float: inline-end;
color: var(--issueheading-text);
font-weight: bold;
text-decoration: none;
}
</style>
<style>/* Boilerplate: style-md-lists */
/* This is a weird hack for me not yet following the commonmark spec
regarding paragraph and lists. */
[data-md] > :first-child {
margin-top: 0;
}
[data-md] > :last-child {
margin-bottom: 0;
}
</style>
<style>/* Boilerplate: style-selflinks */
:root {
--selflink-text: white;
--selflink-bg: gray;
--selflink-hover-text: black;
}
.heading, .issue, .note, .example, li, dt {
position: relative;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
}
a.self-link:hover {
opacity: 1;
}
.heading > a.self-link {
font-size: 83%;
}
.example > a.self-link,
.note > a.self-link,
.issue > a.self-link {
/* These blocks are overflow:auto, so positioning outside
doesn't work. */
left: auto;
right: 0;
}
li > a.self-link {
left: calc(-1 * (3.5rem - 26px) - 2em);
}
dfn > a.self-link {
top: auto;
left: auto;
opacity: 0;
width: 1.5em;
height: 1.5em;
background: var(--selflink-bg);
color: var(--selflink-text);
font-style: normal;
transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
opacity: 1;
}
dfn > a.self-link:hover {
color: var(--selflink-hover-text);
}
a.self-link::before { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before { content: "#"; }
</style>
<style>/* Boilerplate: style-syntax-highlighting */
pre.idl.highlight {
background: var(--borderedblock-bg, var(--def-bg));
}
</style>
<style>/* Boilerplate: style-syntax-highlighting */
code.highlight { padding: .1em; border-radius: .3em; }
pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; }
.highlight:not(.idl) { background: rgba(0, 0, 0, .03); }
c-[a] { color: #990055 } /* Keyword.Declaration */
c-[b] { color: #990055 } /* Keyword.Type */
c-[c] { color: #708090 } /* Comment */
c-[d] { color: #708090 } /* Comment.Multiline */
c-[e] { color: #0077aa } /* Name.Attribute */
c-[f] { color: #669900 } /* Name.Tag */
c-[g] { color: #222222 } /* Name.Variable */
c-[k] { color: #990055 } /* Keyword */
c-[l] { color: #000000 } /* Literal */
c-[m] { color: #000000 } /* Literal.Number */
c-[n] { color: #0077aa } /* Name */
c-[o] { color: #999999 } /* Operator */
c-[p] { color: #999999 } /* Punctuation */
c-[s] { color: #a67f59 } /* Literal.String */
c-[t] { color: #a67f59 } /* Literal.String.Single */
c-[u] { color: #a67f59 } /* Literal.String.Double */
c-[cp] { color: #708090 } /* Comment.Preproc */
c-[c1] { color: #708090 } /* Comment.Single */
c-[cs] { color: #708090 } /* Comment.Special */
c-[kc] { color: #990055 } /* Keyword.Constant */
c-[kn] { color: #990055 } /* Keyword.Namespace */
c-[kp] { color: #990055 } /* Keyword.Pseudo */
c-[kr] { color: #990055 } /* Keyword.Reserved */
c-[ld] { color: #000000 } /* Literal.Date */
c-[nc] { color: #0077aa } /* Name.Class */
c-[no] { color: #0077aa } /* Name.Constant */
c-[nd] { color: #0077aa } /* Name.Decorator */
c-[ni] { color: #0077aa } /* Name.Entity */
c-[ne] { color: #0077aa } /* Name.Exception */
c-[nf] { color: #0077aa } /* Name.Function */
c-[nl] { color: #0077aa } /* Name.Label */
c-[nn] { color: #0077aa } /* Name.Namespace */
c-[py] { color: #0077aa } /* Name.Property */
c-[ow] { color: #999999 } /* Operator.Word */
c-[mb] { color: #000000 } /* Literal.Number.Bin */
c-[mf] { color: #000000 } /* Literal.Number.Float */
c-[mh] { color: #000000 } /* Literal.Number.Hex */
c-[mi] { color: #000000 } /* Literal.Number.Integer */
c-[mo] { color: #000000 } /* Literal.Number.Oct */
c-[sb] { color: #a67f59 } /* Literal.String.Backtick */
c-[sc] { color: #a67f59 } /* Literal.String.Char */
c-[sd] { color: #a67f59 } /* Literal.String.Doc */
c-[se] { color: #a67f59 } /* Literal.String.Escape */
c-[sh] { color: #a67f59 } /* Literal.String.Heredoc */
c-[si] { color: #a67f59 } /* Literal.String.Interpol */
c-[sx] { color: #a67f59 } /* Literal.String.Other */
c-[sr] { color: #a67f59 } /* Literal.String.Regex */
c-[ss] { color: #a67f59 } /* Literal.String.Symbol */
c-[vc] { color: #0077aa } /* Name.Variable.Class */
c-[vg] { color: #0077aa } /* Name.Variable.Global */
c-[vi] { color: #0077aa } /* Name.Variable.Instance */
c-[il] { color: #000000 } /* Literal.Number.Integer.Long */
@media (prefers-color-scheme: dark) {
.highlight:not(.idl) { background: rgba(255, 255, 255, .05); }
c-[a] { color: #d33682 } /* Keyword.Declaration */
c-[b] { color: #d33682 } /* Keyword.Type */
c-[c] { color: #2aa198 } /* Comment */
c-[d] { color: #2aa198 } /* Comment.Multiline */
c-[e] { color: #268bd2 } /* Name.Attribute */
c-[f] { color: #b58900 } /* Name.Tag */
c-[g] { color: #cb4b16 } /* Name.Variable */
c-[k] { color: #d33682 } /* Keyword */
c-[l] { color: #657b83 } /* Literal */
c-[m] { color: #657b83 } /* Literal.Number */
c-[n] { color: #268bd2 } /* Name */
c-[o] { color: #657b83 } /* Operator */
c-[p] { color: #657b83 } /* Punctuation */
c-[s] { color: #6c71c4 } /* Literal.String */
c-[t] { color: #6c71c4 } /* Literal.String.Single */
c-[u] { color: #6c71c4 } /* Literal.String.Double */
c-[ch] { color: #2aa198 } /* Comment.Hashbang */
c-[cp] { color: #2aa198 } /* Comment.Preproc */
c-[cpf] { color: #2aa198 } /* Comment.PreprocFile */
c-[c1] { color: #2aa198 } /* Comment.Single */
c-[cs] { color: #2aa198 } /* Comment.Special */
c-[kc] { color: #d33682 } /* Keyword.Constant */
c-[kn] { color: #d33682 } /* Keyword.Namespace */
c-[kp] { color: #d33682 } /* Keyword.Pseudo */
c-[kr] { color: #d33682 } /* Keyword.Reserved */
c-[ld] { color: #657b83 } /* Literal.Date */
c-[nc] { color: #268bd2 } /* Name.Class */
c-[no] { color: #268bd2 } /* Name.Constant */
c-[nd] { color: #268bd2 } /* Name.Decorator */
c-[ni] { color: #268bd2 } /* Name.Entity */
c-[ne] { color: #268bd2 } /* Name.Exception */
c-[nf] { color: #268bd2 } /* Name.Function */
c-[nl] { color: #268bd2 } /* Name.Label */
c-[nn] { color: #268bd2 } /* Name.Namespace */
c-[py] { color: #268bd2 } /* Name.Property */
c-[ow] { color: #657b83 } /* Operator.Word */
c-[mb] { color: #657b83 } /* Literal.Number.Bin */
c-[mf] { color: #657b83 } /* Literal.Number.Float */
c-[mh] { color: #657b83 } /* Literal.Number.Hex */
c-[mi] { color: #657b83 } /* Literal.Number.Integer */
c-[mo] { color: #657b83 } /* Literal.Number.Oct */
c-[sa] { color: #6c71c4 } /* Literal.String.Affix */
c-[sb] { color: #6c71c4 } /* Literal.String.Backtick */
c-[sc] { color: #6c71c4 } /* Literal.String.Char */
c-[dl] { color: #6c71c4 } /* Literal.String.Delimiter */
c-[sd] { color: #6c71c4 } /* Literal.String.Doc */
c-[se] { color: #6c71c4 } /* Literal.String.Escape */
c-[sh] { color: #6c71c4 } /* Literal.String.Heredoc */
c-[si] { color: #6c71c4 } /* Literal.String.Interpol */
c-[sx] { color: #6c71c4 } /* Literal.String.Other */
c-[sr] { color: #6c71c4 } /* Literal.String.Regex */
c-[ss] { color: #6c71c4 } /* Literal.String.Symbol */
c-[fm] { color: #268bd2 } /* Name.Function.Magic */
c-[vc] { color: #cb4b16 } /* Name.Variable.Class */
c-[vg] { color: #cb4b16 } /* Name.Variable.Global */
c-[vi] { color: #cb4b16 } /* Name.Variable.Instance */
c-[vm] { color: #cb4b16 } /* Name.Variable.Magic */
c-[il] { color: #657b83 } /* Literal.Number.Integer.Long */
}
</style>
<style>/* Boilerplate: style-var-click-highlighting */
/*
Colors were chosen in Lab using https://nixsensor.com/free-color-converter/
D50 2deg illuminant, L in [0,100], a and b in [-128, 128]
0 = lab(85,0,85)
1 = lab(85,80,30)
2 = lab(85,-40,40)
3 = lab(85,-50,0)
4 = lab(85,5,15)
5 = lab(85,-10,-50)
6 = lab(85,35,-15)
*/
var { cursor: pointer; }
var.selected0 { background-color: #F4D200; box-shadow: 0 0 0 2px #F4D200; }
var.selected1 { background-color: #FF87A2; box-shadow: 0 0 0 2px #FF87A2; }
var.selected2 { background-color: #96E885; box-shadow: 0 0 0 2px #96E885; }
var.selected3 { background-color: #3EEED2; box-shadow: 0 0 0 2px #3EEED2; }
var.selected4 { background-color: #EACFB6; box-shadow: 0 0 0 2px #EACFB6; }
var.selected5 { background-color: #82DDFF; box-shadow: 0 0 0 2px #82DDFF; }
var.selected6 { background-color: #FFBCF2; box-shadow: 0 0 0 2px #FFBCF2; }
</style>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2021/logos/W3C" width="72"> </a> </p>
<h1 class="p-name no-ref" id="title">Ambient Light Sensor</h1>
<p id="w3c-state"><a href="https://www.w3.org/standards/types#ED">Editor’s Draft</a>, <time class="dt-updated" datetime="2024-01-24">24 January 2024</time></p>
<details open>
<summary>More details about this document</summary>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="https://w3c.github.io/ambient-light/">https://w3c.github.io/ambient-light/</a>
<dt>Latest published version:
<dd><a href="https://www.w3.org/TR/ambient-light/">https://www.w3.org/TR/ambient-light/</a>
<dt>Version History:
<dd><a href="https://github.com/w3c/ambient-light/commits/main/index.bs">https://github.com/w3c/ambient-light/commits/main/index.bs</a>
<dt>Feedback:
<dd><span><a href="mailto:public-device-apis@w3.org?subject=%5Bambient-light%5D%20YOUR%20TOPIC%20HERE">public-device-apis@w3.org</a> with subject line “<kbd>[ambient-light] <i data-lt>… message topic …</i></kbd>” (<a href="https://lists.w3.org/Archives/Public/public-device-apis/" rel="discussion">archives</a>)</span>
<dd><a href="https://github.com/w3c/ambient-light/issues/">GitHub</a>
<dt>Test Suite:
<dd><a href="https://github.com/web-platform-tests/wpt/tree/master/ambient-light">https://github.com/web-platform-tests/wpt/tree/master/ambient-light</a>
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard" data-editor-id="41974"><a class="p-name fn u-url url" href="https://intel.com/">Anssi Kostiainen</a> (<span class="p-org org">Intel Corporation</span>)
<dd class="editor p-author h-card vcard" data-editor-id="80407"><a class="p-name fn u-url url" href="https://intel.com/">Rijubrata Bhaumik</a> (<span class="p-org org">Intel Corporation</span>)
<dt class="editor">Former Editors:
<dd class="editor p-author h-card vcard" data-editor-id="60809"><a class="p-name fn u-url url" href="https://tobie.me">Tobie Langel</a> (<span class="p-org org">Codespeaks, formerly on behalf of Intel Corporation</span>) <a class="u-email email" href="mailto:tobie@codespeaks.com">tobie@codespeaks.com</a>
<dd class="editor p-author h-card vcard"><a class="p-name fn u-url url" href="https://mozilla.com/">Doug Turner</a> (<span class="p-org org">Mozilla Corporation</span>)
<dt>Issue Tracking:
<dd><a href="https://github.com/w3c/ambient-light/milestones/Level%202">Level 2 Issues</a>
</dl>
</div>
</details>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="https://www.w3.org/policies/#copyright">Copyright</a> © 2024 <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a href="https://www.w3.org/copyright/software-license/" rel="license" title="W3C Software and Document License">permissive document license</a> rules apply. </p>
<hr title="Separator for header">
</div>
<div class="p-summary" data-fill-with="abstract">
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<p>This specification defines a concrete sensor interface to monitor
the ambient light level or illuminance of the device’s environment.</p>
</div>
<h2 class="no-num no-toc no-ref heading settled" id="sotd"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p> This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress. </p>
<p> If you wish to make comments regarding this document, please send them to <a href="mailto:public-device-apis@w3.org?Subject=%5Bambient-light%5D%20PUT%20SUBJECT%20HERE">public-device-apis@w3.org</a> (<a href="mailto:public-device-apis-request@w3.org?subject=subscribe">subscribe</a>, <a href="https://lists.w3.org/Archives/Public/public-device-apis/">archives</a>).
When sending e-mail,
please put the text “ambient-light” in the subject,
preferably like this:
“[ambient-light] <em>…summary of comment…</em>”.
All comments are welcome. </p>
<p> This document was produced by the <a href="https://www.w3.org/groups/wg/das">Devices and Sensors Working Group</a>. </p>
<p> This document was produced by a group operating under
the <a href="https://www.w3.org/Consortium/Patent-Policy/">W3C Patent Policy</a>.
W3C maintains a <a href="https://www.w3.org/groups/wg/das/ipr" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href="https://www.w3.org/Consortium/Patent-Policy-20200915/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="https://www.w3.org/Consortium/Patent-Policy-20200915/#sec-Disclosure">section 6 of the W3C Patent Policy</a>. </p>
<p> This document is governed by the <a href="https://www.w3.org/2023/Process-20231103/" id="w3c_process_revision">03 November 2023 W3C Process Document</a>. </p>
<p></p>
<p>The Devices and Sensors Working Group is pursuing modern security and privacy
reviews for this specification in consideration of the amount of change in both
this specification and in privacy and security review practices since the
horizontal reviews <a href="https://github.com/w3c/sensors/issues/299#issue-262392533">took place
on 3 October 2017</a>. Similarly, the group is pursuing an update to the Technical
Architecture Group review for this specification to account for the latest
architectural review practices.</p>
</div>
<div data-fill-with="at-risk"></div>
<nav data-fill-with="table-of-contents" id="toc">
<h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
<ol class="toc" role="directory">
<li>
<a href="#intro"><span class="secno">1</span> <span class="content">Introduction</span></a>
<ol class="toc">
<li><a href="#scope"><span class="secno">1.1</span> <span class="content">Scope</span></a>
</ol>
<li><a href="#examples"><span class="secno">2</span> <span class="content">Examples</span></a>
<li>
<a href="#security-and-privacy"><span class="secno">3</span> <span class="content">Security and Privacy Considerations</span></a>
<ol class="toc">
<li><a href="#reduce-sensor-accuracy"><span class="secno">3.1</span> <span class="content">Reducing sensor readings accuracy</span></a>
</ol>
<li><a href="#model"><span class="secno">4</span> <span class="content">Model</span></a>
<li>
<a href="#api"><span class="secno">5</span> <span class="content">API</span></a>
<ol class="toc">
<li>
<a href="#ambient-light-sensor-interface"><span class="secno">5.1</span> <span class="content">The AmbientLightSensor Interface</span></a>
<ol class="toc">
<li><a href="#ambient-light-sensor-reading-attribute"><span class="secno">5.1.1</span> <span class="content">The illuminance attribute</span></a>
</ol>
</ol>
<li>
<a href="#abstract-operations"><span class="secno">6</span> <span class="content">Abstract Operations</span></a>
<ol class="toc">
<li><a href="#construct-an-ambient-light-sensor-object"><span class="secno">6.1</span> <span class="content">Construct an ambient light sensor object</span></a>
<li><a href="#ambient-light-threshold-check-algorithm"><span class="secno">6.2</span> <span class="content">Ambient light threshold check algorithm</span></a>
<li><a href="#ambient-light-reading-quantization-algorithm"><span class="secno">6.3</span> <span class="content">Ambient light reading quantization algorithm</span></a>
</ol>
<li><a href="#automation"><span class="secno">7</span> <span class="content">Automation</span></a>
<li><a href="#usecases-requirements"><span class="secno">8</span> <span class="content">Use Cases and Requirements</span></a>
<li><a href="#acknowledgements"><span class="secno">9</span> <span class="content">Acknowledgements</span></a>
<li>
<a href="#w3c-conformance"><span class="secno"></span> <span class="content">Conformance</span></a>
<ol class="toc">
<li><a href="#w3c-conventions"><span class="secno"></span> <span class="content">Document conventions</span></a>
<li><a href="#w3c-conformant-algorithms"><span class="secno"></span> <span class="content">Conformant Algorithms</span></a>
</ol>
<li>
<a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ol class="toc">
<li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ol>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ol class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
</ol>
<li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a>
</ol>
</nav>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">Introduction</span><a class="self-link" href="#intro"></a></h2>
<p>The Ambient Light Sensor extends the Generic Sensor API <a data-link-type="biblio" href="#biblio-generic-sensor" title="Generic Sensor API">[GENERIC-SENSOR]</a> to provide information about ambient light levels,
as detected by the device’s main light detector, in terms of lux units.</p>
<h3 class="heading settled" data-level="1.1" id="scope"><span class="secno">1.1. </span><span class="content">Scope</span><a class="self-link" href="#scope"></a></h3>
<p>This document specifies an API designed for <a href="#usecases-requirements">use cases</a> which require fine grained illuminance data, with low latency, and possibly
sampled at high frequencies.</p>
<p>Common use cases relying on a small set of illuminance values, such as styling
webpages according to contrast level or preferred color scheme that may be
influenced by a device’s measured ambient light level are best served by the the <code>prefers-contrast</code> and <code>prefers-color-scheme</code> CSS media features <a data-link-type="biblio" href="#biblio-mediaqueries-5" title="Media Queries Level 5">[MEDIAQUERIES-5]</a> as well as the accompanying <code>matchMedia</code> API <a data-link-type="biblio" href="#biblio-cssom-view-1" title="CSSOM View Module">[CSSOM-VIEW-1]</a> and are out of scope of this API.</p>
<p class="note" role="note"><span class="marker">Note:</span> The <a data-link-type="biblio" href="#biblio-mediaqueries-5" title="Media Queries Level 5">[MEDIAQUERIES-5]</a> specification used to contain a <code>light-level</code> media feature that was more directly tied to ambient light readings. It has
since been <a href="https://github.com/w3c/csswg-drafts/commit/f5b663c27d5a2715239633f4916880563969d770">dropped</a> from the specification in favor of the higher-level <code>prefers-color-scheme</code> and <code>prefers-contrast</code> media features.</p>
<h2 class="heading settled" data-level="2" id="examples"><span class="secno">2. </span><span class="content">Examples</span><a class="self-link" href="#examples"></a></h2>
<div class="example" id="example-cdf5e857">
<a class="self-link" href="#example-cdf5e857"></a> In this simple example, ambient light sensor is created with
default configuration. Whenever a new <a data-link-type="dfn" href="https://w3c.github.io/sensors/#sensor-reading" id="ref-for-sensor-reading">reading</a> is available,
it is printed to the console.
<pre class="highlight"><c- a>const</c-> sensor <c- o>=</c-> <c- ow>new</c-> AmbientLightSensor<c- p>();</c->
sensor<c- p>.</c->onreading <c- o>=</c-> <c- p>()</c-> <c- p>=></c-> console<c- p>.</c->log<c- p>(</c->sensor<c- p>.</c->illuminance<c- p>);</c->
sensor<c- p>.</c->onerror <c- o>=</c-> event <c- p>=></c-> console<c- p>.</c->log<c- p>(</c->event<c- p>.</c->error<c- p>.</c->name<c- p>,</c-> event<c- p>.</c->error<c- p>.</c->message<c- p>);</c->
sensor<c- p>.</c->start<c- p>();</c->
</pre>
</div>
<div class="example" id="example-20e631c4">
<a class="self-link" href="#example-20e631c4"></a> In this example, the exposure value (EV) at ISO 100 is calculated from
the ambient light <a data-link-type="dfn" href="https://w3c.github.io/sensors/#sensor-reading" id="ref-for-sensor-reading①">sensor readings</a>. Initially, we check that the user
agent has permissions to access ambient light <a data-link-type="dfn" href="https://w3c.github.io/sensors/#sensor-reading" id="ref-for-sensor-reading②">sensor readings</a>. Then,
the <code class="idl"><a class="idl-code" data-link-type="attribute" href="#dom-ambientlightsensor-illuminance" id="ref-for-dom-ambientlightsensor-illuminance">illuminance</a></code> value is converted to the
closest exposure value.
<pre class="highlight">navigator<c- p>.</c->permissions<c- p>.</c->query<c- p>({</c-> name<c- o>:</c-> <c- t>'ambient-light-sensor'</c-> <c- p>}).</c->then<c- p>(</c->result <c- p>=></c-> <c- p>{</c->
<c- k>if</c-> <c- p>(</c->result<c- p>.</c->state <c- o>===</c-> <c- t>'denied'</c-><c- p>)</c-> <c- p>{</c->
console<c- p>.</c->log<c- p>(</c-><c- t>'Permission to use ambient light sensor is denied.'</c-><c- p>);</c->
<c- k>return</c-><c- p>;</c->
<c- p>}</c->
<c- a>const</c-> als <c- o>=</c-> <c- ow>new</c-> AmbientLightSensor<c- p>({</c->frequency<c- o>:</c-> <c- mf>20</c-><c- p>});</c->
als<c- p>.</c->addEventListener<c- p>(</c-><c- t>'activate'</c-><c- p>,</c-> <c- p>()</c-> <c- p>=></c-> console<c- p>.</c->log<c- p>(</c-><c- t>'Ready to measure EV.'</c-><c- p>));</c->
als<c- p>.</c->addEventListener<c- p>(</c-><c- t>'error'</c-><c- p>,</c-> event <c- p>=></c-> console<c- p>.</c->log<c- p>(</c-><c- sb>`Error: </c-><c- si>${</c->event<c- p>.</c->error<c- p>.</c->name<c- si>}</c-><c- sb>`</c-><c- p>));</c->
als<c- p>.</c->addEventListener<c- p>(</c-><c- t>'reading'</c-><c- p>,</c-> <c- p>()</c-> <c- p>=></c-> <c- p>{</c->
<c- c1>// Defaut ISO value.</c->
<c- a>const</c-> ISO <c- o>=</c-> <c- mf>100</c-><c- p>;</c->
<c- c1>// Incident-light calibration constant.</c->
<c- a>const</c-> C <c- o>=</c-> <c- mf>250</c-><c- p>;</c->
<c- a>let</c-> EV <c- o>=</c-> Math<c- p>.</c->round<c- p>(</c->Math<c- p>.</c->log2<c- p>((</c->als<c- p>.</c->illuminance <c- o>*</c-> ISO<c- p>)</c-> <c- o>/</c-> C<c- p>));</c->
console<c- p>.</c->log<c- p>(</c-><c- sb>`Exposure Value (EV) is: </c-><c- si>${</c->EV<c- si>}</c-><c- sb>`</c-><c- p>);</c->
<c- p>});</c->
als<c- p>.</c->start<c- p>();</c->
<c- p>});</c->
</pre>
</div>
<div class="example" id="example-ad1f42be">
<a class="self-link" href="#example-ad1f42be"></a> This example demonstrates how ambient light <a data-link-type="dfn" href="https://w3c.github.io/sensors/#sensor-reading" id="ref-for-sensor-reading③">sensor readings</a> can be mapped
to recommended workplace light levels.
<pre class="highlight"><c- a>const</c-> als <c- o>=</c-> <c- ow>new</c-> AmbientLightSensor<c- p>();</c->
als<c- p>.</c->onreading <c- o>=</c-> <c- p>()</c-> <c- p>=></c-> <c- p>{</c->
<c- a>let</c-> str <c- o>=</c-> luxToWorkplaceLevel<c- p>(</c->als<c- p>.</c->illuminance<c- p>);</c->
<c- k>if</c-> <c- p>(</c->str<c- p>)</c-> <c- p>{</c->
console<c- p>.</c->log<c- p>(</c-><c- sb>`Light level is suitable for: </c-><c- si>${</c->str<c- si>}</c-><c- sb>.`</c-><c- p>);</c->
<c- p>}</c->
<c- p>};</c->
als<c- p>.</c->start<c- p>();</c->
<c- a>function</c-> luxToWorkplaceLevel<c- p>(</c->lux<c- p>)</c-> <c- p>{</c->
<c- k>if</c-> <c- p>(</c->lux <c- o>></c-> <c- mf>20</c-> <c- o>&&</c-> lux <c- o><</c-> <c- mf>100</c-><c- p>)</c-> <c- p>{</c->
<c- k>return</c-> <c- t>'public areas, short visits'</c-><c- p>;</c->
<c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->lux <c- o>></c-> <c- mf>100</c-> <c- o>&&</c-> lux <c- o><</c-> <c- mf>150</c-><c- p>)</c-> <c- p>{</c->
<c- k>return</c-> <c- t>'occasionally performed visual tasks'</c-><c- p>;</c->
<c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->lux <c- o>></c-> <c- mf>150</c-> <c- o>&&</c-> lux <c- o><</c-> <c- mf>250</c-><c- p>)</c-> <c- p>{</c->
<c- k>return</c-> <c- t>'easy office work, classes, homes, theaters'</c-><c- p>;</c->
<c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->lux <c- o>></c-> <c- mf>250</c-> <c- o>&&</c-> lux <c- o><</c-> <c- mf>500</c-><c- p>)</c-> <c- p>{</c->
<c- k>return</c-> <c- t>'normal office work, groceries, laboratories'</c-><c- p>;</c->
<c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->lux <c- o>></c-> <c- mf>500</c-> <c- o>&&</c-> lux <c- o><</c-> <c- mf>1000</c-><c- p>)</c-> <c- p>{</c->
<c- k>return</c-> <c- t>'mechanical workshops, drawing, supermarkets'</c-><c- p>;</c->
<c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->lux <c- o>></c-> <c- mf>1000</c-> <c- o>&&</c-> lux <c- o><</c-> <c- mf>5000</c-><c- p>)</c-> <c- p>{</c->
<c- k>return</c-> <c- t>'detailed drawing work, visual tasks of low contrast'</c-><c- p>;</c->
<c- p>}</c->
<c- k>return</c-><c- p>;</c->
<c- p>}</c->
</pre>
</div>
<h2 class="heading settled" data-level="3" id="security-and-privacy"><span class="secno">3. </span><span class="content">Security and Privacy Considerations</span><a class="self-link" href="#security-and-privacy"></a></h2>
<p><a class="tracking-vector" href="https://infra.spec.whatwg.org/#tracking-vector"><svg aria-label="(This is a tracking vector.)" height="64" role="img" width="46"><title>There is a tracking vector here.</title><use href="#b732b3fe"></use></svg></a> Ambient Light Sensor provides information about lighting conditions near
the device environment. Potential privacy risks include: </p>
<ul>
<li data-md>
<p>Profiling. Ambient Light Sensor can leak information about user’s use
patterns and surrounding. This information can be used to enhance user
profiling and behavioral analysis.</p>
<li data-md>
<p>Cross-device linking. Two devices can access web sites that include the
same third-party script that correlates lighting levels over time.</p>
<li data-md>
<p>Cross-device communication. A simple broadcast communication method can
use device screen or camera LED flashes to broadcast messages read
out with an Ambient Light Sensor in a close by device.</p>
<li data-md>
<p>Cross-origin leaks. Light emitted from the screen can be reflected back to
the sensor from nearby reflective surfaces. Malicious sites can embed
resources from different origins and scale the content to display
particular pixels to allow distinguishing the contents, pixel by pixel.</p>
<li data-md>
<p>Hijacking browsing history. Styling visited links to allow distinguishing
the light levels associated with visited and unvisited links i.e. visited
links styled as a block of black screen; white for unvisited.</p>
</ul>
<p>Works such as <a data-link-type="biblio" href="#biblio-alsprivacyanalysis" title="Privacy analysis of Ambient Light Sensors">[ALSPRIVACYANALYSIS]</a>, <a data-link-type="biblio" href="#biblio-pinskimmingviasensor" title="PIN Skimming: Exploiting the Ambient-Light Sensor in Mobile Devices">[PINSKIMMINGVIASENSOR]</a>, <a data-link-type="biblio" href="#biblio-stealingsensitivedata" title="Stealing sensitive browser data with the W3C Ambient Light Sensor API">[STEALINGSENSITIVEDATA]</a>, <a data-link-type="biblio" href="#biblio-videorecognitionambientlight" title="Video recognition using ambient light sensors">[VIDEORECOGNITIONAMBIENTLIGHT]</a>, and <a data-link-type="biblio" href="#biblio-imagingprivacy" title="Imaging privacy threats from an ambient light sensor">[IMAGINGPRIVACY]</a> delve further into these issues.</p>
<p>To mitigate these threats specific to Ambient Light Sensor, user agents must <a data-link-type="dfn" href="https://w3c.github.io/sensors/#reduce-accuracy" id="ref-for-reduce-accuracy">reduce accuracy</a> of sensor readings. User agents may also <a data-link-type="dfn" href="https://w3c.github.io/sensors/#limit-max-frequency" id="ref-for-limit-max-frequency">limit
maximum sampling frequency</a>.</p>
<p>These mitigation strategies complement the <a data-link-type="dfn" href="https://w3c.github.io/sensors/#mitigation-strategies" id="ref-for-mitigation-strategies">generic mitigations</a> defined in the Generic Sensor API <a data-link-type="biblio" href="#biblio-generic-sensor" title="Generic Sensor API">[GENERIC-SENSOR]</a>.</p>
<h3 class="heading settled" data-level="3.1" id="reduce-sensor-accuracy"><span class="secno">3.1. </span><span class="content">Reducing sensor readings accuracy</span><a class="self-link" href="#reduce-sensor-accuracy"></a></h3>
<p>In order to <a data-link-type="dfn" href="https://w3c.github.io/sensors/#reduce-accuracy" id="ref-for-reduce-accuracy①">reduce accuracy</a> of sensor readings, this specification defines
a <a data-link-type="dfn" href="https://w3c.github.io/sensors/#threshold-check-algorithm" id="ref-for-threshold-check-algorithm">threshold check algorithm</a> (the <a data-link-type="dfn" href="#ambient-light-threshold-check-algorithm" id="ref-for-ambient-light-threshold-check-algorithm">ambient light threshold check
algorithm</a>) and a <a data-link-type="dfn" href="https://w3c.github.io/sensors/#reading-quantization-algorithm" id="ref-for-reading-quantization-algorithm">reading quantization algorithm</a> (the <a data-link-type="dfn" href="#ambient-light-reading-quantization-algorithm" id="ref-for-ambient-light-reading-quantization-algorithm">ambient light
reading quantization algorithm</a>).</p>
<p>These algorithms make use of the <a data-link-type="dfn" href="#illuminance-rounding-multiple" id="ref-for-illuminance-rounding-multiple">illuminance rounding multiple</a> and the <a data-link-type="dfn" href="#illuminance-threshold-value" id="ref-for-illuminance-threshold-value">illuminance threshold value</a>. Implementations must adhere to the following
requirements for their values:</p>
<ul>
<li data-md>
<p>The <a data-link-type="dfn" href="#illuminance-rounding-multiple" id="ref-for-illuminance-rounding-multiple①">illuminance rounding multiple</a> must be at least 50 lux.</p>
<li data-md>
<p>The <a data-link-type="dfn" href="#illuminance-threshold-value" id="ref-for-illuminance-threshold-value①">illuminance threshold value</a> should be at least half of the <a data-link-type="dfn" href="#illuminance-rounding-multiple" id="ref-for-illuminance-rounding-multiple②">illuminance rounding multiple</a>.</p>
</ul>
<p class="note" role="note"><span class="marker">Note:</span> Choosing an <a data-link-type="dfn" href="#illuminance-rounding-multiple" id="ref-for-illuminance-rounding-multiple③">illuminance rounding multiple</a> requires balancing not
exposing readouts that are too precise while also providing readouts that are
still useful for API users. The value of 50 lux as a minimum for the <a data-link-type="dfn" href="#illuminance-rounding-multiple" id="ref-for-illuminance-rounding-multiple④">illuminance rounding multiple</a> was determined in <a href="https://github.com/w3c/ambient-light/issues/13#issuecomment-302393458">GitHub
issue #13</a> after different ambient light level measurements under different
lighting conditions were <a href="https://docs.google.com/spreadsheets/d/1vUojkaaif6AmftQmtqra1w9Z7CH00Cn9pb0Ci6v5_Jk">gathered </a> and shown to thwart the attack described in <a data-link-type="biblio" href="#biblio-stealingsensitivedata" title="Stealing sensitive browser data with the W3C Ambient Light Sensor API">[STEALINGSENSITIVEDATA]</a>. 50
lux is also higher than the 5 lux required to make video recognition using
ambient light sensor readings (<a data-link-type="biblio" href="#biblio-videorecognitionambientlight" title="Video recognition using ambient light sensors">[VIDEORECOGNITIONAMBIENTLIGHT]</a>) infeasible.</p>
<p class="note" role="note"><span class="marker">Note:</span> The <a data-link-type="dfn" href="#illuminance-threshold-value" id="ref-for-illuminance-threshold-value②">illuminance threshold value</a> is used to prevent leaking the fact
that readings are hovering around a particular value but getting quantized to
different values. For example, if <a data-link-type="dfn" href="#illuminance-rounding-multiple" id="ref-for-illuminance-rounding-multiple⑤">illuminance rounding multiple</a> is 50, this
prevents switching the illuminance value between 0 and 50 if the raw readouts
switch between 24 and 26. The efficacy of the <a data-link-type="dfn" href="https://w3c.github.io/sensors/#threshold-check-algorithm" id="ref-for-threshold-check-algorithm①">threshold check algorithm</a> as
an auxiliary fingerprinting mitigation strategy has not been mathematically
proven, but it has been added to this specification based on implementation
experience. <a href="https://crbug.com/1332536">Chromium bug 1332536</a> and <a href="https://crrev.com/c/3666917">Chromium review 3666917</a> contain more
information about this.</p>
<h2 class="heading settled" data-level="4" id="model"><span class="secno">4. </span><span class="content">Model</span><a class="self-link" href="#model"></a></h2>
<p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="ambient-light-sensor">Ambient Light Sensor</dfn> <a data-link-type="dfn" href="https://w3c.github.io/sensors/#sensor-type" id="ref-for-sensor-type">sensor type</a>’s associated <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/sensors/#sensor" id="ref-for-sensor">Sensor</a></code> subclass is the <code class="idl"><a data-link-type="idl" href="#ambientlightsensor" id="ref-for-ambientlightsensor">AmbientLightSensor</a></code> class.</p>
<p>The <a data-link-type="dfn" href="#ambient-light-sensor" id="ref-for-ambient-light-sensor">Ambient Light Sensor</a> has a <a data-link-type="dfn" href="https://w3c.github.io/sensors/#default-sensor" id="ref-for-default-sensor">default sensor</a>,
which is the device’s main light detector.</p>
<p>The <a data-link-type="dfn" href="#ambient-light-sensor" id="ref-for-ambient-light-sensor①">Ambient Light Sensor</a> is a <a data-link-type="dfn" href="https://w3c.github.io/permissions/#dfn-powerful-feature" id="ref-for-dfn-powerful-feature">powerful feature</a> that is identified by
the <a data-link-type="dfn" href="https://w3c.github.io/permissions/#dfn-name" id="ref-for-dfn-name">name</a> "<dfn class="idl-code" data-dfn-type="permission" data-export id="permissiondef-ambient-light-sensor"><code>ambient-light-sensor</code><a class="self-link" href="#permissiondef-ambient-light-sensor"></a></dfn>",
which is also its associated <a data-link-type="dfn" href="https://w3c.github.io/sensors/#sensor-permission-names" id="ref-for-sensor-permission-names">sensor permission name</a>. Its <a data-link-type="dfn" href="https://w3c.github.io/permissions/#dfn-permission-revocation-algorithm" id="ref-for-dfn-permission-revocation-algorithm">permission revocation algorithm</a> is the result of calling
the <a data-link-type="dfn" href="https://w3c.github.io/sensors/#generic-sensor-permission-revocation-algorithm" id="ref-for-generic-sensor-permission-revocation-algorithm">generic sensor permission revocation algorithm</a> with
"ambient-light-sensor".</p>
<p>The <a data-link-type="dfn" href="#ambient-light-sensor" id="ref-for-ambient-light-sensor②">Ambient Light Sensor</a> is a <a data-link-type="dfn" href="https://w3c.github.io/webappsec-permissions-policy/#policy-controlled-feature" id="ref-for-policy-controlled-feature">policy-controlled feature</a> identified by the string "ambient-light-sensor". Its <a data-link-type="dfn" href="https://w3c.github.io/webappsec-permissions-policy/#policy-controlled-feature-default-allowlist" id="ref-for-policy-controlled-feature-default-allowlist">default allowlist</a> is <code>'self'</code>.</p>
<p>The <a data-link-type="dfn" href="#ambient-light-sensor" id="ref-for-ambient-light-sensor③">Ambient Light Sensor</a> has a <a data-link-type="dfn" href="https://w3c.github.io/sensors/#virtual-sensor-type" id="ref-for-virtual-sensor-type">virtual sensor type</a>, which is "<code><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ambient-light virtual sensor type" data-noexport id="ambient-light-virtual-sensor-type">ambient-light</dfn></code>".</p>
<p>The <dfn data-dfn-type="dfn" data-noexport id="current-light-level">current light level<a class="self-link" href="#current-light-level"></a></dfn> or <dfn data-dfn-type="dfn" data-noexport id="illuminance">illuminance<a class="self-link" href="#illuminance"></a></dfn> is a value that represents the ambient light level
around the hosting device. Its unit is the lux (lx) <a data-link-type="biblio" href="#biblio-si" title="SI Brochure: The International System of Units (SI), 8th edition">[SI]</a>.</p>
<p class="note" role="note"><span class="marker">Note:</span> The precise lux value reported by
different devices in the same light can be different,
due to differences in detection method, sensor construction, etc.</p>
<p>The <a data-link-type="dfn" href="#ambient-light-sensor" id="ref-for-ambient-light-sensor④">Ambient Light Sensor</a> has an <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="illuminance rounding multiple" data-noexport id="illuminance-rounding-multiple">illuminance rounding
multiple</dfn>, measured in lux, which represents a number whose multiples the
illuminance readings will be rounded up to.</p>
<p>The <a data-link-type="dfn" href="#ambient-light-sensor" id="ref-for-ambient-light-sensor⑤">Ambient Light Sensor</a> has an <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="illuminance-threshold-value">illuminance threshold value</dfn>,
measured in lux, which is used in the <a data-link-type="dfn" href="#ambient-light-threshold-check-algorithm" id="ref-for-ambient-light-threshold-check-algorithm①">ambient light threshold check
algorithm</a>.</p>
<p class="note" role="note"><span class="marker">Note:</span> see <a href="#reduce-sensor-accuracy">§ 3.1 Reducing sensor readings accuracy</a> for minimum requirements for the values
described above.</p>
<h2 class="heading settled" data-level="5" id="api"><span class="secno">5. </span><span class="content">API</span><a class="self-link" href="#api"></a></h2>
<h3 class="heading settled" data-level="5.1" id="ambient-light-sensor-interface"><span class="secno">5.1. </span><span class="content">The AmbientLightSensor Interface</span><a class="self-link" href="#ambient-light-sensor-interface"></a></h3>
<pre class="idl highlight def">[<a class="idl-code" data-link-type="extended-attribute" href="https://webidl.spec.whatwg.org/#SecureContext" id="ref-for-SecureContext"><c- g>SecureContext</c-></a>, <a class="idl-code" data-link-type="extended-attribute" href="https://webidl.spec.whatwg.org/#Exposed" id="ref-for-Exposed"><c- g>Exposed</c-></a>=<c- n>Window</c->]
<c- b>interface</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="ambientlightsensor"><code><c- g>AmbientLightSensor</c-></code></dfn> : <a data-link-type="idl-name" href="https://w3c.github.io/sensors/#sensor" id="ref-for-sensor①"><c- n>Sensor</c-></a> {
<dfn class="idl-code" data-dfn-for="AmbientLightSensor" data-dfn-type="constructor" data-export data-lt="AmbientLightSensor(sensorOptions)|constructor(sensorOptions)|AmbientLightSensor()|constructor()" id="dom-ambientlightsensor-ambientlightsensor"><code><c- g>constructor</c-></code><a class="self-link" href="#dom-ambientlightsensor-ambientlightsensor"></a></dfn>(<c- b>optional</c-> <a data-link-type="idl-name" href="https://w3c.github.io/sensors/#dictdef-sensoroptions" id="ref-for-dictdef-sensoroptions"><c- n>SensorOptions</c-></a> <dfn class="idl-code" data-dfn-for="AmbientLightSensor/AmbientLightSensor(sensorOptions), AmbientLightSensor/constructor(sensorOptions), AmbientLightSensor/AmbientLightSensor(), AmbientLightSensor/constructor()" data-dfn-type="argument" data-export id="dom-ambientlightsensor-ambientlightsensor-sensoroptions-sensoroptions"><code><c- g>sensorOptions</c-></code><a class="self-link" href="#dom-ambientlightsensor-ambientlightsensor-sensoroptions-sensoroptions"></a></dfn> = {});
<c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-double" id="ref-for-idl-double"><c- b>double</c-></a>? <dfn class="dfn-paneled idl-code" data-dfn-for="AmbientLightSensor" data-dfn-type="attribute" data-export data-readonly data-type="double?" id="dom-ambientlightsensor-illuminance"><code><c- g>illuminance</c-></code></dfn>;
};
</pre>
<p>To construct an <code class="idl"><a data-link-type="idl" href="#ambientlightsensor" id="ref-for-ambientlightsensor①">AmbientLightSensor</a></code> object the user agent must invoke the <a data-link-type="dfn" href="#construct-an-ambient-light-sensor-object" id="ref-for-construct-an-ambient-light-sensor-object">construct an ambient light sensor object</a> abstract operation.</p>
<h4 class="heading settled" data-level="5.1.1" id="ambient-light-sensor-reading-attribute"><span class="secno">5.1.1. </span><span class="content">The illuminance attribute</span><a class="self-link" href="#ambient-light-sensor-reading-attribute"></a></h4>
<p>The <code class="idl"><a data-link-type="idl" href="#dom-ambientlightsensor-illuminance" id="ref-for-dom-ambientlightsensor-illuminance①">illuminance</a></code> getter steps are:</p>
<ol>
<li data-md>
<p>Let <var>illuminance</var> be the result of invoking <a data-link-type="dfn" href="https://w3c.github.io/sensors/#get-value-from-latest-reading" id="ref-for-get-value-from-latest-reading">get value from latest
reading</a> with <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#this" id="ref-for-this">this</a> and "illuminance" as arguments.</p>
<li data-md>
<p>Return <var>illuminance</var>.</p>
</ol>
<h2 class="heading settled" data-level="6" id="abstract-operations"><span class="secno">6. </span><span class="content">Abstract Operations</span><a class="self-link" href="#abstract-operations"></a></h2>
<h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="6.1" data-lt="Construct an ambient light sensor object" id="construct-an-ambient-light-sensor-object"><span class="secno">6.1. </span><span class="content">Construct an ambient light sensor object</span><a class="self-link" href="#construct-an-ambient-light-sensor-object" id="ref-for-construct-an-ambient-light-sensor-object①"></a></h3>
<div class="algorithm" data-algorithm="construct an ambient light sensor object">
<dl>
<dt data-md>input
<dd data-md>
<p><var>options</var>, a <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/sensors/#dictdef-sensoroptions" id="ref-for-dictdef-sensoroptions①">SensorOptions</a></code> object.</p>
<dt data-md>output
<dd data-md>
<p>An <code class="idl"><a data-link-type="idl" href="#ambientlightsensor" id="ref-for-ambientlightsensor②">AmbientLightSensor</a></code> object.</p>
</dl>
<ol>
<li data-md>
<p>Let <var>allowed</var> be the result of invoking <a data-link-type="dfn" href="https://w3c.github.io/sensors/#check-sensor-policy-controlled-features" id="ref-for-check-sensor-policy-controlled-features">check sensor policy-controlled features</a> with <code class="idl"><a data-link-type="idl" href="#ambientlightsensor" id="ref-for-ambientlightsensor③">AmbientLightSensor</a></code>.</p>
<li data-md>
<p>If <var>allowed</var> is false, then:</p>
<ol>
<li data-md>
<p><a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#dfn-throw" id="ref-for-dfn-throw">Throw</a> a <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#securityerror" id="ref-for-securityerror">SecurityError</a></code> <code class="idl"><a data-link-type="idl" href="https://webidl.spec.whatwg.org/#idl-DOMException" id="ref-for-idl-DOMException">DOMException</a></code>.</p>
</ol>
<li data-md>
<p>Let <var>ambient_light_sensor</var> be the new <code class="idl"><a data-link-type="idl" href="#ambientlightsensor" id="ref-for-ambientlightsensor④">AmbientLightSensor</a></code> object.</p>