-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…efine a `prototype` property Merge pull request #5712 from wyrichte:build/wyrichte/bug_5701_1 ES19 requires that, unless otherwise stated, all methods should have a prototype. ChakraCore adds prototypes to methods defined in objects. In order to not allow prototypes to be added to methods defined in objects, the ErrorOnNew flag is atted to the pNodeFnc's FuncInfo's attributes. Class constructors are methods but are defined to have prototypes, so they are not given the ErrorOnNew flag.
- Loading branch information
Showing
10 changed files
with
193 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
|
||
var failed = false; | ||
|
||
var o = { | ||
f() { } | ||
} | ||
|
||
if (o.f.hasOwnProperty("prototype")) { | ||
failed = true; | ||
WScript.Echo("Failed: a method within an object literal should not have a prototype"); | ||
} | ||
|
||
try { | ||
new o.f(); | ||
failed = true; | ||
WScript.Echo("Failed: a method within an object literal should not have a prototype and thus new should not be valid"); | ||
} | ||
catch (e) { | ||
} | ||
|
||
class C { | ||
f() { } | ||
} | ||
|
||
if (new C().f.hasOwnProperty("prototype")) { | ||
failed = true; | ||
WScript.Echo("Failed: a method within a class should not have a prototype"); | ||
} | ||
|
||
if (!(new C().constructor.hasOwnProperty("prototype"))) { | ||
failed = true; | ||
WScript.Echo("Failed: a class' constructor should have a prototype"); | ||
} | ||
|
||
if (!failed) { | ||
WScript.Echo("Pass"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters