summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-11-12 09:54:02 +0100
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-11-12 12:31:09 +0000
commit93745b5452c2ec69c04be2a2043c0937327ee556 (patch)
treecef5f705e8f5cf49bbc334bb51dc65a8c996ff83 /tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
parent6677ddec16488f21c5f730f4a4005c66d11d81e1 (diff)
stabilize tst_QWebEngineScript::injectionPoint
Use QTRY_COMPARE instead of a hard-coded timeout. Fix usage of setTimeout in DOMContentLoaded event listener. Change-Id: I915ea0d2c54cf45be42803963d03b19c15135fd4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp')
-rw-r--r--tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
index 80445051c..53762f54c 100644
--- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
+++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp
@@ -83,8 +83,7 @@ void tst_QWebEngineScript::injectionPoint()
}, 550));\
</script></head><body></body></html>"));
waitForSignal(&page, SIGNAL(loadFinished(bool)));
- QTest::qWait(550);
- QCOMPARE(evaluateJavaScriptSync(&page, "document.body.innerText"), QVariant::fromValue(QStringLiteral("SUCCESS")));
+ QTRY_COMPARE(evaluateJavaScriptSync(&page, "document.body.innerText"), QVariant::fromValue(QStringLiteral("SUCCESS")));
}
void tst_QWebEngineScript::injectionPoint_data()
@@ -95,9 +94,10 @@ void tst_QWebEngineScript::injectionPoint_data()
<< QStringLiteral("var contents = (typeof(foo) == \"undefined\")? \"FAILURE\" : \"SUCCESS\";");
QTest::newRow("DocumentReady") << static_cast<int>(QWebEngineScript::DocumentReady)
// use a zero timeout to make sure the user script got a chance to run as the order is undefined.
- << QStringLiteral("document.addEventListener(\"DOMContentLoaded\", setTimeout(function(event) {\
+ << QStringLiteral("document.addEventListener(\"DOMContentLoaded\", function() {\
+ setTimeout(function() {\
contents = (typeof(foo) == \"undefined\")? \"FAILURE\" : \"SUCCESS\";\
- }, 0));");
+ }, 0)});");
QTest::newRow("Deferred") << static_cast<int>(QWebEngineScript::Deferred)
<< QStringLiteral("document.addEventListener(\"load\", setTimeout(function(event) {\
contents = (typeof(foo) == \"undefined\")? \"FAILURE\" : \"SUCCESS\";\