haikuwebkit/LayoutTests/js/object-literal-shorthand-co...

116 lines
8.0 KiB
Plaintext
Raw Permalink Normal View History

Source/JavaScriptCore: ES6: Object Literal Extensions - Shorthand Properties (Identifiers) https://bugs.webkit.org/show_bug.cgi?id=142353 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-05 Reviewed by Geoffrey Garen. * parser/Parser.cpp: (JSC::Parser<LexerType>::parseProperty): Parsing an identifier property followed by a comma or end brace treat as a shorthand property and create a property that has the same property name as the identifier name and value of a variable with that identifier. Otherwise, fall through to getter/setter parsing. LayoutTests: Web Inspector: Follow-up fixes to ObjectTreeBaseTreeElement https://bugs.webkit.org/show_bug.cgi?id=142367 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-05 Reviewed by Geoffrey Garen. * js/object-literal-shorthand-construction-expected.txt: Added. * js/object-literal-shorthand-construction.html: Added. * js/script-tests/object-literal-shorthand-construction.js: Added. (equivalent): (testShorthandConstructionEquivalent): (testShorthandConstructionNotEquivalent): Tests specifically for new literal construction with shorthands. * sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt: * sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T2-expected.txt: * sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.4_The_for_in_Statement/S12.6.4_A15-expected.txt: These tests use object literal shorthand construction syntax and expected failures. The tests now fail differently, so just rebase their results. Canonical link: https://commits.webkit.org/160409@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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
PASS equivalent({eval}, {eval: eval}) is true
Source/JavaScriptCore: ES6: Object Literal Extensions - Shorthand Properties (Identifiers) https://bugs.webkit.org/show_bug.cgi?id=142353 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-05 Reviewed by Geoffrey Garen. * parser/Parser.cpp: (JSC::Parser<LexerType>::parseProperty): Parsing an identifier property followed by a comma or end brace treat as a shorthand property and create a property that has the same property name as the identifier name and value of a variable with that identifier. Otherwise, fall through to getter/setter parsing. LayoutTests: Web Inspector: Follow-up fixes to ObjectTreeBaseTreeElement https://bugs.webkit.org/show_bug.cgi?id=142367 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-05 Reviewed by Geoffrey Garen. * js/object-literal-shorthand-construction-expected.txt: Added. * js/object-literal-shorthand-construction.html: Added. * js/script-tests/object-literal-shorthand-construction.js: Added. (equivalent): (testShorthandConstructionEquivalent): (testShorthandConstructionNotEquivalent): Tests specifically for new literal construction with shorthands. * sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt: * sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T2-expected.txt: * sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.4_The_for_in_Statement/S12.6.4_A15-expected.txt: These tests use object literal shorthand construction syntax and expected failures. The tests now fail differently, so just rebase their results. Canonical link: https://commits.webkit.org/160409@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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
Allow setting the prototype of cross-origin objects, as long as they don't change https://bugs.webkit.org/show_bug.cgi?id=169787 Reviewed by Mark Lam. LayoutTests/imported/w3c: Import test coverage from W3C web-platform-tests. * web-platform-tests/common/domain-setter.sub.html: Added. * web-platform-tests/common/test-setting-immutable-prototype.js: Added. (self.testSettingImmutablePrototypeToNewValueOnly.test): (self.testSettingImmutablePrototypeToNewValueOnly): (self.testSettingImmutablePrototype.else.test): (self.testSettingImmutablePrototype): * web-platform-tests/common/w3c-import.log: * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-cross-origin-domain.sub-expected.txt: Added. * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-cross-origin-domain.sub.html: Added. * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-goes-cross-origin-domain.sub-expected.txt: Added. * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-goes-cross-origin-domain.sub.html: Added. * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-same-origin-domain.sub-expected.txt: Added. * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-same-origin-domain.sub.html: Added. * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-same-origin-expected.txt: Added. * web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-same-origin.html: Added. * web-platform-tests/html/browsers/history/the-location-interface/w3c-import.log: * web-platform-tests/html/browsers/the-windowproxy-exotic-object/w3c-import.log: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin-domain.sub-expected.txt: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin-domain.sub.html: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub-expected.txt: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-domain.sub-expected.txt: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-domain.sub.html: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-expected.txt: Added. * web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin.html: Added. Source/JavaScriptCore: * runtime/JSGlobalObject.h: Mark JS global object as an immutable prototype exotic object to match Window. * runtime/JSObject.cpp: (JSC::JSObject::setPrototypeWithCycleCheck): Update setPrototypeWithCycleCheck() for immutable prototype exotic objects in order to align with: - https://tc39.github.io/ecma262/#sec-set-immutable-prototype In particular, we need to call [[GetPrototypeOf]] and return true if it returns the same value as the new prototype. We really need to call [[GetPrototypeOf]] and not merely getting the prototype slot via getPrototypeDirect() since Location and Window override [[GetPrototypeOf]] to return null in the cross-origin case. * runtime/JSProxy.cpp: (JSC::JSProxy::setPrototype): Update JSProxy::setPrototype() to forward such calls to its target. This is needed so we end up calling JSObject::setPrototypeWithCycleCheck() for the Window object. Handling immutable prototype exotic objects in that method does the right thing for Window. Source/WebCore: Allow setting the prototype of cross-origin objects, as long as they don't change: - https://html.spec.whatwg.org/multipage/browsers.html#windowproxy-setprototypeof - https://html.spec.whatwg.org/multipage/browsers.html#location-setprototypeof - https://tc39.github.io/ecma262/#sec-set-immutable-prototype Tests: imported/w3c/web-platform-tests/common/domain-setter.sub.html imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-cross-origin-domain.sub.html imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-goes-cross-origin-domain.sub.html imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-same-origin-domain.sub.html imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-prototype-setting-same-origin.html imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin-domain.sub.html imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-domain.sub.html imported/w3c/web-platform-tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin.html * bindings/js/JSLocationCustom.cpp: * page/Location.idl: Drop custom setPrototype() implementation for Location and mark Location as an immutable prototype exotic object now that JSC does the right thing for those. LayoutTests: * http/tests/security/cross-frame-access-object-setPrototypeOf-expected.txt: * http/tests/security/cross-frame-access-object-setPrototypeOf.html: * js/dom/setPrototypeOf-location-window-expected.txt: * js/dom/setPrototypeOf-location-window.html: Add checks for setting prototype of window and location objects to the same value to make sure it does not throw, both in the same origin and the cross origin cases. * fast/dom/Window/window-custom-prototype-crash-expected.txt: * http/tests/security/xss-DENIED-regular-propterty-with-iframe-proto-expected.txt: * js/object-literal-shorthand-construction-expected.txt: Rebaseline tests now that the exception message is a bit different. * js/script-tests/prototype-assignment.js: Remove special casing for Window, it now behaves like a regular immutable prototype exotic object. Canonical link: https://commits.webkit.org/186795@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214135 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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.
[JSC] __proto__ getter should be fast https://bugs.webkit.org/show_bug.cgi?id=178067 Reviewed by Saam Barati. JSTests: * stress/dfg-object-proto-accessor.js: Added. (shouldBe): (shouldThrow): (target): * stress/dfg-object-proto-getter.js: Added. (shouldBe): (shouldThrow): (target): * stress/dfg-object-prototype-of.js: Added. (shouldBe): (shouldThrow): (target): * stress/dfg-reflect-get-prototype-of.js: Added. (shouldBe): (shouldThrow): (target): * stress/intrinsic-getter-with-poly-proto.js: Added. (shouldBe): (makePolyProtoObject.foo.C): (makePolyProtoObject.foo): (makePolyProtoObject): (target): * stress/object-get-prototype-of-filtered.js: Added. (shouldBe): (shouldThrow): (target): (i.Cocoa): * stress/object-get-prototype-of-mono-proto.js: Added. (shouldBe): (makePolyProtoObject.foo.C): (makePolyProtoObject.foo): (makePolyProtoObject): (target): * stress/object-get-prototype-of-poly-mono-proto.js: Added. (shouldBe): (makePolyProtoObject.foo.C): (makePolyProtoObject.foo): (makePolyProtoObject): (target): * stress/object-get-prototype-of-poly-proto.js: Added. (shouldBe): (makePolyProtoObject.foo.C): (makePolyProtoObject.foo): (makePolyProtoObject): (target): * stress/object-proto-getter-filtered.js: Added. (shouldBe): (shouldThrow): (target): (i.Cocoa): * stress/object-proto-getter-poly-mono-proto.js: Added. (shouldBe): (makePolyProtoObject.foo.C): (makePolyProtoObject.foo): (makePolyProtoObject): (target): * stress/object-proto-getter-poly-proto.js: Added. (shouldBe): (makePolyProtoObject.foo.C): (makePolyProtoObject.foo): (makePolyProtoObject): (target): * stress/object-prototype-proto-accessors-should-throw-on-undefined-this.js: * stress/string-proto.js: Added. (shouldBe): (target): Source/JavaScriptCore: In our ES6 class implementation, we access __proto__ field to retrieve super constructor. Currently, it is handled as an usual getter call to a generic function. And DFG just emits Call node for this. It is inefficient since typically we know the `prototype` of the given object when accessing `object.__proto__` since we emit CheckStructure for this `object`. If Structure has mono proto, we can immediately fold it to constant value. If it is poly proto, we can still change this to efficient access to poly proto slot. This patch implements GetPrototypeOf DFG node. This node efficiently accesses to prototype of the given object. And in AI and ByteCodeParser phase, we attempt to fold it to constant. ByteCodeParser's folding is a bit important since we have `callee.__proto__` code to get super constructor. If we can change this to constant, we can reify CallLinkInfo with this constant. This paves the way to optimizing ArrayConstructor super calls[1], which is particularly important for ARES-6 ML. And we also optimize Reflect.getPrototypeOf and Object.getPrototypeOf with this GetPrototypeOf node. Currently, __proto__ access for poly proto object is not handled well in IC. But we add code handling poly proto in GetPrototypeOf since Reflect.getPrototypeOf and Object.getPrototypeOf can use it. Once IC starts handling poly proto & intrinsic getter well, this code will be used for that too. This patch improves SixSpeed super.es6 by 3.42x. baseline patched super.es6 123.6666+-3.9917 ^ 36.1684+-1.0351 ^ definitely 3.4192x faster [1]: https://bugs.webkit.org/show_bug.cgi?id=178064 * dfg/DFGAbstractInterpreterInlines.h: (JSC::DFG::AbstractInterpreter<AbstractStateType>::executeEffects): * dfg/DFGByteCodeParser.cpp: (JSC::DFG::ByteCodeParser::handleIntrinsicCall): (JSC::DFG::ByteCodeParser::handleIntrinsicGetter): (JSC::DFG::ByteCodeParser::handleGetById): * dfg/DFGClobberize.h: (JSC::DFG::clobberize): * dfg/DFGDoesGC.cpp: (JSC::DFG::doesGC): * dfg/DFGFixupPhase.cpp: (JSC::DFG::FixupPhase::fixupNode): (JSC::DFG::FixupPhase::fixupGetPrototypeOf): * dfg/DFGHeapLocation.cpp: (WTF::printInternal): * dfg/DFGHeapLocation.h: * dfg/DFGNode.h: (JSC::DFG::Node::hasHeapPrediction): (JSC::DFG::Node::shouldSpeculateFunction): * dfg/DFGNodeType.h: * dfg/DFGOperations.cpp: * dfg/DFGOperations.h: * dfg/DFGPredictionPropagationPhase.cpp: * dfg/DFGSafeToExecute.h: (JSC::DFG::safeToExecute): * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::speculateFunction): (JSC::DFG::SpeculativeJIT::speculateFinalObject): (JSC::DFG::SpeculativeJIT::compileGetPrototypeOf): * dfg/DFGSpeculativeJIT.h: (JSC::DFG::SpeculativeJIT::callOperation): * dfg/DFGSpeculativeJIT32_64.cpp: (JSC::DFG::SpeculativeJIT::compile): * dfg/DFGSpeculativeJIT64.cpp: (JSC::DFG::SpeculativeJIT::compile): * ftl/FTLCapabilities.cpp: (JSC::FTL::canCompile): * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNode): (JSC::FTL::DFG::LowerDFGToB3::compileGetPrototypeOf): (JSC::FTL::DFG::LowerDFGToB3::compileInstanceOf): * jit/IntrinsicEmitter.cpp: (JSC::IntrinsicGetterAccessCase::canEmitIntrinsicGetter): (JSC::IntrinsicGetterAccessCase::emitIntrinsicGetter): * jit/JITOperations.h: * runtime/Intrinsic.cpp: (JSC::intrinsicName): * runtime/Intrinsic.h: * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::booleanPrototype const): (JSC::JSGlobalObject::numberPrototype const): (JSC::JSGlobalObject::booleanObjectStructure const): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncProtoGetter): * runtime/JSGlobalObjectFunctions.h: * runtime/ObjectConstructor.cpp: * runtime/ReflectObject.cpp: LayoutTests: * js/object-literal-shorthand-construction-expected.txt: * js/script-tests/object-literal-shorthand-construction.js: (set 2): (get 1): * js/script-tests/sloppy-getter-setter-global-object.js: * js/sloppy-getter-setter-global-object-expected.txt: Canonical link: https://commits.webkit.org/194651@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223594 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-18 07:12:53 +00:00
PASS ({__proto__: __proto__}) instanceof Array threw exception TypeError: undefined is not an object (evaluating '__proto__').
test262: test262/test/language/expressions/generators/yield-as-label.js https://bugs.webkit.org/show_bug.cgi?id=170979 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-04-24 Reviewed by Saam Barati. JSTests: * stress/async-await-module-reserved-word.js: * stress/async-await-reserved-word.js: Converge on "Cannot" instead of "Can't". * catch-parameter-syntax.js: * yield-named-variable-generator.js: * yield-named-variable.js: * stress/yield-label-generator.js: * stress/yield-label.js: * stress/yield-reserved-word.js: Added. More complete list of when 'yield' is allowed. * ChakraCore/test/strict/23.reservedWords_sm.baseline-jsc: * test262.yaml: Source/JavaScriptCore: * parser/Parser.cpp: (JSC::Parser<LexerType>::parseVariableDeclarationList): (JSC::Parser<LexerType>::parseDestructuringPattern): (JSC::Parser<LexerType>::parseFormalParameters): Converge on "Cannot" instead of "Can't" in error messages. (JSC::Parser<LexerType>::parseFunctionInfo): Disallow "yield" as the generator function name in function expressions. This refers to the difference between Declaration and Expression, where only GeneratorExpression explicitly has [+Yield] disallowing yield for the generator name: GeneratorDeclaration[Yield, Await, Default]: function * BindingIdentifier[?Yield, ?Await] ... GeneratorExpression: function * BindingIdentifier[+Yield, ~Await]opt ... (JSC::Parser<LexerType>::parseExpressionOrLabelStatement): Disallow "yield" as a label name in strict mode or inside a generator. (JSC::Parser<LexerType>::parseProperty): Disallow "yield" or any keyword in object literal shorthands. * parser/Parser.h: (JSC::Parser::getToken): (JSC::Parser::isDisallowedIdentifierLet): (JSC::Parser::isDisallowedIdentifierYield): (JSC::Parser::disallowedIdentifierLetReason): (JSC::Parser::disallowedIdentifierYieldReason): Follow pattern for improved error messages based on context. LayoutTests: * js/object-literal-shorthand-construction-expected.txt: * js/script-tests/object-literal-shorthand-construction.js: Extend this test to cover object literal shorthand with keywords. * js/dom/reserved-words-as-property-expected.txt: * js/let-syntax-expected.txt: * js/parser-syntax-check-expected.txt: Improved error messages. Canonical link: https://commits.webkit.org/188086@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
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..
Source/JavaScriptCore: ES6: Object Literal Extensions - Shorthand Properties (Identifiers) https://bugs.webkit.org/show_bug.cgi?id=142353 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-05 Reviewed by Geoffrey Garen. * parser/Parser.cpp: (JSC::Parser<LexerType>::parseProperty): Parsing an identifier property followed by a comma or end brace treat as a shorthand property and create a property that has the same property name as the identifier name and value of a variable with that identifier. Otherwise, fall through to getter/setter parsing. LayoutTests: Web Inspector: Follow-up fixes to ObjectTreeBaseTreeElement https://bugs.webkit.org/show_bug.cgi?id=142367 Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-05 Reviewed by Geoffrey Garen. * js/object-literal-shorthand-construction-expected.txt: Added. * js/object-literal-shorthand-construction.html: Added. * js/script-tests/object-literal-shorthand-construction.js: Added. (equivalent): (testShorthandConstructionEquivalent): (testShorthandConstructionNotEquivalent): Tests specifically for new literal construction with shorthands. * sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T1-expected.txt: * sputnik/Conformance/12_Statement/12.1_Block/S12.1_A4_T2-expected.txt: * sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.4_The_for_in_Statement/S12.6.4_A15-expected.txt: These tests use object literal shorthand construction syntax and expected failures. The tests now fail differently, so just rebase their results. Canonical link: https://commits.webkit.org/160409@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-06 01:16:25 +00:00
PASS successfullyParsed is true
TEST COMPLETE