test_stepping-12.js (3841B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Check that step out stops at the parent and the parent's parent. 8 * This checks for the failure found in bug 1530549. 9 */ 10 11 const sourceUrl = "test_stepping-10-test-code.js"; 12 13 add_task( 14 threadFrontTest(async args => { 15 dumpn("Evaluating test code and waiting for first debugger statement"); 16 17 await testGenerator(args); 18 await testAwait(args); 19 await testInterleaving(args); 20 await testMultipleSteps(args); 21 }) 22 ); 23 24 async function testAwait({ threadFront, debuggee }) { 25 function evaluateTestCode() { 26 Cu.evalInSandbox( 27 ` 28 (async function() { 29 debugger; 30 r = await Promise.resolve('yay'); 31 a = 4; 32 })(); 33 `, 34 debuggee, 35 "1.8", 36 sourceUrl, 37 1 38 ); 39 } 40 41 await executeOnNextTickAndWaitForPause(evaluateTestCode, threadFront); 42 43 dumpn("Step Over and land on line 5"); 44 const step1 = await stepOver(threadFront); 45 equal(step1.frame.where.line, 4); 46 equal(step1.frame.where.column, 10); 47 48 const step2 = await stepOver(threadFront); 49 equal(step2.frame.where.line, 5); 50 equal(step2.frame.where.column, 10); 51 equal(debuggee.r, "yay"); 52 await resume(threadFront); 53 } 54 55 async function testInterleaving({ threadFront, debuggee }) { 56 function evaluateTestCode() { 57 Cu.evalInSandbox( 58 ` 59 (async function simpleRace() { 60 debugger; 61 this.result = await new Promise((r) => { 62 Promise.resolve().then(() => { debugger }); 63 Promise.resolve().then(r('yay')) 64 }) 65 var a = 2; 66 debugger; 67 })() 68 `, 69 debuggee, 70 "1.8", 71 sourceUrl, 72 1 73 ); 74 } 75 76 await executeOnNextTickAndWaitForPause(evaluateTestCode, threadFront); 77 78 dumpn("Step Over and land on line 5"); 79 const step1 = await stepOver(threadFront); 80 equal(step1.frame.where.line, 4); 81 82 const step2 = await stepOver(threadFront); 83 equal(step2.frame.where.line, 5); 84 equal(step2.frame.where.column, 43); 85 86 const step3 = await resumeAndWaitForPause(threadFront); 87 equal(step3.frame.where.line, 9); 88 equal(debuggee.result, "yay"); 89 90 await resume(threadFront); 91 } 92 93 async function testMultipleSteps({ threadFront, debuggee }) { 94 function evaluateTestCode() { 95 Cu.evalInSandbox( 96 ` 97 (async function simpleRace() { 98 debugger; 99 await Promise.resolve(); 100 var a = 2; 101 await Promise.resolve(); 102 var b = 2; 103 await Promise.resolve(); 104 debugger; 105 })() 106 `, 107 debuggee, 108 "1.8", 109 sourceUrl, 110 1 111 ); 112 } 113 114 await executeOnNextTickAndWaitForPause(evaluateTestCode, threadFront); 115 116 const step1 = await stepOver(threadFront); 117 equal(step1.frame.where.line, 4); 118 119 const step2 = await stepOver(threadFront); 120 equal(step2.frame.where.line, 5); 121 122 const step3 = await stepOver(threadFront); 123 equal(step3.frame.where.line, 6); 124 resume(threadFront); 125 } 126 127 async function testGenerator({ threadFront, debuggee }) { 128 function evaluateTestCode() { 129 Cu.evalInSandbox( 130 ` 131 (async function() { 132 function* makeSteps() { 133 debugger; 134 yield 1; 135 yield 2; 136 return 3; 137 } 138 const s = makeSteps(); 139 s.next(); 140 s.next(); 141 s.next(); 142 })() 143 `, 144 debuggee, 145 "1.8", 146 sourceUrl, 147 1 148 ); 149 } 150 151 await executeOnNextTickAndWaitForPause(evaluateTestCode, threadFront); 152 153 const step1 = await stepOver(threadFront); 154 equal(step1.frame.where.line, 5); 155 156 const step2 = await stepOver(threadFront); 157 equal(step2.frame.where.line, 6); 158 159 const step3 = await stepOver(threadFront); 160 equal(step3.frame.where.line, 7); 161 await resume(threadFront); 162 }