1 /*
2 * Copyright (c) 2002-2025 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit;
16
17 /**
18 * A listener for WebWindowEvent's.
19 * <p>
20 * This listener informs when a new window is opened, when the content of a window changes
21 * or when a window is closed.
22 * </p>
23 * <p>
24 * Caution: The WebClient creates (and opens) the initial window as part of the construction
25 * process. This implies, the initial window is already open at the time you attach this listener.
26 * Therefore you will receive no open event for this.
27 * </p>
28 * <p>
29 * Caution: Frames and also iFrames are handled as separate windows. Therefore the listener is also
30 * called for each and every containing (i)Frame when e.g. closing a {@link TopLevelWindow}.
31 * </p>
32 *
33 * @author Mike Bowler
34 * @author Ronald Brill
35 */
36 public interface WebWindowListener {
37
38 /**
39 * A web window has been opened.
40 * <p>Caution: the {@link WebClient#getCurrentWindow()} might be not updated so far.
41 * This usually takes place AFTER the event was processed</p>
42 *
43 * @param event the event (the oldPage and newPage properties will be {@code null}
44 * because the event is generated after the window is opened but before the content is loaded)
45 */
46 void webWindowOpened(WebWindowEvent event);
47
48 /**
49 * The contents of a web window has been changed.
50 *
51 * @param event the event
52 */
53 void webWindowContentChanged(WebWindowEvent event);
54
55 /**
56 * A web window has been closed. Closing the last window of the WebClient will automatically open
57 * a new one. You will receive an additional open event in this case.
58 *
59 * @param event the event
60 */
61 void webWindowClosed(WebWindowEvent event);
62 }
63