Skip to content

Commit

Permalink
reducing the core-js dependencies (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Oct 9, 2023
1 parent 2b3e33d commit 7b87556
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/htmlunit/DialogWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package org.htmlunit;

import org.htmlunit.corejs.javascript.ScriptableObject;
import org.htmlunit.javascript.HtmlUnitScriptable;

/**
* A window opened in JavaScript via either <code>window.showModalDialog</code>
Expand Down Expand Up @@ -66,9 +66,9 @@ public WebWindow getTopWindow() {
* {@inheritDoc}
*/
@Override
public <T> void setScriptableObject(final T scriptObject) {
if (scriptObject instanceof ScriptableObject) {
((ScriptableObject) scriptObject).put("dialogArguments", (ScriptableObject) scriptObject, arguments_);
public <T extends HtmlUnitScriptable> void setScriptableObject(final T scriptObject) {
if (scriptObject != null) {
scriptObject.put("dialogArguments", scriptObject, arguments_);
}
super.setScriptableObject(scriptObject);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/htmlunit/WebWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.htmlunit.css.ComputedCssStyleDeclaration;
import org.htmlunit.html.DomElement;
import org.htmlunit.javascript.HtmlUnitScriptable;
import org.htmlunit.javascript.background.JavaScriptJobManager;

/**
Expand Down Expand Up @@ -97,7 +98,7 @@ public interface WebWindow extends Serializable {
* @param <T> the object type
* @param scriptObject the JavaScript object
*/
<T> void setScriptableObject(T scriptObject);
<T extends HtmlUnitScriptable> void setScriptableObject(T scriptObject);

/**
* <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/htmlunit/WebWindowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.htmlunit.corejs.javascript.Scriptable;
import org.htmlunit.css.ComputedCssStyleDeclaration;
import org.htmlunit.css.ElementCssStyleDeclaration;
import org.htmlunit.html.DomElement;
import org.htmlunit.html.HtmlPage;
import org.htmlunit.javascript.HtmlUnitScriptable;
import org.htmlunit.javascript.background.BackgroundJavaScriptFactory;
import org.htmlunit.javascript.background.JavaScriptJobManager;
import org.htmlunit.javascript.host.Element;
Expand Down Expand Up @@ -60,7 +60,7 @@ public abstract class WebWindowImpl implements WebWindow {
private final WebClient webClient_;
private final Screen screen_;
private Page enclosedPage_;
private transient Object scriptObject_;
private transient HtmlUnitScriptable scriptObject_;
private JavaScriptJobManager jobManager_;
private final List<WebWindowImpl> childWindows_ = new ArrayList<>();
private String name_ = "";
Expand Down Expand Up @@ -177,7 +177,7 @@ public void setEnclosedPage(final Page page) {
* {@inheritDoc}
*/
@Override
public <T> void setScriptableObject(final T scriptObject) {
public <T extends HtmlUnitScriptable> void setScriptableObject(final T scriptObject) {
scriptObject_ = scriptObject;
}

Expand Down Expand Up @@ -368,12 +368,12 @@ public void setOuterHeight(final int outerHeight) {

private void writeObject(final ObjectOutputStream oos) throws IOException {
oos.defaultWriteObject();
oos.writeObject(scriptObject_ instanceof Scriptable ? scriptObject_ : null);
oos.writeObject(scriptObject_);
}

private void readObject(final ObjectInputStream ois) throws ClassNotFoundException, IOException {
ois.defaultReadObject();
scriptObject_ = ois.readObject();
scriptObject_ = (HtmlUnitScriptable) ois.readObject();
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/org/htmlunit/archunit/ArchitectureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,12 @@ public void check(final JavaMethod method, final ConditionEvents events) {
.and().doNotHaveFullyQualifiedName("org.htmlunit.WebConsole")
.and().doNotHaveFullyQualifiedName("org.htmlunit.ScriptException")
.and().doNotHaveFullyQualifiedName("org.htmlunit.ScriptResult")
.and().doNotHaveFullyQualifiedName("org.htmlunit.DialogWindow")
.and().doNotHaveFullyQualifiedName("org.htmlunit.html.DomNode")
.and().doNotHaveFullyQualifiedName("org.htmlunit.html.DomElement")
.and().doNotHaveFullyQualifiedName("org.htmlunit.html.HtmlDialog")
.and().doNotHaveFullyQualifiedName("org.htmlunit.html.HtmlDialog$1")
.and().doNotHaveFullyQualifiedName("org.htmlunit.html.HtmlInput")
.and().doNotHaveFullyQualifiedName("org.htmlunit.html.HtmlPage")
.and().doNotHaveFullyQualifiedName("org.htmlunit.WebWindowImpl")
.and().doNotHaveFullyQualifiedName("org.htmlunit.html.impl.SimpleRange")
.and().doNotHaveFullyQualifiedName("org.htmlunit.util.DebuggingWebConnection")
.and().doNotHaveFullyQualifiedName("org.htmlunit.util.WebClientUtils")
Expand Down

0 comments on commit 7b87556

Please sign in to comment.