-
Notifications
You must be signed in to change notification settings - Fork 28
/
engine.html
2093 lines (2006 loc) · 71.7 KB
/
engine.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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=620">
<title>engine</title>
<link rel="stylesheet" type="text/css" href="testindex.css">
<script src="testglobals.js"></script>
<script src="testgeneric.js"></script>
<!-- custom -->
<style>
table {width: 700px;}
#tb3 td:first-child { text-align: left; vertical-align: top;}
hr {color: #dcc18c}
</style>
</head>
<body>
<div class="offscreen">
<div id="mozFont"></div>
<div id="test95a" style="width: min-content; hyphens: auto; border: 1px solid red">2020-1</div>
<div id="test95b" style="width: min-content; hyphens: auto; border: 1px solid red">2020-12020-1</div>
</div>
<div class="hidden">
<div><input type="time" min="14:00:00" max="12:00:00" value="15:00:00" id="test76"></div>
<span id="mozColor"></span>
</div>
<table>
<tr><td><h2>TorZillaPrint</h2></td></tr>
<tr><td class="blurb"><a class="return" href="../index.html">return to TZP index</a></td></tr>
</table>
<table id="tb3">
<col width="50%"><col width="50%">
<thead><tr><th colspan="2">
<div class="nav-title">engine
<div class="nav-up"><span class="c perf" id="perf"></span></div>
</div>
</th></tr></thead>
<tr><td colspan="2" class="intro">
<span class="no_color">A tiny sample of the myriad ways engines differ. This test is tweaked
for gecko [FF52+]: you want <span class="s9"><b> ✓ </b></span>'s. Anything different
<span class="bad"><b> ✖ </b></span> or blocked <span class="s4"><b> ✕ </b></span>
only makes you stand out. A single unspoofable property check can take as little as <span class="s3">0.01 ms</span>.
</span>
</td></tr>
<tr><td colspan="2"><hr></td></tr>
<tr><td colspan="2"><span class="no_color c mono spaces" id="results"></span></td></tr>
</table>
<br>
<script>
'use strict';
s3 = s3.trim()
s14 = s14.trim()
s99 = s99.trim()
sb = sb.trim()
sg = sg.trim()
let results = [],
itemnumbers = [],
data = {},
aPerf = [],
count = 0,
expected = 96,
gt0, // global timer
bBlock = false, // throw a test error
bNum = false // display numbering instead of perf
function fnTrim(str, len) {
str = str.replace(/(\r\n|\n|\r)/gm,"")
if (str.length > len) {str = str.slice(0,len-3) +"..."}
return str
}
function fnClean(str) {
if (str == "") {str = "empty string"
} else if (str === undefined) {str = zU
} else if (str == zU) {str = zUQ}
return str
}
function logPerf() {
if (aPerf.length) {
console.log("PERF LOG\n", aPerf)
}
}
function fnDisplay() {
// perf
let perfValue = ""
if (canPerf) {
perfValue = Math.round(performance.now() - gt0) +" ms"
let perfTop = perfValue
// remove the first 5 items: section headers + hr
if (aPerf.length) {
perfTop = "<span style='cursor: pointer;' onClick='logPerf()'>" + perfTop +"</span>"
aPerf.splice(0, 5)
}
dom.perf.innerHTML = perfTop
}
// data -> ordered results
const names = Object.keys(data).sort((a,b) => a-b)
for (const k of names) {results.push(k +"~~~"+ data[k])}
let display = [],
errcount = 0
let countTrue = 0, countFalse = 0, countBlock = 0, countNA = 0
// check no numbers duplicated
if (expected !== results.length) {
display.push(sb+ "ERROR:"+ sc + " duplicate numbers detected<br>")
}
// parse for pretty output
for (let i=0; i < results.length; i++) {
let pad = 35
let order = results[i].split("~~~")[0],
desc = results[i].split("~~~")[1].trim(),
result = results[i].split("~~~")[2],
match = results[i].split("~~~")[3],
perf = results[i].split("~~~")[4]
if (perf == undefined || perf == "" || perf == "undefined") {perf = " - "
} else if (perf !== "NaN") {
perf = Math.round(perf)
perf = perf.toString()
perf = perf.padStart(2) +" "
}
if (desc == "header") {
let note = ""
if (result == "errors") {
note = " [there are thousands of these]"
}
result = s14 + result.toUpperCase() + sc + note
display.push("<span>"+ result + "</span><br>")
} else if (desc == "hr") {
display.push("<br><hr>")
} else {
if (match == zErr) {match = yellow_block; countBlock++
} else if (match == "true") {match = green_tick; countTrue++
} else if (match == "false") {match = red_cross; countFalse++
} else {match = white_na; countNA++}
match += " "
if (desc == "error") {
pad = 3; errcount++; desc = errcount.toString()
}
desc = s3 + desc.padStart(pad) + sc
let sectionspace = ""
if (i+1 < results.length) {
let nextitem = results[i+1].split("~~~")[1].trim()
if (nextitem == "header") {sectionspace = "<br>"}
}
desc += s99 +" "+ (bNum ? order : perf) + sc
display.push(desc + match +" "+ result + sectionspace)
}
}
// summary
let countValid = countTrue + countFalse + countBlock // na tests ignored
let countFail = countFalse + countBlock
let percentPassed = Math.floor((countTrue/countValid)*100)
let isPass = percentPassed == 100 ? true : false
let percentFailed = Math.ceil((countFail/countValid)*100)
let summary = ""
if (isFFvalid) {
let needStr = "... who needs "+ s3+ (expected - 5) + " tests" + sc
+ " and "+ s3 + "several hundred metrics" + sc
+ (canPerf ? " in "+ s3 + perfValue + sc : "") + "?"
summary += s14 +"MINI TESTS "+ sc + needStr +"<br><br>"
+ "engine: "+ isEnginePretty.trim() +"<br><br>"
+ " gecko: "+ isFFpretty.trim() +"<br><br><hr><br>"
}
summary += s14 +"SUMMARY "+ sc
+"PASS: ".padStart(7) + countTrue + (isPass? sg : sb) +" ["+ percentPassed +"%]"+ sc
+"FAIL: ".padStart(7) + countFail + (isPass? sg : sb) +" ["+ percentFailed +"%]"+ sc
if (countNA > 0) {summary += "N/A: ".padStart(6) + countNA}
if (isFF) {
summary += s14+ "DEBUG".padStart(7) + sc +"RFP:".padStart(6) + (isRFP ? green_tick : red_cross)
let strVer = isVer
strVer += (isVer == isVerMax ? "+" : "")
strVer += (isVer == 52 ? " or lower" : "")
summary += "VER: ".padStart(6) + strVer
}
summary += " " + buildButton(3, "all", "all details")
// output
dom.results.innerHTML = summary + "<br><br>" + display.join("<br>")
}
function fnRecord(order, description, result, match, error, perf) {
if (error !== undefined && error !== "skip") {
let hash = mini(error)
if (hash !== "d8281b3c") { // assignment to undeclared variable bB
console.error(order, result, error)
hash = s3+ " ["+ hash +"]"+ sc
} else {
result = "test error thrown"; hash = ""
}
result += hash
}
aPerf.push([perf, order, description])
order = (order+"").padStart(3,"0")
data[order] = description +"~~~"+ result +"~~~"+ match + "~~~" + perf
count ++
itemnumbers.push(order +" "+ description)
if (count == expected) {
fnDisplay()
}
if (count > expected) {console.error(count, "expected count too low")}
}
function get_colorgamut(num, title) {
// added in FF110+ 1422237
let q = "(color-gamut: ", res = "undefined", bolC = false
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
if (window.matchMedia(q +"srgb)").matches) {res = "srgb"}
if (window.matchMedia(q +"p3)").matches) {res = "p3"}
if (window.matchMedia(q +"rec2020)").matches) {res = "rec2020"}
let bool = res == "undefined"
let perf = canPerf ? performance.now() - t0 : ""
if (isVer > 109) {
bool = zNA
res = zNA +": FF109 or lower"
}
fnRecord(num, title, res, bool, "skip", perf)
} catch(e) {
fnRecord(num, title, e.name, zErr, e.message)
}
}
function get_dates(num) {
// 1274354: meta
// 1557650
let strA = "[5 digit year] new Date"
try {
let t0A; if (canPerf) {t0A = performance.now()}
if (bBlock) {bB = 1}
let resA = new Date("19999-11-11")
let bolA = resA == "Invalid Date" ? true : false
if (!bolA) {resA = fnTrim(resA.toString(), 40)}
let perfA = canPerf ? performance.now() - t0A : ""
fnRecord(num, strA, resA, bolA, "skip", perfA)
} catch(e) {
fnRecord(num, strA, e.name, zErr, e.message)
}
// 1515318
let strB = "[hyphen] new Date"
try {
let t0B; if (canPerf) {t0B = performance.now()}
if (bBlock) {bB = 1}
let resB = new Date("31-Mar-2011").getFullYear()
// FF: 63 and lower = NaN, 64+ = -2011
let bolB = false
if (resB == -2011) {bolB = true
} else if (isVer < 64 && isNaN(resB)) {bolB = true}
let perfB = canPerf ? performance.now() - t0B : ""
fnRecord(num+1, strB, resB, bolB, "skip", perfB)
} catch(e) {
fnRecord(num+1, strB, e.name, zErr, e.message)
}
// 1439800
let strC = "[string] new Data"
try {
let t0C; if (canPerf) {t0C = performance.now()}
if (bBlock) {bB = 1}
let resC = new Date("11-Nov-11")
let bolC = resC.toString() == "Invalid Date" ? true : false
if (!bolC) {resC = fnTrim(resC.toString(), 40)}
let perfC = canPerf ? performance.now() - t0C : ""
fnRecord(num+2, strC, resC, bolC, "skip", perfC)
} catch(e) {
fnRecord(num+2, strC, e.name, zErr, e.message)
}
// 1599375
let strD = "[+0000 UTC] Date.parse"
try {
let t0D; if (canPerf) {t0D = performance.now()}
if (bBlock) {bB = 1}
let resD = Date.parse("2019-11-26 07:39:58.286157072 +0000 UTC")
let bolD = isNaN(resD) ? true : false
let perfD = canPerf ? performance.now() - t0D : ""
fnRecord(num+3, strD, resD, bolD, "skip", perfD)
} catch(e) {
fnRecord(num+3, strD, e.name, zErr, e.message)
}
// 1730155
let strE = "[localized] Date.parse"
try {
let t0E; if (canPerf) {t0E = performance.now()}
if (bBlock) {bB = 1}
let resE = Date.parse("Mercredi 8 Septembre 2021")
let bolE = isNaN(resE) ? true : false
let perfE = canPerf ? performance.now() - t0E : ""
fnRecord(num+4, strE, resE, bolE, "skip", perfE)
} catch(e) {
fnRecord(num+4, strE, e.name, zErr, e.message)
}
// 1783731
let strF = "[subtraction] Date.parse"
try {
let t0F; if (canPerf) {t0F = performance.now()}
if (bBlock) {bB = 1}
let resF = Date.parse('2022-08-08') - Date.parse('2022-08-8')
let bolF = resF == 0
let perfF = canPerf ? performance.now() - t0F : ""
fnRecord(num+6, strF, resF, bolF, "skip", perfF)
} catch(e) {
fnRecord(num+6, strF, e.name, zErr, e.message)
}
}
function get_errors(num) {
let tests = [
["var a = {}; a.b = a; JSON.stringify(a)", "TypeError: cyclic object value"],
["alert('A)","SyntaxError: '' string literal contains an unescaped line break"],
["let a = 1_00_;","SyntaxError: underscore can appear only between digits, not after t...", // FF72+
"SyntaxError: identifier starts immediately after numeric literal", // FF60-69
"SyntaxError: missing digit after '_' numeric separator"], // FF70-71
["const foo;foo.bar","SyntaxError: missing = in const declaration"],
["null.bar","TypeError: can't access property \"bar\" of null","TypeError: null has no properties"],
["(1).toString(1000)","RangeError: radix must be an integer at least 2 and no greater than 36"],
["var x = new Array(-1)","RangeError: invalid array length"],
["[...undefined].length","TypeError: can't access property Symbol.iterator of undefined","TypeError: undefined has no properties"],
["const tzp=1; const tzp=2;","SyntaxError: redeclaration of const tzp"],
["const foo;foo.bar","SyntaxError: missing = in const declaration"],
["var x = @","SyntaxError: illegal character U+0040","SyntaxError: illegal character"],
]
tests.forEach(function(array) {
let t0; if (canPerf) {t0 = performance.now()}
try {
newFn(array[0])
} catch(e) {
let bool = false
let str = fnTrim(e.name +": "+ e.message, 70)
if (isVer < 60 && array[0] == "alert('A)") {
if (str == "SyntaxError: unterminated string literal") {bool = true}
} else {
if (str == array[1] || str == array[2] || str == array[3]) {bool = true}
}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, "error", str, bool, "skip", perf)
num++
}
})
}
function get_eval_length(num, title) {
let bool = false
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
let test = eval.toString().length
if (test == 37) {bool = true}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, test, bool, "skip", perf)
} catch(e) {
fnRecord(num, title, e.name, zErr, e.message)
}
}
function get_iframe_props(num1, num2, title) {
let t0; if (canPerf) {t0 = performance.now()}
// just a small sample
let listE = ['dump','fullScreen','getDefaultComputedStyle','mozInnerScreenX',
'mozInnerScreenY','netscape','onmozfullscreenchange','onmozfullscreenerror']
let listU = ['BatteryManager','HID','Keyboard','Lock','Serial',
'USB','WakeLock','WebKitMutationObserver','XRAnchor','chrome','webkitCancelAnimationFrame',
'webkitMediaStream','webkitRTCPeerConnection','webkitRequestAnimationFrame',
'webkitRequestFileSystem','webkitResolveLocalFileSystemURL','webkitStorageInfo']
// FYI: don't use MIDIAccess: FF60+ behind dom.webmidi.enabled... 1752906: FF99+ default enabled
if (isVer > 92) {
// FF93+ "dom.weblocks.enabled"
// 1739233: FF96+ Lock
listU = listU.filter(x => !["Lock"].includes(x))
}
try {
if (bBlock) {bB = 1}
// create & append iframe
let id = "iframe-window-version"
let el = document.createElement("iframe")
el.setAttribute("id", id)
el.setAttribute('style', 'display: none')
document.body.appendChild(el)
// get props
let iframe = document.getElementById(id)
let contentWindow = iframe.contentWindow
let props = Object.getOwnPropertyNames(contentWindow)
// remove iframe
iframe.parentNode.removeChild(iframe)
props.sort()
// expected
let arrayE = props.filter(x => listE.includes(x))
let resE = "", boolE = false
if (arrayE.length) {
sDetail["expected_"+ title] = arrayE
resE = mini_sha1(arrayE.join()) + buildButton(3, "expected_"+ title, arrayE.length)
if (arrayE.length > 4) {boolE = true}
} else {
resE = "none"
}
// unexpected
let arrayU = props.filter(x => listU.includes(x))
// ignore BatteryManager FF72+
if (isFF && isVer < 72) {arrayU = arrayU.filter(x => !["BatteryManager"].includes(x))}
let resU = "", boolU = false
if (arrayU.length) {
sDetail["unexpected_"+ title] = arrayU
resU = mini_sha1(arrayU.join()) + buildButton(3, "unexpected_"+ title, arrayU.length)
} else {
resU = "none"
boolU = true
}
let perf = canPerf ? performance.now() - t0 : ""
// record
fnRecord(num1, title, resE, boolE, "skip", perf)
fnRecord(num2, title, resU, boolU, "skip", perf)
} catch(e) {
fnRecord(num1, title, e.name, zErr, e.message)
fnRecord(num2, title, e.name, zErr, e.message)
}
}
function get_installtrigger(num) {
// FF100+: 1754441 behind prefs slated for deprecation
let strA = "[typeof] InstallTrigger", boolA = false
try {
let t0A; if (canPerf) {t0A = performance.now()}
if (bBlock) {bB = 1}
let resA = typeof InstallTrigger
if (resA == "object") {boolA = true}
let perfA = canPerf ? performance.now() - t0A : ""
if (isVer > 99 && !boolA) {
fnRecord(num, strA, zNA +": FF99 or lower" + s3 +" ["+ resA +"]"+ sc, zNA, "skip", perfA)
} else {
fnRecord(num, strA, resA, boolA, "skip", perfA)
}
} catch(e) {
fnRecord(num, strA, e.name, zErr, e.message)
}
let strB = "[window] InstallTrigger", boolB = false
try {
let t0B; if (canPerf) {t0B = performance.now()}
if (bBlock) {bB = 1}
let resB = "InstallTrigger" in window
let perfB = canPerf ? performance.now() - t0B : ""
if (isVer > 99 && !resB) {
fnRecord(num+1, strB, zNA +": FF99 or lower" + s3 +" ["+ resB +"]"+ sc, zNA, "skip", perfB)
} else {
fnRecord(num+1, strB, resB, resB, "skip", perfB)
}
} catch(e) {
fnRecord(num+1, strB, e.name, zErr, e.message)
}
let strC = "[typeof] InstallTriggerImpl", boolC = false
// FF60 or lower
if (isFF && isVer < 61) {
fnRecord(num+2, strC, zNA +": FF61+ required", zNA)
} else {
try {
let t0C; if (canPerf) {t0C = performance.now()}
if (bBlock) {bB = 1}
let resC = typeof InstallTriggerImpl
if (resC == "function") {boolC = true}
let perfC = canPerf ? performance.now() - t0C : ""
if (isVer > 99 && !boolC) {
fnRecord(num+2, strC, zNA +": FF99 or lower" + s3 +" ["+ resC +"]"+ sc, zNA, "skip", perfC)
} else {
fnRecord(num+2, strC, resC, boolC, "skip", perfC)
}
} catch(e) {
fnRecord(num+2, strC, e.name, zErr, e.message)
}
}
}
function get_intl_canonical_locale(num, title) {
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
let list = ['bh','hye','no','tl','tw'], bool = false
let res = []
list.forEach(function(i) {
res.push(Intl.getCanonicalLocales(i))
})
let hash = res.length > 0 ? mini_sha1(res.join()) : "none"
if (hash == "49ce6431a6b656b0cdce7fc8bff36cbf60f90558") {bool = true // FF91+
} else if (hash == "ca3fd91866c1a46b8d08c4c1b406e3201fd7fcd7") {bool = true // FF70-90
} else if (hash == "68cbf0ea5d3d3a6bc14f0d574341397d818ba886") {bool = true // FF52-69
}
// FF60-69 : bh=bh, hye=hye, no=no, tl=tl, tw=tw
// FF70-90 : bh=bho, hye=hy, no=nb, tl=fil, tw=ak
// FF91+ : bh=bho, hye=hy, no=no, tl=fil, tw=ak // webkit now matches
// blink : bh=bh, hye=hy, no=no, tl=fil, tw=tw
// webkit : bh=bh, hye=hy, no=no, tl=tl, tw=tw
if (res.length > 0) {
if (res.join(", ").length < 48) {
hash = res.join(", ")
} else {
sDetail["specific_"+ title] = res
hash += buildButton(3, "specific_"+ title, "details")
}
}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, hash, bool, "skip", perf)
} catch(e) {
fnRecord(num, title, e.name, zErr, e.message)
}
}
function get_intl_supportedlocales(num) {
// DTF, NF, RTF, LF, DN
/* NOTES
// FF52+ common items (130) not in blink103 common (59) = 71 items
// FF52: DTF + NF / FF65: RTF / FF78: LF / FF86: DN
// remove if present: bh bho, hye hy, no nb, tl fil, tw ak [aliases/maps]
geckoNotBlink = [
// mix it up per test
'eo','gl','ka','mt','om', // used in C
// from collator list below that is in common with this list
// ^ note mt only added if .compare works
'ki','lu','qu','rn','rw', // used in PR (limited choices)
'as','fo','ln','ne','to', // used in DTF
'br','eu','ii','ks','ps', // used in DN
'ee','gd','kk','lo','yi', // used in LF
'bo','ha','lb','my','sq', // used in NF
'cy','km','mg','os','sn', // used in RTF
// 35 spare
'ast','be','bm','ce','ckb','dsb','dz','ff','fur','fy',
'ga','gv','haw','hsb','ig','is','kab','kl','kok','kw',
'ky','lg','mk','mn','nd','nn','or','rm','se','sg','si',
'so','ti','ug','yo','zu'
]
// webkit items not in FF105
// note: older webkit only: make sure one in each: 'co','cv','oc','nso','tig'
WKnotGecko = [
'ba','co','dv','gn','io','iu','nr','nso','nv','ny','oc','ss','st','tig','tn','ts','ve','wa'
// 'cv' // cv is supported in FF109+
]
*/
// COLLATOR
/*
geckoNotBlink = [
'as','az','be','bo','bs','cy','dsb','dz','ee','eo','fo','ga','gl',
'ha','haw','hsb','ig','is','ka','kk','kl','km','kok','ky','lb',
'ln','lo','mk','mn','mt','my','ne','nn','om','or','pa','ps','se',
'si','sq','to','ug','uz','yi','yo','zu'
]
webkit = same as gecko 91+
old_list = [
'az','cy','dsb','ee','eo','gl','ha','haw','hsb','ig',
'ka','kk','ln','lo','mt','om','pa','se','sq','to',
]
*/
// PR
/*
FF52+ geckoNotBlink = ['ki','kok','lu','qu','rn','rw']
FF105- blinkNotGecko = ['an','dv','io','iu','lij','nr','nso','ny','ss','st','tig','tn','ts','ve','vo','wa']
FF105- webkitNotGecko = ['ba','co','cv','dv','gn','io','iu','nr','nso','nv','ny','oc','ss','st','tig','tn','ts','ve','wa']
therefore
blinkOnly = ['an','lij','vo']
webkitOnly = ['ba',co','cv',''gn','ny','oc']
let list = [
'ki','lu','qu','rn','rw', // gecko: pick 5
'ba','co','cv','gn','oc', // webkit only: pick 4
'an','lij','vo', // chrome only: not needed
]
*/
// MAC supportedlocales == FF91+
// but .compare for mt is not hooked up (the other locales seem to be working)
let aCollator = []
let control = (["c","C"]).sort(Intl.Collator("mt").compare)
if (control.join("") == "Cc") {aCollator = ['mt']} // so while Mac !== Cc then only FF will test and report mt
let aList = [
["f7e01839", 50, ['eo','gl','ka','om'], aCollator, "Collator"],
["2d45bfd6", 50, ['as','fo','ln','ne','to'], ['co','nr','st','tig'], "DateTimeFormat"],
["502f87c2", 86, ['br','eu','ii','ks','ps'], ['gn','iu','nv','tn' ], "DisplayNames"],
["a2d97917", 78, ['ee','gd','kk','lo','yi'], ['ba','io','oc','ve' ], "ListFormat"],
["3709a703", 50, ['bo','ha','lb','my','sq'], ['dv','ny','oc','ts' ], "NumberFormat"],
["73b49209", 58, ['ki','lu','qu','rn','rw'], ['ba','co','gn','oc' ], "PluralRules"],
["fc7fa0cc", 65, ['cy','km','mg','os','sn'], ['gn','nso','ss','wa'], "RelativeTimeFormat"],
]
num = (num - 5)
aList.forEach(function(array) {
num += 5
let t0; if (canPerf) {t0 = performance.now()}
let expected = array[0],
errVer = array[1],
list = array[2].concat(array[3]).sort(),
type = array[4],
res = []
let title = "Intl."+ type
try {
if (bBlock) {bB = 1}
if (type == "Collator") { res = Intl.Collator.supportedLocalesOf(list)
} else if (type == "DateTimeFormat") { res = Intl.DateTimeFormat.supportedLocalesOf(list)
} else if (type == "DisplayNames") { res = Intl.DisplayNames.supportedLocalesOf(list)
} else if (type == "ListFormat") { res = Intl.ListFormat.supportedLocalesOf(list)
} else if (type == "NumberFormat") { res = Intl.NumberFormat.supportedLocalesOf(list)
} else if (type == "PluralRules") { res = Intl.PluralRules.supportedLocalesOf(list)
} else if (type == "RelativeTimeFormat") { res = Intl.RelativeTimeFormat.supportedLocalesOf(list)
}
let hash = res.length > 0 ? mini(res) : "none"
//console.log(title, hash)
let bool = hash == expected
if (res.length > 0) {
if (res.join(", ").length < 48) {
hash = res.join(", ")
} else {
sDetail["specific_"+ title] = res
hash += buildButton(3, "specific_"+ title, res.length)
}
}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, hash, bool, "skip", perf)
} catch(e) {
if (isFF) {
if (isVer >= errVer) {
fnRecord(num, title, e.name, zErr, e.message)
} else {
let msg = e.message
msg = msg.replace("can't access property \"supportedLocalesOf\", ", "") // trim *error_fix
if (e.name == "TypeError" && msg == "Intl." + type +" is undefined") {
fnRecord(num, title, zNA +": FF" + errVer +"+ required", zNA)
} else {
fnRecord(num, title, e.name, zErr, e.message)
}
}
} else {
fnRecord(num, title, zNA +": not supported", zNA)
}
}
})
}
function get_intl_supportedvaluesof(num, title) {
// just use timeZone, the others are either identical or changed too much
/*
gecko only
Africa/Asmara - vs Africa/Asmera
Africa/Timbuktu
America/Argentina/Buenos_Aires - vs America/Buenos_Aires
America/Argentina/Catamarca - vs America/Catamarca
America/Argentina/ComodRivadavia
America/Argentina/Cordoba - vs America/Cordoba
America/Argentina/Jujuy
America/Argentina/Mendoza
America/Atikokan
America/Ensenada
America/Indiana/Indianapolis - vs America/Indianapolis
America/Kentucky/Louisville - vs America/Louisville
America/Nuuk
America/Rosario
Asia/Chongqing
Asia/Harbin
Asia/Ho_Chi_Minh - vs Asia/Saigon
Asia/Kashgar
Asia/Kathmandu - vs Asia/Katmandu
Asia/Kolkata - vs Asia/Calcutta
Asia/Tel_Aviv
Asia/Yangon - vs Asia/Rangoon
Atlantic/Faroe - vs Atlantic/Faeroe
Atlantic/Jan_Mayen
CET
CST6CDT
EET
EST
EST5EDT
Etc/GMT+1
Etc/GMT+10
Etc/GMT+11
Etc/GMT+12
Etc/GMT+2
Etc/GMT+3
Etc/GMT+4
Etc/GMT+5
Etc/GMT+6
Etc/GMT+7
Etc/GMT+8
Etc/GMT+9
Etc/GMT-1
Etc/GMT-10
Etc/GMT-11
Etc/GMT-12
Etc/GMT-13
Etc/GMT-14
Etc/GMT-2
Etc/GMT-3
Etc/GMT-4
Etc/GMT-5
Etc/GMT-6
Etc/GMT-7
Etc/GMT-8
Etc/GMT-9
Europe/Belfast
Europe/Kyiv - vs Europe/Kiev (changed in gecko FF109)
Europe/Tiraspol
Factory
HST
MET
MST
MST7MDT
PST8PDT
Pacific/Chuuk - vs Pacific/Truk
Pacific/Kanton (added at some stage after 93)
Pacific/Pohnpei - vs Pacific/Ponape
WET
gecko does not have
America/Godthab
America/Jujuy
America/Kralendijk
America/Lower_Princes
America/Marigot
America/Mendoza
America/Santa_Isabel
America/St_Barthelemy
Arctic/Longyearbyen
Europe/Bratislava
Europe/Busingen
Europe/Mariehamn
Europe/Podgorica
Europe/San_Marino
Europe/Vatican
*/
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
let aSupported = Intl.supportedValuesOf("timeZone")
let aExpected = ['CET','EET','EST','HST','MET','MST','WET',] // b7a58624
let res = aSupported.filter(x => aExpected.includes(x))
let hash = res.length > 0 ? mini(res) : "none"
let bool = hash == "b7a58624"
if (res.length > 0) {
if (res.join(", ").length < 48) {
hash = res.join(", ")
} else {
sDetail["specific_"+ title] = res
hash += buildButton(3, "specific_"+ title, res.length)
}
}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, hash, bool, "skip", perf)
} catch(e) {
// FF92- not supported
if (isVer < 93) {
fnRecord(num, title, zNA +": not supported", zNA)
} else {
fnRecord(num, title, e.name, zErr, e.message)
}
}
}
function get_js_client_hints(num, title) {
// testing: https://web.dev/user-agent-client-hints/
// https://user-agent-client-hints.glitch.me/javascript.html
// TypeError can't access property "X", navigator.X is undefined
function output() {
let perf = canPerf ? performance.now() - t0 : ""
if (res.length > 0) {
res.sort()
sDetail["unexpected_"+ title] = res
let hash = mini_sha1(res.join()) + buildButton(3, "unexpected_"+ title , res.length)
fnRecord(num, title, hash, false, "skip", perf)
} else {
fnRecord(num, title, "none", true, "skip", perf)
}
}
let res = []
let t0; if (canPerf) {t0 = performance.now()}
try {
let resB = navigator.userAgentData.brands
resB.forEach(function(object) {
let valueB = fnClean(object.version)
res.push("brands: "+ object.brand +": "+ valueB)
})
} catch(e) {}
try {
res.push("mobile: " + navigator.userAgentData.mobile)
} catch(e) {}
try {
res.push("platform: " + navigator.userAgentData.platform)
} catch(e) {}
try {
navigator
.userAgentData.getHighEntropyValues(
["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion"]
).then(ua => {
const names = Object.keys(ua)
for (const k of names) {
let valueU = fnClean(ua[k])
res.push("high entropy: "+ k +": "+ valueU)
}
output()
})
} catch(e) {
output()
}
}
function get_last_prototype_keys(num1, title) {
// HTMLAnchorElement
let title1 = title +" HTMLAnchorElement"
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
Object.keys(HTMLAnchorElement.prototype)
let props1 = Object.getOwnPropertyNames(HTMLAnchorElement.prototype) // includes the constructor
let res1 = props1.slice(-3).join(", ")
// search, hash, constructor
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num1, title1, res1, res1 == "search, hash, constructor", "skip", perf)
} catch(e) {
fnRecord(num1, title1, e.name, zErr, e.message)
}
// HTMLLinkElement
let title2 = title +" HTMLLinkElement"
let num2 = num1 + 1
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
Object.keys(HTMLLinkElement.prototype)
let props2 = Object.getOwnPropertyNames(HTMLLinkElement.prototype) // includes the constructor
let res2 = props2.slice(-3).join(", ")
let bool2 = res2 == "as, sheet, constructor"
// 52-55: integrity, sheet, constructor
if (isVer <= 56 && res2 == "integrity, sheet, constructor") {bool2 = true}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num2, title2, res2, bool2, "skip", perf)
} catch(e) {
fnRecord(num2, title2, e.name, zErr, e.message)
}
}
function get_locale_compare(num, title) {
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
let list = [
["cy","n","ng"],
["gl","\u00F1","ng"],
["ha","ts","tt"],
["hsb","\u0107","\u0109"],
["ig","c","ch"],
["ka","\u0107","\u10D0"],
["mt","c","C"], // MAC: Intl.Collator supportedlocale but does not collate it
["om","ch","\u00ED"],
["sq","\u00EB","ez"],
["to","\u00ED","\u00EE"],
]
let res = []
list.forEach(function(item) {
res.push(item[1].localeCompare(item[2], item[0]))
})
let hash = res.length > 0 ? mini_sha1(res.join()) : "none"
let bool = hash == "d4ed607dd4781454263f3c3fc6d92b55b2980ad2"
if (res.length > 0) {
hash = res.join(", ")
}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, hash, bool, "skip", perf)
} catch(e) {
fnRecord(num, title, e.name, zErr, e.message)
}
}
function get_math(num, title) {
// polyfill
function cbrt(x) {
try {
let y = Math.pow(Math.abs(x), 1 / 3)
return x < 0 ? -y : y
} catch(e) {
return "error"
}
}
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
let res = []
for(let i=0; i < 6; i++) {
try {
let fnResult = "unknown"
if (i == 0) {fnResult = cbrt(Math.PI) // polyfill
} else if (i == 1) {fnResult = Math.log10(7*Math.LOG10E)
} else if (i == 2) {fnResult = Math.log10(2*Math.SQRT1_2)
} else if (i == 3) {fnResult = Math.acos(0.123)
} else if (i == 4) {fnResult = Math.acosh(Math.SQRT2)
} else if (i == 5) {fnResult = Math.atan(2)
}
res.push(fnResult)
} catch(e) {
res.push("error")
}
}
// I have to use sha1 due to legacy data
let hash = sha1(res.join()).substring(0,20)
let engine = "unkown"
if (hash == "ede9ca53efbb1902cc21") {engine = "blink"
} else if (hash == "05513f36d87dd78af60a") {engine = "webkit"
} else if (hash == "38172d9426d77af71baa") {engine = "edgeHTML"
} else if (hash == "36f067c652c8cfd90725") {engine = "trident"
} else if (hash == "225f4a612fdca4065043") {engine = "gecko"
} else if (hash == "cb89002a8d6fabf859f6") {engine = "gecko"
}
let bool = engine == "gecko" ? true : false
// now redo as mini_sha1
sDetail["expected_"+ title] = res
hash = mini_sha1(res.join()) + buildButton(3, "expected_"+ title, engine)
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, hash, bool, "skip", perf)
} catch(e) {
fnRecord(num, title, e.name, zErr, e.message)
}
}
function get_media_constraints(num, title) {
try {
let t0; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
let noiseFF = [
'groupId', // FF70+
'channelCount', // FF56+
'autoGainControl','noiseSuppression', // FF55+
'mozAutoGainControl','mozNoiseSuppression', // FF54-
]
let data = navigator.mediaDevices.getSupportedConstraints()
let res = Object.keys(data)
res = res.filter(x => !noiseFF.includes(x))
res.sort()
let hash = res.length > 0 ? mini_sha1(res.join()) : "none"
let bool = hash == "a4dfaab7d54b96d9a4ed91d06a20b77fa0df2a45" // FF52+
if (res.length > 0) {
sDetail["expected_"+ title] = res
hash += buildButton(3, "expected_"+ title, res.length)
}
let perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, hash, bool, "skip", perf)
} catch(e) {
// e.g. TB disables mediaDevices
let error = mini(e.name +": "+ e.message), isNA = false
if (error == "f2244861") {
// TypeError: can't access property "getSupportedConstraints", navigator.mediaDevices is undefined
isNA = true
} else if (error == "9fc627cf") {
// TypeError: navigator.mediaDevices is undefined
isNA = true
}
if (isNA) {
fnRecord(num, title, zNA +": disabled", zNA)
} else {
fnRecord(num, title, e.name, zErr, e.message)
}
}
}
function get_mimetypes(num, title) {
try {
let t0, perf; if (canPerf) {t0 = performance.now()}
if (bBlock) {bB = 1}
if ("mimeTypes" in navigator) {
let res = [], bool = false
let m = navigator.mimeTypes
if (m.length == 0) {
perf = canPerf ? performance.now() - t0 : ""
fnRecord(num, title, "none", true, "skip", perf)
} else {
for (let i=0; i < m.length; i++) {
res.push( m[i].type + (m[i].description == "" ? ": * " : ": "+ m[i].type)
+ (m[i].suffixes == "" ? ": *" : ": "+ m[i].suffixes) )
}
res.sort()
// FF84 or lower allow just Flash
if (isFF && isVer < 85 && res.length == 2) {
let mime1 = res[0].split(":")[0]
let mime2 = res[1].split(":")[0]
if (mime1 == "application/x-futuresplash" && mime2 == "application/x-shockwave-flash") {
bool = true
}
}
let hash = mini_sha1(res.join())
if (isVer > 98 || !isFF) { // allow non-FF to have the same
// FF99+: controlled by pdfjs.disabled
// 1720353: hardcoded mimeTypes
if (hash == "5b8b5b83ff5790df763d417ec6e2adbbf0570c47") {
bool = true
}
}
sDetail["expected_"+ title] = res