fix ui: fix iframe node onload crash

This commit is contained in:
nick-delirium 2024-05-21 11:14:01 +02:00
parent 122ecfe72a
commit bc4947b486
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0
2 changed files with 12 additions and 6 deletions

View file

@ -1,5 +1,6 @@
import type Screen from '../../Screen/Screen';
import { replaceCSSPseudoclasses } from '../../messages/rewriter/rewriteMessage'
import logger from 'App/logger'
// Doesn't work with css files (hasOwnProperty returns false)
// TODO: recheck and remove if true
@ -38,14 +39,15 @@ export default class StylesManager {
|| this.skipCSSLinks.includes(value)
|| node.ownerDocument !== this.screen.document
) {
console.log('skipped', node, value, this.abortController.signal.aborted, this.skipCSSLinks.includes(value), node.ownerDocument !== this.screen.document)
logger.log('skipped', node, value, this.abortController.signal.aborted, this.skipCSSLinks.includes(value), node.ownerDocument !== this.screen.document)
resolve();
}
this.setLoading(true);
this.linkLoadingCount++;
const addSkipAndResolve = (e: any) => {
this.skipCSSLinks.push(value); // watch out
console.error('skip node', e)
logger.error('skip node', e)
resolve()
}
timeoutId = setTimeout(addSkipAndResolve, 4000);

View file

@ -241,19 +241,23 @@ export class VText extends VNode<Text> {
}
class PromiseQueue<T> {
constructor(private promise: Promise<T>) {}
onCatch?: (err?: any) => void
constructor(private promise: Promise<void | T>) {}
/**
* Call sequence is concerned.
*/
// Doing this with callbacks list instead might be more efficient (but more wordy). TODO: research
whenReady(cb: Callback<T>) {
this.promise = this.promise.then(vRoot => {
cb(vRoot)
cb(vRoot as T)
return vRoot
}).catch(e => {
this.onCatch?.(e)
})
}
catch(cb: Parameters<Promise<T>['catch']>[0]) {
this.promise.catch(cb)
catch(cb:(err?: any) => void) {
this.onCatch = cb
}
}