diff --git a/crates/js/src/builtins/promise.rs b/crates/js/src/builtins/promise.rs index 276acf7e96..4c1b826c0e 100644 --- a/crates/js/src/builtins/promise.rs +++ b/crates/js/src/builtins/promise.rs @@ -30,7 +30,9 @@ use std::rc::Rc; use super::{arg, constructor, create_at, method, native, new_array}; use crate::LimitKind; use crate::bytecode::Code; -use crate::heap::{BOUND_ARG_BYTES, Class, Func, NativeFn, NativeKind, OBJECT_BYTES, OPEN, ObjId, Object, PROP_BYTES, Prop, Roots, key}; +use crate::heap::{ + BOUND_ARG_BYTES, CONFIGURABLE, Class, Func, NativeFn, NativeKind, OBJECT_BYTES, OPEN, ObjId, Object, PROP_BYTES, Prop, Roots, key, +}; use crate::interp::{Abrupt, ErrorType, Interp, JsResult}; use crate::string_builtins::flat_charged; use crate::value::Value; @@ -258,6 +260,9 @@ pub(crate) fn install(interp: &mut Interp) -> JsResult<()> { let object_proto = interp.intrinsics.object_proto; let proto = interp.heap.alloc_object(Object::new(Class::Ordinary, Some(object_proto))); interp.promises.proto = Some(proto); + if let Some(tag) = interp.well_known(|w| &w.to_string_tag) { + interp.define_sym(proto, tag, Prop::Data { value: Value::str("Promise"), flags: CONFIGURABLE })?; + } let ctor = native(interp, "Promise", promise_ctor, 1, NativeKind::Plain, true)?; interp.promises.ctor = Some(ctor); constructor(interp, "Promise", ctor, proto)?; diff --git a/crates/js/src/promise_tests.rs b/crates/js/src/promise_tests.rs index 915427de89..7799d63469 100644 --- a/crates/js/src/promise_tests.rs +++ b/crates/js/src/promise_tests.rs @@ -57,6 +57,22 @@ fn promise_prototype_cannot_be_replaced() { assert_eq!(string(src), "true,true,true"); } +#[test] +fn promise_prototype_has_a_configurable_string_tag() { + assert_eq!( + string( + "var d = Object.getOwnPropertyDescriptor(Promise.prototype, Symbol.toStringTag); \ + [Object.prototype.toString.call(Promise.prototype), \ + Object.prototype.toString.call(Promise.resolve()), \ + d.value, d.writable, d.enumerable, d.configurable].join()" + ), + "[object Promise],[object Promise],Promise,false,false,true" + ); + let mut r = Realm::new(); + r.add_es2015(); + assert_eq!(r.run("Object.prototype.toString.call(Promise.resolve())").unwrap(), JsValue::String("[object Promise]".into())); +} + #[test] fn then_callbacks_run_after_the_scripts_code_in_order() { let src = "Promise.resolve(1).then(function (v) { log.push('a' + v); });\n\ diff --git a/docs/mcp.md b/docs/mcp.md index 437569a1f9..b0dfeb9411 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2880,6 +2880,8 @@ In a `.js` script, `Promise` follows ECMA-262 11th edition section 25.6 `Promise.resolve`, `reject`, `all`, `allSettled` and `race`. `Promise.any` is not provided. These are VectorCraft's own rules: +- `Promise.prototype[Symbol.toStringTag]` is `"Promise"` when Symbols are available. The property is configurable, + non-enumerable and non-writable. Promise instances also report `[object Promise]` in engines without Symbols. - The callbacks `then`, `catch` and `finally` register run as jobs, one at a time, in the order they were queued, after the script's own code ends and before the run ends; a job a callback queues runs after the jobs already waiting. A promise still pending when no job is left stays pending, and the run ends. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 043ae5c403..c0bf5036cd 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -32,6 +32,8 @@ ## Feature submission evidence +Scripts: `Promise.prototype[Symbol.toStringTag]` is `"Promise"` when Symbols are available, with a configurable, non-enumerable, non-writable descriptor. Promise instances report `[object Promise]` in engines without Symbols. Test: `promise_prototype_has_a_configurable_string_tag` in `crates/js/src/promise_tests.rs`. + Variables panel row context menus (2026-11-20, G12): Right-click highlights the clicked variable without changing the canvas selection and offers Select Bound Object, Variable Options…, Unbind Variable, the four Make Dynamic actions, and Delete Variable. Shift+F10 opens the same menu for the focused row; Escape dismisses it. Row actions target that variable; dynamic actions use the canvas selection. Lock and selection checks disable unavailable actions. Headless pointer/accessibility tests cover opening the menu, highlighting, bound-object selection, deletion in one undo step and restoration, and disabled actions. Scores and estimates unchanged. Actions panel item context menus (2026-11-20): Right-clicking an Action Set row selects it and presents a context menu with New Action…, New Set…, Duplicate Set, Delete Set, and Set Options…. Right-clicking an Action row selects it and presents a context menu with Play, Record, Duplicate, Delete, Action Options…, and Batch…. Duplicate on an action duplicates that action and selects the duplicate; Delete removes it. Headless tests in `crates/ui-egui/src/panels/actions.rs`: `right_clicking_an_action_set_selects_it_and_presents_set_context_options`, `right_clicking_an_action_selects_it_and_presents_action_options`, and `clicking_duplicate_on_an_action_duplicates_that_action_in_the_set`. Scores and estimates unchanged.