Chromium Code Reviews| Index: test/mjsunit/proto-accessor.js |
| diff --git a/test/mjsunit/proto-poison.js b/test/mjsunit/proto-accessor.js |
| similarity index 71% |
| rename from test/mjsunit/proto-poison.js |
| rename to test/mjsunit/proto-accessor.js |
| index ca3b5d6d061a21819a6b000fee84397231ad307f..fefbf6df008626f385842daab103d81f9386c755 100644 |
| --- a/test/mjsunit/proto-poison.js |
| +++ b/test/mjsunit/proto-accessor.js |
| @@ -25,21 +25,34 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -// Check that the __proto__ accessor is properly poisoned when extracted |
| -// from Object.prototype using the property descriptor. |
| var desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"); |
| assertEquals("function", typeof desc.get); |
| assertEquals("function", typeof desc.set); |
| assertDoesNotThrow("desc.get.call({})"); |
| -assertThrows("desc.set.call({})", TypeError); |
| +assertDoesNotThrow("desc.set.call({}, {})"); |
| + |
| + |
| +var obj = {}; |
| +var obj2 = {}; |
| +desc.set.call(obj, obj2); |
| +assertEquals(obj.__proto__, obj2); |
| +assertEquals(desc.get.call(obj), obj2); |
| + |
| + |
| +// Check that any redefinition of the __proto__ accessor works. |
|
rossberg
2014/02/06 11:53:22
Maybe add a test case that redefines the setter to
arv (Not doing code reviews)
2014/02/06 15:43:47
Done.
|
| + Object.defineProperty(Object.prototype, "__proto__", { get:function() { |
|
rossberg
2014/02/06 11:53:22
Nit: weird indentation
arv (Not doing code reviews)
2014/02/06 15:43:47
Done.
|
| + return 42; |
| + } }); |
| + assertEquals({}.__proto__, 42); |
| + assertEquals(desc.get.call({}), Object.prototype); |
| + |
| + |
| +var desc2 = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"); |
| +assertEquals(desc2.get.call({}), 42); |
| +assertDoesNotThrow("desc2.set.call({})"); |
| + |
| -// Check that any redefinition of the __proto__ accessor causes poising |
| -// to cease and the accessor to be extracted normally. |
| -Object.defineProperty(Object.prototype, "__proto__", { get:function(){} }); |
| -desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"); |
| -assertDoesNotThrow("desc.get.call({})"); |
| -assertThrows("desc.set.call({})", TypeError); |
| Object.defineProperty(Object.prototype, "__proto__", { set:function(x){} }); |
| -desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"); |
| -assertDoesNotThrow("desc.get.call({})"); |
| -assertDoesNotThrow("desc.set.call({})"); |
| +var desc3 = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__"); |
| +assertDoesNotThrow("desc3.get.call({})"); |
| +assertDoesNotThrow("desc3.set.call({})"); |