Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JSC] Update resizable ArrayBuffer based on spec update
https://bugs.webkit.org/show_bug.cgi?id=248511 rdar://102793557 Reviewed by Ross Kirsling. * LayoutTests/js/dom/resizable-array-buffer-view-serialization-out-of-bounds-expected.txt: * LayoutTests/js/dom/resizable-array-buffer-view-serialization-out-of-bounds-explicit-length-expected.txt: * LayoutTests/js/dom/resizable-array-buffer-view-serialization-out-of-bounds-explicit-length.html: * LayoutTests/js/dom/resizable-array-buffer-view-serialization-out-of-bounds.html: * LayoutTests/js/dom/resizable-data-view-serialization-out-of-bounds-expected.txt: Added. * LayoutTests/js/dom/resizable-data-view-serialization-out-of-bounds-explicit-length-expected.txt: Added. * LayoutTests/js/dom/resizable-data-view-serialization-out-of-bounds-explicit-length.html: Copied from LayoutTests/js/dom/resizable-array-buffer-view-serialization-out-of-bounds-explicit-length.html. * LayoutTests/js/dom/resizable-data-view-serialization-out-of-bounds.html: Copied from LayoutTests/js/dom/resizable-array-buffer-view-serialization-out-of-bounds.html. * Source/JavaScriptCore/runtime/JSArrayBufferView.h: (JSC::JSArrayBufferView::isDetached const): (JSC::JSArrayBufferView::byteOffset const): (JSC::JSArrayBufferView::isOutOfBounds const): Add isOutOfBounds, function aligned to spec's IsArrayBufferViewOutOfBounds. Used in SerializedScriptValue. (JSC::JSArrayBufferView::isDetached): Deleted. * Source/JavaScriptCore/runtime/JSArrayBufferViewInlines.h: (JSC::isArrayBufferViewOutOfBounds): (JSC::isIntegerIndexedObjectOutOfBounds): * Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototypeFunctions.h: (JSC::genericTypedArrayViewProtoFuncSet): This is not actually changing the behavior, but more aligned to the latest spec's change. * Source/WebCore/bindings/js/SerializedScriptValue.cpp: (WebCore::CloneSerializer::dumpArrayBufferView): We reject OOB ArrayBuffer based on discussion in [1]. [1]: whatwg/html#8559 Canonical link: https://commits.webkit.org/257178@main
- Loading branch information
1 parent
464a308
commit ba8ba25ae962e03ccfaa78f078741374667e3475
Showing
12 changed files
with
202 additions
and
57 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Resizable ArrayBuffers should be serializable OOB | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS arrayBuffer.resizable is true | ||
PASS arrayBuffer.byteLength is 36 | ||
PASS arrayBuffer.maxByteLength is 128 | ||
PASS view.byteLength is 32 | ||
PASS view.byteOffset is 4 | ||
PASS structuredClone(view) threw exception DataCloneError: The object can not be cloned.. | ||
PASS arrayBuffer.resizable is true | ||
PASS arrayBuffer.byteLength is 0 | ||
PASS arrayBuffer.maxByteLength is 128 | ||
PASS view.byteLength threw exception TypeError: Underlying ArrayBuffer has been detached from the view or out-of-bounds. | ||
PASS view.byteOffset threw exception TypeError: Underlying ArrayBuffer has been detached from the view or out-of-bounds. | ||
PASS arrayBuffer.resizable is true | ||
PASS arrayBuffer.byteLength is 36 | ||
PASS arrayBuffer.maxByteLength is 128 | ||
PASS view.byteLength is 32 | ||
PASS view.byteOffset is 4 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Resizable ArrayBuffers should be serializable OOB explicit length | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS arrayBuffer.resizable is true | ||
PASS arrayBuffer.byteLength is 36 | ||
PASS arrayBuffer.maxByteLength is 128 | ||
PASS view.byteLength is 4 | ||
PASS view.byteOffset is 4 | ||
PASS structuredClone(view) threw exception DataCloneError: The object can not be cloned.. | ||
PASS arrayBuffer.resizable is true | ||
PASS arrayBuffer.byteLength is 0 | ||
PASS arrayBuffer.maxByteLength is 128 | ||
PASS view.byteLength threw exception TypeError: Underlying ArrayBuffer has been detached from the view or out-of-bounds. | ||
PASS view.byteOffset threw exception TypeError: Underlying ArrayBuffer has been detached from the view or out-of-bounds. | ||
PASS arrayBuffer.resizable is true | ||
PASS arrayBuffer.byteLength is 36 | ||
PASS arrayBuffer.maxByteLength is 128 | ||
PASS view.byteLength is 4 | ||
PASS view.byteOffset is 4 | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE HTML><!-- webkit-test-runner [ jscOptions=--useResizableArrayBuffer=true,--useSharedArrayBuffer=true ] --> | ||
<html> | ||
<head> | ||
<title>Resizable ArrayBuffers serialization</title> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Resizable ArrayBuffers should be serializable OOB explicit length"); | ||
var arrayBuffer = new ArrayBuffer(36, { maxByteLength: 128 }); | ||
var view = new DataView(arrayBuffer, 4, 4); | ||
shouldBeTrue(`arrayBuffer.resizable`); | ||
shouldBe(`arrayBuffer.byteLength`, `36`); | ||
shouldBe(`arrayBuffer.maxByteLength`, `128`); | ||
shouldBe(`view.byteLength`, `4`); | ||
shouldBe(`view.byteOffset`, `4`); | ||
arrayBuffer.resize(0); | ||
shouldThrow(`structuredClone(view)`); | ||
shouldBeTrue(`arrayBuffer.resizable`); | ||
shouldBe(`arrayBuffer.byteLength`, `0`); | ||
shouldBe(`arrayBuffer.maxByteLength`, `128`); | ||
shouldThrow(`view.byteLength`); | ||
shouldThrow(`view.byteOffset`); | ||
arrayBuffer.resize(36); | ||
shouldBeTrue(`arrayBuffer.resizable`); | ||
shouldBe(`arrayBuffer.byteLength`, `36`); | ||
shouldBe(`arrayBuffer.maxByteLength`, `128`); | ||
shouldBe(`view.byteLength`, `4`); | ||
shouldBe(`view.byteOffset`, `4`); | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE HTML><!-- webkit-test-runner [ jscOptions=--useResizableArrayBuffer=true,--useSharedArrayBuffer=true ] --> | ||
<html> | ||
<head> | ||
<title>Resizable ArrayBuffers serialization</title> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<script> | ||
description("Resizable ArrayBuffers should be serializable OOB"); | ||
var arrayBuffer = new ArrayBuffer(36, { maxByteLength: 128 }); | ||
var view = new DataView(arrayBuffer, 4); | ||
shouldBeTrue(`arrayBuffer.resizable`); | ||
shouldBe(`arrayBuffer.byteLength`, `36`); | ||
shouldBe(`arrayBuffer.maxByteLength`, `128`); | ||
shouldBe(`view.byteLength`, `32`); | ||
shouldBe(`view.byteOffset`, `4`); | ||
arrayBuffer.resize(0); | ||
shouldThrow(`structuredClone(view)`); | ||
shouldBeTrue(`arrayBuffer.resizable`); | ||
shouldBe(`arrayBuffer.byteLength`, `0`); | ||
shouldBe(`arrayBuffer.maxByteLength`, `128`); | ||
shouldThrow(`view.byteLength`); | ||
shouldThrow(`view.byteOffset`); | ||
arrayBuffer.resize(36); | ||
shouldBeTrue(`arrayBuffer.resizable`); | ||
shouldBe(`arrayBuffer.byteLength`, `36`); | ||
shouldBe(`arrayBuffer.maxByteLength`, `128`); | ||
shouldBe(`view.byteLength`, `32`); | ||
shouldBe(`view.byteOffset`, `4`); | ||
</script> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
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
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
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
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