Visual Studio Code, rebuilt in Rust
Rust
fix(webview): block mixed-content http scripts in macOS webviews
rokartur18f2ba95c28a
diff --git a/native/crates/app/Cargo.toml b/native/crates/app/Cargo.tomlindex 5a0d3cbdac9..982ef070e70 100644--- a/native/crates/app/Cargo.toml+++ b/native/crates/app/Cargo.toml@@ -47,7 +47,7 @@ core-foundation = "0.10"objc2 = "0.6"objc2-app-kit = { version = "0.3.2", default-features = false, features = ["NSAccessibility", "NSAlert", "NSApplication", "NSButton", "NSCell", "NSControl", "NSEvent", "NSImage", "NSMenu", "NSMenuItem", "NSOpenPanel", "NSPanel", "NSPasteboard", "NSPopUpButton", "NSResponder", "NSSavePanel", "NSSound", "NSTextField", "NSView", "NSWindow", "NSWorkspace", "block2", "objc2-core-foundation"] }objc2-foundation = { version = "0.3.2", default-features = false, features = ["NSArray", "NSData", "NSDate", "NSDateFormatter", "NSDictionary", "NSDistributedNotificationCenter", "NSError", "NSFormatter", "NSGeometry", "NSKeyValueCoding", "NSLocale", "NSNotification", "NSOperation", "NSProcessInfo", "NSString", "NSTimeZone", "NSURL", "NSURLRequest", "NSURLResponse", "NSURLSession", "NSUserDefaults", "NSValue", "block2", "objc2-core-foundation"] }-objc2-web-kit = { version = "0.3.2", default-features = false, features = ["WKNavigation", "WKPreferences", "WKScriptMessage", "WKScriptMessageHandler", "WKURLSchemeHandler", "WKURLSchemeTask", "WKUserContentController", "WKUserScript", "WKWebView", "WKWebViewConfiguration", "block2", "objc2-app-kit", "objc2-core-foundation"] }+objc2-web-kit = { version = "0.3.2", default-features = false, features = ["WKContentRuleList", "WKContentRuleListStore", "WKNavigation", "WKPreferences", "WKScriptMessage", "WKScriptMessageHandler", "WKURLSchemeHandler", "WKURLSchemeTask", "WKUserContentController", "WKUserScript", "WKWebView", "WKWebViewConfiguration", "block2", "objc2-app-kit", "objc2-core-foundation"] }security-framework = "3"[target.'cfg(target_os = "linux")'.dependencies]diff --git a/native/crates/app/src/webview.rs b/native/crates/app/src/webview.rsindex b1166005271..5377fb94e4e 100644--- a/native/crates/app/src/webview.rs+++ b/native/crates/app/src/webview.rs@@ -24,6 +24,16 @@ const HOST_SITE: &str = "vscode-webview.vscode-cdn.net";/// `window.origin` of the Electron workbench, which index.html hashes into the host name.const PARENT_ORIGIN: &str = "vscode-file://vscode-app";const MESSAGE_HANDLER: &str = "vscodeWebviewHost";+/// WebKit blocks every http load in the https host page, loopback included, where Chromium lets loopback through (the+/// Simple Browser's dev servers). With `http` registered secure, these content rules block the rest: http stays loopback+/// only. A rule ends at `(:port)?/` so `http://localhost:[email protected]/` (a user name) does not match.+const HTTP_LOOPBACK_ONLY_RULES: &str = r#"[+ { "trigger": { "url-filter": "^http:" }, "action": { "type": "block" } },+ { "trigger": { "url-filter": "^http://localhost(:[0-9]+)?/" }, "action": { "type": "ignore-previous-rules" } },+ { "trigger": { "url-filter": "^http://[^/:@]*\\.localhost(:[0-9]+)?/" }, "action": { "type": "ignore-previous-rules" } },+ { "trigger": { "url-filter": "^http://127\\.[0-9.]+(:[0-9]+)?/" }, "action": { "type": "ignore-previous-rules" } },+ { "trigger": { "url-filter": "^http://\\[::1\\](:[0-9]+)?/" }, "action": { "type": "ignore-previous-rules" } }+]"#;/// What the host page sends the workbench: the `FromWebviewMessage` channels of webviewMessages.d.ts, and/// `webview-ready` once the page handed over its port.diff --git a/native/crates/app/src/webview/linux.rs b/native/crates/app/src/webview/linux.rsindex 031b72829d4..65692d3d712 100644--- a/native/crates/app/src/webview/linux.rs+++ b/native/crates/app/src/webview/linux.rs@@ -19,7 +19,7 @@ use async_openssl::SslStream;use futures::channel::{mpsc::UnboundedSender, oneshot};use futures::io::{AsyncBufRead, AsyncBufReadExt, AsyncWriteExt, BufReader};use gpui::{App, Bounds, Pixels, Window};-use gtk::glib::translate::ToGlibPtr;+use gtk::glib::translate::{FromGlibPtrFull, ToGlibPtr};use gtk::prelude::*;use gtk::{gdk, gio, glib};use openssl::pkey::PKey;@@ -29,12 +29,12 @@ use raw_window_handle::{HasWindowHandle, RawWindowHandle};use serde_json::{Value, json};pub use std::rc::Rc as Retained;use webkit2gtk::{- NetworkProxyMode, NetworkProxySettings, SettingsExt, UserContentInjectedFrames, UserContentManager, UserContentManagerExt, UserScript, UserScriptInjectionTime, WebContext, WebContextExt, WebInspectorExt,+ NetworkProxyMode, NetworkProxySettings, SecurityManagerExt, SettingsExt, UserContentInjectedFrames, UserContentManager, UserContentManagerExt, UserScript, UserScriptInjectionTime, WebContext, WebContextExt, WebInspectorExt,WebViewExt, WebsiteDataManagerExt,};use x11::xlib;-use super::{BRIDGE_SCRIPT, FIND_SCRIPT, HOST_SITE, MESSAGE_HANDLER, RESOURCE_AUTHORITY, ResourceRead, WebviewEvent, host_message, host_page_url, is_contained, mime_type, resource_response, resource_uri};+use super::{BRIDGE_SCRIPT, FIND_SCRIPT, HOST_SITE, HTTP_LOOPBACK_ONLY_RULES, MESSAGE_HANDLER, RESOURCE_AUTHORITY, ResourceRead, WebviewEvent, host_message, host_page_url, is_contained, mime_type, resource_response, resource_uri};/// The native view of a webview, which `place` shows.pub type View = webkit2gtk::WebView;@@ -96,6 +96,8 @@ impl Webview {let mut settings = NetworkProxySettings::new(None, &[]);settings.add_proxy_for_scheme("https", &format!("http://127.0.0.1:{port}"));context.website_data_manager().expect("a context has a data manager").set_network_proxy_settings(NetworkProxyMode::Custom, Some(&mut settings));+ // HTTP_LOOPBACK_ONLY_RULES keep http to loopback.+ context.security_manager().expect("a context has a security manager").register_uri_scheme_as_secure("http");let content = UserContentManager::new();content.register_script_message_handler(MESSAGE_HANDLER);@@ -118,7 +120,7 @@ impl Webview {let parent = gpui_x_window(window);let gtk_window = embedded_window(parent);gtk_window.add(&view);- view.load_uri(&host_page_url(id, origin, extension_id));+ load_with_http_rules(&view, &content, host_page_url(id, origin, extension_id));Webview { view, window: gtk_window, content, proxy, roots, parent, pending: Some(Vec::new()) }}@@ -227,6 +229,31 @@ impl Webview {}}+/// Loads `url` in `view` once HTTP_LOOPBACK_ONLY_RULES are a filter of `content`; webkit2gtk-rs binds no filter store.+fn load_with_http_rules(view: &webkit2gtk::WebView, content: &UserContentManager, url: String) {+ unsafe extern "C" fn saved(store: *mut glib::gobject_ffi::GObject, result: *mut gio::ffi::GAsyncResult, data: glib::ffi::gpointer) {+ // SAFETY: `data` is the box made below, `store` the filter store it saved to.+ let (view, content, url) = *unsafe { Box::from_raw(data as *mut (webkit2gtk::WebView, UserContentManager, String)) };+ let mut error = std::ptr::null_mut();+ let filter = unsafe { webkit2gtk::ffi::webkit_user_content_filter_store_save_finish(store.cast(), result, &mut error) };+ assert!(!filter.is_null(), "HTTP_LOOPBACK_ONLY_RULES: {}", unsafe { glib::Error::from_glib_full(error) });+ unsafe {+ webkit2gtk::ffi::webkit_user_content_manager_add_filter(content.to_glib_none().0, filter);+ webkit2gtk::ffi::webkit_user_content_filter_unref(filter);+ }+ view.load_uri(&url);+ }+ let path = glib::user_cache_dir().join("vsrustium").join("webview-content-filters");+ let rules = glib::Bytes::from_static(HTTP_LOOPBACK_ONLY_RULES.as_bytes());+ let data = Box::into_raw(Box::new((view.clone(), content.clone(), url)));+ // SAFETY: webkit_user_content_filter_store_save (WebKitGTK 2.24+) holds the store until `saved` runs.+ unsafe {+ let store = webkit2gtk::ffi::webkit_user_content_filter_store_new(path.to_glib_none().0);+ webkit2gtk::ffi::webkit_user_content_filter_store_save(store, c"http-loopback-only".as_ptr(), rules.to_glib_none().0, std::ptr::null_mut(), Some(saved), data.cast());+ glib::gobject_ffi::g_object_unref(store.cast());+ }+}+impl Drop for Webview {fn drop(&mut self) {self.content.unregister_script_message_handler(MESSAGE_HANDLER);diff --git a/native/crates/app/src/webview/macos.rs b/native/crates/app/src/webview/macos.rsindex a253ad1f1a1..a24df85c5c9 100644--- a/native/crates/app/src/webview/macos.rs+++ b/native/crates/app/src/webview/macos.rs@@ -18,11 +18,11 @@ use objc2::runtime::{AnyClass, Bool, Imp, NSObject, NSObjectProtocol, ProtocolObuse objc2::{AnyThread, ClassType, DefinedClass, MainThreadMarker, MainThreadOnly, Message, define_class, msg_send, sel};use objc2_app_kit::{NSView, NSWindow};use objc2_foundation::{NSData, NSDictionary, NSError, NSHTTPURLResponse, NSObjectNSKeyValueCoding, NSOperationQueue, NSPoint, NSRect, NSSize, NSString, NSURLResponse, NSURLSession, NSURLSessionConfiguration};-use objc2_web_kit::{WKScriptMessage, WKScriptMessageHandler, WKURLSchemeHandler, WKURLSchemeTask, WKUserContentController, WKUserScript, WKUserScriptInjectionTime, WKWebView, WKWebViewConfiguration};+use objc2_web_kit::{WKContentRuleList, WKContentRuleListStore, WKScriptMessage, WKScriptMessageHandler, WKURLSchemeHandler, WKURLSchemeTask, WKUserContentController, WKUserScript, WKUserScriptInjectionTime, WKWebView, WKWebViewConfiguration};use raw_window_handle::{HasWindowHandle, RawWindowHandle};use serde_json::{Value, json};-use super::{BRIDGE_SCRIPT, FIND_SCRIPT, HOST_SITE, MESSAGE_HANDLER, RESOURCE_AUTHORITY, ResourceRead, WebviewEvent, host_message, host_page_url, is_contained, mime_type, resource_response, resource_uri};+use super::{BRIDGE_SCRIPT, FIND_SCRIPT, HOST_SITE, HTTP_LOOPBACK_ONLY_RULES, MESSAGE_HANDLER, RESOURCE_AUTHORITY, ResourceRead, WebviewEvent, host_message, host_page_url, is_contained, mime_type, resource_response, resource_uri};pub struct Webview {view: Retained<WKWebView>,@@ -45,8 +45,7 @@ impl Webview {let configuration = unsafe { WKWebViewConfiguration::new(mtm) };let handler = SchemeHandler::new(mtm, SchemeState { id: id.to_string(), pre_dir, roots: roots.clone(), events: events.clone(), tasks: RefCell::default(), session: OnceLock::new() });unsafe { configuration.setURLSchemeHandler_forURLScheme(Some(ProtocolObject::from_ref(&*handler)), &NSString::from_str("https")) };- // WebKit blocks an http frame in the https host page as mixed content, loopback included, where Chromium lets- // http://localhost load (the Simple Browser's dev servers). SAFETY: WKProcessPoolPrivate.h, macOS 10.13+.+ // SAFETY: WKProcessPoolPrivate.h, macOS 10.13+. HTTP_LOOPBACK_ONLY_RULES keep http to loopback.unsafe {let pool: *mut objc2::runtime::AnyObject = msg_send![&*configuration, processPool];let _: () = msg_send![pool, _registerURLSchemeAsSecure: &*NSString::from_str("http")];@@ -71,7 +70,17 @@ impl Webview {let url = objc2_foundation::NSURL::URLWithString(&NSString::from_str(&host_page_url(id, origin, extension_id))).expect("host page URL");let request = objc2_foundation::NSURLRequest::requestWithURL(&url);- unsafe { view.loadRequest(&request) };+ let loading = view.clone();+ let loaded = RcBlock::new(move |rules: *mut WKContentRuleList, error: *mut NSError| {+ // SAFETY: WebKit passes a rule list or an error.+ let rules = unsafe { rules.as_ref() }.unwrap_or_else(|| panic!("HTTP_LOOPBACK_ONLY_RULES: {:?}", unsafe { error.as_ref() }));+ unsafe {+ content.addContentRuleList(rules);+ loading.loadRequest(&request);+ }+ });+ let store = unsafe { WKContentRuleListStore::defaultStore(mtm) }.expect("a default content rule list store");+ unsafe { store.compileContentRuleListForIdentifier_encodedContentRuleList_completionHandler(Some(&NSString::from_str("http-loopback-only")), Some(&NSString::from_str(HTTP_LOOPBACK_ONLY_RULES)), Some(&loaded)) };// The scheme and message handlers are retained by the configuration the view copied.Webview { view, roots, pending: Some(Vec::new()) }}diff --git a/port/fixtures/extensions/webview-tests/tests/index.js b/port/fixtures/extensions/webview-tests/tests/index.jsindex b468d361c69..ecbc3b9ee56 100644--- a/port/fixtures/extensions/webview-tests/tests/index.js+++ b/port/fixtures/extensions/webview-tests/tests/index.js@@ -196,6 +196,8 @@ const checks = {const online = await new Promise(resolve => http.get('http://example.com/', response => resolve(response.statusCode === 200)).on('error', () => resolve(false)));assert.ok(online, 'http://example.com/ is reachable');assert.strictEqual(await loadScript('http://example.com/'), 'blocked');+ await vscode.commands.executeCommand('workbench.action.closeAllEditors');+ assert.strictEqual(await loadScript('http://localhost:[email protected]/'), 'blocked', 'a loopback user name');},async 'webviews should load http scripts from loopback'() {const server = http.createServer((request, response) => {@@ -208,9 +210,6 @@ const checks = {},};-// Ledger rows `M23 Linux`: what the Linux build lacks, printed as `gap` and not counted as failed.-const linuxGaps = ['webviews should load http scripts from loopback'];-/** Whether a webview page's `<script src>` loaded, was blocked, or is still pending after 5 s. */async function loadScript(src) {const webview = createPanel({ enableScripts: true });@@ -235,9 +234,8 @@ exports.run = async () => {await Promise.race([check(), new Promise((_, reject) => setTimeout(() => reject(new Error('timed out after 10 s')), 10000))]);console.log(`ok ${name}`);} catch (error) {- const gap = process.platform === 'linux' && linuxGaps.includes(name);- failed += gap ? 0 : 1;- console.log(`${gap ? 'gap' : 'FAILED'} ${name}: ${error.message}`);+ failed++;+ console.log(`FAILED ${name}: ${error.message}`);}await vscode.commands.executeCommand('workbench.action.closeAllEditors');disposables.splice(0).forEach(disposable => disposable.dispose());diff --git a/port/ledger.md b/port/ledger.mdindex accb61d826d..894f227e282 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -41,9 +41,8 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,| Milestones | M23 Linux build | in progress | Branch `port-linux` (a Linux build container on the Studio). The app is macOS-only today: 24 files of `native/crates` call AppKit, Foundation, WebKit, Security or Core Foundation directly (objc2, core-foundation, security-framework); GPUI (`native/vendor/wu`) already has its Linux platform (Wayland and X11). Every macOS call goes behind `cfg(target_os = "macos")` with the Linux counterpart VS Code uses there, in the same function where the two are a few lines, in a `platform/linux.rs` beside a `platform/macos.rs` where they are not: webview (WebKitGTK through wry), file dialogs (xdg-desktop-portal, rfd), the application menu (drawn in the window: `window.titleBarStyle`, `window.menuBarVisibility`), clipboard and the find pasteboard (GPUI's), proxy (`http.proxy` and the system proxy via reqwest instead of NSURLSession), secrets (Secret Service, keyring), `code` CLI install (`~/.local/bin`), file watching (inotify, notify), the updater (a download link, as `update.mode` on a tar.gz), and the settings import paths (`~/.config/Code`, `~/.config/Cursor`, `~/.config/VSCodium`). Packaging: `port/tools/package-linux` writes `VSRustium-<version>-linux-<arch>.tar.gz` and the `linux-<arch>.json` and `linux-<arch>-prerelease.json` feed entries (port/notes.md milestone 23); deb and AppImage after it. Builds in a Linux container on the Studio (`docker`, linux/arm64) for the build and the unit tests; linux-x64 on a GitHub Actions `ubuntu` runner once arm64 is green. | `cargo build --release -p app` and the area tests pass on Linux arm64 and x64; the app opens a folder, edits, saves, runs an extension (the exthost handshake, emmet and git activate) and shows a webview under Xvfb or Wayland in the container; `v1.147.0-insider` carries `VSRustium-1.147.0-insider-linux-arm64.tar.gz` and `VSRustium-1.147.0-insider-linux-x64.tar.gz`; the macOS build is unchanged (its area tests and api-tests as before). || Milestones | M24 Windows build | later | After milestone 23, on the same seams: WebView2 (wry), the Win32 file dialogs, the in-window menu bar and custom title bar, Credential Manager (keyring), the user-setup install path and `code` on PATH, `%APPDATA%\Code` settings import, ConPTY for the terminal (alacritty_terminal has it), an x64 and arm64 zip and a user installer, no Authenticode signing (the Windows signing decision). Builds on a GitHub Actions `windows` runner. | As milestone 23, for win32-x64 and win32-arm64. || Milestones | M25 virtual workspaces | later | Artur: its own milestone after M20, not part of the gap audits. A folder of a non-file scheme (`.code-workspace` `uri` folders, `--folder-uri`, `vscode.openFolder` with an extension file system provider scheme) kept as a URI; every reader of workspace folders (173 `.folders` uses in 70 files: explorer, search, quick open, terminal cwd, tasks, git, watcher, settings layers, trust) goes through the file system providers; the workspace marked virtual, `virtualWorkspaces: false` extensions disabled with the `notSupportedInWorkspace` message (config/workspace.rs:101, port/notes.md provider entries deferred until virtual workspaces). | not started |-| M23 Linux | app/src/webview/linux.rs:66 | done | [linux L] webviews through WebKitGTK: webview panels and views, editor insets, notebook outputs, extension details, release notes. | `FIXTURE=webview-tests port/tools/linux/smoke` on X11 (Xvfb): 9 ok and the loopback http gap (linux.rs:97 row); `cargo gc test -p app webview` on Linux: 19 passed |+| M23 Linux | app/src/webview/linux.rs:66 | done | [linux L] webviews through WebKitGTK: webview panels and views, editor insets, notebook outputs, extension details, release notes. | `FIXTURE=webview-tests port/tools/linux/smoke` on X11 (Xvfb): 10/10 ok; `cargo gc test -p app webview` on Linux: 19 passed || M23 Linux | app/src/webview/linux.rs:47 | open | [linux M] webviews in a Wayland session. Linux shows now: no webview under Wayland: GPUI has no X window there to hold the GTK window, so `supported()` is false and each webview surface stays empty. | |-| M23 Linux | app/src/webview/linux.rs:97 | open | [linux S] http from loopback in a webview (the Simple Browser on a `http://localhost` dev server). Linux shows now: WebKitGTK blocks every http load in the https host page as mixed content, loopback included, and has no per-host setting; `register_uri_scheme_as_secure("http")` would let any http script in (port/notes.md M23). | || M23 Linux | exthost/src/main_thread_secret_state.rs:46 | done | [linux M] secrets in the Secret Service (libsecret). | `cargo test -p exthost secret` on Linux: `secrets_in_a_keyring` (oo7's file backend); a desktop Secret Service not run || M23 Linux | app/src/clipboard.rs:97 | open | [linux M] clipboard file lists, HTML and other custom formats, the find text. Linux shows now: text only; the other formats read empty. | || M23 Linux | app/src/workbench/themes.rs:47 | done | [linux S] host color scheme and high contrast from the xdg-desktop-portal Settings. | GPUI's `window_appearance()`, which gpui_linux reads from the portal's `color-scheme`; high contrast stays off, as Chromium on Linux |@@ -610,7 +609,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/contrib/url | workbench contribution | M12 | verified | | trusted_domains.rs (isURLDomainTrusted, globs, localhost) and workbench/url_actions.rs: workbench.action.url.openUrl, workbench.action.manageTrustedDomain (trustedDomains:/Trusted Domains.jsonc editor, saved to http.linkProtectionTrustedDomains), link prompt "Do you want Code - OSS to open the external website?" with Copy and Configure Trusted Domains; cargo test -p app -- trusted_domains:: url_actions; verified at port-m12b-verify: cargo test -p app trusted_domains 10/10, url_actions 2/2; trustedDomainsValidator `fromWorkspace` (editor links and webview links ask for workspace trust before a command link, skip the domain prompt in a trusted workspace unless `workbench.trustedDomains.promptInTrustedWorkspace`): cargo test -p app -- a_workspace_link_follows_workspace_trust an_editor_link_opens_without_the_domain_prompt a_webview_command_link_asks_for_workspace_trust || workbench/contrib/userDataProfile | workbench contribution | M10 | verified | | workbench/user_data_profile.rs, workbench/profiles_editor_view.rs, workbench/icon_select_box.rs: cargo test -p app icon_select_box profiles_editor_view preview_opens_a_window_on_a_transient_profile_that_goes_with_it; ui-pair Profiles editor and new profile form (port/results/profiles.md) || workbench/contrib/userDataSync | workbench contribution | | removed | | no sign-in/AI by decision (port/notes.md); not ported |-| workbench/contrib/webview | workbench contribution | M17 | verified | | webview.rs, webview/macos.rs: cargo test -p app a_webview_right_click_shows_the_webview_context_menu maps_resource_urls_to_resources_inside_the_roots webview_resource_reads_answer_with_the_file_service_bytes reads_resource_roots_and_stable_origins; `FIXTURE=webview-tests port/tools/webview-check` 8/8; api-tests `MOCHA_GREP="vscode API - webview"` 1 passing; ui-pair markdown-preview.json find (port/results/webviews.md), `webview-devtools.json` (a Web Inspector window per webview, where upstream docks Chromium devtools); ui-pair m17/webview-context.json with port/fixtures/extensions/webview-context-pair: `webview/context` item, Cut, Copy and Paste on a real WKWebView, pasteboard text as the reference's (port/notes.md Webview context menu) |+| workbench/contrib/webview | workbench contribution | M17 | verified | | webview.rs, webview/macos.rs: cargo test -p app a_webview_right_click_shows_the_webview_context_menu maps_resource_urls_to_resources_inside_the_roots webview_resource_reads_answer_with_the_file_service_bytes reads_resource_roots_and_stable_origins; `FIXTURE=webview-tests port/tools/webview-check` 10/10; api-tests `MOCHA_GREP="vscode API - webview"` 1 passing; ui-pair markdown-preview.json find (port/results/webviews.md), `webview-devtools.json` (a Web Inspector window per webview, where upstream docks Chromium devtools); ui-pair m17/webview-context.json with port/fixtures/extensions/webview-context-pair: `webview/context` item, Cut, Copy and Paste on a real WKWebView, pasteboard text as the reference's (port/notes.md Webview context menu) || workbench/contrib/webviewPanel | workbench contribution | M17 | verified | | webview panels as editors in groups (workbench/webview_panels.rs), reveal moves to the target group, `activeWebviewPanelId`/`activeCustomEditorId` per group, a focused group focuses its webview; `FIXTURE=webview-tests` and `FIXTURE=markdown-tests port/tools/webview-check`; cargo test -p app webview_panels; panel restore on restart and reload: ui-pair webview-panel-restore.json, cargo test -p app panels_with_a_serializer || workbench/contrib/webviewView | workbench contribution | M17 | verified | | `contributes.views` of type webview as contributed views beside the tree views: their container, `when`, pane layout and `<id>.focus`, collapsed at first (viewsExtensionPoint.ts `showCollapsed`), resolved on first show with `onView:` activation (workbench/webview_views.rs); `$setWebviewViewBadge` on the view's container (webviewViewPane.ts `updateBadge`: cargo test -p app a_webview_view_shows_in_its_own_container_while_its_when_holds); `FIXTURE=webview-view-tests port/tools/webview-check` 5/5 on both apps || workbench/contrib/welcomeBanner | workbench contribution | M19 | n/a | | shows the web embedder's `welcomeBanner` option; a desktop window has none |diff --git a/port/notes.md b/port/notes.mdindex 32d699ea58b..803643be806 100644--- a/port/notes.md+++ b/port/notes.md@@ -987,7 +987,7 @@ What to do (milestone 21, in order):- Package (`port/tools/package-linux`, the app files from `port/tools/app-files.ts`): `VSRustium-linux-<arch>/` as VS Code's Linux archive lays it out, the release binary named `applicationName` (debug info stripped: `debug = "limited"` stays in the ELF on Linux, 571 MB with it) beside bun, `bin/vsrustium` from upstream's `resources/linux/bin/code.sh`, `com.rokartur.vsrustium.desktop` from upstream's `resources/linux/code.desktop` (Exec is `vsrustium` on PATH, as an archive does not know where it is unpacked; `StartupWMClass` is `product.linuxDesktopName`, which the windows set as their X11 WM_CLASS and Wayland app id) with `vsrustium.png` (`port/AppIcon.png`, ictool's 512 px render of `port/AppIcon.icon`), the app files in `resources/app` (`product::BUNDLED_APP`, which the binary takes as its root when it is there). Native modules built for another system or arch are rebuilt with node-gyp from their source; a binding.gyp that builds nothing on Linux (@vscode/fs-copyfile) leaves the module out, any other foreign binary fails the package. It writes `VSRustium-<version>-linux-<arch>.tar.gz` and the `linux-<arch>.json` and `linux-<arch>-prerelease.json` feed entries (`gallery::CURRENT_TARGET_PLATFORM` is `linux-<arch>` on Linux, for the gallery and the update feed). arm64 1.147.0: folder 412 MB, archive 131 MB; the extracted archive passes `port/tools/linux/smoke` with `APP=<folder>/vsrustium` in a container without the reference mounted. linux-x64 builds on GitHub Actions (`.github/workflows/linux.yml`, run by hand, the README's build steps with upstream's pnpm install building the native modules for Linux). The binary needs the glibc it links: GLIBC_2.39 for both (Debian 13's container, the ubuntu-24.04 runner; ubuntu-latest, 26.04, asked for 2.43 and the x64 package did not start on Debian 13).- Desktop services over D-Bus (zbus 5, the one gpui_linux's ashpd and oo7 build; blocking proxies on their own threads, each service optional): power (`power/linux.rs`) takes idle time from Mutter's IdleMonitor, else the ScreenSaver service's `GetSessionIdleTime`; the lock state from logind's session `LockedHint`; the power source from UPower's `OnBattery`; `prevent-display-sleep` is a ScreenSaver `Inhibit` cookie and `prevent-app-suspension` a logind `sleep` inhibitor fd; the events are logind's `PrepareForSleep` and `PrepareForShutdown`, as Electron has no lock, battery, thermal or speed limit events on Linux. A blocker the bus refuses still counts as started, as Electron's map of ids. Metered is NetworkManager's `Metered` (`YES` or `GUESS_YES`), the screen reader AT-SPI's `org.a11y.Status` `ScreenReaderEnabled`, reduced motion the portal's `org.gnome.desktop.interface` `enable-animations` (Chromium follows GTK's `gtk-enable-animations`). None of these ran against a desktop session yet: the container has no session or system bus.- Secrets (`exthost/src/main_thread_secret_state.rs`) are Secret Service items of the default collection through oo7 (gpui_linux's version and features), with keytar's `service` and `account` attributes; the test runs the flow on oo7's file keyring.-- Webviews (`app/src/webview/linux.rs`, the host page and its answers shared with macOS in `webview.rs`) are WebKitGTK 4.1 views, each in an undecorated GTK popup window whose X window is reparented into GPUI's; a notebook's back layer webview sits in a clip window whose X input shape passes presses through to GPUI outside the outputs. GTK runs on GPUI's main thread, iterated every 8 ms (`pump_gtk`). Keyboard focus moves with `XSetInputFocus` (a reparented window gets none from the window manager); Cut, Copy and Paste run WebKitGTK's editing commands. WebKitGTK refuses a URI scheme handler on `https`, so each view's ephemeral context sets a loopback proxy as its https proxy: `CONNECT` to `*.vscode-webview.vscode-cdn.net` and `*.vscode-resource.vscode-cdn.net` is answered over TLS with a process-local self-signed certificate the context trusts for those hosts only (the host page's files, and resources as the macOS scheme handler reads them), every other host is tunneled. OpenSSL serves that TLS: GnuTLS, glib-networking's backend, refuses a resource host's SNI (`file+.vscode-resource...`, the `+` is no DNS character). The proxy answers only connections /proc/net/tcp shows as the app user's. WebKitGTK 2.54 blocks every http load in the https host page as mixed content, loopback included, where Chromium lets loopback through (the Simple Browser's `http://localhost` dev servers): registering `http` as a secure scheme would let any http script in, and WebKitGTK has no per-host setting, so loopback http stays blocked (an open M23 row; webview-tests `webviews should load http scripts from loopback` prints `gap` on Linux). Wayland sessions show no webview (GPUI has no X window there; the open M23 row).+- Webviews (`app/src/webview/linux.rs`, the host page and its answers shared with macOS in `webview.rs`) are WebKitGTK 4.1 views, each in an undecorated GTK popup window whose X window is reparented into GPUI's; a notebook's back layer webview sits in a clip window whose X input shape passes presses through to GPUI outside the outputs. GTK runs on GPUI's main thread, iterated every 8 ms (`pump_gtk`). Keyboard focus moves with `XSetInputFocus` (a reparented window gets none from the window manager); Cut, Copy and Paste run WebKitGTK's editing commands. WebKitGTK refuses a URI scheme handler on `https`, so each view's ephemeral context sets a loopback proxy as its https proxy: `CONNECT` to `*.vscode-webview.vscode-cdn.net` and `*.vscode-resource.vscode-cdn.net` is answered over TLS with a process-local self-signed certificate the context trusts for those hosts only (the host page's files, and resources as the macOS scheme handler reads them), every other host is tunneled. OpenSSL serves that TLS: GnuTLS, glib-networking's backend, refuses a resource host's SNI (`file+.vscode-resource...`, the `+` is no DNS character). The proxy answers only connections /proc/net/tcp shows as the app user's. WebKit (WebKitGTK 2.54, WKWebView on macOS 27) blocks every http load in the https host page as mixed content, loopback included, where Chromium lets loopback through (the Simple Browser's `http://localhost` dev servers), and has no per-host setting: both platforms register `http` as a secure scheme and add content rules (`HTTP_LOOPBACK_ONLY_RULES`) that block http except `localhost`, `*.localhost`, `127.*` and `[::1]`. Unlike Chromium, a network http image is blocked rather than upgraded to https. Wayland sessions show no webview (GPUI has no X window there; the open M23 row).- Updates follow updateService.linux.ts: a found build waits in AvailableForDownload (no metered deferral, no Squirrel read-only check) and Download opens product.json `downloadUrl`, else the update's url, and goes back to Idle. The running build counts as installed when its executable sits beside `resources/app`.- Accessibility signal sounds run `pw-play`, else `paplay` (both decode mp3 through libsndfile 1.1 or later), one process per sound file, killed when the sound replays.- The `code` shell command on Linux links `~/.local/bin/<applicationName>` to the archive's `bin/<applicationName>` without a privilege prompt (upstream has the command on macOS only; a Linux package puts it on PATH itself). Proxy `<local>` adds the request's host to `--noproxy` when it has no dot, curl has no such rule. Machine info reads `/proc/cpuinfo`, `/proc/meminfo` and the cpufreq `scaling_cur_freq`.diff --git a/port/tools/linux/smoke b/port/tools/linux/smokeindex 4b6c7d9fd19..213ec9407c9 100755--- a/port/tools/linux/smoke+++ b/port/tools/linux/smoke@@ -21,6 +21,6 @@ tests=$PWD/port/fixtures/extensions/${FIXTURE:-linux-smoke-tests}timeout 300 "$APP" "$dir/workspace" --user-data-dir "$dir/user-data" --skip-welcome --disable-workspace-trust \--extensionDevelopmentPath="$tests" --extensionTestsPath="$tests/tests" >"$dir/log" 2>&1code=$?-grep -E "^handshake done|^(ok|gap|FAILED) " "$dir/log"+grep -E "^handshake done|^(ok|FAILED) " "$dir/log"echo "linux smoke: exit $code"exit $codediff --git a/port/tools/webview-check b/port/tools/webview-checkindex 066f850cb04..5343560fa9d 100755--- a/port/tools/webview-check+++ b/port/tools/webview-check@@ -21,7 +21,7 @@ for app in ${APP:-reference port}; doficode=$?echo "== $app"- grep -E '(^| )(ok|gap|FAILED) ' "$out/log" | sed -E 's/^.*(ok|gap|FAILED) /\1 /' || tail -20 "$out/log"+ grep -E '(^| )(ok|FAILED) ' "$out/log" | sed -E 's/^.*(ok|FAILED) /\1 /' || tail -20 "$out/log"echo "exit $code"[[ $code == 0 ]] || status=$coderm -rf "$out"