Skip to content

Commit 2b91d05

Browse files
committed
sope handling (wip)
1 parent c7d098f commit 2b91d05

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public void jsConstructor() {
127127
final BrowserVersion browserVersion = webClient.getBrowserVersion();
128128

129129
final TopLevel scope = context.initSafeStandardObjects(new TopLevel(this));
130+
this.setParentScope(scope);
130131
JavaScriptEngine.configureRhino(webClient, browserVersion, scope, this);
131132

132133
final WorkerJavaScriptConfiguration jsConfig = WorkerJavaScriptConfiguration.getInstance(browserVersion);
@@ -143,8 +144,8 @@ public void jsConstructor() {
143144

144145
final FunctionObject functionObject =
145146
new FunctionObject(DedicatedWorkerGlobalScope.class.getSimpleName(),
146-
config.getJsConstructor().getValue(), this);
147-
functionObject.addAsConstructor(this, prototype, ScriptableObject.DONTENUM);
147+
config.getJsConstructor().getValue(), scope);
148+
functionObject.addAsConstructor(scope, prototype, ScriptableObject.DONTENUM);
148149

149150
JavaScriptEngine.configureGlobalThis(scope, this, config, functionObject, jsConfig,
150151
browserVersion, prototypes, prototypesPerJSName);

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ public Worker() {
4949
workerScope_ = null;
5050
}
5151

52-
private Worker(final Context cx, final Window owningWindow, final String url,
53-
final Scriptable options) throws Exception {
52+
private Worker(final Context cx, final Scriptable scope,
53+
final Window owningWindow, final String url,
54+
final Scriptable options) throws Exception {
5455
super();
55-
setParentScope(owningWindow);
56+
setParentScope(scope);
5657
setPrototype(getPrototype(getClass()));
5758

5859
final WebClient webClient = getWindow().getWebWindow().getWebClient();
@@ -88,7 +89,7 @@ public static Worker jsConstructor(final Context cx, final Scriptable scope,
8889
if (args.length > 1 && args[1] instanceof Scriptable scriptable) {
8990
options = scriptable;
9091
}
91-
return new Worker(cx, getWindow(ctorObj), url, options);
92+
return new Worker(cx, scope, getWindow(ctorObj), url, options);
9293
}
9394

9495
/**

0 commit comments

Comments
 (0)