diff --git a/tests/src/test/java/org/mozilla/javascript/tests/ImportClassTest.java b/tests/src/test/java/org/mozilla/javascript/tests/ImportClassTest.java index 355d246a7b..745bd92627 100644 --- a/tests/src/test/java/org/mozilla/javascript/tests/ImportClassTest.java +++ b/tests/src/test/java/org/mozilla/javascript/tests/ImportClassTest.java @@ -77,21 +77,25 @@ public void importInSameContext() { @Test public void importMultipleTimes() { - Utils.runWithAllOptimizationLevels(cx -> { - ScriptableObject sharedScope = cx.initStandardObjects(); - //sharedScope.sealObject(); code below will try to modify sealed object - - Script script = cx.compileString("importClass(java.util.UUID);true", "TestScript", 1, null); - - for (int i = 0; i < 3; i++) { - Scriptable scope = new ImporterTopLevel(cx); - scope.setParentScope(sharedScope); - script.exec(cx, scope); - assertEquals(UniqueTag.NOT_FOUND, sharedScope.get("UUID", sharedScope)); - assertTrue(scope.get("UUID", scope) instanceof NativeJavaClass); - } - return null; - }); + Utils.runWithAllModes( + cx -> { + ScriptableObject sharedScope = cx.initStandardObjects(); + // sharedScope.sealObject(); // code below will try to modify sealed object + + Script script = + cx.compileString( + "importClass(java.util.UUID);true", "TestScript", 1, null); + + for (int i = 0; i < 3; i++) { + Scriptable scope = new ImporterTopLevel(cx); + scope.setPrototype(sharedScope); + scope.setParentScope(null); + script.exec(cx, scope); + assertEquals(UniqueTag.NOT_FOUND, sharedScope.get("UUID", sharedScope)); + assertTrue(scope.get("UUID", scope) instanceof NativeJavaClass); + } + return null; + }); } private Object runScript(final String scriptSourceText) { diff --git a/tests/src/test/java/org/mozilla/javascript/tests/SealedSharedScopeTest.java b/tests/src/test/java/org/mozilla/javascript/tests/SealedSharedScopeTest.java index c334487638..7888e35c06 100644 --- a/tests/src/test/java/org/mozilla/javascript/tests/SealedSharedScopeTest.java +++ b/tests/src/test/java/org/mozilla/javascript/tests/SealedSharedScopeTest.java @@ -21,7 +21,6 @@ import org.mozilla.javascript.EvaluatorException; import org.mozilla.javascript.IdFunctionObject; import org.mozilla.javascript.ImporterTopLevel; -import org.mozilla.javascript.NativeObject; import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Wrapper; @@ -42,10 +41,12 @@ public void setUp() throws Exception { ctx = Context.enter(); ctx.setLanguageVersion(Context.VERSION_DEFAULT); - scope1 = new NativeObject(); + scope1 = ctx.newObject(sharedScope); scope1.setPrototype(sharedScope); - scope2 = new NativeObject(); + scope1.setParentScope(null); + scope2 = ctx.newObject(sharedScope); scope2.setPrototype(sharedScope); + scope2.setParentScope(null); } @After