Diff
Modified: trunk/JSTests/ChangeLog (208639 => 208640)
--- trunk/JSTests/ChangeLog 2016-11-12 03:10:31 UTC (rev 208639)
+++ trunk/JSTests/ChangeLog 2016-11-12 04:00:55 UTC (rev 208640)
@@ -1,5 +1,17 @@
2016-11-11 Joseph Pecoraro <[email protected]>
+ test262: DataView with explicit undefined byteLength should be the same as it not being present
+ https://bugs.webkit.org/show_bug.cgi?id=164453
+
+ Reviewed by Darin Adler.
+
+ * stress/dataview-construct.js: Added.
+ (assert):
+ (shouldThrow):
+ * test262.yaml:
+
+2016-11-11 Joseph Pecoraro <[email protected]>
+
test262: DataView get methods should allow for missing offset, set methods should allow for missing value
https://bugs.webkit.org/show_bug.cgi?id=164451
Added: trunk/JSTests/stress/dataview-construct.js (0 => 208640)
--- trunk/JSTests/stress/dataview-construct.js (rev 0)
+++ trunk/JSTests/stress/dataview-construct.js 2016-11-12 04:00:55 UTC (rev 208640)
@@ -0,0 +1,76 @@
+function assert(condition) {
+ if (!condition)
+ throw new Error("Bad assertion");
+}
+
+function shouldThrow(func, message) {
+ var errorThrown = false;
+ var error = null;
+ try {
+ func();
+ } catch (e) {
+ errorThrown = true;
+ error = e;
+ }
+ if (!errorThrown)
+ throw new Error('not thrown');
+ if (String(error) !== message)
+ throw new Error("bad error: " + String(error));
+}
+
+var buffer = new ArrayBuffer(128);
+var dataView = null;
+
+dataView = new DataView(buffer);
+assert(dataView.byteOffset === 0);
+assert(dataView.byteLength === 128);
+
+dataView = new DataView(buffer, undefined);
+assert(dataView.byteOffset === 0);
+assert(dataView.byteLength === 128);
+
+dataView = new DataView(buffer, 10);
+assert(dataView.byteOffset === 10);
+assert(dataView.byteLength === 118);
+
+dataView = new DataView(buffer, 10, undefined);
+assert(dataView.byteOffset === 10);
+assert(dataView.byteLength === 118);
+
+dataView = new DataView(buffer, 10, 20);
+assert(dataView.byteOffset === 10);
+assert(dataView.byteLength === 20);
+
+assert(new DataView(buffer, 10).byteLength === new DataView(buffer, 10, undefined).byteLength);
+
+shouldThrow(() => {
+ new DataView;
+}, "TypeError: DataView constructor requires at least one argument.");
+
+shouldThrow(() => {
+ new DataView(1);
+}, "TypeError: Expected ArrayBuffer for the first argument.");
+
+shouldThrow(() => {
+ new DataView(buffer, 256);
+}, "RangeError: Length out of range of buffer");
+
+shouldThrow(() => {
+ new DataView(buffer, -1);
+}, "RangeError: byteOffset cannot be negative");
+
+shouldThrow(() => {
+ new DataView(buffer, Infinity);
+}, "RangeError: byteOffset too large");
+
+shouldThrow(() => {
+ new DataView(buffer, 0, 256);
+}, "RangeError: Length out of range of buffer");
+
+shouldThrow(() => {
+ new DataView(buffer, 0, -1);
+}, "RangeError: byteLength cannot be negative");
+
+shouldThrow(() => {
+ new DataView(buffer, 0, Infinity);
+}, "RangeError: byteLength too large");
Modified: trunk/JSTests/test262.yaml (208639 => 208640)
--- trunk/JSTests/test262.yaml 2016-11-12 03:10:31 UTC (rev 208639)
+++ trunk/JSTests/test262.yaml 2016-11-12 04:00:55 UTC (rev 208640)
@@ -13542,9 +13542,9 @@
- path: test262/test/built-ins/DataView/defined-bytelength-and-byteoffset.js
cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], [:strict]
- path: test262/test/built-ins/DataView/defined-byteoffset-undefined-bytelength.js
- cmd: runTest262 :fail, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], []
+ cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], []
- path: test262/test/built-ins/DataView/defined-byteoffset-undefined-bytelength.js
- cmd: runTest262 :fail, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], [:strict]
+ cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], [:strict]
- path: test262/test/built-ins/DataView/defined-byteoffset.js
cmd: runTest262 :normal, "NoException", ["../../../harness/assert.js", "../../../harness/sta.js"], []
- path: test262/test/built-ins/DataView/defined-byteoffset.js
Modified: trunk/Source/_javascript_Core/ChangeLog (208639 => 208640)
--- trunk/Source/_javascript_Core/ChangeLog 2016-11-12 03:10:31 UTC (rev 208639)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-11-12 04:00:55 UTC (rev 208640)
@@ -1,5 +1,16 @@
2016-11-11 Joseph Pecoraro <[email protected]>
+ test262: DataView with explicit undefined byteLength should be the same as it not being present
+ https://bugs.webkit.org/show_bug.cgi?id=164453
+
+ Reviewed by Darin Adler.
+
+ * runtime/JSGenericTypedArrayViewConstructorInlines.h:
+ (JSC::constructGenericTypedArrayView):
+ Handle the special case of DataView construction with an undefined byteLength value.
+
+2016-11-11 Joseph Pecoraro <[email protected]>
+
test262: DataView get methods should allow for missing offset, set methods should allow for missing value
https://bugs.webkit.org/show_bug.cgi?id=164451
Modified: trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewConstructorInlines.h (208639 => 208640)
--- trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewConstructorInlines.h 2016-11-12 03:10:31 UTC (rev 208639)
+++ trunk/Source/_javascript_Core/runtime/JSGenericTypedArrayViewConstructorInlines.h 2016-11-12 04:00:55 UTC (rev 208640)
@@ -237,8 +237,17 @@
RETURN_IF_EXCEPTION(scope, encodedJSValue());
if (argCount > 2) {
- length = exec->uncheckedArgument(2).toIndex(exec, ViewClass::TypedArrayStorageType == TypeDataView ? "byteLength" : "length");
- RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ if (ViewClass::TypedArrayStorageType == TypeDataView) {
+ // If the DataView byteLength is present but undefined, treat it as missing.
+ JSValue byteLengthValue = exec->uncheckedArgument(2);
+ if (!byteLengthValue.isUndefined()) {
+ length = byteLengthValue.toIndex(exec, "byteLength");
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ }
+ } else {
+ length = exec->uncheckedArgument(2).toIndex(exec, "length");
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ }
}
}