Refactor browser-specific postMessage code into RESUtils.sendMessage