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

hazendaz / httpunit / 636

05 Dec 2025 03:27AM UTC coverage: 80.509%. Remained the same
636

push

github

hazendaz
Cleanup more old since tags

you guessed it, at this point going to jautodoc the rest so the warnings on builds go away ;)

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8249 of 10132 relevant lines covered (81.42%)

0.81 hits per line

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

76.19
/src/main/java/com/meterware/httpunit/dom/DomWindow.java
1
/*
2
 * MIT License
3
 *
4
 * Copyright 2011-2025 Russell Gold
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
9
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions
12
 * of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
15
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
 * DEALINGS IN THE SOFTWARE.
19
 */
20
package com.meterware.httpunit.dom;
21

22
import com.meterware.httpunit.scripting.ScriptingHandler;
23

24
import java.io.IOException;
25
import java.net.URL;
26

27
import org.mozilla.javascript.Scriptable;
28
import org.w3c.dom.html.HTMLDocument;
29
import org.xml.sax.SAXException;
30

31
public class DomWindow extends AbstractDomComponent implements Scriptable {
32

33
    private static final long serialVersionUID = 1L;
34
    private DomWindowProxy _proxy;
35
    private HTMLDocumentImpl _document;
36

37
    /**
38
     * construct me from a document
39
     *
40
     * @param document
41
     */
42
    public DomWindow(HTMLDocumentImpl document) {
1✔
43
        _document = document;
1✔
44
    }
1✔
45

46
    public DomWindow(DomWindowProxy implementation) {
×
47
        _proxy = implementation;
×
48
    }
×
49

50
    public void setProxy(DomWindowProxy proxy) {
51
        _proxy = proxy;
1✔
52
    }
1✔
53

54
    public DomWindow getWindow() {
55
        return this;
1✔
56
    }
57

58
    public DomWindow getSelf() {
59
        return this;
1✔
60
    }
61

62
    public HTMLDocument getDocument() {
63
        return _document;
1✔
64
    }
65

66
    /**
67
     * Returns the document associated with this window. Uses the same name as that used by elements in the DOM.
68
     */
69
    public HTMLDocument getOwnerDocument() {
70
        return _document;
×
71
    }
72

73
    /**
74
     * Opens a named window.
75
     *
76
     * @param urlString
77
     *            the location (relative to the current page) from which to populate the window.
78
     * @param name
79
     *            the name of the window.
80
     * @param features
81
     *            special features for the window.
82
     * @param replace
83
     *            if true, replaces the contents of an existing window.
84
     *
85
     * @return a new populated window object
86
     */
87
    public DomWindow open(String urlString, String name, String features, boolean replace) {
88
        try {
89
            if (_proxy == null) {
1!
90
                throw new RuntimeException("DomWindow.open failed for '" + name + "' _proxy is null");
×
91
            }
92

93
            DomWindowProxy newWindow = _proxy.openNewWindow(name, urlString);
1✔
94
            if (newWindow == null) {
1!
95
                // throw new RuntimeException("DomWindow.open failed for '"+name+"','"+urlString+"' openNewWindow
96
                // returned null");
97
                return null;
×
98
            }
99
            ScriptingHandler result = newWindow.getScriptingHandler();
1✔
100
            return (DomWindow) result;
1✔
101
        } catch (IOException | SAXException e) {
×
102
            return null;
×
103
        }
104
    }
105

106
    /**
107
     * Closes the current window. Has no effect if this "window" is actually a nested frame.
108
     */
109
    public void close() {
110
        _proxy.close();
1✔
111
    }
1✔
112

113
    /**
114
     * Displays an alert box with the specified message.
115
     *
116
     * @param message
117
     *            the message to display
118
     */
119
    public void alert(String message) {
120
        _proxy.alert(message);
1✔
121
    }
1✔
122

123
    /**
124
     * Displays a prompt, asking for a yes or no answer and returns the answer.
125
     *
126
     * @param prompt
127
     *            the prompt text to display
128
     *
129
     * @return true if the user answered 'yes'
130
     */
131
    public boolean confirm(String prompt) {
132
        return _proxy.confirm(prompt);
1✔
133
    }
134

135
    /**
136
     * Displays a promptand returns the user's textual reply, which could be the default reply.
137
     *
138
     * @param message
139
     *            the prompt text to display
140
     * @param defaultResponse
141
     *            the response to return if the user doesn't enter anything
142
     *
143
     * @return the reply selected by the user.
144
     */
145
    public String prompt(String message, String defaultResponse) {
146
        return _proxy.prompt(message, defaultResponse);
1✔
147
    }
148

149
    public void setTimeout(int timeout) {
150
    }
1✔
151

152
    public void focus() {
153
    }
1✔
154

155
    public void moveTo(int x, int y) {
156
    }
1✔
157

158
    public void scrollTo(int x, int y) {
159
    }
1✔
160

161
    @Override
162
    protected String getDocumentWriteBuffer() {
163
        return _document.getWriteBuffer().toString();
1✔
164
    }
165

166
    @Override
167
    protected void discardDocumentWriteBuffer() {
168
        _document.clearWriteBuffer();
1✔
169
    }
1✔
170

171
    boolean replaceText(String string, String mimeType) {
172
        return _proxy.replaceText(string, mimeType);
1✔
173
    }
174

175
    URL getUrl() {
176
        return _proxy.getURL();
1✔
177
    }
178

179
    void submitRequest(HTMLElementImpl sourceElement, String method, String location, String target, byte[] requestBody)
180
            throws IOException, SAXException {
181
        _proxy.submitRequest(sourceElement, method, location, target, null);
1✔
182
    }
1✔
183
}
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