Bug 1006234 - Fix some timeout problems with test_hangui. r=bsmedberg

This commit is contained in:
Aaron Klotz 2014-08-27 12:03:00 -04:00
parent a5690968ac
commit 8e73c3df23
2 changed files with 20 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -8,6 +8,8 @@
<title>Plugin Hang UI Test</title>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
<script type="application/javascript"
src="utils.js" />
<script type="application/javascript"
src="http://mochi.test:8888/chrome/dom/plugins/test/mochitest/hang_test.js" />
<script type="application/javascript"
@ -19,6 +21,7 @@
<script class="testbody" type="application/javascript">
<![CDATA[
SimpleTest.waitForExplicitFinish();
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
Components.utils.import("resource://gre/modules/Services.jsm");
@ -100,7 +103,8 @@ function runTests() {
resetVars();
hanguiExpect("Prime ChromeWorker", false, false, "test1");
hanguiOperation("Prime ChromeWorker", 0, false, false, HANGUIOP_NOTHING, 0,
false, "test1");
}
window.frameLoaded = runTests;
@ -244,7 +248,7 @@ function test3() {
}
function test2() {
// This test is identical to test1 because there were some bugs where the
// This test is identical to test1 because there were some bugs where the
// Hang UI would show on the first hang but not on subsequent hangs
hanguiExpect("test2: Plugin Hang UI is showing", true, true, "test3");
p.stall(STALL_DURATION);