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

Side by Side Diff: test/mjsunit/es6/proxies-json.js

Issue 1994183002: [json] handle proxies in BasicJsonSerializer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 7 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
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 500
501 var result = JSON.parse('{"foo":0,"bar":1}', reviver); 501 var result = JSON.parse('{"foo":0,"bar":1}', reviver);
502 assertEquals({foo: 0, bar: proxy}, result); 502 assertEquals({foo: 0, bar: proxy}, result);
503 assertSame(result.bar, proxy); 503 assertSame(result.bar, proxy);
504 assertEquals(3, log.length); 504 assertEquals(3, log.length);
505 for (var i in log) assertSame(target, log[i][1]); 505 for (var i in log) assertSame(target, log[i][1]);
506 506
507 assertEquals(["get", target, "length", proxy], log[0]); 507 assertEquals(["get", target, "length", proxy], log[0]);
508 assertEquals(["get", target, "0", proxy], log[1]); 508 assertEquals(["get", target, "0", proxy], log[1]);
509 assertEquals(["deleteProperty", target, "0"], log[2]); 509 assertEquals(["deleteProperty", target, "0"], log[2]);
510
511 proxy = new Proxy([], {
512 get: function(target, property) {
513 if (property == "length") return 7;
514 return 0;
515 },
516 });
517 assertEquals('[[0,0,0,0,0,0,0]]', JSON.stringify([proxy]));
518
519 proxy = new Proxy([], {
520 get: function(target, property) {
521 if (property == "length") return 1E40;
522 return 0;
523 },
524 });
525 assertThrows(() => JSON.stringify([proxy]), RangeError);
526
527 log = [];
528 proxy = new Proxy({}, {
529 ownKeys: function() {
530 log.push("ownKeys");
531 return ["0", "a", "b"];
532 },
533 get: function(target, property) {
534 log.push("get " + property);
535 return property.toUpperCase();
536 },
537 getOwnPropertyDescriptor: function(target, property) {
538 log.push("descriptor " + property);
539 return {enumerable: true, configurable: true};
540 },
541 isExtensible: assertUnreachable,
542 has: assertUnreachable,
543 getPrototypeOf: assertUnreachable,
544 setPrototypeOf: assertUnreachable,
545 preventExtensions: assertUnreachable,
546 setPrototypeOf: assertUnreachable,
547 defineProperty: assertUnreachable,
548 set: assertUnreachable,
549 deleteProperty: assertUnreachable,
550 apply: assertUnreachable,
551 construct: assertUnreachable,
552 });
553
554 assertEquals('[{"0":"0","a":"A","b":"B"}]', JSON.stringify([proxy]));
555 assertEquals(['get toJSON',
556 'ownKeys',
557 'descriptor 0',
558 'descriptor a',
559 'descriptor b',
560 'get 0',
561 'get a',
562 'get b'], log);
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698