| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 28 matching lines...) Expand all Loading... |
| 39 TestWithObjectProxy(test, x, y, z); | 39 TestWithObjectProxy(test, x, y, z); |
| 40 TestWithFunctionProxy(test, x, y, z); | 40 TestWithFunctionProxy(test, x, y, z); |
| 41 } | 41 } |
| 42 | 42 |
| 43 function TestWithObjectProxy(test, x, y, z) { | 43 function TestWithObjectProxy(test, x, y, z) { |
| 44 test((handler) => { return new Proxy({}, handler) }, x, y, z) | 44 test((handler) => { return new Proxy({}, handler) }, x, y, z) |
| 45 | 45 |
| 46 } | 46 } |
| 47 | 47 |
| 48 function TestWithFunctionProxy(test, x, y, z) { | 48 function TestWithFunctionProxy(test, x, y, z) { |
| 49 test((handler) => { | 49 test((handler) => { return new Proxy(() => {}, handler) }, x, y, z) |
| 50 return new Proxy(function() {}, handler) | |
| 51 }, x, y, z) | |
| 52 } | 50 } |
| 53 | 51 |
| 54 // --------------------------------------------------------------------------- | 52 // --------------------------------------------------------------------------- |
| 55 // Getting property descriptors (Object.getOwnPropertyDescriptor). | 53 // Getting property descriptors (Object.getOwnPropertyDescriptor). |
| 56 | 54 |
| 57 var key | 55 var key |
| 58 | 56 |
| 59 function TestGetOwnProperty(handler) { | 57 function TestGetOwnProperty(handler) { |
| 60 TestWithProxies(TestGetOwnProperty2, handler) | 58 TestWithProxies(TestGetOwnProperty2, handler) |
| 61 } | 59 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 })) | 97 })) |
| 100 | 98 |
| 101 | 99 |
| 102 // --------------------------------------------------------------------------- | 100 // --------------------------------------------------------------------------- |
| 103 function TestGetOwnPropertyThrow(handler) { | 101 function TestGetOwnPropertyThrow(handler) { |
| 104 TestWithProxies(TestGetOwnPropertyThrow2, handler) | 102 TestWithProxies(TestGetOwnPropertyThrow2, handler) |
| 105 } | 103 } |
| 106 | 104 |
| 107 function TestGetOwnPropertyThrow2(create, handler) { | 105 function TestGetOwnPropertyThrow2(create, handler) { |
| 108 var p = create(handler) | 106 var p = create(handler) |
| 109 assertThrows(function(){ Object.getOwnPropertyDescriptor(p, "a") }, "myexn") | 107 assertThrowsEquals(() => Object.getOwnPropertyDescriptor(p, "a"), "myexn") |
| 110 assertThrows(function(){ Object.getOwnPropertyDescriptor(p, 77) }, "myexn") | 108 assertThrowsEquals(() => Object.getOwnPropertyDescriptor(p, 77), "myexn") |
| 111 } | 109 } |
| 112 | 110 |
| 113 TestGetOwnPropertyThrow({ | 111 TestGetOwnPropertyThrow({ |
| 114 getOwnPropertyDescriptor: function(k) { throw "myexn" } | 112 getOwnPropertyDescriptor: function(k) { throw "myexn" } |
| 115 }) | 113 }) |
| 116 | 114 |
| 117 TestGetOwnPropertyThrow({ | 115 TestGetOwnPropertyThrow({ |
| 118 getOwnPropertyDescriptor: function(k) { | 116 getOwnPropertyDescriptor: function(k) { |
| 119 return this.getPropertyDescriptor2(k) | 117 return this.getOwnPropertyDescriptor2(k) |
| 120 }, | 118 }, |
| 121 getOwnPropertyDescriptor2: function(k) { throw "myexn" } | 119 getOwnPropertyDescriptor2: function(k) { throw "myexn" } |
| 122 }) | 120 }) |
| 123 | 121 |
| 124 TestGetOwnPropertyThrow({ | 122 TestGetOwnPropertyThrow({ |
| 125 getOwnPropertyDescriptor: function(k) { | 123 getOwnPropertyDescriptor: function(k) { |
| 126 return {get value() { throw "myexn" }} | 124 return {get value() { throw "myexn" }} |
| 127 } | 125 } |
| 128 }) | 126 }) |
| 129 | 127 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 })) | 258 })) |
| 261 | 259 |
| 262 | 260 |
| 263 // --------------------------------------------------------------------------- | 261 // --------------------------------------------------------------------------- |
| 264 function TestGetThrow(handler) { | 262 function TestGetThrow(handler) { |
| 265 TestWithProxies(TestGetThrow2, handler) | 263 TestWithProxies(TestGetThrow2, handler) |
| 266 } | 264 } |
| 267 | 265 |
| 268 function TestGetThrow2(create, handler) { | 266 function TestGetThrow2(create, handler) { |
| 269 var p = create(handler) | 267 var p = create(handler) |
| 270 assertThrows(function(){ p.a }, "myexn") | 268 assertThrowsEquals(function(){ p.a }, "myexn") |
| 271 assertThrows(function(){ p["b"] }, "myexn") | 269 assertThrowsEquals(function(){ p["b"] }, "myexn") |
| 272 assertThrows(function(){ p[3] }, "myexn") | 270 assertThrowsEquals(function(){ p[3] }, "myexn") |
| 273 assertThrows(function(){ (function(n) { p[n] })("c") }, "myexn") | 271 assertThrowsEquals(function(){ (function(n) { p[n] })("c") }, "myexn") |
| 274 assertThrows(function(){ (function(n) { p[n] })(99) }, "myexn") | 272 assertThrowsEquals(function(){ (function(n) { p[n] })(99) }, "myexn") |
| 275 | 273 |
| 276 var o = Object.create(p, {x: {value: 88}, '4': {value: 89}}) | 274 var o = Object.create(p, {x: {value: 88}, '4': {value: 89}}) |
| 277 assertThrows(function(){ o.a }, "myexn") | 275 assertThrowsEquals(function(){ o.a }, "myexn") |
| 278 assertThrows(function(){ o["b"] }, "myexn") | 276 assertThrowsEquals(function(){ o["b"] }, "myexn") |
| 279 assertThrows(function(){ o[3] }, "myexn") | 277 assertThrowsEquals(function(){ o[3] }, "myexn") |
| 280 assertThrows(function(){ (function(n) { o[n] })("c") }, "myexn") | 278 assertThrowsEquals(function(){ (function(n) { o[n] })("c") }, "myexn") |
| 281 assertThrows(function(){ (function(n) { o[n] })(99) }, "myexn") | 279 assertThrowsEquals(function(){ (function(n) { o[n] })(99) }, "myexn") |
| 282 } | 280 } |
| 283 | 281 |
| 284 TestGetThrow({ | 282 TestGetThrow({ |
| 285 get(r, k) { throw "myexn" } | 283 get(r, k) { throw "myexn" } |
| 286 }) | 284 }) |
| 287 | 285 |
| 288 TestGetThrow({ | 286 TestGetThrow({ |
| 289 get(r, k) { return this.get2(r, k) }, | 287 get(r, k) { return this.get2(r, k) }, |
| 290 get2(r, k) { throw "myexn" } | 288 get2(r, k) { throw "myexn" } |
| 291 }) | 289 }) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 })) | 349 })) |
| 352 | 350 |
| 353 | 351 |
| 354 // --------------------------------------------------------------------------- | 352 // --------------------------------------------------------------------------- |
| 355 function TestSetThrow(handler) { | 353 function TestSetThrow(handler) { |
| 356 TestWithProxies(TestSetThrow2, handler) | 354 TestWithProxies(TestSetThrow2, handler) |
| 357 } | 355 } |
| 358 | 356 |
| 359 function TestSetThrow2(create, handler) { | 357 function TestSetThrow2(create, handler) { |
| 360 var p = create(handler) | 358 var p = create(handler) |
| 361 assertThrows(function(){ p.a = 42 }, "myexn") | 359 assertThrowsEquals(function(){ p.a = 42 }, "myexn") |
| 362 assertThrows(function(){ p["b"] = 42 }, "myexn") | 360 assertThrowsEquals(function(){ p["b"] = 42 }, "myexn") |
| 363 assertThrows(function(){ p[22] = 42 }, "myexn") | 361 assertThrowsEquals(function(){ p[22] = 42 }, "myexn") |
| 364 assertThrows(function(){ (function(n) { p[n] = 45 })("c") }, "myexn") | 362 assertThrowsEquals(function(){ (function(n) { p[n] = 45 })("c") }, "myexn") |
| 365 assertThrows(function(){ (function(n) { p[n] = 46 })(99) }, "myexn") | 363 assertThrowsEquals(function(){ (function(n) { p[n] = 46 })(99) }, "myexn") |
| 366 } | 364 } |
| 367 | 365 |
| 368 TestSetThrow({ | 366 TestSetThrow({ |
| 369 set: function(r, k, v) { throw "myexn" } | 367 set: function(r, k, v) { throw "myexn" } |
| 370 }) | 368 }) |
| 371 | 369 |
| 372 TestSetThrow({ | 370 TestSetThrow({ |
| 373 set: function(r, k, v) { return this.set2(r, k, v) }, | 371 set: function(r, k, v) { return this.set2(r, k, v) }, |
| 374 set2: function(r, k, v) { throw "myexn" } | 372 set2: function(r, k, v) { throw "myexn" } |
| 375 }) | 373 }) |
| 376 | 374 |
| 377 TestSetThrow({ | 375 TestSetThrow({ |
| 378 getOwnPropertyDescriptor: function(k) { throw "myexn" }, | 376 getOwnPropertyDescriptor: function(k) { throw "myexn" }, |
| 379 defineProperty: function(k, desc) { key = k; val = desc.value } | 377 defineProperty: function(k, desc) { key = k; val = desc.value } |
| 380 }) | 378 }) |
| 381 | 379 |
| 382 TestSetThrow({ | 380 TestSetThrow({ |
| 383 getOwnPropertyDescriptor: function(k) { return {writable: true} }, | 381 getOwnPropertyDescriptor: function(k) { |
| 382 return {configurable: true, writable: true} |
| 383 }, |
| 384 defineProperty: function(k, desc) { throw "myexn" } | 384 defineProperty: function(k, desc) { throw "myexn" } |
| 385 }) | 385 }) |
| 386 | 386 |
| 387 TestSetThrow({ | 387 TestSetThrow({ |
| 388 getOwnPropertyDescriptor: function(k) { | 388 getOwnPropertyDescriptor: function(k) { |
| 389 return this.getOwnPropertyDescriptor2(k) | 389 return this.getOwnPropertyDescriptor2(k) |
| 390 }, | 390 }, |
| 391 getOwnPropertyDescriptor2: function(k) { throw "myexn" }, | 391 getOwnPropertyDescriptor2: function(k) { throw "myexn" }, |
| 392 defineProperty: function(k, desc) { this.defineProperty2(k, desc) }, | 392 defineProperty: function(k, desc) { this.defineProperty2(k, desc) }, |
| 393 defineProperty2: function(k, desc) { key = k; val = desc.value } | 393 defineProperty2: function(k, desc) { key = k; val = desc.value } |
| 394 }) | 394 }) |
| 395 | 395 |
| 396 TestSetThrow({ | 396 TestSetThrow({ |
| 397 getOwnPropertyDescriptor: function(k) { | 397 getOwnPropertyDescriptor: function(k) { |
| 398 return this.getOwnPropertyDescriptor2(k) | 398 return this.getOwnPropertyDescriptor2(k) |
| 399 }, | 399 }, |
| 400 getOwnPropertyDescriptor2: function(k) { return {writable: true} }, | 400 getOwnPropertyDescriptor2: function(k) { |
| 401 return {configurable: true, writable: true} |
| 402 }, |
| 401 defineProperty: function(k, desc) { this.defineProperty2(k, desc) }, | 403 defineProperty: function(k, desc) { this.defineProperty2(k, desc) }, |
| 402 defineProperty2: function(k, desc) { throw "myexn" } | 404 defineProperty2: function(k, desc) { throw "myexn" } |
| 403 }) | 405 }) |
| 404 | 406 |
| 405 TestSetThrow({ | 407 TestSetThrow({ |
| 406 getOwnPropertyDescriptor: function(k) { throw "myexn" }, | 408 getOwnPropertyDescriptor: function(k) { throw "myexn" }, |
| 407 defineProperty: function(k, desc) { key = k; val = desc.value } | 409 defineProperty: function(k, desc) { key = k; val = desc.value } |
| 408 }) | 410 }) |
| 409 | 411 |
| 410 TestSetThrow({ | 412 TestSetThrow({ |
| 411 getOwnPropertyDescriptor: function(k) { | 413 getOwnPropertyDescriptor: function(k) { |
| 412 return {get writable() { return true }} | 414 return { |
| 415 get configurable() { return true }, |
| 416 get writable() { return true } |
| 417 } |
| 413 }, | 418 }, |
| 414 defineProperty: function(k, desc) { throw "myexn" } | 419 defineProperty: function(k, desc) { throw "myexn" } |
| 415 }) | 420 }) |
| 416 | 421 |
| 417 TestSetThrow({ | 422 TestSetThrow({ |
| 418 getOwnPropertyDescriptor: function(k) { throw "myexn" } | 423 getOwnPropertyDescriptor: function(k) { throw "myexn" } |
| 419 }) | 424 }) |
| 420 | 425 |
| 421 TestSetThrow({ | 426 TestSetThrow({ |
| 422 getOwnPropertyDescriptor: function(k) { | |
| 423 return {set: function(v) { throw "myexn" }} | |
| 424 } | |
| 425 }) | |
| 426 | |
| 427 TestSetThrow({ | |
| 428 getOwnPropertyDescriptor: function(k) { throw "myexn" }, | 427 getOwnPropertyDescriptor: function(k) { throw "myexn" }, |
| 429 getPropertyDescriptor: function(k) { return {writable: true} }, | |
| 430 defineProperty: function(k, desc) { key = k; val = desc.value } | 428 defineProperty: function(k, desc) { key = k; val = desc.value } |
| 431 }) | 429 }) |
| 432 | 430 |
| 433 TestSetThrow({ | |
| 434 getOwnPropertyDescriptor: function(k) { return null }, | |
| 435 getPropertyDescriptor: function(k) { throw "myexn" }, | |
| 436 defineProperty: function(k, desc) { key = k; val = desc.value } | |
| 437 }) | |
| 438 | |
| 439 TestSetThrow({ | |
| 440 getOwnPropertyDescriptor: function(k) { return null }, | |
| 441 getPropertyDescriptor: function(k) { return {writable: true} }, | |
| 442 defineProperty: function(k, desc) { throw "myexn" } | |
| 443 }) | |
| 444 | |
| 445 TestSetThrow({ | |
| 446 getOwnPropertyDescriptor: function(k) { return null }, | |
| 447 getPropertyDescriptor: function(k) { | |
| 448 return {get writable() { throw "myexn" }} | |
| 449 }, | |
| 450 defineProperty: function(k, desc) { key = k; val = desc.value } | |
| 451 }) | |
| 452 | |
| 453 TestSetThrow({ | |
| 454 getOwnPropertyDescriptor: function(k) { return null }, | |
| 455 getPropertyDescriptor: function(k) { | |
| 456 return {set: function(v) { throw "myexn" }} | |
| 457 } | |
| 458 }) | |
| 459 | |
| 460 TestSetThrow({ | |
| 461 getOwnPropertyDescriptor: function(k) { return null }, | |
| 462 getPropertyDescriptor: function(k) { return null }, | |
| 463 defineProperty: function(k, desc) { throw "myexn" } | |
| 464 }) | |
| 465 | |
| 466 TestSetThrow(new Proxy({}, { | 431 TestSetThrow(new Proxy({}, { |
| 467 get: function(pr, pk) { throw "myexn" } | 432 get: function(pr, pk) { throw "myexn" } |
| 468 })) | 433 })) |
| 469 | 434 |
| 470 TestSetThrow(new Proxy({}, { | 435 TestSetThrow(new Proxy({}, { |
| 471 get: function(pr, pk) { | 436 get: function(pr, pk) { |
| 472 return function(r, k, v) { throw "myexn" } | 437 return function(r, k, v) { throw "myexn" } |
| 473 } | 438 } |
| 474 })) | 439 })) |
| 475 | 440 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 535 } |
| 571 Object.defineProperty(props, "hidden", {value: "hidden", enumerable: false}) | 536 Object.defineProperty(props, "hidden", {value: "hidden", enumerable: false}) |
| 572 assertEquals(p, Object.defineProperties(p, props)) | 537 assertEquals(p, Object.defineProperties(p, props)) |
| 573 assertEquals("last", key) | 538 assertEquals("last", key) |
| 574 assertEquals(2, Object.getOwnPropertyNames(desc).length) | 539 assertEquals(2, Object.getOwnPropertyNames(desc).length) |
| 575 assertEquals(21, desc.value) | 540 assertEquals(21, desc.value) |
| 576 assertEquals(true, desc.configurable) | 541 assertEquals(true, desc.configurable) |
| 577 assertEquals(undefined, desc.mine) // Arguably a bug in the spec... | 542 assertEquals(undefined, desc.mine) // Arguably a bug in the spec... |
| 578 | 543 |
| 579 var props = {bla: {get value() { throw "myexn" }}} | 544 var props = {bla: {get value() { throw "myexn" }}} |
| 580 assertThrows(function(){ Object.defineProperties(p, props) }, "myexn") | 545 assertThrowsEquals(function(){ Object.defineProperties(p, props) }, "myexn") |
| 581 } | 546 } |
| 582 | 547 |
| 583 TestDefine({ | 548 TestDefine({ |
| 584 defineProperty(t, k, d) { key = k; desc = d; return true } | 549 defineProperty(t, k, d) { key = k; desc = d; return true } |
| 585 }) | 550 }) |
| 586 | 551 |
| 587 TestDefine({ | 552 TestDefine({ |
| 588 defineProperty(t, k, d) { return this.defineProperty2(k, d) }, | 553 defineProperty(t, k, d) { return this.defineProperty2(k, d) }, |
| 589 defineProperty2(k, d) { key = k; desc = d; return true } | 554 defineProperty2(k, d) { key = k; desc = d; return true } |
| 590 }) | 555 }) |
| 591 | 556 |
| 592 | 557 |
| 593 // --------------------------------------------------------------------------- | 558 // --------------------------------------------------------------------------- |
| 594 function TestDefineThrow(handler) { | 559 function TestDefineThrow(handler) { |
| 595 TestWithProxies(TestDefineThrow2, handler) | 560 TestWithProxies(TestDefineThrow2, handler) |
| 596 } | 561 } |
| 597 | 562 |
| 598 function TestDefineThrow2(create, handler) { | 563 function TestDefineThrow2(create, handler) { |
| 599 var p = create(handler) | 564 var p = create(handler) |
| 600 assertThrows(function(){ Object.defineProperty(p, "a", {value: 44})}, "myexn") | 565 assertThrowsEquals(() => Object.defineProperty(p, "a", {value: 44}), "myexn") |
| 601 assertThrows(function(){ Object.defineProperty(p, 0, {value: 44})}, "myexn") | 566 assertThrowsEquals(() => Object.defineProperty(p, 0, {value: 44}), "myexn") |
| 602 | 567 |
| 603 var d1 = create({ | 568 var d1 = create({ |
| 604 get: function(r, k) { throw "myexn" }, | 569 get: function(r, k) { throw "myexn" }, |
| 605 getOwnPropertyNames: function() { return ["value"] } | 570 getOwnPropertyNames: function() { return ["value"] } |
| 606 }) | 571 }) |
| 607 assertThrows(function(){ Object.defineProperty(p, "p", d1) }, "myexn") | 572 assertThrowsEquals(function(){ Object.defineProperty(p, "p", d1) }, "myexn") |
| 608 var d2 = create({ | 573 var d2 = create({ |
| 609 get: function(r, k) { return 77 }, | 574 get: function(r, k) { return 77 }, |
| 610 getOwnPropertyNames: function() { throw "myexn" } | 575 getOwnPropertyNames: function() { throw "myexn" } |
| 611 }) | 576 }) |
| 612 assertThrows(function(){ Object.defineProperty(p, "p", d2) }, "myexn") | 577 assertThrowsEquals(function(){ Object.defineProperty(p, "p", d2) }, "myexn") |
| 613 | 578 |
| 614 var props = {bla: {get value() { throw "otherexn" }}} | 579 var props = {bla: {get value() { throw "otherexn" }}} |
| 615 assertThrows(function(){ Object.defineProperties(p, props) }, "otherexn") | 580 assertThrowsEquals(() => Object.defineProperties(p, props), "otherexn") |
| 616 } | 581 } |
| 617 | 582 |
| 618 TestDefineThrow({ | 583 TestDefineThrow({ |
| 619 defineProperty: function(k, d) { throw "myexn" } | 584 defineProperty: function(k, d) { throw "myexn" } |
| 620 }) | 585 }) |
| 621 | 586 |
| 622 TestDefineThrow({ | 587 TestDefineThrow({ |
| 623 defineProperty: function(k, d) { return this.defineProperty2(k, d) }, | 588 defineProperty: function(k, d) { return this.defineProperty2(k, d) }, |
| 624 defineProperty2: function(k, d) { throw "myexn" } | 589 defineProperty2: function(k, d) { throw "myexn" } |
| 625 }) | 590 }) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 })) | 656 })) |
| 692 | 657 |
| 693 | 658 |
| 694 // --------------------------------------------------------------------------- | 659 // --------------------------------------------------------------------------- |
| 695 function TestDeleteThrow(handler) { | 660 function TestDeleteThrow(handler) { |
| 696 TestWithProxies(TestDeleteThrow2, handler) | 661 TestWithProxies(TestDeleteThrow2, handler) |
| 697 } | 662 } |
| 698 | 663 |
| 699 function TestDeleteThrow2(create, handler) { | 664 function TestDeleteThrow2(create, handler) { |
| 700 var p = create(handler) | 665 var p = create(handler) |
| 701 assertThrows(function(){ delete p.a }, "myexn") | 666 assertThrowsEquals(function(){ delete p.a }, "myexn") |
| 702 assertThrows(function(){ delete p["b"] }, "myexn"); | 667 assertThrowsEquals(function(){ delete p["b"] }, "myexn"); |
| 703 assertThrows(function(){ delete p[3] }, "myexn"); | 668 assertThrowsEquals(function(){ delete p[3] }, "myexn"); |
| 704 | 669 |
| 705 (function() { | 670 (function() { |
| 706 "use strict" | 671 "use strict" |
| 707 assertThrows(function(){ delete p.c }, "myexn") | 672 assertThrowsEquals(function(){ delete p.c }, "myexn") |
| 708 assertThrows(function(){ delete p["d"] }, "myexn") | 673 assertThrowsEquals(function(){ delete p["d"] }, "myexn") |
| 709 assertThrows(function(){ delete p[4] }, "myexn"); | 674 assertThrowsEquals(function(){ delete p[4] }, "myexn"); |
| 710 })() | 675 })() |
| 711 } | 676 } |
| 712 | 677 |
| 713 TestDeleteThrow({ | 678 TestDeleteThrow({ |
| 714 deleteProperty(t, k) { throw "myexn" } | 679 deleteProperty(t, k) { throw "myexn" } |
| 715 }) | 680 }) |
| 716 | 681 |
| 717 TestDeleteThrow({ | 682 TestDeleteThrow({ |
| 718 deleteProperty(t, k) { return this.delete2(k) }, | 683 deleteProperty(t, k) { return this.delete2(k) }, |
| 719 delete2(k) { throw "myexn" } | 684 delete2(k) { throw "myexn" } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 }) | 737 }) |
| 773 | 738 |
| 774 | 739 |
| 775 // --------------------------------------------------------------------------- | 740 // --------------------------------------------------------------------------- |
| 776 function TestDescriptorThrow(handler) { | 741 function TestDescriptorThrow(handler) { |
| 777 TestWithProxies(TestDescriptorThrow2, handler) | 742 TestWithProxies(TestDescriptorThrow2, handler) |
| 778 } | 743 } |
| 779 | 744 |
| 780 function TestDescriptorThrow2(create, handler) { | 745 function TestDescriptorThrow2(create, handler) { |
| 781 var p = create(handler) | 746 var p = create(handler) |
| 782 assertThrows(function(){ Object.getOwnPropertyDescriptor(p, "a") }, "myexn") | 747 assertThrowsEquals(() => Object.getOwnPropertyDescriptor(p, "a"), "myexn") |
| 783 } | 748 } |
| 784 | 749 |
| 785 TestDescriptorThrow({ | 750 TestDescriptorThrow({ |
| 786 getOwnPropertyDescriptor: function(k) { throw "myexn" } | 751 getOwnPropertyDescriptor: function(k) { throw "myexn" } |
| 787 }) | 752 }) |
| 788 | 753 |
| 789 TestDescriptorThrow({ | 754 TestDescriptorThrow({ |
| 790 getOwnPropertyDescriptor: function(k) { | 755 getOwnPropertyDescriptor: function(k) { |
| 791 return this.getOwnPropertyDescriptor2(k) | 756 return this.getOwnPropertyDescriptor2(k) |
| 792 }, | 757 }, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 })) | 865 })) |
| 901 | 866 |
| 902 | 867 |
| 903 // --------------------------------------------------------------------------- | 868 // --------------------------------------------------------------------------- |
| 904 function TestInThrow(handler) { | 869 function TestInThrow(handler) { |
| 905 TestWithProxies(TestInThrow2, handler) | 870 TestWithProxies(TestInThrow2, handler) |
| 906 } | 871 } |
| 907 | 872 |
| 908 function TestInThrow2(create, handler) { | 873 function TestInThrow2(create, handler) { |
| 909 var p = create(handler) | 874 var p = create(handler) |
| 910 assertThrows(function(){ return "a" in o }, "myexn") | 875 assertThrowsEquals(function(){ return "a" in p }, "myexn") |
| 911 assertThrows(function(){ return 99 in o }, "myexn") | 876 assertThrowsEquals(function(){ return 99 in p }, "myexn") |
| 912 assertThrows(function(){ return !("a" in o) }, "myexn") | 877 assertThrowsEquals(function(){ return !("a" in p) }, "myexn") |
| 913 assertThrows(function(){ return ("a" in o) ? 2 : 3 }, "myexn") | 878 assertThrowsEquals(function(){ return ("a" in p) ? 2 : 3 }, "myexn") |
| 914 assertThrows(function(){ if ("b" in o) {} }, "myexn") | 879 assertThrowsEquals(function(){ if ("b" in p) {} }, "myexn") |
| 915 assertThrows(function(){ if (!("b" in o)) {} }, "myexn") | 880 assertThrowsEquals(function(){ if (!("b" in p)) {} }, "myexn") |
| 916 assertThrows(function(){ if ("zzz" in o) {} }, "myexn") | 881 assertThrowsEquals(function(){ if ("zzz" in p) {} }, "myexn") |
| 917 } | 882 } |
| 918 | 883 |
| 919 TestInThrow({ | 884 TestInThrow({ |
| 920 has: function(k) { throw "myexn" } | 885 has: function(k) { throw "myexn" } |
| 921 }) | 886 }) |
| 922 | 887 |
| 923 TestInThrow({ | 888 TestInThrow({ |
| 924 has: function(k) { return this.has2(k) }, | 889 has: function(k) { return this.has2(k) }, |
| 925 has2: function(k) { throw "myexn" } | 890 has2: function(k) { throw "myexn" } |
| 926 }) | 891 }) |
| 927 | 892 |
| 928 TestInThrow({ | |
| 929 getPropertyDescriptor: function(k) { throw "myexn" } | |
| 930 }) | |
| 931 | |
| 932 TestInThrow({ | |
| 933 getPropertyDescriptor: function(k) { return this.getPropertyDescriptor2(k) }, | |
| 934 getPropertyDescriptor2: function(k) { throw "myexn" } | |
| 935 }) | |
| 936 | |
| 937 TestInThrow({ | |
| 938 has: undefined, | |
| 939 getPropertyDescriptor: function(k) { throw "myexn" } | |
| 940 }) | |
| 941 | |
| 942 TestInThrow(new Proxy({},{ | 893 TestInThrow(new Proxy({},{ |
| 943 get: function(pr, pk) { throw "myexn" } | 894 get: function(pr, pk) { throw "myexn" } |
| 944 })) | 895 })) |
| 945 | 896 |
| 946 TestInThrow(new Proxy({},{ | 897 TestInThrow(new Proxy({},{ |
| 947 get: function(pr, pk) { | 898 get: function(pr, pk) { |
| 948 return function(k) { throw "myexn" } | 899 return function(k) { throw "myexn" } |
| 949 } | 900 } |
| 950 })) | 901 })) |
| 951 | 902 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 | 937 |
| 987 | 938 |
| 988 | 939 |
| 989 // --------------------------------------------------------------------------- | 940 // --------------------------------------------------------------------------- |
| 990 function TestHasOwnThrow(handler) { | 941 function TestHasOwnThrow(handler) { |
| 991 TestWithProxies(TestHasOwnThrow2, handler) | 942 TestWithProxies(TestHasOwnThrow2, handler) |
| 992 } | 943 } |
| 993 | 944 |
| 994 function TestHasOwnThrow2(create, handler) { | 945 function TestHasOwnThrow2(create, handler) { |
| 995 var p = create(handler) | 946 var p = create(handler) |
| 996 assertThrows(function(){ Object.prototype.hasOwnProperty.call(p, "a")}, | 947 assertThrowsEquals(function(){ Object.prototype.hasOwnProperty.call(p, "a")}, |
| 997 "myexn") | 948 "myexn") |
| 998 assertThrows(function(){ Object.prototype.hasOwnProperty.call(p, 99)}, | 949 assertThrowsEquals(function(){ Object.prototype.hasOwnProperty.call(p, 99)}, |
| 999 "myexn") | 950 "myexn") |
| 1000 } | 951 } |
| 1001 | 952 |
| 1002 TestHasOwnThrow({ | 953 TestHasOwnThrow({ |
| 1003 getOwnPropertyDescriptor(t, k) { throw "myexn" } | 954 getOwnPropertyDescriptor(t, k) { throw "myexn" } |
| 1004 }) | 955 }) |
| 1005 | 956 |
| 1006 TestHasOwnThrow({ | 957 TestHasOwnThrow({ |
| 1007 getOwnPropertyDescriptor(t, k) { return this.getOwnPropertyDescriptor2(k) }, | 958 getOwnPropertyDescriptor(t, k) { return this.getOwnPropertyDescriptor2(k) }, |
| 1008 getOwnPropertyDescriptor2(k) { throw "myexn" } | 959 getOwnPropertyDescriptor2(k) { throw "myexn" } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 })(); | 1126 })(); |
| 1176 | 1127 |
| 1177 | 1128 |
| 1178 // --------------------------------------------------------------------------- | 1129 // --------------------------------------------------------------------------- |
| 1179 function TestPropertyNamesThrow(handler) { | 1130 function TestPropertyNamesThrow(handler) { |
| 1180 TestWithProxies(TestPropertyNamesThrow2, handler) | 1131 TestWithProxies(TestPropertyNamesThrow2, handler) |
| 1181 } | 1132 } |
| 1182 | 1133 |
| 1183 function TestPropertyNamesThrow2(create, handler) { | 1134 function TestPropertyNamesThrow2(create, handler) { |
| 1184 var p = create(handler) | 1135 var p = create(handler) |
| 1185 assertThrows(function(){ Object.getOwnPropertyNames(p) }, "myexn") | 1136 assertThrowsEquals(function(){ Object.getOwnPropertyNames(p) }, "myexn") |
| 1186 } | 1137 } |
| 1187 | 1138 |
| 1188 TestPropertyNamesThrow({ | 1139 TestPropertyNamesThrow({ |
| 1189 ownKeys() { throw "myexn" } | 1140 ownKeys() { throw "myexn" } |
| 1190 }) | 1141 }) |
| 1191 | 1142 |
| 1192 TestPropertyNamesThrow({ | 1143 TestPropertyNamesThrow({ |
| 1193 ownKeys() { return this.getOwnPropertyNames2() }, | 1144 ownKeys() { return this.getOwnPropertyNames2() }, |
| 1194 getOwnPropertyNames2() { throw "myexn" } | 1145 getOwnPropertyNames2() { throw "myexn" } |
| 1195 }) | 1146 }) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 getOwnPropertyDescriptor: function(k) { return {configurable: true} } | 1207 getOwnPropertyDescriptor: function(k) { return {configurable: true} } |
| 1257 }) | 1208 }) |
| 1258 | 1209 |
| 1259 | 1210 |
| 1260 // --------------------------------------------------------------------------- | 1211 // --------------------------------------------------------------------------- |
| 1261 function TestKeysThrow(handler) { | 1212 function TestKeysThrow(handler) { |
| 1262 TestWithProxies(TestKeysThrow2, handler) | 1213 TestWithProxies(TestKeysThrow2, handler) |
| 1263 } | 1214 } |
| 1264 | 1215 |
| 1265 function TestKeysThrow2(create, handler) { | 1216 function TestKeysThrow2(create, handler) { |
| 1266 var p = create(handler) | 1217 var p = create(handler); |
| 1267 assertThrows(function(){ Object.keys(p) }, "myexn") | 1218 assertThrowsEquals(function(){ Object.keys(p) }, "myexn"); |
| 1268 } | 1219 } |
| 1269 | 1220 |
| 1270 TestKeysThrow({ | 1221 TestKeysThrow({ |
| 1271 ownKeys() { throw "myexn" } | 1222 ownKeys() { throw "myexn" } |
| 1272 }) | 1223 }) |
| 1273 | 1224 |
| 1274 TestKeysThrow({ | 1225 TestKeysThrow({ |
| 1275 ownKeys() { return this.keys2() }, | 1226 ownKeys() { return this.keys2() }, |
| 1276 keys2() { throw "myexn" } | 1227 keys2() { throw "myexn" } |
| 1277 }) | 1228 }) |
| 1278 | 1229 |
| 1279 TestKeysThrow({ | 1230 TestKeysThrow({ |
| 1280 ownKeys() { return ['1'] }, | 1231 ownKeys() { return ['1'] }, |
| 1281 getOwnPropertyDescriptor: function() { throw "myexn" }, | 1232 getOwnPropertyDescriptor: function() { throw "myexn" }, |
| 1282 }) | 1233 }) |
| 1283 | 1234 |
| 1284 TestKeysThrow({ | 1235 TestKeysThrow({ |
| 1285 ownKeys() { return this.getOwnPropertyNames2() }, | 1236 ownKeys() { return this.getOwnPropertyNames2() }, |
| 1286 getOwnPropertyNames2() { return [1, 2] }, | 1237 getOwnPropertyNames2() { return ['1', '2'] }, |
| 1287 getOwnPropertyDescriptor(k) { | 1238 getOwnPropertyDescriptor(k) { |
| 1288 return this.getOwnPropertyDescriptor2(k) | 1239 return this.getOwnPropertyDescriptor2(k) |
| 1289 }, | 1240 }, |
| 1290 getOwnPropertyDescriptor2(k) { throw "myexn" } | 1241 getOwnPropertyDescriptor2(k) { throw "myexn" } |
| 1291 }) | 1242 }) |
| 1292 | 1243 |
| 1293 TestKeysThrow({ | 1244 TestKeysThrow({ |
| 1294 get ownKeys() { throw "myexn" } | 1245 get ownKeys() { throw "myexn" } |
| 1295 }) | 1246 }) |
| 1296 | 1247 |
| 1297 TestKeysThrow({ | 1248 TestKeysThrow({ |
| 1298 get ownKeys() { | 1249 get ownKeys() { |
| 1299 return function() { throw "myexn" } | 1250 return function() { throw "myexn" } |
| 1300 }, | 1251 }, |
| 1301 }) | 1252 }) |
| 1302 | 1253 |
| 1303 TestKeysThrow({ | 1254 TestKeysThrow({ |
| 1304 get ownKeys() { | 1255 get ownKeys() { |
| 1305 return function() { return [1, 2] } | 1256 return function() { return ['1', '2'] } |
| 1306 }, | 1257 }, |
| 1307 getOwnPropertyDescriptor(k) { throw "myexn" } | 1258 getOwnPropertyDescriptor(k) { throw "myexn" } |
| 1308 }) | 1259 }) |
| 1309 | 1260 |
| 1310 | 1261 |
| 1311 | 1262 |
| 1312 // --------------------------------------------------------------------------- | 1263 // --------------------------------------------------------------------------- |
| 1313 // String conversion (Object.prototype.toString, | 1264 // String conversion (Object.prototype.toString, |
| 1314 // Object.prototype.toLocaleString, | 1265 // Object.prototype.toLocaleString, |
| 1315 // Function.prototype.toString) | 1266 // Function.prototype.toString) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 TestToString(new Proxy({}, { | 1305 TestToString(new Proxy({}, { |
| 1355 get: function(pr, pk) { | 1306 get: function(pr, pk) { |
| 1356 return function(r, k) { key = k; return function() { return "my_proxy" } } | 1307 return function(r, k) { key = k; return function() { return "my_proxy" } } |
| 1357 } | 1308 } |
| 1358 })) | 1309 })) |
| 1359 | 1310 |
| 1360 | 1311 |
| 1361 function TestToStringThrow(handler) { | 1312 function TestToStringThrow(handler) { |
| 1362 var p = new Proxy({}, handler) | 1313 var p = new Proxy({}, handler) |
| 1363 assertEquals("[object Object]", Object.prototype.toString.call(p)) | 1314 assertEquals("[object Object]", Object.prototype.toString.call(p)) |
| 1364 assertThrows(function(){ Object.prototype.toLocaleString.call(p) }, "myexn") | 1315 assertThrowsEquals(() => Object.prototype.toLocaleString.call(p), "myexn") |
| 1365 | 1316 |
| 1366 var f = new Proxy(function(){}, handler) | 1317 var f = new Proxy(function(){}, handler) |
| 1367 assertEquals("[object Function]", Object.prototype.toString.call(f)) | 1318 assertEquals("[object Function]", Object.prototype.toString.call(f)) |
| 1368 assertThrows(function(){ Object.prototype.toLocaleString.call(f) }, "myexn") | 1319 assertThrowsEquals(() => Object.prototype.toLocaleString.call(f), "myexn") |
| 1369 | 1320 |
| 1370 var o = Object.create(p) | 1321 var o = Object.create(p) |
| 1371 assertEquals("[object Object]", Object.prototype.toString.call(o)) | 1322 assertEquals("[object Object]", Object.prototype.toString.call(o)) |
| 1372 assertThrows(function(){ Object.prototype.toLocaleString.call(o) }, "myexn") | 1323 assertThrowsEquals(() => Object.prototype.toLocaleString.call(o), "myexn") |
| 1373 } | 1324 } |
| 1374 | 1325 |
| 1375 TestToStringThrow({ | 1326 TestToStringThrow({ |
| 1376 get: function(r, k) { throw "myexn" } | 1327 get: function(r, k) { throw "myexn" } |
| 1377 }) | 1328 }) |
| 1378 | 1329 |
| 1379 TestToStringThrow({ | 1330 TestToStringThrow({ |
| 1380 get: function(r, k) { return function() { throw "myexn" } } | 1331 get: function(r, k) { return function() { throw "myexn" } } |
| 1381 }) | 1332 }) |
| 1382 | 1333 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 })) | 1422 })) |
| 1472 | 1423 |
| 1473 | 1424 |
| 1474 // --------------------------------------------------------------------------- | 1425 // --------------------------------------------------------------------------- |
| 1475 function TestIsEnumerableThrow(handler) { | 1426 function TestIsEnumerableThrow(handler) { |
| 1476 TestWithProxies(TestIsEnumerableThrow2, handler) | 1427 TestWithProxies(TestIsEnumerableThrow2, handler) |
| 1477 } | 1428 } |
| 1478 | 1429 |
| 1479 function TestIsEnumerableThrow2(create, handler) { | 1430 function TestIsEnumerableThrow2(create, handler) { |
| 1480 var p = create(handler) | 1431 var p = create(handler) |
| 1481 assertThrows(function(){ Object.prototype.propertyIsEnumerable.call(p, "a") }, | 1432 assertThrowsEquals(() => Object.prototype.propertyIsEnumerable.call(p, "a"), |
| 1482 "myexn") | 1433 "myexn") |
| 1483 assertThrows(function(){ Object.prototype.propertyIsEnumerable.call(p, 11) }, | 1434 assertThrowsEquals(() => Object.prototype.propertyIsEnumerable.call(p, 11), |
| 1484 "myexn") | 1435 "myexn") |
| 1485 } | 1436 } |
| 1486 | 1437 |
| 1487 TestIsEnumerableThrow({ | 1438 TestIsEnumerableThrow({ |
| 1488 getOwnPropertyDescriptor: function(k) { throw "myexn" } | 1439 getOwnPropertyDescriptor: function(k) { throw "myexn" } |
| 1489 }) | 1440 }) |
| 1490 | 1441 |
| 1491 TestIsEnumerableThrow({ | 1442 TestIsEnumerableThrow({ |
| 1492 getOwnPropertyDescriptor: function(k) { | 1443 getOwnPropertyDescriptor: function(k) { |
| 1493 return this.getOwnPropertyDescriptor2(k) | 1444 return this.getOwnPropertyDescriptor2(k) |
| 1494 }, | 1445 }, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 var o = new C(); | 1492 var o = new C(); |
| 1542 | 1493 |
| 1543 function f() { | 1494 function f() { |
| 1544 return o.x; | 1495 return o.x; |
| 1545 } | 1496 } |
| 1546 assertEquals(10, f()); | 1497 assertEquals(10, f()); |
| 1547 assertEquals(10, f()); | 1498 assertEquals(10, f()); |
| 1548 %OptimizeFunctionOnNextCall(f); | 1499 %OptimizeFunctionOnNextCall(f); |
| 1549 assertEquals(10, f()); | 1500 assertEquals(10, f()); |
| 1550 })(); | 1501 })(); |
| OLD | NEW |