Skip to content

Commit

Permalink
We still need a slightly changes setup of the wrapper
Browse files Browse the repository at this point in the history
Revert "Auxiliary commit to revert individual files from 053eff6"
This reverts commit b8de434084f42894670e1286bf67da4b7d8fecaf.
  • Loading branch information
rbri committed Nov 20, 2023
1 parent b6464c1 commit 271e314
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.htmlunit.corejs.javascript.Script;
import org.htmlunit.corejs.javascript.ScriptRuntime;
import org.htmlunit.corejs.javascript.Scriptable;
import org.htmlunit.corejs.javascript.WrapFactory;
import org.htmlunit.corejs.javascript.debug.Debugger;
import org.htmlunit.html.HtmlElement;
import org.htmlunit.html.HtmlPage;
Expand All @@ -59,6 +60,7 @@ public class HtmlUnitContextFactory extends ContextFactory {
private final BrowserVersion browserVersion_;
private long timeout_;
private Debugger debugger_;
private final WrapFactory wrapFactory_ = new HtmlUnitWrapFactory();
private boolean deminifyFunctionCode_;

/**
Expand Down Expand Up @@ -291,6 +293,7 @@ protected Context makeContext() {
cx.setInstructionObserverThreshold(INSTRUCTION_COUNT_THRESHOLD);

cx.setErrorReporter(new HtmlUnitErrorReporter(webClient_.getJavaScriptErrorListener()));
cx.setWrapFactory(wrapFactory_);

if (debugger_ != null) {
cx.setDebugger(debugger_, null);
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/org/htmlunit/javascript/HtmlUnitWrapFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2002-2023 Gargoyle Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.htmlunit.javascript;

import java.io.Serializable;

import org.htmlunit.corejs.javascript.Scriptable;
import org.htmlunit.corejs.javascript.WrapFactory;

/**
* Called by Rhino to Wrap Object as {@link Scriptable}.
*
* @author Marc Guillemot
* @author Ronald Brill
*/
public class HtmlUnitWrapFactory extends WrapFactory implements Serializable {

/**
* Constructor.
*/
public HtmlUnitWrapFactory() {
setJavaPrimitiveWrap(false); // We don't want to wrap String & Co.
}
}

0 comments on commit 271e314

Please sign in to comment.