Merge pull request #3316 from daboe01/new-platform-unload-fix

fixed: terminate on pagehide instead of unload instead of unload
This commit is contained in:
daboe01
2026-09-28 15:48:47 +02:00
committed by GitHub
+15 -1
View File
@@ -57,11 +57,25 @@ var screenNeedsInitialization = NO,
return [CPApp _sendDelegateApplicationShouldTerminateMessage];
};
window.onunload = function()
var terminateApplication = function()
{
[self closeAllPlatformWindows];
[CPApp terminate:nil];
};
// "unload" is blocked by the permissions policy in current Chrome and prevents the
// back/forward cache. "pagehide" fires reliably instead. If event.persisted is true the
// page goes into the bfcache and may be restored, so the application must not terminate.
if ("onpagehide" in window)
{
window.addEventListener("pagehide", function(anEvent)
{
if (!anEvent.persisted)
terminateApplication();
}, NO);
}
else
window.onunload = terminateApplication;
}
}