Changeset 207618 in webkit
- Timestamp:
- Oct 20, 2016 8:00:43 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r207572 r207618 1 2016-10-20 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] throw TypeError when constructing dynamically created JSGeneratorFunction 4 https://bugs.webkit.org/show_bug.cgi?id=163714 5 6 Reviewed by Mark Lam. 7 8 Add missing test coverage that dynamically created 9 JSGeneratorFunctions can not be constructed. 10 11 * stress/generator-function-constructor.js: 12 (shouldThrow): 13 1 14 2016-10-19 JF Bastien <jfbastien@apple.com> 2 15 -
trunk/JSTests/stress/generator-function-constructor.js
r206710 r207618 3 3 throw new Error('bad value: ' + actual); 4 4 } 5 6 function shouldThrow(func, errorMessage) { 7 var errorThrown = false; 8 var error = null; 9 try { 10 func(); 11 } catch (e) { 12 errorThrown = true; 13 error = e; 14 } 15 if (!errorThrown) 16 throw new Error('not thrown'); 17 if (String(error) !== errorMessage) 18 throw new Error(`bad error: ${String(error)}`); 19 } 20 5 21 var global = (new Function("return this"))(); 6 22 shouldBe(typeof global.GeneratorFunction, 'undefined'); … … 11 27 shouldBe(generatorFunctionConstructor("a") instanceof generatorFunctionConstructor, true); 12 28 shouldBe(generatorFunctionConstructor("a", "b") instanceof generatorFunctionConstructor, true); 29 30 // Generator functions created by the GeneratorFunction constructor are not themselves constructors. 31 shouldThrow(() => new (generatorFunctionConstructor()), "TypeError: function is not a constructor (evaluating 'new (generatorFunctionConstructor())')"); -
trunk/Source/JavaScriptCore/ChangeLog
r207576 r207618 1 2016-10-20 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] throw TypeError when constructing dynamically created JSGeneratorFunction 4 https://bugs.webkit.org/show_bug.cgi?id=163714 5 6 Reviewed by Mark Lam. 7 8 According to CreateDynamicFunction() (https://tc39.github.io/ecma262/#sec-createdynamicfunction), 9 non-normal functions are not constructors. Previously, dynamically created functions would always 10 be constructible, and so it was possible to evaluate `new (function*() {}.constructor())`, 11 and have it return an Iterator object. 12 13 This change selects a dynamically created function's ConstructAbility based on its parse mode instead. 14 15 * runtime/CodeCache.cpp: 16 (JSC::CodeCache::getFunctionExecutableFromGlobalCode): 17 1 18 2016-10-19 JF Bastien <jfbastien@apple.com> 2 19 -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r206400 r207618 203 203 // The Function constructor only has access to global variables, so no variables will be under TDZ. 204 204 VariableEnvironment emptyTDZVariables; 205 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, JSParserScriptMode::Classic, emptyTDZVariables, DerivedContextType::None); 205 ConstructAbility constructAbility = constructAbilityForParseMode(metadata->parseMode()); 206 UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, constructAbility, JSParserScriptMode::Classic, emptyTDZVariables, DerivedContextType::None); 206 207 207 208 functionExecutable->setSourceURLDirective(source.provider()->sourceURL());
Note: See TracChangeset
for help on using the changeset viewer.