Implement ArrayBuffer.isView
https://bugs.webkit.org/show_bug.cgi?id=126004
Reviewed by Filip Pizlo.
Source/JavaScriptCore:
Test coverage in webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html
* runtime/JSArrayBufferConstructor.cpp:
(JSC::JSArrayBufferConstructor::finishCreation): Add 'isView' to object constructor.
(JSC::arrayBufferFuncIsView): New method.
LayoutTests:
* webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html:
Correct test for 'isView' to actually check for 'isView' function.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160876 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index a0b4a9c..9c5e470 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2013-12-19 Brent Fulgham <bfulgham@apple.com>
+
+ Implement ArrayBuffer.isView
+ https://bugs.webkit.org/show_bug.cgi?id=126004
+
+ Reviewed by Filip Pizlo.
+
+ * webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html:
+ Correct test for 'isView' to actually check for 'isView' function.
+
2013-12-19 Alexey Proskuryakov <ap@apple.com>
Layout Test plugins/destroy-during-npp-new.html is flaky
diff --git a/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html b/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html
index 0ada09d..3a5d995 100644
--- a/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html
+++ b/LayoutTests/webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html
@@ -148,7 +148,7 @@
debug('test ArrayBuffer.isView() with various values');
try {
- if (!ArrayBuffer.create) {
+ if (!ArrayBuffer.isView) {
testFailed('ArrayBuffer.isView() method does not exist');
} else {
testPassed('ArrayBuffer.isView() method exists');
diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog
index 1c97beb..2990ebc 100644
--- a/Source/JavaScriptCore/ChangeLog
+++ b/Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,16 @@
+2013-12-19 Brent Fulgham <bfulgham@apple.com>
+
+ Implement ArrayBuffer.isView
+ https://bugs.webkit.org/show_bug.cgi?id=126004
+
+ Reviewed by Filip Pizlo.
+
+ Test coverage in webgl/1.0.2/resources/webgl_test_files/conformance/typedarrays/array-unit-tests.html
+
+ * runtime/JSArrayBufferConstructor.cpp:
+ (JSC::JSArrayBufferConstructor::finishCreation): Add 'isView' to object constructor.
+ (JSC::arrayBufferFuncIsView): New method.
+
2013-12-19 Mark Lam <mark.lam@apple.com>
Fix broken C loop LLINT build.
diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.h b/Source/JavaScriptCore/runtime/CommonIdentifiers.h
index d4e4ed2..e4c2685 100644
--- a/Source/JavaScriptCore/runtime/CommonIdentifiers.h
+++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.h
@@ -112,6 +112,7 @@
macro(instructionCount) \
macro(isArray) \
macro(isPrototypeOf) \
+ macro(isView) \
macro(isWatchpoint) \
macro(join) \
macro(keys) \
diff --git a/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp b/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
index fdeb9ea..ca7e030 100644
--- a/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
@@ -35,6 +35,8 @@
namespace JSC {
+static EncodedJSValue JSC_HOST_CALL arrayBufferFuncIsView(ExecState*);
+
const ClassInfo JSArrayBufferConstructor::s_info = {
"Function", &Base::s_info, 0, 0,
CREATE_METHOD_TABLE(JSArrayBufferConstructor)
@@ -50,6 +52,9 @@
Base::finishCreation(vm, "ArrayBuffer");
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontEnum | DontDelete | ReadOnly);
+
+ JSGlobalObject* globalObject = this->globalObject();
+ JSC_NATIVE_FUNCTION(vm.propertyNames->isView, arrayBufferFuncIsView, DontEnum, 1);
}
JSArrayBufferConstructor* JSArrayBufferConstructor::create(VM& vm, Structure* structure, JSArrayBufferPrototype* prototype)
@@ -108,5 +113,14 @@
return CallTypeHost;
}
+// ------------------------------ Functions --------------------------------
+
+// ECMA 24.1.3.1
+EncodedJSValue JSC_HOST_CALL arrayBufferFuncIsView(ExecState* exec)
+{
+ return JSValue::encode(jsBoolean(jsDynamicCast<JSArrayBufferView*>(exec->argument(0))));
+}
+
+
} // namespace JSC