| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 s = soo.bind("foo"); | 261 s = soo.bind("foo"); |
| 262 assertEquals(["foo", 0, undefined], s()); | 262 assertEquals(["foo", 0, undefined], s()); |
| 263 | 263 |
| 264 s = soo.bind(true); | 264 s = soo.bind(true); |
| 265 assertEquals([true, 0, undefined], s()); | 265 assertEquals([true, 0, undefined], s()); |
| 266 | 266 |
| 267 // Test that .arguments and .caller are poisoned according to the ES5 spec. | 267 // Test that .arguments and .caller are poisoned according to the ES5 spec. |
| 268 | 268 |
| 269 // Check that property descriptors are correct (unconfigurable, unenumerable, | 269 // Check that property descriptors are correct (unconfigurable, unenumerable, |
| 270 // and both get and set is the ThrowTypeError function). | 270 // and both get and set is the ThrowTypeError function). |
| 271 var cdesc = Object.getOwnPropertyDescriptor(f, "caller"); | 271 // |
| 272 var adesc = Object.getOwnPropertyDescriptor(f, "arguments"); | 272 // Poisoned accessors are no longer own properties --- get them from the |
| 273 // prototype |
| 274 var f_proto = Object.getPrototypeOf(f); |
| 275 var cdesc = Object.getOwnPropertyDescriptor(f_proto, "caller"); |
| 276 var adesc = Object.getOwnPropertyDescriptor(f_proto, "arguments"); |
| 273 | 277 |
| 274 assertFalse(cdesc.enumerable); | 278 assertFalse(cdesc.enumerable); |
| 275 assertFalse(cdesc.configurable); | 279 assertTrue(cdesc.configurable); |
| 276 | 280 |
| 277 assertFalse(adesc.enumerable); | 281 assertFalse(adesc.enumerable); |
| 278 assertFalse(adesc.configurable); | 282 assertTrue(adesc.configurable); |
| 279 | 283 |
| 280 assertSame(cdesc.get, cdesc.set); | 284 assertSame(cdesc.get, cdesc.set); |
| 281 assertSame(cdesc.get, adesc.get); | 285 assertSame(cdesc.get, adesc.get); |
| 282 assertSame(cdesc.get, adesc.set); | 286 assertSame(cdesc.get, adesc.set); |
| 283 | 287 |
| 284 assertTrue(cdesc.get instanceof Function); | 288 assertTrue(cdesc.get instanceof Function); |
| 285 assertEquals(0, cdesc.get.length); | 289 assertEquals(0, cdesc.get.length); |
| 286 assertThrows(cdesc.get, TypeError); | 290 assertThrows(cdesc.get, TypeError); |
| 287 | 291 |
| 288 assertThrows(function() { return f.caller; }, TypeError); | 292 assertThrows(function() { return f.caller; }, TypeError); |
| 289 assertThrows(function() { f.caller = 42; }, TypeError); | 293 assertThrows(function() { f.caller = 42; }, TypeError); |
| 290 assertThrows(function() { return f.arguments; }, TypeError); | 294 assertThrows(function() { return f.arguments; }, TypeError); |
| 291 assertThrows(function() { f.arguments = 42; }, TypeError); | 295 assertThrows(function() { f.arguments = 42; }, TypeError); |
| 292 | 296 |
| 293 // Shouldn't throw. Accessing the functions caller must throw if | 297 // Shouldn't throw. Accessing the functions caller must throw if |
| 294 // the caller is strict and the callee isn't. A bound function is built-in, | 298 // the caller is strict and the callee isn't. A bound function is built-in, |
| 295 // but not considered strict. | 299 // but not considered strict. |
| 296 (function foo() { return foo.caller; }).bind()(); | 300 (function foo() { return foo.caller; }).bind()(); |
| OLD | NEW |