This is an automated email from the ASF dual-hosted git repository. reiern70 pushed a commit to branch unload-listener-1962 in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 07525293862ee272efabd5f8eb373ddcecd413cf 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 99ae9fbfa9..b4560c3ab0 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 @@ -2716,11 +2716,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 1647a3cc4e..5a0badf71f 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 @@ -2929,11 +2929,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(); - }); - })();
