JavaScript waitForever

Writing mochitests for new features in DevTools can be difficult and time-consuming.  There are so many elements interacting in an async manner that I oftentimes find myself using the debugger to debug the debugger!  In the case where it’s unclear what interaction isn’t working properly, I find myself going to a neat utility function: waitForever.  By using this function, paired with await, I can interact with the page while a given test is running to find the problem!

The JavaScript

waitForever is a super small snippet:

function waitForever() {
  return new Promise(r => {});
}

// Usage:
await waitForever();

The function uses a promise which never resolves, thus no additional statements are triggered while also not locking up the browser.

Check Full Content Here […]