TZP: trap resource:// blocking
I make sure several global vars are set before we start fingerprinting: such as isFF, isOS, isTB, isEngine, prototype lies. Unfortunately, isTB never resolves with cydec (at least in total mode), and thus the promise never happens and we have no output: section re-runs work sweet š
note: isTB is initially an empty string = āā, and I set it once to a boolean. I do not have any instances of (!isFF)
. TB shouldnāt have any extensions that cause the script to break, so Iām happy to trap this and change isTB into false based on assumptions
note: this is the only resource://
that is set via code. The only other one is an image set via css: and that function works on the same assumption: if itās there = TB, if it isnāt = not TB.
here is the code
function get_isTB() {
return new Promise(resolve => {
if (isFF && isTB === "") {
try {
let t0 = performance.now()
console.debug("a")
let css = document.createElement("link")
console.debug("b")
css.href = "resource://torbutton-assets/aboutTor.css"
css.type = "text/css"
css.rel = "stylesheet"
console.debug("c")
document.head.appendChild(css)
console.debug("d")
css.onload = function() {
isTB = true
debug_page("TB"," resource:// = aboutTor.css")
if (logPerf) {debug_perf("[yes] isTB [immutables]",t0)}
return resolve("done")
}
css.onerror = function() {
isTB = false
if (logPerf) {debug_perf("[no] isTB [immutables]",t0)}
return resolve("done")
}
document.head.removeChild(css)
} catch(e) {
console.error("get_isTB", e.name, e.message)
return resolve("error")
}
} else {
return resolve("done")
}
})
}
everything debugs - a,b,c,d, no error is trapped. So I need a timeout
These three run a single Promise.all
-> prototypeLies promise -> kick it all off
Firefox
perf detail: global
isOS [immutables]: 0 ms | 0 ms
isEngine [immutables]: 0 ms | 1 ms
[no] isTB [immutables]: 1 ms | 2 ms
TB with RFP disabled so I can get some perf
perf detail: global
isOS [immutables]: 1 ms | 1 ms
isEngine [immutables]: 1 ms | 2 ms
[yes] isTB [immutables]: 17 ms | 19 ms
So Iām happy to add a timeout, but not sure of the syntax to add that. That is e.g. after 100ms set isTB true and resolve as rejected or something - help appreciated
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 18 (11 by maintainers)
OK, Iāll rerun prototype for section reruns as well š
I notice the delay (I use F5) on file:// ā¦ have to close and restart nightly after a dozen or of them. Not noticed it on http ā¦ so will be interesting when I upload all my changes: so much stuff here
I changed up line-height and scrollbar info by only reporting a narrower range of known zoom values: since FF recently added 400 and 500% - that and I think a lot of values on Linux will change with native theming disabled. In order to test it I made it update-able in real time: that was fun.
closing: have sorted out timing out in promises, and overall hardened all the
isThings
used throughout my code: promising them once on each pageload@sereneblue FYI: on Cydec
That cydec really is a piece of work: right now Iām returning
[object Object]
in navigator.connection because of itās hijinksCorrect. Hereās an example of Privacy Possom starting with
none
on page load and then10 lies
on re-run.Yes, thatās it. The timeout resolve only resolves the promise if the promise is still pending.
If you like, you can reduce some of the nested bracket layers by checking if
!(isFF && isTB === "")
, resolve early if true, and then the else block can be omitted since afalse
condition will execute everything else. It reads fine either way though.ā¦And, an arrow function can remove the nested function brackets (minimal nesting).
you mean like this? I think I get it now, the resolve can only be resolved once, then the promise is over, including the timeout?