diff options
-rw-r--r-- | tests/auto/core/origins/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/core/origins/resources/mixedSchemes.html | 29 | ||||
-rw-r--r-- | tests/auto/core/origins/resources/mixedSchemes_frame.html | 9 | ||||
-rw-r--r-- | tests/auto/core/origins/resources/red.png | bin | 0 -> 146 bytes | |||
-rw-r--r-- | tests/auto/core/origins/tst_origins.cpp | 28 |
5 files changed, 45 insertions, 22 deletions
diff --git a/tests/auto/core/origins/CMakeLists.txt b/tests/auto/core/origins/CMakeLists.txt index 4a4219267..10a185f0a 100644 --- a/tests/auto/core/origins/CMakeLists.txt +++ b/tests/auto/core/origins/CMakeLists.txt @@ -32,6 +32,7 @@ set(tst_origins_resource_files "resources/viewSource.html" "resources/websocket.html" "resources/websocket2.html" + "resources/red.png" ) qt_internal_add_resource(tst_origins "tst_origins" diff --git a/tests/auto/core/origins/resources/mixedSchemes.html b/tests/auto/core/origins/resources/mixedSchemes.html index 53c8c83ff..3e50c2c3b 100644 --- a/tests/auto/core/origins/resources/mixedSchemes.html +++ b/tests/auto/core/origins/resources/mixedSchemes.html @@ -6,23 +6,34 @@ var result; var canary; - function setIFrameUrl(url) { + function setIFrameUrl(frameUrl,imgUrl) { result = undefined; canary = undefined; - document.getElementById("iframe").setAttribute("src", url); - // Early fire is OK unless the test is expecting cannotLoad. - // If timeout is too short then a false positive is possible. - setTimeout(() => { result = result || "cannotLoad"; }, 3000); + let img = document.createElement('img'); + img.onerror = function() { + console.log("TEST:cannotLoad"); + console.log("TEST:done"); + }; + img.onload = function() { + document.getElementById("iframe").setAttribute("src", frameUrl); + }; + img.src = imgUrl } addEventListener("load", function() { document.getElementById("iframe").addEventListener("load", function() { - if (canary && window[0].canary) - result = "canLoadAndAccess"; - else - result = "canLoadButNotAccess"; + if (canary && window[0].canary) { + console.log("TEST:canLoadAndAccess"); + console.log("TEST:done"); + } else { + console.log("TEST:canLoadButNotAccess"); + console.log("TEST:done"); + } }); }); + window.onerror = function(message, url, line, col, errorObj) { + return true; + }; </script> </head> <body> diff --git a/tests/auto/core/origins/resources/mixedSchemes_frame.html b/tests/auto/core/origins/resources/mixedSchemes_frame.html index 40ace2d2f..9499caa1f 100644 --- a/tests/auto/core/origins/resources/mixedSchemes_frame.html +++ b/tests/auto/core/origins/resources/mixedSchemes_frame.html @@ -3,9 +3,12 @@ <head> <title>Mixed - Frame</title> <script> - console.log('Frame Loaded'); - var canary = true; - parent.canary = true; + try{ + var canary = true; + parent.canary = true; + }catch(exception){ + }; + </script> </head> <body></body> diff --git a/tests/auto/core/origins/resources/red.png b/tests/auto/core/origins/resources/red.png Binary files differnew file mode 100644 index 000000000..5ae85192b --- /dev/null +++ b/tests/auto/core/origins/resources/red.png diff --git a/tests/auto/core/origins/tst_origins.cpp b/tests/auto/core/origins/tst_origins.cpp index 71285dcf0..2e58ed746 100644 --- a/tests/auto/core/origins/tst_origins.cpp +++ b/tests/auto/core/origins/tst_origins.cpp @@ -1005,9 +1005,14 @@ void tst_Origins::mixedContent() auto setIFrameUrl = [&] (const QString &scheme) { if (scheme == "data") - return QString("setIFrameUrl('data:,<script>var canary = true; parent.canary = true</script>')"); + return QString("setIFrameUrl('data:,<script>var canary = true; parent.canary = " + "true</script>','data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA" + "AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/" + "w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==')"); auto frameUrl = QString("%1:%2/resources/mixedSchemes_frame.html").arg(scheme).arg(scheme == "file" ? srcDir : ""); - return QString("setIFrameUrl('%1')").arg(frameUrl); + auto imgUrl = + QString("%1:%2/resources/red.png").arg(scheme).arg(scheme == "file" ? srcDir : ""); + return QString("setIFrameUrl('%1','%2')").arg(frameUrl).arg(imgUrl); }; m_page->messages.clear(); @@ -1019,15 +1024,18 @@ void tst_Origins::mixedContent() eval(setIFrameUrl(schemeTo)); - QTRY_COMPARE(eval(QSL("result !== undefined")), QVariant(true)); - auto result = eval(QSL("result")).toString(); - // Work-around some combinations missing JS loaded signals: - if (m_page->messages.size() > 0) { - if (m_page->messages[0] == QSL("Frame Loaded") && result == QSL("cannotLoad")) - result = QSL("canLoadButNotAccess"); - m_page->messages.clear(); + // wait for token in the log + QTRY_VERIFY(m_page->messages.contains("TEST:done")); + QString result; + // make sure we do not have some extra logs from blink + for (auto message : m_page->messages) { + QStringList s = message.split(':'); + if (s.size() > 1 && s[0] == "TEST") { + result = s[1]; + break; + } } - + m_page->messages.clear(); schemesTo.append(schemeTo.rightJustified(20)); results.append(result.rightJustified(20)); expected.append(expectedResult.rightJustified(20)); |