[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/+/3440068 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/main@{#78976}
This commit is contained in:
parent
aa8cf1f0c2
commit
7ca4e9cad5
@ -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") \
|
||||
|
6
test/message/fail/data-view-invalid-length-1.js
Normal file
6
test/message/fail/data-view-invalid-length-1.js
Normal file
@ -0,0 +1,6 @@
|
||||
// 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);
|
6
test/message/fail/data-view-invalid-length-1.out
Normal file
6
test/message/fail/data-view-invalid-length-1.out
Normal file
@ -0,0 +1,6 @@
|
||||
*%(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
|
6
test/message/fail/data-view-invalid-length-2.js
Normal file
6
test/message/fail/data-view-invalid-length-2.js
Normal file
@ -0,0 +1,6 @@
|
||||
// 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);
|
6
test/message/fail/data-view-invalid-length-2.out
Normal file
6
test/message/fail/data-view-invalid-length-2.out
Normal file
@ -0,0 +1,6 @@
|
||||
*%(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
|
6
test/message/fail/data-view-invalid-length-3.js
Normal file
6
test/message/fail/data-view-invalid-length-3.js
Normal file
@ -0,0 +1,6 @@
|
||||
// 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; }});
|
6
test/message/fail/data-view-invalid-length-3.out
Normal file
6
test/message/fail/data-view-invalid-length-3.out
Normal file
@ -0,0 +1,6 @@
|
||||
*%(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
|
Loading…
Reference in New Issue
Block a user