Skip to content

Commit a4f6282

Browse files
committed
scope handling (wip)
1 parent b929959 commit a4f6282

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/main/java/org/htmlunit/javascript/host/Window.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ public History getHistory() {
744744
@JsxGetter
745745
public External getExternal() {
746746
final External external = new External();
747-
external.setParentScope(this);
747+
external.setParentScope(getParentScope());
748748
external.setPrototype(getPrototype(external.getClass()));
749749
return external;
750750
}
@@ -2155,7 +2155,7 @@ public boolean find(final String search, final boolean caseSensitive,
21552155
@JsxGetter({CHROME, EDGE})
21562156
public SpeechSynthesis getSpeechSynthesis() {
21572157
final SpeechSynthesis speechSynthesis = new SpeechSynthesis();
2158-
speechSynthesis.setParentScope(this);
2158+
speechSynthesis.setParentScope(getParentScope());
21592159
speechSynthesis.setPrototype(getPrototype(speechSynthesis.getClass()));
21602160
return speechSynthesis;
21612161
}

src/main/java/org/htmlunit/javascript/host/abort/AbortController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class AbortController extends HtmlUnitScriptable {
3636
@JsxConstructor
3737
public void jsConstructor() {
3838
signal_ = new AbortSignal();
39-
signal_.setParentScope(this);
39+
signal_.setParentScope(getParentScope());
4040
signal_.setPrototype(getPrototype(signal_.getClass()));
4141
}
4242

src/main/java/org/htmlunit/javascript/host/worker/DedicatedWorkerGlobalScope.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ void loadAndExecute(final WebClient webClient, final String url,
336336
final URL fullUrl = page.getFullyQualifiedUrl(url);
337337

338338
workerLocation_ = new WorkerLocation(fullUrl, origin_);
339-
workerLocation_.setParentScope(this);
339+
workerLocation_.setParentScope(getParentScope());
340340
workerLocation_.setPrototype(getPrototype(workerLocation_.getClass()));
341341

342342
workerNavigator_ = new WorkerNavigator(webClient.getBrowserVersion());
343-
workerNavigator_.setParentScope(this);
343+
workerNavigator_.setParentScope(getParentScope());
344344
workerNavigator_.setPrototype(getPrototype(workerNavigator_.getClass()));
345345

346346
final WebRequest webRequest = new WebRequest(fullUrl);
@@ -353,9 +353,8 @@ void loadAndExecute(final WebClient webClient, final String url,
353353
final String scriptCode = response.getContentAsString();
354354
final AbstractJavaScriptEngine<?> javaScriptEngine = webClient.getJavaScriptEngine();
355355

356-
final DedicatedWorkerGlobalScope thisScope = this;
357356
final ContextAction<Object> action =
358-
cx -> javaScriptEngine.execute(page, thisScope, scriptCode, fullUrl.toExternalForm(), 1);
357+
cx -> javaScriptEngine.execute(page, getParentScope(), scriptCode, fullUrl.toExternalForm(), 1);
359358

360359
final HtmlUnitContextFactory cf = javaScriptEngine.getContextFactory();
361360

0 commit comments

Comments
 (0)