OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 375 |
376 var funcJSON = function() { /* Is callable */ }; | 376 var funcJSON = function() { /* Is callable */ }; |
377 funcJSON.toJSON = function() { return "has toJSON"; }; | 377 funcJSON.toJSON = function() { return "has toJSON"; }; |
378 | 378 |
379 var re = /Is callable/; | 379 var re = /Is callable/; |
380 | 380 |
381 var reJSON = /Is callable/; | 381 var reJSON = /Is callable/; |
382 reJSON.toJSON = function() { return "has toJSON"; }; | 382 reJSON.toJSON = function() { return "has toJSON"; }; |
383 | 383 |
384 assertEquals( | 384 assertEquals( |
385 '[37,null,1,"foo","37","true",null,"has toJSON",null,"has toJSON"]', | 385 '[37,null,1,"foo","37","true",null,"has toJSON",{},"has toJSON"]', |
386 JSON.stringify([num37, numFoo, numTrue, | 386 JSON.stringify([num37, numFoo, numTrue, |
387 strFoo, str37, strTrue, | 387 strFoo, str37, strTrue, |
388 func, funcJSON, re, reJSON])); | 388 func, funcJSON, re, reJSON])); |
389 | 389 |
390 | 390 |
391 var oddball = Object(42); | 391 var oddball = Object(42); |
392 oddball.__proto__ = { __proto__: null, toString: function() { return true; } }; | 392 oddball.__proto__ = { __proto__: null, toString: function() { return true; } }; |
393 assertEquals('1', JSON.stringify(oddball)); | 393 assertEquals('1', JSON.stringify(oddball)); |
394 | 394 |
395 var getCount = 0; | 395 var getCount = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
422 // | 422 // |
423 // Parse a non-object value as __proto__. This must not create a | 423 // Parse a non-object value as __proto__. This must not create a |
424 // __proto__ property different from the original, and should not | 424 // __proto__ property different from the original, and should not |
425 // change the original. | 425 // change the original. |
426 var o = JSON.parse('{"__proto__":5}'); | 426 var o = JSON.parse('{"__proto__":5}'); |
427 assertEquals(Object.prototype, o.__proto__); // __proto__ isn't changed. | 427 assertEquals(Object.prototype, o.__proto__); // __proto__ isn't changed. |
428 assertEquals(0, Object.keys(o).length); // __proto__ isn't added as enumerable. | 428 assertEquals(0, Object.keys(o).length); // __proto__ isn't added as enumerable. |
429 | 429 |
430 | 430 |
431 | 431 |
OLD | NEW |