okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8667a3dbf
main
1// Linux file drop (found on z440 under Xvfb with a real GTK drag, WebKitGTK 2.52): the page gets no files and WebKit never raises the drop signal, 2// so the shell reads the file:// addresses from the drag data, accepts the drag itself, takes the "leave" with every button up as the drop and 3// hands the paths to the host. The behaviour itself is checked on a real X display (scripts in phaseA-tests); these keep the pieces in place. 4import test from 'node:test' ; 5import assert from 'node:assert/strict' ; 6import { readFile } from 'node:fs/promises' ; 7 8const read = path => readFile ( new URL ( path , import . meta. url ), 'utf8' ). then ( s => s . replace ( / \r\n / g , '\n' )); 9 10test ( 'the Linux shell hooks the drag signals of the page and keeps Windows and macOS on their own paths' , async () => { 11const rust = await read ( '../../desktop/src-tauri/src/main.rs' ); 12assert . match ( rust , / #\[cfg\(target_os = "linux"\)\]\s + hook_linux_drops\(&window, port, shell_token\); / ); 13assert . match ( rust , / view\.connect_drag_data_received\( / ); assert . match ( rust , / file_uri_to_path\(u\.as_str\(\)\) / ); 14assert . match ( rust , / ctx\.drag_status\(gtk::gdk::DragAction::COPY, time\) / ); 15assert . match ( rust , / pointer_buttons_up\(widget\) / ); 16assert . match ( rust , / hand_over_drop\(target\.clone\(\), port, token\.clone\(\), list\) / ); 17assert . match ( rust , / fn file_uri_to_path\(uri: &str\) -> Option<String> / ); 18assert . match ( rust , / #\[cfg\(windows\)\]\s + let builder = builder\.disable_drag_drop_handler\(\); / ); 19const toml = await read ( '../../desktop/src-tauri/Cargo.toml' ); 20assert . match ( toml , / \[target\.'cfg\(target_os = "linux"\)'\.dependencies\]\ngtk = "0\.18"\nwebkit2gtk = "2\.0" / ); 21}); 22 23test ( 'only file:// addresses reach the host, which applies the same limits as for every drop' , async () => { 24const rust = await read ( '../../desktop/src-tauri/src/main.rs' ); 25assert . match ( rust , / strip_prefix\("file:\/\/"\)\? / ); 26const host = await read ( '../server/native-drop.mjs' ); 27assert . match ( host , / MAX_FILES = 10, MAX_BYTES = 25 \* 1024 \* 1024 / ); 28assert . match ( host , / !isAbsolute\(path\) / ); 29});