mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-26 11:41:13 +08:00
feat: ArrayBuffer 三访问器与 markImmutable 及 detach 宿主真化
This commit is contained in:
@@ -63,11 +63,6 @@ fn eval_script_syntax_error_is_catchable() {
|
||||
/// 未实现方法抛能力缺失错误(消息带 `not supported`),不抛 ReferenceError。
|
||||
#[test]
|
||||
fn unsupported_methods_throw_not_supported() {
|
||||
let r =
|
||||
eval("try { $262.detachArrayBuffer(new ArrayBuffer(8)); 'no-throw' } catch (e) { e.name + ':' + e.message }");
|
||||
assert!(r.contains("TypeError"), "期望 TypeError,实际 {r}");
|
||||
assert!(r.contains("not supported"), "期望能力缺失消息,实际 {r}");
|
||||
|
||||
let r = eval("try { $262.createRealm(); 'no-throw' } catch (e) { e.name + ':' + e.message }");
|
||||
assert!(r.contains("TypeError"), "期望 TypeError,实际 {r}");
|
||||
assert!(r.contains("not supported"), "期望能力缺失消息,实际 {r}");
|
||||
@@ -76,6 +71,15 @@ fn unsupported_methods_throw_not_supported() {
|
||||
assert!(r.contains("TypeError"), "期望 TypeError,实际 {r}");
|
||||
}
|
||||
|
||||
/// `detachArrayBuffer` 真实现钉:detach 后 `detached` 访问器读 true、
|
||||
/// 非 ArrayBuffer 实参抛 TypeError。
|
||||
#[test]
|
||||
fn detach_array_buffer_detaches() {
|
||||
assert_eq!(eval("var ab = new ArrayBuffer(8); $262.detachArrayBuffer(ab); ab.detached"), "true");
|
||||
let r = eval("try { $262.detachArrayBuffer(1); 'no-throw' } catch (e) { e.name }");
|
||||
assert_eq!(r, "TypeError");
|
||||
}
|
||||
|
||||
/// `$262.gc()` 触发一次 session 回收且不抛错。
|
||||
#[test]
|
||||
fn gc_runs_without_error() {
|
||||
|
||||
Reference in New Issue
Block a user