Skip to content

Commit 94e3715

Browse files
committed
mend
1 parent c136969 commit 94e3715

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

core/src/main/resources/lib/form/link/link.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ Behaviour.specify("A.post", "link.post", 0, function (element) {
55
element.removeAttribute("data-post-href");
66
}
77

8-
// Use addEventListener for robust event handling (allows multiple listeners, less prone to overwriting)
9-
// Check if we already attached a listener (avoid duplicates)
108
if (element._postLinkHandlerAttached) {
119
return;
1210
}
1311

14-
// Remove any existing onclick to avoid conflicts
1512
if (element.onclick) {
1613
element.onclick = null;
1714
}
1815

19-
// Create handler function
2016
var postHandler = function (ev) {
2117
if (ev) {
2218
ev.preventDefault();
@@ -31,6 +27,6 @@ Behaviour.specify("A.post", "link.post", 0, function (element) {
3127
return false;
3228
};
3329

34-
element.addEventListener("click", postHandler, true); // Use capture phase to ensure we handle it early
35-
element._postLinkHandlerAttached = true; // Mark as attached
30+
element.addEventListener("click", postHandler, true);
31+
element._postLinkHandlerAttached = true;
3632
});

test/src/test/java/jenkins/model/JenkinsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void testPaneToggleCollapsePostSucceeds() throws Exception {
165165
assertNotNull(paneId, "Collapse link should have data-post-href");
166166

167167
HtmlElementUtil.click(collapseLink);
168-
168+
169169
wc.waitForBackgroundJavaScript(500);
170170

171171
HtmlPage currentPage = (HtmlPage) wc.getCurrentWindow().getEnclosedPage();

test/src/test/java/lib/form/PostLinkTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,30 +106,22 @@ void rapidClicksDoNotCauseRaceCondition() throws Exception {
106106
HtmlAnchor link = page.getAnchorByText("Rapid Click Test");
107107
assertNotNull(link, "POST link should be present");
108108

109-
// Reset counter
110109
rapidClickAction.reset();
111110

112111
// Click multiple times rapidly to simulate race condition
113-
// Note: HtmlUnit may not handle rapid clicks the same way as a real browser,
114-
// but this tests that handlers are attached correctly
115112
for (int i = 0; i < 3; i++) {
116113
try {
117-
// Reload page to get fresh link
118114
page = wc.goTo(rapidClickAction.getUrlName());
119115
wc.waitForBackgroundJavaScript(500);
120116
link = page.getAnchorByText("Rapid Click Test");
121117
HtmlElementUtil.click(link);
122-
// Small delay
123118
Thread.sleep(50);
124119
} catch (Exception e) {
125-
// Ignore navigation exceptions
126120
}
127121
}
128122

129-
// Wait for all requests to complete
130123
Thread.sleep(500);
131124

132-
// Verify POST was called (may be called multiple times, but should all be POST)
133125
assertTrue(rapidClickAction.getCallCount() > 0, "POST action should have been called");
134126
assertFalse(rapidClickAction.wasGetRequest(), "Should not have any GET requests");
135127
}

0 commit comments

Comments
 (0)