Skip to content

Commit

Permalink
tidy (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorin-Oakenpants authored Dec 7, 2024
1 parent d40fa34 commit 0bd10c4
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 150 deletions.
9 changes: 4 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@
<td>domrect spoof detection</td></tr>
<tr><td colspan="2"><a class="blue" href="tests/elementkeys.html"> element keys</a></td>
<td>test: element properties</td></tr>
<tr><td colspan="2"><a class="blue" href="tests/elementfont.html">element font</a></td>
<td>test: element sizes (font)</td></tr>
<tr><td colspan="2"><a class="blue" href="tests/elementforms.html"> element forms</a></td>
<td>test: element sizes (forms)</td></tr>
<tr><td colspan="2"><a class="blue" href="tests/elements.html"> element sizes</a></td>
<td>test: element sizes (non forms)</td></tr>
<tr><td colspan="2"><a class="blue" href="tests/elementforms.html"> element widgets</a></td>
<td>test: element sizes (forms)</td></tr>
<tr><td colspan="2"><a class="blue" href="tests/lineheight.html">lineheight</a></td>
<td>test: generic test to see what alters lineheight</td></tr>
<tr><td colspan="3"></td></tr>

<tr><td colspan="3" class="intro"><a name="misc"></a><span class="s18">MISC</span></td></tr>
Expand All @@ -160,7 +160,6 @@
<td>test: generic test page</td></tr>
<tr><td colspan="2"><a id="test" class="blue" href="tests/windownamea.html">window.name</a></td>
<td>check window.name clearance per eTLD+1</td></tr>

</table>
<br>

Expand Down
17 changes: 9 additions & 8 deletions js/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,26 +444,27 @@ function get_isVer(METRIC) {
return

function cascade() {
let test
try {
// old-timey check: avoid false postives: must be 115 or higher
if (!CanvasRenderingContext2D.prototype.hasOwnProperty('letterSpacing')) return 114 // 1778909

// now cascade
try {
if ('$1.00' == (1).toLocaleString('en-CA', {style: 'currency', currencyDisplay: 'narrowSymbol', currency: 'USD'})) return 134 // 1927706
} catch(e){}
try {
// this works on my windows, android, mac but seems to fail in linux (debain)
let parser = (new DOMParser).parseFromString("<select><option name=''></option></select>", 'text/html')
if (null === parser.body.firstChild.namedItem('')) return 133 // 1837773
} catch(e) {}
try {
const re = new RegExp('(?:)', 'gv');
let test132 = RegExp.prototype[Symbol.matchAll].call(re, '𠮷')
for (let i=0; i < 3; i++) {if (true == test132.next().done) return 132} // 1899413
test = RegExp.prototype[Symbol.matchAll].call(re, '𠮷')
for (let i=0; i < 3; i++) {if (true == test.next().done) return 132} // 1899413
} catch(e) {}
try {
let test131 = new Intl.DateTimeFormat('zh', {calendar: 'chinese', dateStyle: 'medium'}).format(new Date(2033, 9, 1))
if ('2033' == test131.slice(0,4)) return 131 // 1900196
test = new Intl.DateTimeFormat('zh', {calendar: 'chinese', dateStyle: 'medium'}).format(new Date(2033, 9, 1))
if ('2033' == test.slice(0,4)) return 131 // 1900196
} catch(e) {}
try {new RegExp('[\\00]','u')} catch(e) {if (e+'' == 'SyntaxError: invalid decimal escape in regular expression') return 130} // 1907236
if (CSS2Properties.prototype.hasOwnProperty('WebkitFontFeatureSettings')) return 129 // 1595620
Expand All @@ -478,7 +479,7 @@ function get_isVer(METRIC) {
if (!CSS2Properties.prototype.hasOwnProperty('MozUserFocus')) {
try {
el.style.zIndex = 'calc(1 / max(-0, 0))'
let test = getComputedStyle(el).zIndex
test = getComputedStyle(el).zIndex
el.style.zIndex = 'auto'
if (test > 0) {return 124} // 1867569
} catch(e) {}
Expand All @@ -487,7 +488,7 @@ function get_isVer(METRIC) {
if ('function' === typeof Promise.withResolvers) {
try {
el.style.zIndex = 'calc(1 / abs(-0))'
let test = getComputedStyle(el).zIndex
test = getComputedStyle(el).zIndex
el.style.zIndex = 'auto'
if (test > 0) {return 122} // 1867558
} catch(e) {}
Expand Down Expand Up @@ -720,7 +721,7 @@ function json_stringify(passedObj, options = {}) {
indent === ''
? Infinity
: options.maxLength === undefined
? 80
? 88
: options.maxLength;
let { replacer } = options;

Expand Down
26 changes: 15 additions & 11 deletions js/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,23 @@ let zErrLog = '', // log error in addBoth
zErrShort = '' // log error in addBoth but display zErr in addDisplay

// grab as soon as possible
let isInitial = {}
let isInitial = {height: {}, width: {}}
function get_scr_initial() {
// we don't need any error entropy: we get these properties again later
let x, aList = ['innerHeight', 'innerWidth', 'outerHeight', 'outerWidth']
aList.forEach(function(k){
try {
x = window[k]
if ('number' !== typeof x || Number.isNaN(x)) {x = zErr}
} catch(e) {
x = zErr
}
isInitial[k] = x
})
let x, oList = {height: ['innerHeight','outerHeight'], width: ['innerWidth','outerWidth']}
for (const axis of Object.keys(oList)) {
let aList = oList[axis]
aList.forEach(function(k){
try {
x = window[k]
if ('number' !== typeof x || Number.isNaN(x)) {x = zErr}
} catch(e) {
x = zErr
}
if (k.includes('inner')) {k = 'inner'} else {k = 'outer'}
isInitial[axis][k] = x
})
}
}
get_scr_initial()
let avh = 'undefined' // android
Expand Down
18 changes: 12 additions & 6 deletions js/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,12 @@ function get_language_locale() {
} catch(e) {
oRes[m] = e+''
log_error(4, METRIC, e)
oErr[m] = e+''
return zErr
}
}
// LOCALES
let METRIC = 'locale', value ='', res = [], oRes = {}
let METRIC = 'locale', value ='', res = [], oRes = {}, oErr = {}
metrics = [
'collator','datetimeformat','displaynames','durationformat','listformat',
'numberformat','pluralrules','relativetimeformat','segmenter',
Expand Down Expand Up @@ -480,11 +481,16 @@ function get_language_locale() {
}
if (isLanguageSmart && isTB) { // only notate TB/MB
notation = tb_red
let key = oData.language
// only green if TB supported
if (languagesSupported[key] !== undefined) {
let expected = languagesSupported[key][1] == undefined ? key : languagesSupported[key][1]
if (value === expected) {notation = tb_green}
let errHash = mini(oErr)
//61a9b098: { durationformat: "TypeError: Intl.DurationFormat is not a constructor" }
// we only expect 1 exact error for TB14
if ('61a9b098' == errHash) {
let key = oData.language
// only green if TB supported
if (languagesSupported[key] !== undefined) {
let expected = languagesSupported[key][1] == undefined ? key : languagesSupported[key][1]
if (value === expected) {notation = tb_green}
}
}
}
addDisplay(4, METRIC, value, btn, notation, isLies)
Expand Down
Loading

0 comments on commit 0bd10c4

Please sign in to comment.