NodeIterator.
- * @exception DOMException
+ * @throws DOMException
* NOT_SUPPORTED_ERR: Raised if the specified root is null.
*/
public DomNodeIterator createNodeIterator(final Node root, final int whatToShow, final NodeFilter filter,
diff --git a/src/main/java/org/htmlunit/WebClient.java b/src/main/java/org/htmlunit/WebClient.java
index d176d5326c2..acd8fbcde20 100644
--- a/src/main/java/org/htmlunit/WebClient.java
+++ b/src/main/java/org/htmlunit/WebClient.java
@@ -16,8 +16,6 @@
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.htmlunit.BrowserVersionFeatures.HTTP_HEADER_CH_UA;
-import static org.htmlunit.BrowserVersionFeatures.HTTP_HEADER_PRIORITY;
import java.io.BufferedInputStream;
import java.io.File;
@@ -26,6 +24,8 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.Serializable;
+import java.lang.ref.Cleaner;
+import java.lang.ref.Cleaner.Cleanable;
import java.lang.ref.WeakReference;
import java.net.MalformedURLException;
import java.net.URL;
@@ -164,6 +164,8 @@ public class WebClient implements Serializable, AutoCloseable {
private static final WebResponseData RESPONSE_DATA_NO_HTTP_RESPONSE = new WebResponseData(
0, "No HTTP Response", Collections.emptyList());
+ static final Cleaner CLEANER = Cleaner.create();
+
/**
* These response headers are not copied from a 304 response to the cached
* response headers. This list is based on Chromium http_response_headers.cc
@@ -1364,6 +1366,18 @@ public void deregisterWebWindow(final WebWindow webWindow) {
}
}
+ /**
+ * Registers an object and a cleaning action to run when the object
+ * becomes phantom reachable. This forwards the call to our static {@link Cleaner}.
+ *
+ * @param obj the object to monitor
+ * @param action a {@code Runnable} to invoke when the object becomes phantom reachable
+ * @return a {@code Cleanable} instance
+ */
+ public static Cleanable registerCleanerAction(final Object obj, final Runnable action) {
+ return CLEANER.register(obj, action);
+ }
+
/**
* Expands a relative URL relative to the specified base. In most situations
* this is the same as new URL(baseUrl, relativeUrl) but
@@ -1707,6 +1721,10 @@ && getOptions().isRedirectEnabled()) {
for (final Map.Entry+ * This is used to compute the value of the {@code Sec-Fetch-Dest} request + * header (see + * https://www.w3.org/TR/fetch-metadata/) and also determines the default + * {@link FetchMode} to be used, unless explicitly overridden via + * {@link #setFetchModeOverride(FetchMode)}. + *
+ */ + public enum FetchDestination { + /** A top-level document, e.g. loaded by the address bar, a link, or a form submission. */ + DOCUMENT("document"), + /** A nested browsing context of type {@code