misc_bugs.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
  6. var tests = [
  7. {
  8. name: "calling Symbol.toPrimitive on Date prototype should not AV",
  9. body: function () {
  10. Date.prototype[Symbol.toPrimitive].call({},'strin' + 'g');
  11. }
  12. },
  13. {
  14. name: "updated stackTraceLimit should not fire re-entrancy assert",
  15. body: function () {
  16. Error.__defineGetter__('stackTraceLimit', function () { return 1;});
  17. assert.throws(()=> Array.prototype.map.call([]));
  18. }
  19. },
  20. {
  21. name: "Array.prototype.slice should not fire re-entrancy error when the species returns proxy",
  22. body: function () {
  23. let arr = [1, 2];
  24. arr.__proto__ = {
  25. constructor: {
  26. [Symbol.species]: function () {
  27. return new Proxy({}, {
  28. defineProperty(...args) {
  29. return Reflect.defineProperty(...args);
  30. }
  31. });
  32. }
  33. }
  34. }
  35. Array.prototype.slice.call(arr);
  36. }
  37. },
  38. {
  39. name: "rest param under eval with arguments usage in the body should not fail assert",
  40. body: function () {
  41. f();
  42. function f() {
  43.     eval("function bar(...x){arguments;}")
  44. }
  45. }
  46. },
  47. {
  48. name: "Token left after parsing lambda result to the syntax error",
  49. body: function () {
  50. assert.throws(()=> { eval('function foo ([ [] = () => { } = {a2:z2}]) { };'); });
  51. }
  52. },
  53. {
  54. name: "Token left after parsing lambda in ternary operator should not throw",
  55. body: function () {
  56. assert.doesNotThrow(()=> { eval('function foo () { true ? e => {} : 1};'); });
  57. }
  58. },
  59. {
  60. name: "ArrayBuffer.slice with proxy constructor should not fail fast",
  61. body: function () {
  62. let arr = new ArrayBuffer(10);
  63. arr.constructor = new Proxy(ArrayBuffer, {});
  64. arr.slice(1,2);
  65. }
  66. },
  67. {
  68. name: "Large proxy chain should not cause IsConstructor to crash on stack overflow",
  69. body: function () {
  70. let p = new Proxy(Object, {});
  71. for (let i=0; i<20000; ++i)
  72. {
  73. p = new Proxy(p, {});
  74. }
  75. try
  76. {
  77. let a = new p();
  78. }
  79. catch(e)
  80. {
  81. }
  82. }
  83. }
  84. ];
  85. testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });