• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / httpunit / 755

14 Feb 2026 07:14PM UTC coverage: 80.526%. Remained the same
755

push

github

hazendaz
[ci] Fix badge

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10124 relevant lines covered (81.44%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/main/java/com/meterware/httpunit/dom/HTMLEventHandler.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2000-2026 Russell Gold
6
 * Copyright 2021-2000 hazendaz
7
 */
8
package com.meterware.httpunit.dom;
9

10
import org.mozilla.javascript.Context;
11
import org.mozilla.javascript.Function;
12

13
/**
14
 * The handler for HTML events.
15
 */
16
class HTMLEventHandler {
17

18
    /** The base element. */
19
    private HTMLElementImpl _baseElement;
20

21
    /** The handler name. */
22
    private String _handlerName;
23

24
    /** The handler. */
25
    private Function _handler;
26

27
    /**
28
     * create a handler for the given HTML Event.
29
     *
30
     * @param baseElement
31
     *            the base element
32
     * @param handlerName
33
     *            the handler name
34
     */
35
    public HTMLEventHandler(HTMLElementImpl baseElement, String handlerName) {
1✔
36
        _baseElement = baseElement;
1✔
37
        _handlerName = handlerName;
1✔
38
    }
1✔
39

40
    /**
41
     * set the handler Function for this event Handler.
42
     *
43
     * @param handler
44
     *            the new handler
45
     */
46
    void setHandler(Function handler) {
47
        _handler = handler;
×
48
    }
×
49

50
    /**
51
     * get the (cached) handler Function for this event Handler on first access compile the function.
52
     *
53
     * @return the handler
54
     */
55
    Function getHandler() {
56
        if (_handler == null) {
1✔
57
            String attribute = _baseElement.getAttributeWithNoDefault(_handlerName);
1✔
58
            if (attribute != null && Context.getCurrentContext() != null) {
1!
59
                _handler = Context.getCurrentContext().compileFunction(_baseElement,
1✔
60
                        "function " + AbstractDomComponent.createAnonymousFunctionName() + "() { " + attribute + "}",
1✔
61
                        "httpunit", 0, null);
62
            }
63
        }
64
        return _handler;
1✔
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc