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

hazendaz / httpunit / 656

06 Dec 2025 09:11PM UTC coverage: 80.452% (+0.02%) from 80.435%
656

push

github

hazendaz
[maven-release-plugin] prepare for next development iteration

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10137 relevant lines covered (81.34%)

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
/**
32
 * The Class DomWindow.
33
 */
34
public class DomWindow extends AbstractDomComponent implements Scriptable {
35

36
    /** The Constant serialVersionUID. */
37
    private static final long serialVersionUID = 1L;
38

39
    /** The proxy. */
40
    private DomWindowProxy _proxy;
41

42
    /** The document. */
43
    private HTMLDocumentImpl _document;
44

45
    /**
46
     * construct me from a document.
47
     *
48
     * @param document
49
     *            the document
50
     */
51
    public DomWindow(HTMLDocumentImpl document) {
1✔
52
        _document = document;
1✔
53
    }
1✔
54

55
    /**
56
     * Instantiates a new dom window.
57
     *
58
     * @param implementation
59
     *            the implementation
60
     */
61
    public DomWindow(DomWindowProxy implementation) {
×
62
        _proxy = implementation;
×
63
    }
×
64

65
    /**
66
     * Sets the proxy.
67
     *
68
     * @param proxy
69
     *            the new proxy
70
     */
71
    public void setProxy(DomWindowProxy proxy) {
72
        _proxy = proxy;
1✔
73
    }
1✔
74

75
    /**
76
     * Gets the window.
77
     *
78
     * @return the window
79
     */
80
    public DomWindow getWindow() {
81
        return this;
1✔
82
    }
83

84
    /**
85
     * Gets the self.
86
     *
87
     * @return the self
88
     */
89
    public DomWindow getSelf() {
90
        return this;
1✔
91
    }
92

93
    /**
94
     * Gets the document.
95
     *
96
     * @return the document
97
     */
98
    public HTMLDocument getDocument() {
99
        return _document;
1✔
100
    }
101

102
    /**
103
     * Returns the document associated with this window. Uses the same name as that used by elements in the DOM.
104
     *
105
     * @return the owner document
106
     */
107
    public HTMLDocument getOwnerDocument() {
108
        return _document;
×
109
    }
110

111
    /**
112
     * Opens a named window.
113
     *
114
     * @param urlString
115
     *            the location (relative to the current page) from which to populate the window.
116
     * @param name
117
     *            the name of the window.
118
     * @param features
119
     *            special features for the window.
120
     * @param replace
121
     *            if true, replaces the contents of an existing window.
122
     *
123
     * @return a new populated window object
124
     */
125
    public DomWindow open(String urlString, String name, String features, boolean replace) {
126
        try {
127
            if (_proxy == null) {
1!
128
                throw new RuntimeException("DomWindow.open failed for '" + name + "' _proxy is null");
×
129
            }
130

131
            DomWindowProxy newWindow = _proxy.openNewWindow(name, urlString);
1✔
132
            if (newWindow == null) {
1!
133
                // throw new RuntimeException("DomWindow.open failed for '"+name+"','"+urlString+"' openNewWindow
134
                // returned null");
135
                return null;
×
136
            }
137
            ScriptingHandler result = newWindow.getScriptingHandler();
1✔
138
            return (DomWindow) result;
1✔
139
        } catch (IOException | SAXException e) {
×
140
            return null;
×
141
        }
142
    }
143

144
    /**
145
     * Closes the current window. Has no effect if this "window" is actually a nested frame.
146
     */
147
    public void close() {
148
        _proxy.close();
1✔
149
    }
1✔
150

151
    /**
152
     * Displays an alert box with the specified message.
153
     *
154
     * @param message
155
     *            the message to display
156
     */
157
    public void alert(String message) {
158
        _proxy.alert(message);
1✔
159
    }
1✔
160

161
    /**
162
     * Displays a prompt, asking for a yes or no answer and returns the answer.
163
     *
164
     * @param prompt
165
     *            the prompt text to display
166
     *
167
     * @return true if the user answered 'yes'
168
     */
169
    public boolean confirm(String prompt) {
170
        return _proxy.confirm(prompt);
1✔
171
    }
172

173
    /**
174
     * Displays a promptand returns the user's textual reply, which could be the default reply.
175
     *
176
     * @param message
177
     *            the prompt text to display
178
     * @param defaultResponse
179
     *            the response to return if the user doesn't enter anything
180
     *
181
     * @return the reply selected by the user.
182
     */
183
    public String prompt(String message, String defaultResponse) {
184
        return _proxy.prompt(message, defaultResponse);
1✔
185
    }
186

187
    /**
188
     * Sets the timeout.
189
     *
190
     * @param timeout
191
     *            the new timeout
192
     */
193
    public void setTimeout(int timeout) {
194
    }
1✔
195

196
    /**
197
     * Focus.
198
     */
199
    public void focus() {
200
    }
1✔
201

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

213
    /**
214
     * Scroll to.
215
     *
216
     * @param x
217
     *            the x
218
     * @param y
219
     *            the y
220
     */
221
    public void scrollTo(int x, int y) {
222
    }
1✔
223

224
    @Override
225
    protected String getDocumentWriteBuffer() {
226
        return _document.getWriteBuffer().toString();
1✔
227
    }
228

229
    @Override
230
    protected void discardDocumentWriteBuffer() {
231
        _document.clearWriteBuffer();
1✔
232
    }
1✔
233

234
    /**
235
     * Replace text.
236
     *
237
     * @param string
238
     *            the string
239
     * @param mimeType
240
     *            the mime type
241
     *
242
     * @return true, if successful
243
     */
244
    boolean replaceText(String string, String mimeType) {
245
        return _proxy.replaceText(string, mimeType);
1✔
246
    }
247

248
    /**
249
     * Gets the url.
250
     *
251
     * @return the url
252
     */
253
    URL getUrl() {
254
        return _proxy.getURL();
1✔
255
    }
256

257
    /**
258
     * Submit request.
259
     *
260
     * @param sourceElement
261
     *            the source element
262
     * @param method
263
     *            the method
264
     * @param location
265
     *            the location
266
     * @param target
267
     *            the target
268
     * @param requestBody
269
     *            the request body
270
     *
271
     * @throws IOException
272
     *             Signals that an I/O exception has occurred.
273
     * @throws SAXException
274
     *             the SAX exception
275
     */
276
    void submitRequest(HTMLElementImpl sourceElement, String method, String location, String target, byte[] requestBody)
277
            throws IOException, SAXException {
278
        _proxy.submitRequest(sourceElement, method, location, target, null);
1✔
279
    }
1✔
280
}
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