Boscop / Boscop/web-view

`external` becoming undefined after changing pages

Open
#212 9 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2k
Forks
179
PR merge metrics
No merged PRs in 30d

Description

Whenever I get redirected browsing the page I'd like (having to login via Google Auth), the `external` becomes undefined and I'm unable to send data back to Rust.

I'm trying to fetch cookies before and after login, so that I can load them next time and have user pre-logged.

This is the output I have:
```
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
arg: GPS=1; PREF=volume=100
CONSOLE ERROR Unrecognized Content-Security-Policy directive 'worker-src'.

https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
https://examplewebsite.com/:1:9: CONSOLE ERROR ReferenceError: Can't find variable: external
```
The first `arg: ` lines are printing cookies once a second before login. `CONSOLE ERROR` and a line after that are printed when I open the Google Auth page and after that is the same code that should be outputting `arg: `, but it's throwing errors, as the `external` cannot be found.

What am I missing?

This is the full code, replace `examplewebsite` with any website that uses Google Auth:
```Rust
use web_view::*;
use std::thread;
use std::time::Duration;
fn main() {
let webview = WebViewBuilder::new()
.title("WebView Test")
.content(Content::Url("https://examplewebsite.com"))
.size(800, 600)
.resizable(true)
.debug(true)
.user_data(())
.invoke_handler(|_webview, arg| {
println!("arg: {}", arg);
if arg.contains("__Secure"){
println!("Logged in! {}", arg);
Ok(())
}else{
Ok(())
}
})
.build()
.unwrap();
let handle = webview.handle();
thread::spawn(move || loop {
{
handle
.dispatch(move |webview| {
webview.eval("external.invoke(document.cookie);").unwrap();
Ok(())
})
.unwrap();
}
thread::sleep(Duration::from_secs(1));
});
webview.run().unwrap();
}
```

I'm using GTK backend on VoidLinux

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.