Skip to content

Commit 974b15b

Browse files
committed
1 parent c1be564 commit 974b15b

6 files changed

Lines changed: 23 additions & 7 deletions

File tree

src/main/java/org/htmlunit/HttpMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* @author Mike Bowler
2424
* @author Ahmed Ashour
2525
* @author Marc Guillemot
26-
* @author Ronald Broöö
26+
* @author Ronald Brill
2727
*/
2828
public enum HttpMethod {
2929
/** OPTIONS. */

src/main/java/org/htmlunit/javascript/DebugFrameAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* exists as a convenience for creating debug frame objects.
2424
*
2525
* @author Daniel Gredler
26+
* @author Ronald Brill
2627
*/
2728
public class DebugFrameAdapter implements DebugFrame {
2829

src/main/java/org/htmlunit/javascript/DebugFrameImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@
4444
* HtmlUnit itself, rather than the debugging and development of web applications.
4545
* </p>
4646
*
47+
* @see DebuggerImpl
48+
*
4749
* @author Daniel Gredler
4850
* @author Marc Guillemot
4951
* @author Sven Strickroth
50-
*
51-
* @see DebuggerImpl
52+
* @author Ronald Brill
5253
*/
5354
public class DebugFrameImpl extends DebugFrameAdapter {
5455

src/main/java/org/htmlunit/javascript/DebuggerAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* exists as a convenience for creating debugger objects.
2525
*
2626
* @author Daniel Gredler
27+
* @author Ronald Brill
2728
*/
2829
public class DebuggerAdapter implements Debugger {
2930

src/main/java/org/htmlunit/javascript/DebuggerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@
3838
* {@link HtmlUnitContextFactory#setDebugger(org.htmlunit.corejs.javascript.debug.Debugger)}, passing in
3939
* an instance of this class, and make sure your loggers are configured to output <code>TRACE</code> level log messages.
4040
* </p>
41-
*
42-
* @author Daniel Gredler
4341
* @see DebugFrameImpl
4442
* @see HtmlUnitContextFactory#setDebugger(org.htmlunit.corejs.javascript.debug.Debugger)
43+
*
44+
* @author Daniel Gredler
45+
* @author Ronald Brill
4546
*/
4647
public class DebuggerImpl extends DebuggerAdapter {
4748

src/main/java/org/htmlunit/javascript/JavaScriptEngine.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
import org.htmlunit.corejs.javascript.VarScope;
6161
import org.htmlunit.corejs.javascript.WithScope;
6262
import org.htmlunit.html.DomNode;
63+
import org.htmlunit.html.HtmlElement;
64+
import org.htmlunit.html.HtmlForm;
6365
import org.htmlunit.html.HtmlPage;
6466
import org.htmlunit.javascript.background.BackgroundJavaScriptFactory;
6567
import org.htmlunit.javascript.background.JavaScriptExecutor;
@@ -73,6 +75,7 @@
7375
import org.htmlunit.javascript.host.URLSearchParams;
7476
import org.htmlunit.javascript.host.Window;
7577
import org.htmlunit.javascript.host.dom.DOMException;
78+
import org.htmlunit.javascript.host.html.HTMLElement;
7679
import org.htmlunit.javascript.host.html.HTMLImageElement;
7780
import org.htmlunit.javascript.host.html.HTMLOptionElement;
7881
import org.htmlunit.javascript.host.intl.Intl;
@@ -861,9 +864,18 @@ protected String getSourceCode(final Context cx) {
861864

862865
private static VarScope getScope(final HtmlPage page, final DomNode node) {
863866
final TopLevel topLevel = page.getEnclosingWindow().getTopLevelScope();
864-
if (node != null) {
865-
return new WithScope(topLevel, node.getScriptableObject());
867+
if (node != null && node instanceof HtmlElement htmlElement) {
868+
final HTMLElement elem = htmlElement.getScriptableObject();
869+
WithScope scope = new WithScope(topLevel, elem.getOwnerDocument());
870+
871+
final HtmlForm enclosingForm = htmlElement.getEnclosingForm();
872+
if (enclosingForm != null) {
873+
scope = new WithScope(scope, enclosingForm.getScriptableObject());
874+
}
875+
876+
return new WithScope(scope, node.getScriptableObject());
866877
}
878+
867879
return topLevel;
868880
}
869881

0 commit comments

Comments
 (0)