Skip to content

Commit

Permalink
It works when I get the symbol by eval Symbol.for
Browse files Browse the repository at this point in the history
```
$ ./target/debug/deno test cli/tests/unit/message_channel_test.ts
running 2 tests from ./cli/tests/unit/message_channel_test.ts
messagechannel ... ok (34ms)
messagechannel clone port ...result=Some(false) constructor=Object keys.length=0, identity hash:253732785 is_object false is_symbol true
result=Some(true) constructor=MessagePort keys.length=4, identity hash:253732785 is_object false is_symbol true
0 symbol "Deno.core.customHostObject" is true, hash 253732785 is_object false is_symbol true
1 symbol "[[webidl.brand]]" is false, hash 764160415 is_object false is_symbol true
2 symbol "undefined" is false, hash 758685447 is_object false is_symbol true
3 symbol "id" is false, hash 997007839 is_object false is_symbol true
 ok (19ms)

ok | 2 passed | 0 failed (141ms)
```
  • Loading branch information
lrowe committed Sep 16, 2023
1 parent 0410188 commit fde7947
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/ops_builtin_v8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,14 @@ impl<'a> v8::ValueSerializerImpl for SerializeDeserialize<'a> {
scope: &mut v8::HandleScope<'s>,
object: v8::Local<'s, v8::Object>,
) -> Option<bool> {
let description = v8::String::new(scope, "Deno.core.customHostObject").unwrap();
let customHostObject = v8::Symbol::for_global(scope, description);
//let description = v8::String::new(scope, "Deno.core.customHostObject").unwrap();
//let customHostObject = v8::Symbol::for_global(scope, description);
let code = "Symbol.for('Deno.core.customHostObject')";
let source = v8::String::new(scope, code).unwrap();
let script = v8::Script::compile(scope, source, None).unwrap();
let script_result = script.run(scope).unwrap();;
let customHostObject = unsafe { v8::Local::<v8::Symbol>::cast(script_result) };

let result = object.has_own_property(scope, customHostObject.into());
let keys = object.get_own_property_names(scope, v8::GetPropertyNamesArgs {
mode: v8::KeyCollectionMode::OwnOnly,
Expand Down

0 comments on commit fde7947

Please sign in to comment.