• 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

64.71
/src/main/java/com/meterware/httpunit/javascript/JavaScriptEngineFactory.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.javascript;
9

10
import com.meterware.httpunit.HTMLElement;
11
import com.meterware.httpunit.HttpUnitUtils;
12
import com.meterware.httpunit.WebResponse;
13
import com.meterware.httpunit.scripting.ScriptableDelegate;
14
import com.meterware.httpunit.scripting.ScriptingEngineFactory;
15
import com.meterware.httpunit.scripting.ScriptingHandler;
16

17
/**
18
 * An implementation of the scripting engine factory which selects a Rhino-based implementation of JavaScript.
19
 **/
20
public class JavaScriptEngineFactory implements ScriptingEngineFactory {
1✔
21

22
    @Override
23
    public boolean isEnabled() {
24
        try {
25
            Class.forName("org.mozilla.javascript.Context");
1✔
26
            return true;
1✔
27
        } catch (Exception e) {
×
28
            System.err.println("Rhino classes (js.jar) not found - Javascript disabled");
×
29
            return false;
×
30
        }
31
    }
32

33
    @Override
34
    public void associate(WebResponse response) {
35
        try {
36
            JavaScript.run(response);
1✔
37
        } catch (RuntimeException e) {
×
38
            throw e;
×
39
        } catch (Exception e) {
×
40
            HttpUnitUtils.handleException(e);
×
41
            throw new RuntimeException(e.toString());
×
42
        }
1✔
43
    }
1✔
44

45
    @Override
46
    public void load(WebResponse response) {
47
        try {
48
            JavaScript.load(response);
1✔
49
        } catch (RuntimeException e) {
1✔
50
            throw e;
1✔
51
        } catch (Exception e) {
×
52
            e.printStackTrace();
×
53
            throw new RuntimeException(e.toString());
×
54
        }
1✔
55
    }
1✔
56

57
    @Override
58
    public void setThrowExceptionsOnError(boolean throwExceptions) {
59
        JavaScript.setThrowExceptionsOnError(throwExceptions);
1✔
60
    }
1✔
61

62
    @Override
63
    public boolean isThrowExceptionsOnError() {
64
        return JavaScript.isThrowExceptionsOnError();
×
65
    }
66

67
    @Override
68
    public String[] getErrorMessages() {
69
        return ScriptingEngineImpl.getErrorMessages();
1✔
70
    }
71

72
    /**
73
     * delegate the handling for Script exceptions
74
     */
75
    @Override
76
    public void handleScriptException(Exception e, String badScript) {
77
        ScriptingEngineImpl.handleScriptException(e, badScript);
1✔
78
    }
1✔
79

80
    @Override
81
    public void clearErrorMessages() {
82
        ScriptingEngineImpl.clearErrorMessages();
1✔
83
    }
1✔
84

85
    @Override
86
    public ScriptingHandler createHandler(HTMLElement elementBase) {
87
        ScriptableDelegate delegate = elementBase.newScriptable();
1✔
88
        delegate.setScriptEngine(elementBase.getParentDelegate().getScriptEngine(delegate));
1✔
89
        return delegate;
1✔
90
    }
91

92
    @Override
93
    public ScriptingHandler createHandler(WebResponse response) {
94
        return response.createJavascriptScriptingHandler();
1✔
95
    }
96

97
}
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