$OpenBSD$ index b146a4a..a45e511 100644 --- dom/plugins/test/mochitest/dialog_watcher.js.orig Fri Feb 20 15:40:37 2015 +++ dom/plugins/test/mochitest/dialog_watcher.js Fri Feb 20 15:40:37 2015 @@ -97,12 +97,22 @@ DialogWatcher.prototype.init = function() { ctypes.jschar.ptr, ctypes.int); } + if (!this.messageBox) { + // Handy for debugging this code + this.messageBox = user32.declare("MessageBoxW", + ctypes.winapi_abi, + ctypes.int, + ctypes.uintptr_t, + ctypes.jschar.ptr, + ctypes.jschar.ptr, + ctypes.uint32_t); + } }; DialogWatcher.prototype.getWindowText = function(hwnd) { var bufType = ctypes.ArrayType(ctypes.jschar); var buffer = new bufType(256); - + if (this.getWindowTextW(hwnd, buffer, buffer.length)) { return buffer.readString(); } @@ -154,13 +164,15 @@ DialogWatcher.prototype.processWindowEvents = function(timeout) { var waitStatus = WAIT_OBJECT_0; var expectingStart = this.onDialogStart && this.hwnd === undefined; + var startWaitTime = Date.now(); while (this.hwnd === undefined || this.onDialogEnd && this.hwnd) { waitStatus = this.msgWaitForMultipleObjects(0, null, 0, expectingStart ? INFINITE : timeout, 0); if (waitStatus == WAIT_OBJECT_0) { var msg = new this.msgType; this.peekMessage(msg.address(), 0, 0, 0, PM_NOREMOVE); - } else if (waitStatus == WAIT_TIMEOUT) { + } + if (waitStatus == WAIT_TIMEOUT || (Date.now() - startWaitTime) >= timeout) { break; } }