LEFT | RIGHT |
1 // Copyright (C) 2013 Google Inc. | 1 // Copyright (C) 2013 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 expectedAlwaysThrow.set( | 567 expectedAlwaysThrow.set( |
568 RefAnyFrame('cajaVM.anonIntrinsics.GeneratorFunction.prototype'), | 568 RefAnyFrame('cajaVM.anonIntrinsics.GeneratorFunction.prototype'), |
569 true); // the prototype of function*s is not callable | 569 true); // the prototype of function*s is not callable |
570 | 570 |
571 // Using evalInTamingFrame because SES mitigated eval will reject | 571 // Using evalInTamingFrame because SES mitigated eval will reject |
572 // generator syntax when it parses. TODO(kpreid): use cajaVM.eval once we | 572 // generator syntax when it parses. TODO(kpreid): use cajaVM.eval once we |
573 // fully support generators. | 573 // fully support generators. |
574 var aGeneratorFunction = directAccess.evalInGuestFrame( | 574 var aGeneratorFunction = directAccess.evalInGuestFrame( |
575 '(function*() { "use strict"; ' +· | 575 '(function*() { "use strict"; ' +· |
576 'while (true) { try { yield 1; } catch (e) {} } })'); | 576 'while (true) { try { yield 1; } catch (e) {} } })'); |
| 577 var aGenerator = aGeneratorFunction(); |
| 578 aGenerator.next(); // so .throw() will be caught |
577 obtainInstance.define(cajaVM.anonIntrinsics.GeneratorFunction, | 579 obtainInstance.define(cajaVM.anonIntrinsics.GeneratorFunction, |
578 aGeneratorFunction); | 580 aGeneratorFunction); |
579 obtainInstance.define(cajaVM.anonIntrinsics.GeneratorFunction.prototype, | 581 obtainInstance.define(cajaVM.anonIntrinsics.GeneratorFunction.prototype, |
580 aGeneratorFunction()); | 582 aGenerator); |
581 ······ | 583 ······ |
582 var generatorIteratorPrototype = | 584 var generatorIteratorPrototype = |
583 cajaVM.anonIntrinsics.GeneratorFunction.prototype.prototype; | 585 cajaVM.anonIntrinsics.GeneratorFunction.prototype.prototype; |
584 ······ | 586 ······ |
585 // TODO(kpreid): Would be nice to be able to say "these methods on any | 587 // TODO(kpreid): Would be nice to be able to say "these methods on any |
586 // subtype of Iterator". | 588 // subtype of Iterator". |
587 functionArgs.set( | 589 functionArgs.set( |
588 Ref.all( | 590 Ref.all( |
589 Ref.is(generatorIteratorPrototype.next), | 591 Ref.is(generatorIteratorPrototype.next), |
590 Ref.is(generatorIteratorPrototype['return']), | 592 Ref.is(generatorIteratorPrototype['return']), |
591 Ref.is(generatorIteratorPrototype['throw'])), | 593 Ref.is(generatorIteratorPrototype['throw'])), |
592 // fresh because it returns { value: ..., done: ... } | 594 // fresh because it returns { value: ..., done: ... } |
593 freshResult(G.any( | 595 freshResult(G.any( |
594 genAllCall(), genMethod(), genMethod(genSmallInteger)))); | 596 genMethod(G.value('foo')), genMethod()))); |
595 } | 597 } |
596 | 598 |
597 argsByIdentity(cajaVM.anonIntrinsics.ThrowTypeError, genAllCall()); | 599 argsByIdentity(cajaVM.anonIntrinsics.ThrowTypeError, genAllCall()); |
598 expectedAlwaysThrow.setByIdentity( | 600 expectedAlwaysThrow.setByIdentity( |
599 cajaVM.anonIntrinsics.ThrowTypeError, true); | 601 cajaVM.anonIntrinsics.ThrowTypeError, true); |
600 // TODO test other intrinsics like %TypedArray% | 602 // TODO test other intrinsics like %TypedArray% |
601 | 603 |
602 argsByIdentity(Number, genAllCall(genSmallInteger)); | 604 argsByIdentity(Number, genAllCall(genSmallInteger)); |
603 argsByAnyFrame('Number.prototype.toExponential', | 605 argsByAnyFrame('Number.prototype.toExponential', |
604 genMethod(genSmallInteger)); | 606 genMethod(genSmallInteger)); |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 el.className = el.className.replace(/ scan-hide-non-errors/g, ''); | 1625 el.className = el.className.replace(/ scan-hide-non-errors/g, ''); |
1624 } | 1626 } |
1625 hideCheckbox.checked = hide; | 1627 hideCheckbox.checked = hide; |
1626 } | 1628 } |
1627 document.addEventListener('DOMContentLoaded', function() { | 1629 document.addEventListener('DOMContentLoaded', function() { |
1628 hideCheckbox = document.getElementById('hide-non-errors-checkbox'); | 1630 hideCheckbox = document.getElementById('hide-non-errors-checkbox'); |
1629 hideCheckbox.onclick = function() { toggleNonErrors(); }; | 1631 hideCheckbox.onclick = function() { toggleNonErrors(); }; |
1630 }, false); | 1632 }, false); |
1631 window.toggleNonErrors = toggleNonErrors; | 1633 window.toggleNonErrors = toggleNonErrors; |
1632 }()); | 1634 }()); |
LEFT | RIGHT |