-
-
Notifications
You must be signed in to change notification settings - Fork 713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full text search doesn't work when scripts are blocked #2494
Comments
It seems that when JS is disabled, calling
(this breaks full-text search because the text extraction is wrapped in a setTimeout) |
Ok, since setTimeout doesn't work in preload script when JS disabled, I tried the below and used it in textExtractor's setTimeout usage. It resolved the issue for full text search when JS disabled in settings page. There are some more setTimeout usages in preload scripts...will need to investigate if those instances can also be replaced with this custom setTimeout In const customTimer = {}
customTimer.delay = ms => new Promise(resolve => {
const before = Date.now()
const stopAt = before + ms
while (Date.now() < stopAt) { };
resolve()
})
customTimer.setTimeout = async (fn, ms) => {
await customTimer.delay(ms)
fn()
} |
Wouldn't that block the rest of the preload (and potentially the whole page) while it's running? I think my preference would be to just run the text extraction immediately if we're in this state. I wonder if there are other things that are broken still though; I'm thinking that disabling JS execution but still running a preload script probably isn't intended to be supported by Chromium. |
I guess global setTimeout doesn't work because it seems to use webview's setTimeout which can't work as JS disabled inside webview. |
It looks like requestAnimationFrame works, so we could do something hacky like this:
There's also the node It seems like there's potentially more features of the preload broken also though, so I'm not convinced the text extraction will actually work correctly even if we do this. For example, if I try to reproduce this in electron-quick-start, my preload script actually doesn't run at all, until I open the devtools and reload, then it does. |
Also tried writing a custom timeout logic using window.requestIdleCallback, inside that preload script. It works but the timer won't be accurate, will be approximate. |
That's OK, the existing timeout is approximate anyways. |
1.33.0
Windows 10
Expected Behavior
Full text search to work when scripts are blocked via settings page 'block scripts'
Actual Behavior
Full text search didn't work when scripts are blocked.
To Reproduce
The text was updated successfully, but these errors were encountered: