Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeArrayBuffer.initPrototypeId throws IllegalArgumentException #437

Closed
szegedi opened this issue May 15, 2018 · 2 comments
Closed

NativeArrayBuffer.initPrototypeId throws IllegalArgumentException #437

szegedi opened this issue May 15, 2018 · 2 comments
Assignees

Comments

@szegedi
Copy link
Contributor

szegedi commented May 15, 2018

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)
@szegedi
Copy link
Contributor Author

szegedi commented May 15, 2018

Assigned @gbrail as he authored the class.

szegedi added a commit to szegedi/rhino that referenced this issue Jun 17, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jun 17, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jun 17, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jun 17, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jun 17, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jun 17, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jun 17, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jul 1, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jul 1, 2018
szegedi added a commit to szegedi/rhino that referenced this issue Jul 1, 2018
gbrail pushed a commit that referenced this issue Jul 12, 2018
rbri added a commit to HtmlUnit/htmlunit-rhino-fork that referenced this issue Jul 28, 2018
@gbrail
Copy link
Collaborator

gbrail commented Aug 2, 2018

Fixed by rbri: #464

@gbrail gbrail closed this as completed Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants