From c00a85bfea21d748f0f9d11fdbc326087f34c411 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Wed, 13 Jan 2021 16:50:49 +0200 Subject: [PATCH] update goja to latest master --- go.mod | 2 +- go.sum | 4 +- js/tc39/breaking_test_errors.json | 36 -------- .../dop251/goja/.tc39_test262_checkout.sh | 9 ++ vendor/github.com/dop251/goja/README.md | 4 +- .../github.com/dop251/goja/builtin_array.go | 82 +++++++++++++++++-- vendor/github.com/dop251/goja/builtin_date.go | 2 +- .../github.com/dop251/goja/builtin_global.go | 4 +- .../github.com/dop251/goja/builtin_number.go | 6 +- .../github.com/dop251/goja/builtin_regexp.go | 41 +++++++--- .../github.com/dop251/goja/builtin_string.go | 4 +- .../dop251/goja/builtin_typedarrays.go | 7 +- vendor/github.com/dop251/goja/object.go | 7 +- vendor/github.com/dop251/goja/parser/lexer.go | 4 +- vendor/github.com/dop251/goja/regexp.go | 33 ++++++-- vendor/github.com/dop251/goja/runtime.go | 11 --- vendor/github.com/dop251/goja/string.go | 1 - vendor/github.com/dop251/goja/typedarrays.go | 16 ++-- vendor/modules.txt | 2 +- 19 files changed, 174 insertions(+), 101 deletions(-) create mode 100644 vendor/github.com/dop251/goja/.tc39_test262_checkout.sh diff --git a/go.mod b/go.mod index 25667e8ba7a..deb5a83df22 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/andybalholm/cascadia v1.0.0 // indirect github.com/daaku/go.zipexe v0.0.0-20150329023125-a5fe2436ffcb // indirect github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect - github.com/dop251/goja v0.0.0-20210106133455-27b0a7dc4c7f + github.com/dop251/goja v0.0.0-20210111190058-952c20e23c35 github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 github.com/eapache/go-resiliency v1.1.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20160609142408-bb955e01b934 // indirect diff --git a/go.sum b/go.sum index 2700dc9e111..9a89e5bc211 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16/II7vuEo/nHjodOg0p7+OiDpjX5t1E= github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dop251/goja v0.0.0-20210106133455-27b0a7dc4c7f h1:tHoCUlro23JdXvcvYXH1AseEyWJf+b8cBbVm16RYRkU= -github.com/dop251/goja v0.0.0-20210106133455-27b0a7dc4c7f/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= +github.com/dop251/goja v0.0.0-20210111190058-952c20e23c35 h1:Wk/lMSLwLOjur+6f48utCuxUylqbPkPN4BZHIoyiNIc= +github.com/dop251/goja v0.0.0-20210111190058-952c20e23c35/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4 h1:qk/FSDDxo05wdJH28W+p5yivv7LuLYLRXPPD8KQCtZs= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eapache/go-resiliency v1.1.0 h1:1NtRmCAqadE2FN4ZcN6g90TP3uk8cg9rn9eNK2197aU= diff --git a/js/tc39/breaking_test_errors.json b/js/tc39/breaking_test_errors.json index a553cce641c..c6fc888acdf 100644 --- a/js/tc39/breaking_test_errors.json +++ b/js/tc39/breaking_test_errors.json @@ -11,34 +11,12 @@ "test/built-ins/Array/length/define-own-prop-length-coercion-order-set.js-strict:true": "[test/built-ins/Array/length/define-own-prop-length-coercion-order-set.js Test262Error: Expected [number] and [number, number] to have the same contents. at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/length/define-own-prop-length-coercion-order.js-strict:true": "[test/built-ins/Array/length/define-own-prop-length-coercion-order.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/length/define-own-prop-length-overflow-order.js-strict:true": "[test/built-ins/Array/length/define-own-prop-length-overflow-order.js Test262Error: Expected a RangeError but got a TypeError at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/Symbol.unscopables/value.js-strict:true": "[test/built-ins/Array/prototype/Symbol.unscopables/value.js Test262Error: `flat` property value Expected SameValue(«undefined», «true») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/concat/create-species-non-ctor.js-strict:true": "[test/built-ins/Array/prototype/concat/create-species-non-ctor.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/filter/create-species-non-ctor.js-strict:true": "[test/built-ins/Array/prototype/filter/create-species-non-ctor.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/array-like-objects.js-strict:true": "[test/built-ins/Array/prototype/flat/array-like-objects.js TypeError: Cannot read property 'call' of undefined or null at test/built-ins/Array/prototype/flat/array-like-objects.js:17:14(20)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/bound-function-call.js-strict:true": "[test/built-ins/Array/prototype/flat/bound-function-call.js TypeError: Cannot read property 'bind' of undefined or null at test/built-ins/Array/prototype/flat/bound-function-call.js:16:14(15)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/call-with-boolean.js-strict:true": "[test/built-ins/Array/prototype/flat/call-with-boolean.js TypeError: Cannot read property 'call' of undefined or null at test/built-ins/Array/prototype/flat/call-with-boolean.js:11:21(7)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/empty-array-elements.js-strict:true": "[test/built-ins/Array/prototype/flat/empty-array-elements.js TypeError: Object has no member 'flat' at test/built-ins/Array/prototype/flat/empty-array-elements.js:13:28(11)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/empty-object-elements.js-strict:true": "[test/built-ins/Array/prototype/flat/empty-object-elements.js TypeError: Object has no member 'flat' at test/built-ins/Array/prototype/flat/empty-object-elements.js:15:29(17)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/length.js-strict:true": "[test/built-ins/Array/prototype/flat/length.js TypeError: Cannot read property 'length' of undefined at test/built-ins/Array/prototype/flat/length.js:14:3(6)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/name.js-strict:true": "[test/built-ins/Array/prototype/flat/name.js TypeError: Cannot read property 'name' of undefined at test/built-ins/Array/prototype/flat/name.js:15:3(6)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/non-numeric-depth-should-not-throw.js-strict:true": "[test/built-ins/Array/prototype/flat/non-numeric-depth-should-not-throw.js TypeError: Object has no member 'flat' at test/built-ins/Array/prototype/flat/non-numeric-depth-should-not-throw.js:17:20(24)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/non-object-ctor-throws.js-strict:true": "[test/built-ins/Array/prototype/flat/non-object-ctor-throws.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/null-undefined-elements.js-strict:true": "[test/built-ins/Array/prototype/flat/null-undefined-elements.js TypeError: Object has no member 'flat' at test/built-ins/Array/prototype/flat/null-undefined-elements.js:14:43(14)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/null-undefined-input-throws.js-strict:true": "[test/built-ins/Array/prototype/flat/null-undefined-input-throws.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/positive-infinity.js-strict:true": "[test/built-ins/Array/prototype/flat/positive-infinity.js TypeError: Object has no member 'flat' at test/built-ins/Array/prototype/flat/positive-infinity.js:13:27(19)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/prop-desc.js-strict:true": "[test/built-ins/Array/prototype/flat/prop-desc.js Test262Error: `typeof Array.prototype.flat` is `function` Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/proxy-access-count.js-strict:true": "[test/built-ins/Array/prototype/flat/proxy-access-count.js TypeError: Cannot read property 'call' of undefined or null at test/built-ins/Array/prototype/flat/proxy-access-count.js:34:1(51)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/symbol-object-create-null-depth-throws.js-strict:true": "[test/built-ins/Array/prototype/flat/symbol-object-create-null-depth-throws.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flat/target-array-with-non-writable-property.js-strict:true": "[test/built-ins/Array/prototype/flat/target-array-with-non-writable-property.js TypeError: Object has no member 'flat' at test/built-ins/Array/prototype/flat/target-array-with-non-writable-property.js:44:19(29)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flatMap/not-a-constructor.js-strict:true": "[test/built-ins/Array/prototype/flatMap/not-a-constructor.js Test262Error: isConstructor(Array.prototype.flatMap) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flatMap/proxy-access-count.js-strict:true": "[test/built-ins/Array/prototype/flatMap/proxy-access-count.js Test262Error: Expected [length, constructor, 0, 1, 2, 3, Symbol(Symbol.isConcatSpreadable), length, 0, 1, 4] and [length, constructor, 0, 1, 2, 3, length, 0, 1, 4] to have the same contents. getProperty by .flatMap should occur exactly once per property and once for length and constructor at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flatMap/target-array-with-non-configurable-property.js-strict:true": "[test/built-ins/Array/prototype/flatMap/target-array-with-non-configurable-property.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/flatMap/target-array-with-non-writable-property.js-strict:true": "[test/built-ins/Array/prototype/flatMap/target-array-with-non-writable-property.js TypeError: Cannot assign to read only property '0' at flattenIntoArray (core-js/shim.min.js:8:7014(107))]: %!v(MISSING)", "test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js-strict:true": "[test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js Test262Error: throw TypeError if @@species is a number Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js-strict:true": "[test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js Test262Error: Return abrupt completion from species custom ctor Expected a Test262Error to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js-strict:true": "[test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js Test262Error: returned value is an instance of custom ctor at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species.js-strict:true": "[test/built-ins/Array/prototype/flatMap/this-value-ctor-object-species.js Test262Error: got species once Expected SameValue(«0», «1») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js-strict:true": "[test/built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js Test262Error: [[GetPrototypeOf]] trap called at harness/proxyTrapsHelper.js:12:32(4)]: %!v(MISSING)", "test/built-ins/Array/prototype/item/index-argument-tointeger.js-strict:true": "[test/built-ins/Array/prototype/item/index-argument-tointeger.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/item/index-non-numeric-argument-tointeger-invalid.js-strict:true": "[test/built-ins/Array/prototype/item/index-non-numeric-argument-tointeger-invalid.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/item/index-non-numeric-argument-tointeger.js-strict:true": "[test/built-ins/Array/prototype/item/index-non-numeric-argument-tointeger.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", @@ -50,7 +28,6 @@ "test/built-ins/Array/prototype/item/returns-item.js-strict:true": "[test/built-ins/Array/prototype/item/returns-item.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/item/returns-undefined-for-holes-in-sparse-arrays.js-strict:true": "[test/built-ins/Array/prototype/item/returns-undefined-for-holes-in-sparse-arrays.js Test262Error: The value of `typeof Array.prototype.item` is \"function\" Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/item/returns-undefined-for-out-of-range-index.js-strict:true": "[test/built-ins/Array/prototype/item/returns-undefined-for-out-of-range-index.js Test262Error: Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js-strict:true": "[test/built-ins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js Test262Error: [[GetPrototypeOf]] trap called at harness/proxyTrapsHelper.js:12:32(4)]: %!v(MISSING)", "test/built-ins/Array/prototype/map/create-species-non-ctor.js-strict:true": "[test/built-ins/Array/prototype/map/create-species-non-ctor.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js-strict:true": "[test/built-ins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js Test262Error: Expected [Get:length, Get:0, Get:9007199254740990, Set:0, GetOwnPropertyDescriptor:0, DefineProperty:0, Set:9007199254740990, GetOwnPropertyDescriptor:9007199254740990, DefineProperty:9007199254740990, Get:1, Get:9007199254740989, Set:1, GetOwnPropertyDescriptor:1, DefineProperty:1, Set:9007199254740989, GetOwnPropertyDescriptor:9007199254740989, DefineProperty:9007199254740989, Get:2, Get:9007199254740988, Set:2, GetOwnPropertyDescriptor:2, DefineProperty:2, Set:9007199254740988, GetOwnPropertyDescriptor:9007199254740988, DefineProperty:9007199254740988, Get:3, Get:9007199254740987, Set:3, GetOwnPropertyDescriptor:3, DefineProperty:3, Set:9007199254740987, GetOwnPropertyDescriptor:9007199254740987, DefineProperty:9007199254740987, Get:4] and [Get:length, Has:0, Get:0, Has:9007199254740990, Get:9007199254740990, Set:0, GetOwnPropertyDescriptor:0, DefineProperty:0, Set:9007199254740990, GetOwnPropertyDescriptor:9007199254740990, DefineProperty:9007199254740990, Has:1, Has:9007199254740989, Has:2, Get:2, Has:9007199254740988, Delete:2, Set:9007199254740988, GetOwnPropertyDescriptor:9007199254740988, DefineProperty:9007199254740988, Has:3, Has:9007199254740987, Get:9007199254740987, Set:3, GetOwnPropertyDescriptor:3, DefineProperty:3, Delete:9007199254740987, Has:4, Get:4] to have the same contents. at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Array/prototype/slice/create-species-non-ctor.js-strict:true": "[test/built-ins/Array/prototype/slice/create-species-non-ctor.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", @@ -64,9 +41,6 @@ "test/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js-strict:true": "[test/built-ins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js TypeError: Constructor TypedArray requires 'new' (Testing with Float64Array.) at testWithTypedArrayConstructors (harness/testTypedArray.js:61:13(43))]: %!v(MISSING)", "test/built-ins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js-strict:true": "[test/built-ins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js Test262Error: `this` value cannot be a SharedArrayBuffer Expected a TypeError but got a GoError at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Date/UTC/fp-evaluation-order.js-strict:true": "[test/built-ins/Date/UTC/fp-evaluation-order.js Test262Error: order of operations / precision in MakeTime Expected SameValue(«29256», «29312») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js-strict:true": "[test/built-ins/Date/prototype/Symbol.toPrimitive/called-as-function.js TypeError: Cannot redefine property: toString at defineProperty (native)]: %!v(MISSING)", - "test/built-ins/Date/prototype/toJSON/called-as-function.js-strict:true": "[test/built-ins/Date/prototype/toJSON/called-as-function.js TypeError: Cannot redefine property: toString at defineProperty (native)]: %!v(MISSING)", - "test/built-ins/Date/prototype/toJSON/to-object.js-strict:true": "[test/built-ins/Date/prototype/toJSON/to-object.js TypeError: Value is not an object: 10 at call (native)]: %!v(MISSING)", "test/built-ins/FinalizationRegistry/is-a-constructor.js-strict:true": "[test/built-ins/FinalizationRegistry/is-a-constructor.js ReferenceError: FinalizationRegistry is not defined at test/built-ins/FinalizationRegistry/is-a-constructor.js:23:32(4)]: %!v(MISSING)", "test/built-ins/FinalizationRegistry/prototype/cleanupSome/not-a-constructor.js-strict:true": "[test/built-ins/FinalizationRegistry/prototype/cleanupSome/not-a-constructor.js ReferenceError: FinalizationRegistry is not defined at test/built-ins/FinalizationRegistry/prototype/cleanupSome/not-a-constructor.js:26:15(4)]: %!v(MISSING)", "test/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js-strict:true": "[test/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js ReferenceError: FinalizationRegistry is not defined at test/built-ins/FinalizationRegistry/prototype/register/not-a-constructor.js:26:15(4)]: %!v(MISSING)", @@ -140,12 +114,10 @@ "test/built-ins/JSON/stringify/not-a-constructor.js-strict:true": "[test/built-ins/JSON/stringify/not-a-constructor.js Test262Error: isConstructor(JSON.stringify) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Math/sinh/not-a-constructor.js-strict:true": "[test/built-ins/Math/sinh/not-a-constructor.js Test262Error: isConstructor(Math.sinh) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/NativeErrors/AggregateError/is-a-constructor.js-strict:true": "[test/built-ins/NativeErrors/AggregateError/is-a-constructor.js ReferenceError: AggregateError is not defined at test/built-ins/NativeErrors/AggregateError/is-a-constructor.js:23:32(4)]: %!v(MISSING)", - "test/built-ins/Number/isSafeInteger/safe-integers.js-strict:true": "[test/built-ins/Number/isSafeInteger/safe-integers.js Test262Error: -0 Expected SameValue(«false», «true») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Number/parseFloat/not-a-constructor.js-strict:true": "[test/built-ins/Number/parseFloat/not-a-constructor.js Test262Error: isConstructor(Number.parseFloat) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Number/parseInt/not-a-constructor.js-strict:true": "[test/built-ins/Number/parseInt/not-a-constructor.js Test262Error: isConstructor(Number.parseInt) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Object/entries/not-a-constructor.js-strict:true": "[test/built-ins/Object/entries/not-a-constructor.js Test262Error: isConstructor(Object.entries) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Object/getOwnPropertyDescriptors/not-a-constructor.js-strict:true": "[test/built-ins/Object/getOwnPropertyDescriptors/not-a-constructor.js Test262Error: isConstructor(Object.getOwnPropertyDescriptors) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/Object/prototype/__proto__/set-cycle-shadowed.js-strict:true": "[test/built-ins/Object/prototype/__proto__/set-cycle-shadowed.js TypeError: Cyclic __proto__ value at test/built-ins/Object/prototype/__proto__/set-cycle-shadowed.js:34:18(28)]: %!v(MISSING)", "test/built-ins/Object/prototype/__proto__/set-invalid-value.js-strict:true": "[test/built-ins/Object/prototype/__proto__/set-invalid-value.js TypeError: Object prototype may only be an Object or null: true at call (native)]: %!v(MISSING)", "test/built-ins/Object/prototype/__proto__/set-non-object.js-strict:true": "[test/built-ins/Object/prototype/__proto__/set-non-object.js TypeError: Object prototype may only be an Object or null: undefined at call (native)]: %!v(MISSING)", "test/built-ins/Object/values/not-a-constructor.js-strict:true": "[test/built-ins/Object/values/not-a-constructor.js Test262Error: isConstructor(Object.values) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", @@ -162,7 +134,6 @@ "test/built-ins/RegExp/named-groups/groups-object-unmatched.js-strict:true": "[test/built-ins/RegExp/named-groups/groups-object-unmatched.js Test262Error: Expected true but got false at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/RegExp/named-groups/groups-object.js-strict:true": "[test/built-ins/RegExp/named-groups/groups-object.js Test262Error: obj should have an own property groups at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/RegExp/named-groups/groups-properties.js-strict:true": "[test/built-ins/RegExp/named-groups/groups-properties.js SyntaxError: test/built-ins/RegExp/named-groups/groups-properties.js: Expected atom at position 1\n (?\u003cfst\u003e.)|(\n ^ at \u003ceval\u003e:2:28542(114)]: %!v(MISSING)", - "test/built-ins/RegExp/prototype/Symbol.replace/coerce-lastindex.js-strict:true": "[test/built-ins/RegExp/prototype/Symbol.replace/coerce-lastindex.js Test262Error: Expected SameValue(«18014398509481985», «9007199254740992») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/RegExp/prototype/Symbol.replace/named-groups-fn.js-strict:true": "[test/built-ins/RegExp/prototype/Symbol.replace/named-groups-fn.js Test262Error: Expected SameValue(«a», «null») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/RegExp/prototype/Symbol.replace/poisoned-stdlib.js-strict:true": "[test/built-ins/RegExp/prototype/Symbol.replace/poisoned-stdlib.js Test262Error: 0 setter should be unreachable. at set (test/built-ins/RegExp/prototype/Symbol.replace/poisoned-stdlib.js:27:19(8))]: %!v(MISSING)", "test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-err.js-strict:true": "[test/built-ins/RegExp/prototype/Symbol.replace/result-coerce-groups-err.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", @@ -230,7 +201,6 @@ "test/built-ins/String/prototype/replaceAll/this-is-undefined-throws.js-strict:true": "[test/built-ins/String/prototype/replaceAll/this-is-undefined-throws.js Test262Error: function must exist Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/String/prototype/replaceAll/this-tostring-abrupt.js-strict:true": "[test/built-ins/String/prototype/replaceAll/this-tostring-abrupt.js Test262Error: function must exist Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/String/prototype/replaceAll/this-tostring.js-strict:true": "[test/built-ins/String/prototype/replaceAll/this-tostring.js TypeError: Cannot read property 'call' of undefined or null at test/built-ins/String/prototype/replaceAll/this-tostring.js:48:10(46)]: %!v(MISSING)", - "test/built-ins/String/prototype/split/separator-tostring-error.js-strict:true": "[test/built-ins/String/prototype/split/separator-tostring-error.js Test262Error: ToString should be called on the separator before checking if the limit is zero. Expected a ExpectedError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/String/prototype/trim/not-a-constructor.js-strict:true": "[test/built-ins/String/prototype/trim/not-a-constructor.js Test262Error: isConstructor(String.prototype.trim) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/String/prototype/trimEnd/name.js-strict:true": "[test/built-ins/String/prototype/trimEnd/name.js Test262Error: descriptor value should be trimEnd at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/String/prototype/trimEnd/not-a-constructor.js-strict:true": "[test/built-ins/String/prototype/trimEnd/not-a-constructor.js Test262Error: isConstructor(String.prototype.trimEnd) must return false Expected SameValue(«true», «false») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", @@ -247,9 +217,6 @@ "test/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-priority.js-strict:true": "[test/built-ins/String/prototype/trimStart/this-value-object-valueof-meth-priority.js Test262Error: thisVal[Symbol.toPrimitive should have been accessed. Expected SameValue(«0», «1») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js-strict:true": "[test/built-ins/String/prototype/trimStart/this-value-symbol-typeerror.js Test262Error: String.prototype.trimStart.call(Symbol()) Expected a TypeError to be thrown but no exception was thrown at all at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/Symbol/species/builtin-getter-name.js-strict:true": "[test/built-ins/Symbol/species/builtin-getter-name.js Test262Error: Expected SameValue(«», «get [Symbol.species]») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js-strict:true": "panic while running [test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js runtime error: slice bounds out of range [:808] with capacity 0]: %!v(MISSING)", - "test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js-strict:true": "panic while running [test/built-ins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js runtime error: slice bounds out of range [:7200] with capacity 0]: %!v(MISSING)", - "test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js-strict:true": "panic while running [test/built-ins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js runtime error: slice bounds out of range [:8000] with capacity 0]: %!v(MISSING)", "test/built-ins/TypedArray/prototype/item/index-argument-tointeger.js-strict:true": "[test/built-ins/TypedArray/prototype/item/index-argument-tointeger.js Test262Error: The value of `typeof TypedArray.prototype.item` is \"function\" Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/TypedArray/prototype/item/index-non-numeric-argument-tointeger-invalid.js-strict:true": "[test/built-ins/TypedArray/prototype/item/index-non-numeric-argument-tointeger-invalid.js Test262Error: The value of `typeof TypedArray.prototype.item` is \"function\" Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/TypedArray/prototype/item/index-non-numeric-argument-tointeger.js-strict:true": "[test/built-ins/TypedArray/prototype/item/index-non-numeric-argument-tointeger.js Test262Error: The value of `typeof TypedArray.prototype.item` is \"function\" Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", @@ -261,10 +228,7 @@ "test/built-ins/TypedArray/prototype/item/returns-item.js-strict:true": "[test/built-ins/TypedArray/prototype/item/returns-item.js Test262Error: The value of `typeof TypedArray.prototype.item` is \"function\" Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/TypedArray/prototype/item/returns-undefined-for-holes-in-sparse-arrays.js-strict:true": "[test/built-ins/TypedArray/prototype/item/returns-undefined-for-holes-in-sparse-arrays.js Test262Error: The value of `typeof TypedArray.prototype.item` is \"function\" Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", "test/built-ins/TypedArray/prototype/item/returns-undefined-for-out-of-range-index.js-strict:true": "[test/built-ins/TypedArray/prototype/item/returns-undefined-for-out-of-range-index.js Test262Error: The value of `typeof TypedArray.prototype.item` is \"function\" Expected SameValue(«undefined», «function») to be true at harness/sta.js:22:9(49)]: %!v(MISSING)", - "test/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js-strict:true": "[test/built-ins/TypedArray/prototype/set/array-arg-primitive-toobject.js TypeError: Value is not an object: 678 (Testing with Float64Array.) at testWithTypedArrayConstructors (harness/testTypedArray.js:61:13(43))]: %!v(MISSING)", "test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js-strict:true": "[test/built-ins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js Test262Error: Expected obj[0] to have configurable:true. (Testing with Float64Array.) at testWithTypedArrayConstructors (harness/testTypedArray.js:61:13(43))]: %!v(MISSING)", - "test/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js-strict:true": "[test/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.) at testWithTypedArrayConstructors (harness/testTypedArray.js:61:13(43))]: %!v(MISSING)", - "test/built-ins/TypedArray/prototype/sort/sorted-values.js-strict:true": "[test/built-ins/TypedArray/prototype/sort/sorted-values.js Test262Error: 0s (Testing with Float64Array.) at testWithTypedArrayConstructors (harness/testTypedArray.js:61:13(43))]: %!v(MISSING)", "test/built-ins/TypedArray/prototype/sort/stability.js-strict:true": "[test/built-ins/TypedArray/prototype/sort/stability.js Test262Error: pre-sorted (Testing with Float64Array.) at testWithTypedArrayConstructors (harness/testTypedArray.js:61:13(43))]: %!v(MISSING)", "test/built-ins/TypedArrayConstructors/BigUint64Array/is-a-constructor.js-strict:true": "[test/built-ins/TypedArrayConstructors/BigUint64Array/is-a-constructor.js ReferenceError: BigUint64Array is not defined at test/built-ins/TypedArrayConstructors/BigUint64Array/is-a-constructor.js:23:32(4)]: %!v(MISSING)", "test/built-ins/WeakRef/is-a-constructor.js-strict:true": "[test/built-ins/WeakRef/is-a-constructor.js ReferenceError: WeakRef is not defined at test/built-ins/WeakRef/is-a-constructor.js:23:32(4)]: %!v(MISSING)", diff --git a/vendor/github.com/dop251/goja/.tc39_test262_checkout.sh b/vendor/github.com/dop251/goja/.tc39_test262_checkout.sh new file mode 100644 index 00000000000..68f4d1c0357 --- /dev/null +++ b/vendor/github.com/dop251/goja/.tc39_test262_checkout.sh @@ -0,0 +1,9 @@ +#!/bin/sh +sha=ddfe24afe3043388827aa220ef623b8540958bbd # this is just the commit it was last tested with +mkdir -p testdata/test262 +cd testdata/test262 +git init +git remote add origin https://github.com/tc39/test262.git +git fetch origin --depth=1 "${sha}" +git reset --hard "${sha}" +cd - diff --git a/vendor/github.com/dop251/goja/README.md b/vendor/github.com/dop251/goja/README.md index a2668a0374a..72470bb39dd 100644 --- a/vendor/github.com/dop251/goja/README.md +++ b/vendor/github.com/dop251/goja/README.md @@ -16,7 +16,9 @@ Features -------- * Full ECMAScript 5.1 support (including regex and strict mode). - * Passes nearly all [tc39 tests](https://github.com/tc39/test262) tagged with es5id. The goal is to pass all of them. Note, the last working commit is https://github.com/tc39/test262/commit/1ba3a7c4a93fc93b3d0d7e4146f59934a896837d. The next commit made use of template strings which goja does not support. + * Passes nearly all [tc39 tests](https://github.com/tc39/test262) tagged with es5id. The goal is to pass all of them. + Note, the current working commit is https://github.com/tc39/test262/commit/ddfe24afe3043388827aa220ef623b8540958bbd. + The next commit removed most of the es5id tags which made it impossible to distinguish which tests to run. * Capable of running Babel, Typescript compiler and pretty much anything written in ES5. * Sourcemaps. * Some ES6 functionality, still work in progress, see https://github.com/dop251/goja/milestone/1?closed=1 diff --git a/vendor/github.com/dop251/goja/builtin_array.go b/vendor/github.com/dop251/goja/builtin_array.go index 27a896a1675..4b933961e92 100644 --- a/vendor/github.com/dop251/goja/builtin_array.go +++ b/vendor/github.com/dop251/goja/builtin_array.go @@ -267,6 +267,9 @@ func (r *Runtime) arrayproto_concat_append(a *Object, item Value) { aLength := toLength(a.self.getStr("length", nil)) if obj, ok := item.(*Object); ok && isConcatSpreadable(obj) { length := toLength(obj.self.getStr("length", nil)) + if aLength+length >= maxInt { + panic(r.NewTypeError("Invalid array length")) + } for i := int64(0); i < length; i++ { v := obj.self.getIdx(valueInt(i), nil) if v != nil { @@ -516,9 +519,11 @@ func (r *Runtime) arrayproto_indexOf(call FunctionCall) Value { for ; n < length; n++ { idx := valueInt(n) - if val := o.self.getIdx(idx, nil); val != nil { - if searchElement.StrictEquals(val) { - return idx + if o.self.hasPropertyIdx(idx) { + if val := o.self.getIdx(idx, nil); val != nil { + if searchElement.StrictEquals(val) { + return idx + } } } } @@ -601,9 +606,11 @@ func (r *Runtime) arrayproto_lastIndexOf(call FunctionCall) Value { for k := fromIndex; k >= 0; k-- { idx := valueInt(k) - if val := o.self.getIdx(idx, nil); val != nil { - if searchElement.StrictEquals(val) { - return idx + if o.self.hasPropertyIdx(idx) { + if val := o.self.getIdx(idx, nil); val != nil { + if searchElement.StrictEquals(val) { + return idx + } } } } @@ -1023,6 +1030,65 @@ func (r *Runtime) arrayproto_findIndex(call FunctionCall) Value { return intToValue(-1) } +func (r *Runtime) arrayproto_flat(call FunctionCall) Value { + o := call.This.ToObject(r) + l := toLength(o.self.getStr("length", nil)) + depthNum := int64(1) + if len(call.Arguments) > 0 { + depthNum = call.Argument(0).ToInteger() + } + a := arraySpeciesCreate(o, 0) + r.flattenIntoArray(a, o, l, 0, depthNum, nil, nil) + return a +} + +func (r *Runtime) flattenIntoArray(target, source *Object, sourceLen, start, depth int64, mapperFunction func(FunctionCall) Value, thisArg Value) int64 { + targetIndex, sourceIndex := start, int64(0) + for sourceIndex < sourceLen { + p := intToValue(sourceIndex) + if source.hasProperty(p.toString()) { + element := source.get(p, source) + if mapperFunction != nil { + element = mapperFunction(FunctionCall{ + This: thisArg, + Arguments: []Value{element, p, source}, + }) + } + var elementArray *Object + if depth > 0 { + if elementObj, ok := element.(*Object); ok && isArray(elementObj) { + elementArray = elementObj + } + } + if elementArray != nil { + elementLen := toLength(elementArray.self.getStr("length", nil)) + targetIndex = r.flattenIntoArray(target, elementArray, elementLen, targetIndex, depth-1, nil, nil) + } else { + if targetIndex >= maxInt-1 { + panic(r.NewTypeError("Invalid array length")) + } + createDataPropertyOrThrow(target, intToValue(targetIndex), element) + targetIndex++ + } + } + sourceIndex++ + } + return targetIndex +} + +func (r *Runtime) arrayproto_flatMap(call FunctionCall) Value { + o := call.This.ToObject(r) + l := toLength(o.self.getStr("length", nil)) + callbackFn := r.toCallable(call.Argument(0)) + thisArg := Undefined() + if len(call.Arguments) > 1 { + thisArg = call.Argument(1) + } + a := arraySpeciesCreate(o, 0) + r.flattenIntoArray(a, o, l, 0, 1, callbackFn, thisArg) + return a +} + func (r *Runtime) checkStdArrayObj(obj *Object) *arrayObject { if arr, ok := obj.self.(*arrayObject); ok && arr.propValueCount == 0 && @@ -1204,6 +1270,8 @@ func (r *Runtime) createArrayProto(val *Object) objectImpl { o._putProp("filter", r.newNativeFunc(r.arrayproto_filter, nil, "filter", nil, 1), true, false, true) o._putProp("find", r.newNativeFunc(r.arrayproto_find, nil, "find", nil, 1), true, false, true) o._putProp("findIndex", r.newNativeFunc(r.arrayproto_findIndex, nil, "findIndex", nil, 1), true, false, true) + o._putProp("flat", r.newNativeFunc(r.arrayproto_flat, nil, "flat", nil, 0), true, false, true) + o._putProp("flatMap", r.newNativeFunc(r.arrayproto_flatMap, nil, "flatMap", nil, 1), true, false, true) o._putProp("forEach", r.newNativeFunc(r.arrayproto_forEach, nil, "forEach", nil, 1), true, false, true) o._putProp("includes", r.newNativeFunc(r.arrayproto_includes, nil, "includes", nil, 1), true, false, true) o._putProp("indexOf", r.newNativeFunc(r.arrayproto_indexOf, nil, "indexOf", nil, 1), true, false, true) @@ -1236,6 +1304,8 @@ func (r *Runtime) createArrayProto(val *Object) objectImpl { bl.setOwnStr("fill", valueTrue, true) bl.setOwnStr("find", valueTrue, true) bl.setOwnStr("findIndex", valueTrue, true) + bl.setOwnStr("flat", valueTrue, true) + bl.setOwnStr("flatMap", valueTrue, true) bl.setOwnStr("includes", valueTrue, true) bl.setOwnStr("keys", valueTrue, true) bl.setOwnStr("values", valueTrue, true) diff --git a/vendor/github.com/dop251/goja/builtin_date.go b/vendor/github.com/dop251/goja/builtin_date.go index 793b6b2817f..61ff1d64f8b 100644 --- a/vendor/github.com/dop251/goja/builtin_date.go +++ b/vendor/github.com/dop251/goja/builtin_date.go @@ -140,7 +140,7 @@ func (r *Runtime) dateproto_toISOString(call FunctionCall) Value { } func (r *Runtime) dateproto_toJSON(call FunctionCall) Value { - obj := r.toObject(call.This) + obj := call.This.ToObject(r) tv := obj.toPrimitiveNumber() if f, ok := tv.(valueFloat); ok { f := float64(f) diff --git a/vendor/github.com/dop251/goja/builtin_global.go b/vendor/github.com/dop251/goja/builtin_global.go index 71bfdde85f9..1d9c5a7b35a 100644 --- a/vendor/github.com/dop251/goja/builtin_global.go +++ b/vendor/github.com/dop251/goja/builtin_global.go @@ -343,9 +343,7 @@ func (r *Runtime) initGlobalObject() { o._putProp("escape", r.newNativeFunc(r.builtin_escape, nil, "escape", nil, 1), true, false, true) o._putProp("unescape", r.newNativeFunc(r.builtin_unescape, nil, "unescape", nil, 1), true, false, true) - o._putProp("toString", r.newNativeFunc(func(FunctionCall) Value { - return stringGlobalObject - }, nil, "toString", nil, 0), false, false, false) + o._putSym(SymToStringTag, valueProp(asciiString(classGlobal), false, false, true)) // TODO: Annex B diff --git a/vendor/github.com/dop251/goja/builtin_number.go b/vendor/github.com/dop251/goja/builtin_number.go index 6a15bd56b9a..163e16e01a5 100644 --- a/vendor/github.com/dop251/goja/builtin_number.go +++ b/vendor/github.com/dop251/goja/builtin_number.go @@ -169,7 +169,11 @@ func (r *Runtime) number_isNaN(call FunctionCall) Value { } func (r *Runtime) number_isSafeInteger(call FunctionCall) Value { - if i, ok := call.Argument(0).(valueInt); ok && i >= -(maxInt-1) && i <= maxInt-1 { + arg := call.Argument(0) + if i, ok := arg.(valueInt); ok && i >= -(maxInt-1) && i <= maxInt-1 { + return valueTrue + } + if arg == _negativeZero { return valueTrue } return valueFalse diff --git a/vendor/github.com/dop251/goja/builtin_regexp.go b/vendor/github.com/dop251/goja/builtin_regexp.go index 014dfab9b02..a1b0034fc3a 100644 --- a/vendor/github.com/dop251/goja/builtin_regexp.go +++ b/vendor/github.com/dop251/goja/builtin_regexp.go @@ -298,15 +298,15 @@ func (r *Runtime) builtin_newRegExp(args []Value, proto *Object) *Object { func (r *Runtime) newRegExp(patternVal, flagsVal Value, proto *Object) *Object { var pattern valueString var flags string - if obj, ok := patternVal.(*Object); ok { - if rx, ok := obj.self.(*regexpObject); ok { - if flagsVal == nil || flagsVal == _undefined { - return rx.clone() + if isRegexp(patternVal) { // this may have side effects so need to call it anyway + if obj, ok := patternVal.(*Object); ok { + if rx, ok := obj.self.(*regexpObject); ok { + if flagsVal == nil || flagsVal == _undefined { + return rx.clone() + } else { + return r._newRegExp(rx.source, flagsVal.toString().String(), proto) + } } else { - return r._newRegExp(rx.source, flagsVal.toString().String(), proto) - } - } else { - if isRegexp(patternVal) { pattern = nilSafe(obj.self.getStr("source", nil)).toString() if flagsVal == nil || flagsVal == _undefined { flags = nilSafe(obj.self.getStr("flags", nil)).toString().String() @@ -660,8 +660,8 @@ func (r *Runtime) getGlobalRegexpMatches(rxObj *Object, s valueString) []Value { a = append(a, res) matchStr := nilSafe(r.toObject(res).self.getIdx(valueInt(0), nil)).toString() if matchStr.length() == 0 { - thisIndex := toIntStrict(nilSafe(rxObj.self.getStr("lastIndex", nil)).ToInteger()) - rxObj.self.setOwnStr("lastIndex", valueInt(advanceStringIndex(s, thisIndex, fullUnicode)), true) + thisIndex := toLength(rxObj.self.getStr("lastIndex", nil)) + rxObj.self.setOwnStr("lastIndex", valueInt(advanceStringIndex64(s, thisIndex, fullUnicode)), true) } } @@ -855,6 +855,24 @@ func advanceStringIndex(s valueString, pos int, unicode bool) int { return next + 1 } +func advanceStringIndex64(s valueString, pos int64, unicode bool) int64 { + next := pos + 1 + if !unicode { + return next + } + l := int64(s.length()) + if next >= l { + return next + } + if !isUTF16FirstSurrogate(s.charAt(int(pos))) { + return next + } + if !isUTF16SecondSurrogate(s.charAt(int(next))) { + return next + } + return next + 1 +} + func (r *Runtime) regexpproto_stdSplitter(call FunctionCall) Value { rxObj := r.toObject(call.This) s := call.Argument(0).toString() @@ -877,6 +895,7 @@ func (r *Runtime) regexpproto_stdSplitter(call FunctionCall) Value { } } + pattern := search.pattern // toUint32() may recompile the pattern, but we still need to use the original limit := -1 if limitValue != _undefined { limit = int(toUint32(limitValue)) @@ -891,7 +910,7 @@ func (r *Runtime) regexpproto_stdSplitter(call FunctionCall) Value { lastIndex := 0 found := 0 - result := search.pattern.findAllSubmatchIndex(s, 0, -1, false) + result := pattern.findAllSubmatchIndex(s, 0, -1, false) if targetLength == 0 { if result == nil { valueArray = append(valueArray, s) diff --git a/vendor/github.com/dop251/goja/builtin_string.go b/vendor/github.com/dop251/goja/builtin_string.go index 0ce003217be..d55518f0707 100644 --- a/vendor/github.com/dop251/goja/builtin_string.go +++ b/vendor/github.com/dop251/goja/builtin_string.go @@ -735,6 +735,8 @@ func (r *Runtime) stringproto_split(call FunctionCall) Value { limit = int(toUint32(limitValue)) } + separatorValue = separatorValue.ToString() + if limit == 0 { return r.newArrayValues(nil) } @@ -743,7 +745,7 @@ func (r *Runtime) stringproto_split(call FunctionCall) Value { return r.newArrayValues([]Value{s}) } - separator := separatorValue.toString().String() + separator := separatorValue.String() excess := false str := s.String() diff --git a/vendor/github.com/dop251/goja/builtin_typedarrays.go b/vendor/github.com/dop251/goja/builtin_typedarrays.go index 05fc37f0de4..b4bdf996e5f 100644 --- a/vendor/github.com/dop251/goja/builtin_typedarrays.go +++ b/vendor/github.com/dop251/goja/builtin_typedarrays.go @@ -407,6 +407,7 @@ func (r *Runtime) typedArrayProto_copyWithin(call FunctionCall) Value { offset := ta.offset elemSize := ta.elemSize if final > from { + ta.viewedArrayBuf.ensureNotDetached() copy(data[(offset+to)*elemSize:], data[(offset+from)*elemSize:(offset+final)*elemSize]) } return call.This @@ -828,7 +829,7 @@ func (r *Runtime) typedArrayProto_reverse(call FunctionCall) Value { func (r *Runtime) typedArrayProto_set(call FunctionCall) Value { if ta, ok := r.toObject(call.This).self.(*typedArrayObject); ok { - srcObj := r.toObject(call.Argument(0)) + srcObj := call.Argument(0).ToObject(r) targetOffset := toIntStrict(call.Argument(1).ToInteger()) if targetOffset < 0 { panic(r.newError(r.global.RangeError, "offset should be >= 0")) @@ -963,8 +964,8 @@ func (r *Runtime) typedArrayProto_sort(call FunctionCall) Value { ta.viewedArrayBuf.ensureNotDetached() var compareFn func(FunctionCall) Value - if arg, ok := call.Argument(0).(*Object); ok { - compareFn, _ = arg.self.assertCallable() + if arg := call.Argument(0); arg != _undefined { + compareFn = r.toCallable(arg) } ctx := typedArraySortCtx{ diff --git a/vendor/github.com/dop251/goja/object.go b/vendor/github.com/dop251/goja/object.go index c2cc0a7b020..ec0ddda2c2f 100644 --- a/vendor/github.com/dop251/goja/object.go +++ b/vendor/github.com/dop251/goja/object.go @@ -27,6 +27,7 @@ const ( classRegExp = "RegExp" classDate = "Date" classJSON = "JSON" + classGlobal = "global" classArrayIterator = "Array Iterator" classMapIterator = "Map Iterator" @@ -485,12 +486,14 @@ func (o *baseObject) setProto(proto *Object, throw bool) bool { o.val.runtime.typeErrorResult(throw, "%s is not extensible", o.val) return false } - for p := proto; p != nil; { + for p := proto; p != nil; p = p.self.proto() { if p.SameAs(o.val) { o.val.runtime.typeErrorResult(throw, "Cyclic __proto__ value") return false } - p = p.self.proto() + if _, ok := p.self.(*proxyObject); ok { + break + } } o.prototype = proto return true diff --git a/vendor/github.com/dop251/goja/parser/lexer.go b/vendor/github.com/dop251/goja/parser/lexer.go index d3713dfe642..ffb632deeea 100644 --- a/vendor/github.com/dop251/goja/parser/lexer.go +++ b/vendor/github.com/dop251/goja/parser/lexer.go @@ -440,8 +440,8 @@ func (self *_parser) switch6(tkn0, tkn1 token.Token, chr2 rune, tkn2, tkn3 token } func (self *_parser) _peek() rune { - if self.offset+1 < self.length { - return rune(self.str[self.offset+1]) + if self.offset < self.length { + return rune(self.str[self.offset]) } return -1 } diff --git a/vendor/github.com/dop251/goja/regexp.go b/vendor/github.com/dop251/goja/regexp.go index 426791cf8b5..b00d2390c24 100644 --- a/vendor/github.com/dop251/goja/regexp.go +++ b/vendor/github.com/dop251/goja/regexp.go @@ -608,6 +608,17 @@ func (r *regexpObject) defineOwnPropertyStr(name unistring.String, desc Property return res } +func (r *regexpObject) defineOwnPropertySym(name *Symbol, desc PropertyDescriptor, throw bool) bool { + res := r.baseObject.defineOwnPropertySym(name, desc, throw) + if res && r.standard { + switch name { + case SymMatch, SymSearch, SymSplit, SymReplace: + r.standard = false + } + } + return res +} + func (r *regexpObject) deleteStr(name unistring.String, throw bool) bool { res := r.baseObject.deleteStr(name, throw) if res { @@ -617,14 +628,20 @@ func (r *regexpObject) deleteStr(name unistring.String, throw bool) bool { } func (r *regexpObject) setOwnStr(name unistring.String, value Value, throw bool) bool { - if r.standard { - if name == "exec" { - res := r.baseObject.setOwnStr(name, value, throw) - if res { - r.standard = false - } - return res + res := r.baseObject.setOwnStr(name, value, throw) + if res && r.standard && name == "exec" { + r.standard = false + } + return res +} + +func (r *regexpObject) setOwnSym(name *Symbol, value Value, throw bool) bool { + res := r.baseObject.setOwnSym(name, value, throw) + if res && r.standard { + switch name { + case SymMatch, SymSearch, SymSplit, SymReplace: + r.standard = false } } - return r.baseObject.setOwnStr(name, value, throw) + return res } diff --git a/vendor/github.com/dop251/goja/runtime.go b/vendor/github.com/dop251/goja/runtime.go index 1b498e37a2b..c666cde6440 100644 --- a/vendor/github.com/dop251/goja/runtime.go +++ b/vendor/github.com/dop251/goja/runtime.go @@ -1125,17 +1125,6 @@ func MustCompile(name, src string, strict bool) *Program { func Parse(name, src string, options ...parser.Option) (prg *js_ast.Program, err error) { prg, err1 := parser.ParseFile(nil, name, src, 0, options...) if err1 != nil { - switch err1 := err1.(type) { - case parser.ErrorList: - if len(err1) > 0 && err1[0].Message == "Invalid left-hand side in assignment" { - err = &CompilerReferenceError{ - CompilerError: CompilerError{ - Message: err1.Error(), - }, - } - return - } - } // FIXME offset err = &CompilerSyntaxError{ CompilerError: CompilerError{ diff --git a/vendor/github.com/dop251/goja/string.go b/vendor/github.com/dop251/goja/string.go index 6955054a2f4..29ac5837ddf 100644 --- a/vendor/github.com/dop251/goja/string.go +++ b/vendor/github.com/dop251/goja/string.go @@ -44,7 +44,6 @@ var ( stringObjectNull valueString = asciiString("[object Null]") stringObjectObject valueString = asciiString("[object Object]") stringObjectUndefined valueString = asciiString("[object Undefined]") - stringGlobalObject valueString = asciiString("Global Object") stringInvalidDate valueString = asciiString("Invalid Date") ) diff --git a/vendor/github.com/dop251/goja/typedarrays.go b/vendor/github.com/dop251/goja/typedarrays.go index 874eca2b5c1..162adcd1a89 100644 --- a/vendor/github.com/dop251/goja/typedarrays.go +++ b/vendor/github.com/dop251/goja/typedarrays.go @@ -385,19 +385,15 @@ func (a *float32Array) setRaw(idx int, v uint64) { func typedFloatLess(x, y float64) bool { xNan := math.IsNaN(x) yNan := math.IsNaN(y) - if xNan && yNan { - return false - } - if xNan { - return false - } if yNan { - return true - } - if x >= y { + return !xNan + } else if xNan { return false } - return true + if x == 0 && y == 0 { // handle neg zero + return math.Signbit(x) + } + return x < y } func (a *float32Array) less(i, j int) bool { diff --git a/vendor/modules.txt b/vendor/modules.txt index 3bdb38c0276..cb0bc916c8c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -34,7 +34,7 @@ github.com/davecgh/go-spew/spew ## explicit github.com/dlclark/regexp2 github.com/dlclark/regexp2/syntax -# github.com/dop251/goja v0.0.0-20210106133455-27b0a7dc4c7f +# github.com/dop251/goja v0.0.0-20210111190058-952c20e23c35 ## explicit github.com/dop251/goja github.com/dop251/goja/ast