2015-03-06 01:16:25 +00:00
|
|
|
basic tests for object literal shorthand construction
|
|
|
|
|
|
|
|
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
|
|
|
|
|
|
|
|
|
|
|
|
PASS !!{a} is true
|
|
|
|
PASS ({a}).a === 1 is true
|
|
|
|
PASS ({a}).a === a is true
|
|
|
|
PASS ({foo})['foo'] === foo is true
|
|
|
|
PASS Object.getOwnPropertyDescriptor({a}, 'a').enumerable is true
|
|
|
|
PASS Object.getOwnPropertyDescriptor({a}, 'a').configurable is true
|
|
|
|
PASS Object.getOwnPropertyDescriptor({a}, 'a').writable is true
|
|
|
|
PASS Object.keys({a,b}).join() is "a,b"
|
|
|
|
PASS Object.keys({b,a}).join() is "b,a"
|
|
|
|
PASS equivalent({a}, {a:a}) is true
|
|
|
|
PASS equivalent({a}, {a:a}) is true
|
|
|
|
PASS equivalent({a,}, {a:a}) is true
|
|
|
|
PASS equivalent({a,a}, {a:a}) is true
|
|
|
|
PASS equivalent({a,b}, {a:a, b:b}) is true
|
|
|
|
PASS equivalent({ a , b }, {a:a, b:b}) is true
|
|
|
|
PASS equivalent({a,b,}, {a:a, b:b}) is true
|
|
|
|
PASS equivalent({a,b,a}, {a:a, b:b}) is true
|
|
|
|
PASS equivalent({b,a,a}, {b:b, a:a}) is true
|
|
|
|
PASS !equivalent({a}, {b:a}) is true
|
|
|
|
PASS !equivalent({b}, {a:b}) is true
|
|
|
|
PASS !equivalent({a,b}, {a:b, b:a}) is true
|
|
|
|
PASS equivalent({foo}, {foo:foo}) is true
|
|
|
|
PASS equivalent({foo}, {foo:foo}) is true
|
|
|
|
PASS equivalent({foo,}, {foo:foo}) is true
|
|
|
|
PASS equivalent({foo,foo}, {foo:foo}) is true
|
|
|
|
PASS equivalent({foo,bar}, {foo:foo, bar:bar}) is true
|
|
|
|
PASS equivalent({ foo , bar }, {foo:foo, bar:bar}) is true
|
|
|
|
PASS equivalent({foo,bar,}, {foo:foo, bar:bar}) is true
|
|
|
|
PASS equivalent({foo,bar,foo}, {foo:foo, bar:bar}) is true
|
|
|
|
PASS equivalent({bar,foo,foo}, {bar:bar, foo:foo}) is true
|
|
|
|
PASS equivalent({foo,bar,foo}, {foo:foo, bar:bar}) is true
|
|
|
|
PASS equivalent({bar,foo,foo}, {bar:bar, foo:foo}) is true
|
|
|
|
PASS !equivalent({foo}, {bar:foo}) is true
|
|
|
|
PASS !equivalent({bar}, {foo:bar}) is true
|
|
|
|
PASS !equivalent({foo,bar}, {foo:bar, bar:foo}) is true
|
|
|
|
PASS equivalent({a, b:b, c}, {a, b, c}) is true
|
|
|
|
PASS equivalent({a:a, b, c:c}, {a, b, c}) is true
|
|
|
|
PASS equivalent({a, b, c:c}, {a, b, c}) is true
|
|
|
|
PASS equivalent({'a':a, b, c:c}, {a, b, c}) is true
|
|
|
|
PASS equivalent({nest:{a}}.nest, {nest: {a:a}}.nest) is true
|
|
|
|
PASS equivalent({nest:[{a}]}.nest[0], {nest: [{a:a}]}.nest[0]) is true
|
|
|
|
PASS equivalent([{nest:[{a}]}][0].nest[0], [{nest: [{a:a}]}][0].nest[0]) is true
|
|
|
|
PASS equivalent({a,b,t,x,f,nul,un,fun,foo,bar}, {a:a, b:b, t:t, x:x, f:f, nul:null, un:un, fun:fun, foo:foo, bar:bar}) is true
|
2015-03-06 03:41:16 +00:00
|
|
|
PASS equivalent({eval}, {eval: eval}) is true
|
2015-03-06 01:16:25 +00:00
|
|
|
PASS ({noSuchIdentifier}) threw exception ReferenceError: Can't find variable: noSuchIdentifier.
|
|
|
|
PASS ({a,noSuchIdentifier}) threw exception ReferenceError: Can't find variable: noSuchIdentifier.
|
|
|
|
PASS ({noSuchIdentifier,a}) threw exception ReferenceError: Can't find variable: noSuchIdentifier.
|
|
|
|
PASS ({a,b,noSuchIdentifier}) threw exception ReferenceError: Can't find variable: noSuchIdentifier.
|
|
|
|
PASS ({get}) threw exception ReferenceError: Can't find variable: get.
|
|
|
|
PASS ({set}) threw exception ReferenceError: Can't find variable: set.
|
|
|
|
PASS equivalent({get}, {get: 1}) is true
|
|
|
|
PASS equivalent({set}, {set: 2}) is true
|
|
|
|
PASS ({get x(){ return true; }}).x is true
|
|
|
|
PASS ({get 'x'(){ return true; }}).x is true
|
|
|
|
PASS ({get 42(){ return true; }})['42'] is true
|
|
|
|
PASS !!Object.getOwnPropertyDescriptor({set x(value){}}, 'x').set is true
|
|
|
|
PASS !!Object.getOwnPropertyDescriptor({set 'x'(value){}}, 'x').set is true
|
|
|
|
PASS !!Object.getOwnPropertyDescriptor({set 42(value){}}, '42').set is true
|
2017-03-18 17:52:01 +00:00
|
|
|
PASS this.__proto__ = [] threw exception TypeError: Cannot set prototype of immutable prototype object.
|
Invoking Object.prototype.__proto__ accessors directly should throw a TypeError.
https://bugs.webkit.org/show_bug.cgi?id=154377
<rdar://problem/27330808>
Reviewed by Filip Pizlo and Saam Barati.
JSTests:
* stress/object-prototype-proto-accessors-should-throw-on-undefined-this.js: Added.
Source/JavaScriptCore:
In a scenario where we cache the __proto__ accessors in global variables, and
later explicitly invoke those accessors as functions, the spec for Function Calls
(see https://tc39.github.io/ecma262/#sec-function-calls) states that the function
ref value is of type Reference, and base of ref is an Environment Record. Then,
it follows that the thisValue should be set to refEnv.WithBaseObject()
(see section 4.b.ii of 12.3.4.1 at
https://tc39.github.io/ecma262/#sec-function-calls-runtime-semantics-evaluation).
refEnv in this case is the environment record that the cached accessors were
found in i.e. the global object. The WithBaseObject() of the global object is
undefined (see details about WithBaseObject at
https://tc39.github.io/ecma262/#sec-environment-records).
Hence, the __proto__ accessors should see a thisValue of undefined, and throw
TypeErrors. See https://tc39.github.io/ecma262/#sec-get-object.prototype.__proto__,
https://tc39.github.io/ecma262/#sec-set-object.prototype.__proto__,
https://tc39.github.io/ecma262/#sec-toobject, and
https://tc39.github.io/ecma262/#sec-requireobjectcoercible.
In JSC's implementation, the callee needs to do a ToThis operation on the
incoming "this" argument in order to get the specified thisValue. The
implementations of the __proto__ accessors were not doing this correctly. This
has now been fixed.
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncProtoGetter):
(JSC::globalFuncProtoSetter):
LayoutTests:
* http/tests/security/xss-DENIED-htmlelelment-with-iframe-proto-expected.txt:
* http/tests/security/xss-DENIED-method-with-iframe-proto-expected.txt:
* http/tests/security/xss-DENIED-non-shadowable-propterty-with-iframe-proto-expected.txt:
* http/tests/security/xss-DENIED-regular-propterty-with-iframe-proto-expected.txt:
* http/tests/security/xss-DENIED-regular-propterty-with-iframe-proto.html:
* js/dom/activation-proto-expected.txt:
* js/dom/script-tests/activation-proto.js:
* js/object-literal-shorthand-construction-expected.txt:
* js/script-tests/object-literal-shorthand-construction.js:
* js/script-tests/sloppy-getter-setter-global-object.js:
* js/sloppy-getter-setter-global-object-expected.txt:
Canonical link: https://commits.webkit.org/181428@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207518 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-19 03:52:29 +00:00
|
|
|
PASS ({__proto__: this.__proto__}) instanceof Array is false
|
|
|
|
PASS __proto__ = [] threw exception TypeError: Object.prototype.__proto__ called on null or undefined.
|
2017-10-18 07:12:53 +00:00
|
|
|
PASS ({__proto__: __proto__}) instanceof Array threw exception TypeError: undefined is not an object (evaluating '__proto__').
|
2017-04-24 16:06:33 +00:00
|
|
|
SyntaxErrors
|
|
|
|
PASS ({break}) threw exception SyntaxError: Cannot use the keyword 'break' as a shorthand property name..
|
|
|
|
PASS ({case}) threw exception SyntaxError: Cannot use the keyword 'case' as a shorthand property name..
|
|
|
|
PASS ({catch}) threw exception SyntaxError: Cannot use the keyword 'catch' as a shorthand property name..
|
|
|
|
PASS ({class}) threw exception SyntaxError: Cannot use the keyword 'class' as a shorthand property name..
|
|
|
|
PASS ({const}) threw exception SyntaxError: Cannot use the keyword 'const' as a shorthand property name..
|
|
|
|
PASS ({continue}) threw exception SyntaxError: Cannot use the keyword 'continue' as a shorthand property name..
|
|
|
|
PASS ({debugger}) threw exception SyntaxError: Cannot use the keyword 'debugger' as a shorthand property name..
|
|
|
|
PASS ({default}) threw exception SyntaxError: Cannot use the keyword 'default' as a shorthand property name..
|
|
|
|
PASS ({delete}) threw exception SyntaxError: Cannot use the keyword 'delete' as a shorthand property name..
|
|
|
|
PASS ({do}) threw exception SyntaxError: Cannot use the keyword 'do' as a shorthand property name..
|
|
|
|
PASS ({else}) threw exception SyntaxError: Cannot use the keyword 'else' as a shorthand property name..
|
|
|
|
PASS ({enum}) threw exception SyntaxError: Cannot use the reserved word 'enum' as a shorthand property name..
|
|
|
|
PASS ({export}) threw exception SyntaxError: Cannot use the keyword 'export' as a shorthand property name..
|
|
|
|
PASS ({extends}) threw exception SyntaxError: Cannot use the keyword 'extends' as a shorthand property name..
|
|
|
|
PASS ({false}) threw exception SyntaxError: Cannot use the keyword 'false' as a shorthand property name..
|
|
|
|
PASS ({finally}) threw exception SyntaxError: Cannot use the keyword 'finally' as a shorthand property name..
|
|
|
|
PASS ({for}) threw exception SyntaxError: Cannot use the keyword 'for' as a shorthand property name..
|
|
|
|
PASS ({function}) threw exception SyntaxError: Cannot use the keyword 'function' as a shorthand property name..
|
|
|
|
PASS ({if}) threw exception SyntaxError: Cannot use the keyword 'if' as a shorthand property name..
|
|
|
|
PASS ({import}) threw exception SyntaxError: Cannot use the keyword 'import' as a shorthand property name..
|
|
|
|
PASS ({in}) threw exception SyntaxError: Cannot use the keyword 'in' as a shorthand property name..
|
|
|
|
PASS ({instanceof}) threw exception SyntaxError: Cannot use the keyword 'instanceof' as a shorthand property name..
|
|
|
|
PASS ({new}) threw exception SyntaxError: Cannot use the keyword 'new' as a shorthand property name..
|
|
|
|
PASS ({null}) threw exception SyntaxError: Cannot use the keyword 'null' as a shorthand property name..
|
|
|
|
PASS ({return}) threw exception SyntaxError: Cannot use the keyword 'return' as a shorthand property name..
|
|
|
|
PASS ({super}) threw exception SyntaxError: Cannot use the keyword 'super' as a shorthand property name..
|
|
|
|
PASS ({switch}) threw exception SyntaxError: Cannot use the keyword 'switch' as a shorthand property name..
|
|
|
|
PASS ({throw}) threw exception SyntaxError: Cannot use the keyword 'throw' as a shorthand property name..
|
|
|
|
PASS ({true}) threw exception SyntaxError: Cannot use the keyword 'true' as a shorthand property name..
|
|
|
|
PASS ({try}) threw exception SyntaxError: Cannot use the keyword 'try' as a shorthand property name..
|
|
|
|
PASS ({typeof}) threw exception SyntaxError: Cannot use the keyword 'typeof' as a shorthand property name..
|
|
|
|
PASS ({var}) threw exception SyntaxError: Cannot use the keyword 'var' as a shorthand property name..
|
|
|
|
PASS ({void}) threw exception SyntaxError: Cannot use the keyword 'void' as a shorthand property name..
|
|
|
|
PASS ({while}) threw exception SyntaxError: Cannot use the keyword 'while' as a shorthand property name..
|
|
|
|
PASS ({with}) threw exception SyntaxError: Cannot use the keyword 'with' as a shorthand property name..
|
|
|
|
Contextual Keywords
|
|
|
|
PASS ({let}) threw exception ReferenceError: Can't find variable: let.
|
|
|
|
PASS ({async}) threw exception ReferenceError: Can't find variable: async.
|
|
|
|
PASS ({yield}) threw exception ReferenceError: Can't find variable: yield.
|
|
|
|
PASS ({await}) threw exception ReferenceError: Can't find variable: await.
|
|
|
|
PASS "use strict"; ({let}) } threw exception SyntaxError: Cannot use 'let' as a shorthand property name in strict mode..
|
|
|
|
PASS function* generator() { ({yield}) } threw exception SyntaxError: Cannot use 'yield' as a shorthand property name in a generator function..
|
|
|
|
PASS async function func() { ({await}) } threw exception SyntaxError: Cannot use 'await' as a shorthand property name in an async function..
|
2015-03-06 01:16:25 +00:00
|
|
|
PASS successfullyParsed is true
|
|
|
|
|
|
|
|
TEST COMPLETE
|
|
|
|
|