Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: test/mjsunit/function-bind.js

Issue 8333019: Make bound functions have poisoned .caller and .arguments. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/strict-mode.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 assertEquals([null, 0, undefined], s()); 256 assertEquals([null, 0, undefined], s());
257 257
258 s = soo.bind(42); 258 s = soo.bind(42);
259 assertEquals([42, 0, undefined], s()); 259 assertEquals([42, 0, undefined], s());
260 260
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
267 // Test that .arguments and .caller are poisoned according to the ES5 spec.
268
269 // Check that property descriptors are correct (unconfigurable, unenumerable,
270 // and both get and set is the ThrowTypeError function).
271 var cdesc = Object.getOwnPropertyDescriptor(f, "caller");
272 var adesc = Object.getOwnPropertyDescriptor(f, "arguments");
273
274 assertFalse(cdesc.enumerable);
275 assertFalse(cdesc.configurable);
276
277 assertFalse(adesc.enumerable);
278 assertFalse(adesc.configurable);
279
280 assertSame(cdesc.get, cdesc.set);
281 assertSame(cdesc.get, adesc.get);
282 assertSame(cdesc.get, adesc.set);
283
284 assertTrue(cdesc.get instanceof Function);
285 assertEquals(0, cdesc.get.length);
286 assertThrows(cdesc.get, TypeError);
287
288 assertThrows(function() { return f.caller; }, TypeError);
289 assertThrows(function() { f.caller = 42; }, TypeError);
290 assertThrows(function() { return f.arguments; }, TypeError);
291 assertThrows(function() { f.arguments = 42; }, TypeError);
292
293 // 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,
295 // but not considered strict.
296 (function foo() { return foo.caller; }).bind()();
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/strict-mode.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698