Changeset 202734 in webkit
- Timestamp:
- Jul 1, 2016 8:25:35 AM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r202728 r202734 1 2016-07-01 Caio Lima <ticaiolima@gmail.com> 2 3 ES6: Implement HasRestrictedGlobalProperty when checking for global lexical tier conflicts 4 https://bugs.webkit.org/show_bug.cgi?id=148763 5 6 Reviewed by Saam Barati 7 8 I've implemented the ES6 spec 8.1.1.4.14 9 (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty) 10 that defines when a global property can be shadowed. 11 12 Added some test cases into global-lexical-redeclare-variable.js 13 14 * runtime/Executable.cpp: 15 (JSC::ProgramExecutable::initializeGlobalProperties): 16 * tests/stress/global-lexical-redeclare-variable.js: 17 (catch): 18 * tests/stress/multiple-files-tests/global-lexical-redeclare-variable/eighth.js: Added. 19 * tests/stress/multiple-files-tests/global-lexical-redeclare-variable/nineth.js: Added. 20 * tests/stress/multiple-files-tests/global-lexical-redeclare-variable/seventh.js: Added. 21 * tests/stress/multiple-files-tests/global-lexical-redeclare-variable/sixth.js: 22 * tests/stress/multiple-files-tests/global-lexical-redeclare-variable/tenth.js: Added. 23 1 24 2016-07-01 Youenn Fablet <youennf@gmail.com> 2 25 -
trunk/Source/JavaScriptCore/runtime/Executable.cpp
r201542 r202734 606 606 // It's an error to introduce a shadow. 607 607 for (auto& entry : lexicalDeclarations) { 608 if (globalObject->hasProperty(exec, entry.key.get())) 609 return createSyntaxError(exec, makeString("Can't create duplicate variable that shadows a global property: '", String(entry.key.get()), "'")); 610 608 if (globalObject->hasProperty(exec, entry.key.get())) { 609 // The ES6 spec says that just RestrictedGlobalProperty can't be shadowed 610 // This carried out section 8.1.1.4.14 of the ES6 spec: http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty 611 PropertyDescriptor descriptor; 612 globalObject->getOwnPropertyDescriptor(exec, entry.key.get(), descriptor); 613 614 if (descriptor.value() != jsUndefined() && !descriptor.configurable()) 615 return createSyntaxError(exec, makeString("Can't create duplicate variable that shadows a global property: '", String(entry.key.get()), "'")); 616 } 617 611 618 if (globalLexicalEnvironment->hasProperty(exec, entry.key.get())) { 612 619 if (UNLIKELY(entry.value.isConst() && !vm.globalConstRedeclarationShouldThrow() && !isStrictMode())) { -
trunk/Source/JavaScriptCore/tests/stress/global-lexical-redeclare-variable.js
r189279 r202734 65 65 assertExpectations(); 66 66 67 // Checking if the implementation is following 68 // ES6 spec 8.1.1.4.14 http://www.ecma-international.org/ecma-262/6.0/index.html#sec-hasrestrictedglobalproperty 69 67 70 try { 71 sentinel = "bad"; 72 assert(Object.getOwnPropertyDescriptor(this, "globalProperty").configurable); 68 73 load("./multiple-files-tests/global-lexical-redeclare-variable/sixth.js"); 74 } catch(e) { 75 assert(false); 76 } 77 assertExpectations(); 78 79 try { 80 sentinel = "bad"; 81 assert(Object.getOwnPropertyDescriptor(this, "Array").configurable); 82 load("./multiple-files-tests/global-lexical-redeclare-variable/seventh.js"); 83 } catch(e) { 84 assert(false); 85 } 86 assertExpectations(); 87 88 try { 89 sentinel = "bad"; 90 Object.defineProperty(this, 'foo', {value: 5, configurable: true, writable: true}); 91 load("./multiple-files-tests/global-lexical-redeclare-variable/eighth.js"); 92 } catch(e) { 93 assert(false); 94 } 95 assertExpectations(); 96 97 try { 98 Object.defineProperty(this, 'bar', {value: 5, configurable: false, writable: true}); 99 load("./multiple-files-tests/global-lexical-redeclare-variable/ninth.js"); 69 100 } catch(e) { 70 101 assertProperError(e); … … 73 104 74 105 assert(errorCount === 6); 106 107 try { 108 sentinel = "bad"; 109 Object.defineProperty(this, 'zoo', {value: undefined, configurable: false, writable: true}); 110 load("./multiple-files-tests/global-lexical-redeclare-variable/tenth.js"); 111 } catch(e) { 112 assert(false); 113 } 114 assertExpectations(); 115 -
trunk/Source/JavaScriptCore/tests/stress/multiple-files-tests/global-lexical-redeclare-variable/sixth.js
r189279 r202734 1 let globalProperty = " bad";2 sentinel = " bad";1 let globalProperty = "good"; 2 sentinel = "__s__";
Note: See TracChangeset
for help on using the changeset viewer.