Fix Firefox native messaging: separate manifests and expose disconnect reason
CI / Build & Test (push) Successful in 3m9s
CI / Build & Test (push) Successful in 3m9s
- Firefox rejects native messaging manifest if allowed_origins is present. Install script now writes Chrome-only manifest (allowed_origins) and Firefox-only manifest (allowed_extensions) to their respective locations. - Fix local Firefox manifest by removing allowed_origins. - Log disconnect reason from port.error (Firefox) in addition to runtime.lastError (Chrome) so native messaging failures are visible. - Log getState failures on disconnect for easier debugging.
This commit is contained in:
@@ -128,7 +128,7 @@ function connect() {
|
|||||||
applyPAC();
|
applyPAC();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => applyPAC());
|
.catch((err) => { log('getState failed:', err.message); applyPAC(); });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('connectNative failed:', e);
|
log('connectNative failed:', e);
|
||||||
debugLog('connect: failed', e.message, e.stack);
|
debugLog('connect: failed', e.message, e.stack);
|
||||||
@@ -219,12 +219,10 @@ function connect() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
port.onDisconnect.addListener(() => {
|
port.onDisconnect.addListener((p) => {
|
||||||
// Reading lastError suppresses the "Unchecked runtime.lastError: Native host has exited"
|
const reason = p?.error?.message || browser.runtime.lastError?.message || null;
|
||||||
// console error that Chrome logs when the host process exits unexpectedly.
|
if (reason) {
|
||||||
const disconnectReason = browser.runtime.lastError?.message || null;
|
log('onDisconnect reason:', reason);
|
||||||
if (disconnectReason) {
|
|
||||||
debugLog('onDisconnect reason:', disconnectReason);
|
|
||||||
}
|
}
|
||||||
log('Native host disconnected');
|
log('Native host disconnected');
|
||||||
extensionState.hostConnected = false;
|
extensionState.hostConnected = false;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+26
-6
@@ -164,35 +164,55 @@ curl -fsSL "${RELEASE_BASE}/${EXT_XPI}" -o "${DOWNLOADS}/${EXT_XPI}" 2>/dev/null
|
|||||||
# ── Native messaging manifest ──────────────────────────────────────────────────
|
# ── Native messaging manifest ──────────────────────────────────────────────────
|
||||||
echo "Installing native messaging manifest..."
|
echo "Installing native messaging manifest..."
|
||||||
|
|
||||||
MANIFEST=$(cat <<JSON
|
MANIFEST_CHROME=$(cat <<JSON
|
||||||
|
{
|
||||||
|
"name": "com.holesail.browser",
|
||||||
|
"description": "Holesail Browser native host",
|
||||||
|
"path": "${HOST_BIN}",
|
||||||
|
"type": "stdio",
|
||||||
|
"allowed_origins": ["chrome-extension://fmcenppcipeikpnpopolicnllljclmmi/"]
|
||||||
|
}
|
||||||
|
JSON
|
||||||
|
)
|
||||||
|
|
||||||
|
MANIFEST_FIREFOX=$(cat <<JSON
|
||||||
{
|
{
|
||||||
"name": "com.holesail.browser",
|
"name": "com.holesail.browser",
|
||||||
"description": "Holesail Browser native host",
|
"description": "Holesail Browser native host",
|
||||||
"path": "${HOST_BIN}",
|
"path": "${HOST_BIN}",
|
||||||
"type": "stdio",
|
"type": "stdio",
|
||||||
"allowed_origins": ["chrome-extension://fmcenppcipeikpnpopolicnllljclmmi/"],
|
|
||||||
"allowed_extensions": ["[email protected]"]
|
"allowed_extensions": ["[email protected]"]
|
||||||
}
|
}
|
||||||
JSON
|
JSON
|
||||||
)
|
)
|
||||||
|
|
||||||
if [[ "$PLATFORM" == "darwin" ]]; then
|
if [[ "$PLATFORM" == "darwin" ]]; then
|
||||||
DIRS=(
|
CHROME_DIRS=(
|
||||||
"$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
|
"$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
|
||||||
"$HOME/Library/Application Support/Chromium/NativeMessagingHosts"
|
"$HOME/Library/Application Support/Chromium/NativeMessagingHosts"
|
||||||
|
)
|
||||||
|
FIREFOX_DIRS=(
|
||||||
"$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"
|
"$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
DIRS=(
|
CHROME_DIRS=(
|
||||||
"$HOME/.config/google-chrome/NativeMessagingHosts"
|
"$HOME/.config/google-chrome/NativeMessagingHosts"
|
||||||
"$HOME/.config/chromium/NativeMessagingHosts"
|
"$HOME/.config/chromium/NativeMessagingHosts"
|
||||||
|
)
|
||||||
|
FIREFOX_DIRS=(
|
||||||
"$HOME/.mozilla/native-messaging-hosts"
|
"$HOME/.mozilla/native-messaging-hosts"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for dir in "${DIRS[@]}"; do
|
for dir in "${CHROME_DIRS[@]}"; do
|
||||||
mkdir -p "$dir"
|
mkdir -p "$dir"
|
||||||
echo "$MANIFEST" > "${dir}/${MANIFEST_NAME}.json"
|
echo "$MANIFEST_CHROME" > "${dir}/${MANIFEST_NAME}.json"
|
||||||
|
echo " Wrote: ${dir}/${MANIFEST_NAME}.json"
|
||||||
|
done
|
||||||
|
|
||||||
|
for dir in "${FIREFOX_DIRS[@]}"; do
|
||||||
|
mkdir -p "$dir"
|
||||||
|
echo "$MANIFEST_FIREFOX" > "${dir}/${MANIFEST_NAME}.json"
|
||||||
echo " Wrote: ${dir}/${MANIFEST_NAME}.json"
|
echo " Wrote: ${dir}/${MANIFEST_NAME}.json"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user