You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of trying to detect upfront if an object can be serialized,
just do it and see if it throws a DataCloneError.
Unexpected DataCloneErrors were of course already being handled but
the new approach does it in a centralized and generic manner.
Failed serialization now passes an object with a single "error" string
property back to Ruby land.
Fixes the failing test from rubyjs#329
Copy file name to clipboardExpand all lines: test/mini_racer_test.rb
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -893,14 +893,13 @@ def test_wasm_ref
893
893
skip"TruffleRuby does not support WebAssembly"
894
894
end
895
895
context=MiniRacer::Context.new
896
-
# Error: [object Object] could not be cloned
897
-
assert_raises(MiniRacer::RuntimeError)do
898
-
context.eval("
899
-
var b = [0,97,115,109,1,0,0,0,1,26,5,80,0,95,0,80,0,95,1,127,0,96,0,1,110,96,1,100,2,1,111,96,0,1,100,3,3,4,3,3,2,4,7,26,2,12,99,114,101,97,116,101,83,116,114,117,99,116,0,1,7,114,101,102,70,117,110,99,0,2,9,5,1,3,0,1,0,10,23,3,8,0,32,0,20,2,251,27,11,7,0,65,12,251,0,1,11,4,0,210,0,11,0,44,4,110,97,109,101,1,37,3,0,11,101,120,112,111,114,116,101,100,65,110,121,1,12,99,114,101,97,116,101,83,116,114,117,99,116,2,7,114,101,102,70,117,110,99]
900
-
var o = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array(b))).exports
901
-
o.refFunc()(o.createStruct) // exotic object
902
-
")
903
-
end
896
+
expected={"error"=>"Error: [object Object] could not be cloned."}
897
+
actual=context.eval("
898
+
var b = [0,97,115,109,1,0,0,0,1,26,5,80,0,95,0,80,0,95,1,127,0,96,0,1,110,96,1,100,2,1,111,96,0,1,100,3,3,4,3,3,2,4,7,26,2,12,99,114,101,97,116,101,83,116,114,117,99,116,0,1,7,114,101,102,70,117,110,99,0,2,9,5,1,3,0,1,0,10,23,3,8,0,32,0,20,2,251,27,11,7,0,65,12,251,0,1,11,4,0,210,0,11,0,44,4,110,97,109,101,1,37,3,0,11,101,120,112,111,114,116,101,100,65,110,121,1,12,99,114,101,97,116,101,83,116,114,117,99,116,2,7,114,101,102,70,117,110,99]
899
+
var o = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array(b))).exports
900
+
o.refFunc()(o.createStruct) // exotic object
901
+
")
902
+
assert_equalexpected,actual
904
903
end
905
904
906
905
deftest_proxy_support
@@ -1060,16 +1059,17 @@ def test_map
1060
1059
1061
1060
deftest_regexp_string_iterator
1062
1061
context=MiniRacer::Context.new
1063
-
exc=false
1064
-
begin
1065
-
context.eval("'abc'.matchAll(/./g)")
1066
-
rescueMiniRacer::RuntimeError=>e
1067
-
# TODO(bnoordhuis) maybe detect the iterator object and serialize
1068
-
# it as an array of strings; problem is there is no V8 API to detect
1069
-
# regexp string iterator objects
1070
-
assert_match(/\[object RegExp String Iterator\] could not be cloned/,e.message)
1071
-
exc=true
1072
-
end
1073
-
assertexc
1062
+
# TODO(bnoordhuis) maybe detect the iterator object and serialize
1063
+
# it as a string or array of strings; problem is there is no V8 API
1064
+
# to detect regexp string iterator objects
1065
+
expected={"error"=>"Error: [object RegExp String Iterator] could not be cloned."}
0 commit comments