27
27
qtest_expectedLoadsCommittedCount = 0;
30
property var qtest_testApiHosts: new Object()
30
32
function getTestApi() {
31
return new TestUtils.TestApiHost(this, rootFrame);
33
if (!(rootFrame in qtest_testApiHosts)) {
34
qtest_testApiHosts[rootFrame] = new TestUtils.TestApiHost(rootFrame);
37
return qtest_testApiHosts[rootFrame];
34
40
function getTestApiForFrame(frame) {
35
return new TestUtils.TestApiHost(this, frame);
41
if (!(frame in qtest_testApiHosts)) {
42
qtest_testApiHosts[frame] = new TestUtils.TestApiHost(frame);
45
return qtest_testApiHosts[frame];
38
48
function waitForLoadStarted(timeout) {
39
49
var expected = ++qtest_expectedLoadsStartedCount;
50
return TestUtils.waitFor(
41
51
function() { return expected == qtest_loadsStartedCount; },
45
55
function waitForLoadSucceeded(timeout) {
46
56
var expected = ++qtest_expectedLoadsSucceededCount;
57
return TestUtils.waitFor(
48
58
function() { return expected == qtest_loadsSucceededCount; },
52
62
function waitForLoadStopped(timeout, gcDuringWait) {
53
63
var expected = ++qtest_expectedLoadsStoppedCount;
64
return TestUtils.waitFor(
55
65
function() { return expected == qtest_loadsStoppedCount; },
56
66
timeout, gcDuringWait);
59
69
function waitForLoadFailed(timeout) {
60
70
var expected = ++qtest_expectedLoadsFailedCount;
71
return TestUtils.waitFor(
62
72
function() { return expected == qtest_loadsFailedCount; },
66
76
function waitForLoadCommitted(timeout) {
67
77
var expected = ++qtest_expectedLoadsCommittedCount;
78
return TestUtils.waitFor(
69
79
function() { return expected == qtest_loadsCommittedCount; },
73
function waitFor(predicate, timeout, gcDuringWait) {
74
timeout = timeout || 5000;
75
var end = Date.now() + timeout;
77
while (i < end && !predicate()) {
78
qtest_testResult.wait(50);
79
if (gcDuringWait) gc();
85
function wait(timeout) {
86
qtest_testResult.wait(timeout);
89
83
property int qtest_loadsStartedCount: 0
90
84
property int qtest_loadsSucceededCount: 0
91
85
property int qtest_loadsFailedCount: 0