Make WordPress Core

Opened 5 weeks ago

Closed 4 weeks ago

#65193 closed enhancement (fixed)

Tests: Add unit tests for wp_page_reload_on_back_button_js()

Reported by: pbearne's profile pbearne Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.1 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch has-unit-tests
Focuses: tests Cc:

Description

This ticket adds unit tests for the wp_page_reload_on_back_button_js() function in wp-admin/includes/misc.php. The tests will verify the correct HTML/JavaScript output.

Change History (4)

This ticket was mentioned in PR #11753 on WordPress/wordpress-develop by @pbearne.


5 weeks ago
#1

  • Keywords has-patch has-unit-tests added

Description:
This PR adds unit tests for the wp_page_reload_on_back_button_js() function in wp-admin/includes/misc.php. This function outputs a small JavaScript snippet designed to force a page reload if the user navigates to the page using the browser's back or forward buttons, ensuring that content (like post titles and editor state) is not stale.

The tests cover:

  • Verification of the <script> tag output.
  • Verification of the performance.navigation.type === 2 check (which detects back/forward navigation).
  • Verification of the document.location.reload( true ) call.

Trac ticket: https://core.trac.wordpress.org/ticket/65193

AI Disclosure:

  • AI assistance: Yes
  • Tool(s): Junie (JetBrains)
  • Model(s): gemini-3-flash-preview
  • Used for: Code analysis, test implementation, and workflow management.

#2 @desrosj
5 weeks ago

  • Focuses tests added

Adding the tests focus, which is used to indicate a ticket is solely focused on adding tests.

#3 @SergeyBiryukov
4 weeks ago

  • Milestone changed from Awaiting Review to 7.1

#4 @SergeyBiryukov
4 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 62367:

Tests: Add unit tests for wp_page_reload_on_back_button_js().

Follow-up to [37619].

Props pbearne.
Fixes #65193.

Note: See TracTickets for help on using tickets.