-
Notifications
You must be signed in to change notification settings - Fork 900
Closed
Description
Trying to access property "isView" on a NativeArrayBuffer
throws an IllegalArgumentException
. The issue seems to be that PrototypeValues.maxId
for NativeArrayBuffer
is 3 (to account for Id_isView
property) but initPrototypeId
only recognizes Id_constructor
and Id_slice
.
Id_isView
seems to have some special handling as it's separately initialized; there's this whole business with it and ConstructorId_isView
that I don't fully understand how's it supposed to work.
Here's a little test that illustrates the issue:
package org.mozilla.javascript.tests;
import junit.framework.TestCase;
import org.mozilla.javascript.*;
public class ArrayBufferInitTest extends TestCase {
public void test() throws Exception {
Context cx = Context.enter();
cx.setLanguageVersion(Context.VERSION_ES6);
Scriptable global = cx.initStandardObjects();
cx.evaluateString(global, "(new ArrayBuffer(5)).isView", "", 1, null);
Context.exit();
}
}
It results in:
java.lang.IllegalArgumentException: 3
at org.mozilla.javascript.typedarrays.NativeArrayBuffer.initPrototypeId(NativeArrayBuffer.java:156)
at org.mozilla.javascript.IdScriptableObject$PrototypeValues.ensureId(IdScriptableObject.java:312)
at org.mozilla.javascript.IdScriptableObject$PrototypeValues.get(IdScriptableObject.java:190)
at org.mozilla.javascript.IdScriptableObject.get(IdScriptableObject.java:410)
at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:2331)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1579)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1572)
at org.mozilla.javascript.gen.c_1._c_script_0(:1)
at org.mozilla.javascript.gen.c_1.call()
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:404)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3508)
at org.mozilla.javascript.gen.c_1.call()
at org.mozilla.javascript.gen.c_1.exec()
at org.mozilla.javascript.Context.evaluateString(Context.java:1266)
at org.mozilla.javascript.tests.ArrayBufferInitTest.test(ArrayBufferInitTest.java:13)
Metadata
Metadata
Assignees
Labels
No labels