forked from qtwebkit/qtwebkit
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JSC] Update ArrayBuffer#resize's detach check timing
https://bugs.webkit.org/show_bug.cgi?id=259076 rdar://112041092 Reviewed by Mark Lam. Change the order of detach check according to the latest spec[1], but this only changes the type of error (from RangeError to TypeError). [1]: tc39/ecma262#3116 * JSTests/stress/arraybuffer-resizable-resize-update.js: Added. (shouldThrow): * Source/JavaScriptCore/runtime/JSArrayBufferPrototype.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/265935@main
- Loading branch information
1 parent
6eb8d1e
commit 1510211
Showing
2 changed files
with
27 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function shouldThrow(func, errorMessage) { | ||
var errorThrown = false; | ||
var error = null; | ||
try { | ||
func(); | ||
} catch (e) { | ||
errorThrown = true; | ||
error = e; | ||
} | ||
if (!errorThrown) | ||
throw new Error('not thrown'); | ||
if (String(error) !== errorMessage) | ||
throw new Error(`bad error: ${String(error)}`); | ||
} | ||
|
||
let buffer = new ArrayBuffer(16, {maxByteLength: 16}); | ||
shouldThrow(() => { | ||
buffer.resize({ | ||
valueOf() { | ||
$.detachArrayBuffer(buffer); | ||
return 0; | ||
} | ||
}); | ||
}, `TypeError: Receiver is detached`); |
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