Nimbin[12]?Web & Tools / Browser / commits / 80991a6

Browser git · main

Minimal browser in C (mini and big variant)

browser c · first commit 2026-08-25 · last commit 2026-11-12 (12 days ago) · synced 1 hour ago · upstream: github.com/nimbin2/Browser

C 95.6% Markdown 4.2%
git clone https://git.christianimmanuel.de/web-tools/Browser.gitwget https://git.christianimmanuel.de/web-tools/Browser/archive/Browser.tar.gz

Enable storage api and filesystem

Christian Immanuel · 2026-11-12 00:20 · 80991a6abe2c807e43b3e14dbf0b33895abd6ad3

 Makefile       |  2 +-
 README.md      | 16 +++++++++++++++-
 browser_core.c | 42 +++++++++++++++++++++++++++++++++++++++---
 3 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 0b9dfaf..f678f1d 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CC      ?= gcc
 CFLAGS  ?= -O2 -Wall -Wextra -rdynamic
 PREFIX  ?= /usr
 
-VERSION  := 4.45.0
+VERSION  := 4.47.0
 SOURCES  := browser_core.c browser_core.h browser-mini.c browser-big.c Makefile
 BUILD_ID := $(shell cat $(SOURCES) 2>/dev/null | md5sum | cut -c1-7)
 
diff --git a/README.md b/README.md
index f7ff265..c5b7049 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ make                # build both
 make install        # into /usr/bin (PREFIX=... to change)
 make uninstall
 make clean
-make version        # 4.45.0 (build …), md5 of the sources
+make version        # 4.47.0 (build …), md5 of the sources
 ```
 
 ## Usage
@@ -271,6 +271,20 @@ browser-mini URL --gsk cairo       # GTK renderer (default gl)
 `--feature NAME[=on|off]` sets a WebKit runtime feature, `--list-features`
 lists them. `--gl-info` checks the graphics stack.
 
+These are turned on here, because WebKit ships them off outside Cocoa
+and a page that stores data cannot see the API at all without them:
+
+| feature | without it |
+| --- | --- |
+| `StorageAPI` | `navigator.storage` undefined |
+| `StorageAPIEstimate` | `navigator.storage.estimate()` undefined |
+| `FileSystem` | `navigator.storage.getDirectory()` undefined |
+| `AccessHandle` + `FileSystemWritableStream` | `createWritable()` absent, so OPFS is read-only |
+
+`createWritable` needs both of the last two: it is declared
+`[EnabledBySetting=AccessHandleEnabled&FileSystemWritableStreamEnabled]`,
+so one alone changes nothing. `--feature StorageAPI=off` still wins.
+
 ## When a gallery of GIFs freezes
 
 It does not any more. WebKit used to suspend a muted video that scrolled
diff --git a/browser_core.c b/browser_core.c
index 0a26660..039095a 100644
--- a/browser_core.c
+++ b/browser_core.c
@@ -1262,15 +1262,51 @@ features_list (const char *filter)
     webkit_feature_list_unref (all);
 }
 
+/*
+ * WebKit ships all of these off outside Cocoa, and without them a page
+ * that keeps data sees nothing to keep it in: no StorageAPI means
+ * navigator.storage is undefined, no FileSystem means getDirectory is.
+ *
+ * createWritable - the whole point of a private file system - is
+ * declared [EnabledBySetting=AccessHandleEnabled&FileSystemWritableStr\
+ * eamEnabled], so both of those have to be on or the method is absent
+ * and only reads work. The code is portable WebCore; it is the per-port
+ * default that is false, not the implementation that is missing.
+ *
+ * Applied before the list from the config and the command line, so
+ * --feature StorageAPI=off still wins.
+ */
+static const struct { const char *id; gboolean on; } FEATURE_DEFAULTS[] = {
+    { "StorageAPI",               TRUE },
+    { "StorageAPIEstimate",       TRUE },
+    { "FileSystem",               TRUE },
+    { "AccessHandle",             TRUE },
+    { "FileSystemWritableStream", TRUE },
+};
+
 static void
 features_apply (WebKitSettings *s)
 {
-    if (!g_features)
-        return;
-
     WebKitFeatureList *all = webkit_settings_get_all_features ();
     gsize              n   = webkit_feature_list_get_length (all);
 
+    for (gsize d = 0; d < G_N_ELEMENTS (FEATURE_DEFAULTS); d++)
+        for (gsize i = 0; i < n; i++) {
+            WebKitFeature *f  = webkit_feature_list_get (all, i);
+            const char    *id = webkit_feature_get_identifier (f);
+
+            if (!id || g_ascii_strcasecmp (id, FEATURE_DEFAULTS[d].id) != 0)
+                continue;
+            if (webkit_settings_get_feature_enabled (s, f) != FEATURE_DEFAULTS[d].on)
+                webkit_settings_set_feature_enabled (s, f, FEATURE_DEFAULTS[d].on);
+            break;
+        }
+
+    if (!g_features) {
+        webkit_feature_list_unref (all);
+        return;
+    }
+
     for (guint k = 0; k < g_features->len; k++) {
         char     *spec = g_ptr_array_index (g_features, k);
         char     *eq   = strchr (spec, '=');