This is an automated email from the ASF dual-hosted git repository. reiern70 pushed a commit to branch unload-listener-1962-11.x in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 2598d97669d4021a7c41adaea1f7eaada7cf638b Author: reiern70 <[email protected]> AuthorDate: Thu Nov 19 14:06:32 2026 -0500 Stop binding an unload listener on window in the Ajax engine The Ajax engine bound a listener for the "unload" event on window to clear the scheduled Ajax timers when the page was left. Browsers are deprecating unload listeners. Chrome is phasing them out; where it has disabled them it does not run the listener and logs a "Permissions policy violation: unload is not allowed in this document" on every page that loads the Ajax engine. Where the listener still runs, it keeps the page out of the back/forward cache. Clearing the timers on unload is not needed in the first place: the timers end with the document that scheduled them. The listener is removed. It is not replaced by a pagehide listener: pagehide also fires when the page enters the back/forward cache, and the timers would then be gone when the user navigates back to it. An application sees no difference when the page is left. A page that is restored from the back/forward cache keeps its running Ajax timers, and pages that were barred from that cache by Wicket's listener alone become eligible for it. Wicket.Timer.clearAll() stays available for applications that want to clear the timers themselves. GitHub issue #1962 --- .../main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js | 7 ------- .../src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax.js | 7 ------- 2 files changed, 14 deletions(-) diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js index 375a15b2b0..9a17a25e98 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js @@ -2586,11 +2586,4 @@ Wicket.Event.add(window, 'focusin', Wicket.Focus.focusin); Wicket.Event.add(window, 'focusout', Wicket.Focus.focusout); - /** - * Clear any scheduled Ajax timers when leaving the current page - */ - Wicket.Event.add(window, "unload", function() { - Wicket.Timer.clearAll(); - }); - })(jQuery); diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax.js index f1469d11ce..e777a464d8 100644 --- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax.js +++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax.js @@ -2861,11 +2861,4 @@ Wicket.Event.add(window, 'focusin', Wicket.Focus.focusin); Wicket.Event.add(window, 'focusout', Wicket.Focus.focusout); - /** - * Clear any scheduled Ajax timers when leaving the current page - */ - Wicket.Event.add(window, "unload", function() { - Wicket.Timer.clearAll(); - }); - })();
