Commit 7ca4e9ca authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[errors] Enhance the DataView construction error message

Make it include the invalid length again, but this time consistently.

Bug: chromium:923688
Change-Id: I0ec2543e02b58ff2b79547021a8e0d47a9debe46
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3440068Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78976}
parent aa8cf1f0
......@@ -88,7 +88,8 @@ BUILTIN(DataViewConstructor) {
MessageTemplate::kInvalidDataViewLength));
if (view_byte_offset + byte_length->Number() > buffer_byte_length) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kInvalidDataViewLength));
isolate,
NewRangeError(MessageTemplate::kInvalidDataViewLength, byte_length));
}
view_byte_length = byte_length->Number();
}
......
......@@ -353,7 +353,7 @@ namespace internal {
T(InvalidCountValue, "Invalid count value") \
T(InvalidDataViewAccessorOffset, \
"Offset is outside the bounds of the DataView") \
T(InvalidDataViewLength, "Invalid DataView length") \
T(InvalidDataViewLength, "Invalid DataView length %") \
T(InvalidOffset, "Start offset % is outside the bounds of the buffer") \
T(InvalidHint, "Invalid hint: %") \
T(InvalidIndex, "Invalid value: not (convertible to) a safe integer") \
......
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
let t = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let t2 = new DataView(t.buffer, 8, 1);
*%(basename)s:6: RangeError: Invalid DataView length 1
let t2 = new DataView(t.buffer, 8, 1);
^
RangeError: Invalid DataView length 1
at new DataView (<anonymous>)
at *%(basename)s:6:10
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
let t = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let t2 = new DataView(t.buffer, 7, -1);
*%(basename)s:6: RangeError: Invalid DataView length -1
let t2 = new DataView(t.buffer, 7, -1);
^
RangeError: Invalid DataView length -1
at new DataView (<anonymous>)
at *%(basename)s:6:10
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
let t = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
let t2 = new DataView(t.buffer, 7, {valueOf() { return -1; }});
*%(basename)s:6: RangeError: Invalid DataView length -1
let t2 = new DataView(t.buffer, 7, {valueOf() { return -1; }});
^
RangeError: Invalid DataView length -1
at new DataView (<anonymous>)
at *%(basename)s:6:10
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment