Created
May 9, 2011 20:00
-
-
Save sdwilsh/963265 to your computer and use it in GitHub Desktop.
JS API test file for possible Typed Arrays Bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- | |
* vim: set ts=4 sw=4 et tw=99: | |
*/ | |
#include "tests.h" | |
#include "jsobj.h" | |
BEGIN_TEST(testPrototypeLookup) | |
{ | |
jsval arrVal; | |
EVAL("new Uint8Array(new ArrayBuffer(10))", &arrVal); | |
JSObject* obj = JSVAL_TO_OBJECT(arrVal); | |
CHECK(JS_SetProperty(cx, global, "arr", &arrVal)); | |
JSObject* newProto = JS_NewObject(cx, NULL, NULL, JS_GetParent(cx, obj)); | |
CHECK(newProto); | |
jsval tp = INT_TO_JSVAL(42); | |
CHECK(JS_SetProperty(cx, newProto, "testprop", &tp)); | |
JSObject* ref = JS_GetPrototype(cx, obj); | |
js_DumpObject(ref); | |
CHECK(JS_SetPrototype(cx, ref, newProto)); | |
CHECK(newProto == JS_GetPrototype(cx, ref)); | |
jsval lookup; | |
CHECK(JS_GetProperty(cx, obj, "testprop", &lookup)); | |
CHECK(JSVAL_TO_INT(lookup) == 42); | |
jsval jsLookup; | |
EVAL("arr.testprop", &jsLookup); | |
CHECK(JSVAL_TO_INT(jsLookup) == 42); | |
return true; | |
} | |
END_TEST(testPrototypeLookup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment