Use setTimeout to detect timeouts rather than Date arithmetic

The values provided by `Date` are subject to system clock skew and manipulation
from testing frameworks that override native APIs. So instead of detecting
timeouts in a setInterval callback that computes the difference of two Date
objects, use setTimeout to start a timeout countdown that is cleared whenever
a message is received. To protect against manipulation of setTimeout /
clearTimeout, bind them to closure-local 'set' / 'clear' vars.

This patch applies the same strategy to the screenshot timestamps: it binds
dateNow to Date.now before test code has a chance to tamper with it.