• 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

76.19
/src/main/java/com/meterware/httpunit/dom/DomWindow.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 com.meterware.httpunit.scripting.ScriptingHandler;
11

12
import java.io.IOException;
13
import java.net.URL;
14

15
import org.mozilla.javascript.Scriptable;
16
import org.w3c.dom.html.HTMLDocument;
17
import org.xml.sax.SAXException;
18

19
/**
20
 * The Class DomWindow.
21
 */
22
public class DomWindow extends AbstractDomComponent implements Scriptable {
23

24
    /** The Constant serialVersionUID. */
25
    private static final long serialVersionUID = 1L;
26

27
    /** The proxy. */
28
    private DomWindowProxy _proxy;
29

30
    /** The document. */
31
    private HTMLDocumentImpl _document;
32

33
    /**
34
     * construct me from a document.
35
     *
36
     * @param document
37
     *            the document
38
     */
39
    public DomWindow(HTMLDocumentImpl document) {
1✔
40
        _document = document;
1✔
41
    }
1✔
42

43
    /**
44
     * Instantiates a new dom window.
45
     *
46
     * @param implementation
47
     *            the implementation
48
     */
49
    public DomWindow(DomWindowProxy implementation) {
×
50
        _proxy = implementation;
×
51
    }
×
52

53
    /**
54
     * Sets the proxy.
55
     *
56
     * @param proxy
57
     *            the new proxy
58
     */
59
    public void setProxy(DomWindowProxy proxy) {
60
        _proxy = proxy;
1✔
61
    }
1✔
62

63
    /**
64
     * Gets the window.
65
     *
66
     * @return the window
67
     */
68
    public DomWindow getWindow() {
69
        return this;
1✔
70
    }
71

72
    /**
73
     * Gets the self.
74
     *
75
     * @return the self
76
     */
77
    public DomWindow getSelf() {
78
        return this;
1✔
79
    }
80

81
    /**
82
     * Gets the document.
83
     *
84
     * @return the document
85
     */
86
    public HTMLDocument getDocument() {
87
        return _document;
1✔
88
    }
89

90
    /**
91
     * Returns the document associated with this window. Uses the same name as that used by elements in the DOM.
92
     *
93
     * @return the owner document
94
     */
95
    public HTMLDocument getOwnerDocument() {
96
        return _document;
×
97
    }
98

99
    /**
100
     * Opens a named window.
101
     *
102
     * @param urlString
103
     *            the location (relative to the current page) from which to populate the window.
104
     * @param name
105
     *            the name of the window.
106
     * @param features
107
     *            special features for the window.
108
     * @param replace
109
     *            if true, replaces the contents of an existing window.
110
     *
111
     * @return a new populated window object
112
     */
113
    public DomWindow open(String urlString, String name, String features, boolean replace) {
114
        try {
115
            if (_proxy == null) {
1!
116
                throw new RuntimeException("DomWindow.open failed for '" + name + "' _proxy is null");
×
117
            }
118

119
            DomWindowProxy newWindow = _proxy.openNewWindow(name, urlString);
1✔
120
            if (newWindow == null) {
1!
121
                // throw new RuntimeException("DomWindow.open failed for '"+name+"','"+urlString+"' openNewWindow
122
                // returned null");
123
                return null;
×
124
            }
125
            ScriptingHandler result = newWindow.getScriptingHandler();
1✔
126
            return (DomWindow) result;
1✔
127
        } catch (IOException | SAXException e) {
×
128
            return null;
×
129
        }
130
    }
131

132
    /**
133
     * Closes the current window. Has no effect if this "window" is actually a nested frame.
134
     */
135
    public void close() {
136
        _proxy.close();
1✔
137
    }
1✔
138

139
    /**
140
     * Displays an alert box with the specified message.
141
     *
142
     * @param message
143
     *            the message to display
144
     */
145
    public void alert(String message) {
146
        _proxy.alert(message);
1✔
147
    }
1✔
148

149
    /**
150
     * Displays a prompt, asking for a yes or no answer and returns the answer.
151
     *
152
     * @param prompt
153
     *            the prompt text to display
154
     *
155
     * @return true if the user answered 'yes'
156
     */
157
    public boolean confirm(String prompt) {
158
        return _proxy.confirm(prompt);
1✔
159
    }
160

161
    /**
162
     * Displays a promptand returns the user's textual reply, which could be the default reply.
163
     *
164
     * @param message
165
     *            the prompt text to display
166
     * @param defaultResponse
167
     *            the response to return if the user doesn't enter anything
168
     *
169
     * @return the reply selected by the user.
170
     */
171
    public String prompt(String message, String defaultResponse) {
172
        return _proxy.prompt(message, defaultResponse);
1✔
173
    }
174

175
    /**
176
     * Sets the timeout.
177
     *
178
     * @param timeout
179
     *            the new timeout
180
     */
181
    public void setTimeout(int timeout) {
182
    }
1✔
183

184
    /**
185
     * Focus.
186
     */
187
    public void focus() {
188
    }
1✔
189

190
    /**
191
     * Move to.
192
     *
193
     * @param x
194
     *            the x
195
     * @param y
196
     *            the y
197
     */
198
    public void moveTo(int x, int y) {
199
    }
1✔
200

201
    /**
202
     * Scroll to.
203
     *
204
     * @param x
205
     *            the x
206
     * @param y
207
     *            the y
208
     */
209
    public void scrollTo(int x, int y) {
210
    }
1✔
211

212
    @Override
213
    protected String getDocumentWriteBuffer() {
214
        return _document.getWriteBuffer().toString();
1✔
215
    }
216

217
    @Override
218
    protected void discardDocumentWriteBuffer() {
219
        _document.clearWriteBuffer();
1✔
220
    }
1✔
221

222
    /**
223
     * Replace text.
224
     *
225
     * @param string
226
     *            the string
227
     * @param mimeType
228
     *            the mime type
229
     *
230
     * @return true, if successful
231
     */
232
    boolean replaceText(String string, String mimeType) {
233
        return _proxy.replaceText(string, mimeType);
1✔
234
    }
235

236
    /**
237
     * Gets the url.
238
     *
239
     * @return the url
240
     */
241
    URL getUrl() {
242
        return _proxy.getURL();
1✔
243
    }
244

245
    /**
246
     * Submit request.
247
     *
248
     * @param sourceElement
249
     *            the source element
250
     * @param method
251
     *            the method
252
     * @param location
253
     *            the location
254
     * @param target
255
     *            the target
256
     * @param requestBody
257
     *            the request body
258
     *
259
     * @throws IOException
260
     *             Signals that an I/O exception has occurred.
261
     * @throws SAXException
262
     *             the SAX exception
263
     */
264
    void submitRequest(HTMLElementImpl sourceElement, String method, String location, String target, byte[] requestBody)
265
            throws IOException, SAXException {
266
        _proxy.submitRequest(sourceElement, method, location, target, null);
1✔
267
    }
1✔
268
}
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