diff options
-rw-r--r-- | src/core/api/qwebenginescript.cpp | 7 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_webchannel.qml | 6 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/webchannel-test.html | 1 |
3 files changed, 9 insertions, 5 deletions
diff --git a/src/core/api/qwebenginescript.cpp b/src/core/api/qwebenginescript.cpp index f23e91ea5..e414a8a6f 100644 --- a/src/core/api/qwebenginescript.cpp +++ b/src/core/api/qwebenginescript.cpp @@ -181,12 +181,11 @@ void QWebEngineScript::setSourceUrl(const QUrl &url) d->setSourceUrl(url); QFile file; - if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) { + if (url.isLocalFile()) { + file.setFileName(url.toLocalFile()); + } else if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) { if (url.authority().isEmpty()) file.setFileName(QLatin1Char(':') + url.path()); - return; - } else { - file.setFileName(url.toLocalFile()); } if (!file.open(QIODevice::ReadOnly)) { diff --git a/tests/auto/quick/qmltests/data/tst_webchannel.qml b/tests/auto/quick/qmltests/data/tst_webchannel.qml index 70edc1bcd..82db70288 100644 --- a/tests/auto/quick/qmltests/data/tst_webchannel.qml +++ b/tests/auto/quick/qmltests/data/tst_webchannel.qml @@ -81,6 +81,12 @@ Item { } function test_basic() { + webView.userScripts.collection = [ { + name: "qtwebchanneljs", + sourceUrl: Qt.resolvedUrl("qrc:/qtwebchannel/qwebchannel.js"), + injectionPoint: WebEngineScript.DocumentCreation, + worldId: WebEngineScript.MainWorld + }] webView.url = testUrl; verify(webView.waitForLoadSucceeded()); diff --git a/tests/auto/quick/qmltests/data/webchannel-test.html b/tests/auto/quick/qmltests/data/webchannel-test.html index 92966b24a..d8c3b1305 100644 --- a/tests/auto/quick/qmltests/data/webchannel-test.html +++ b/tests/auto/quick/qmltests/data/webchannel-test.html @@ -2,7 +2,6 @@ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script> <script type="text/javascript"> //BEGIN SETUP var channel = new QWebChannel(qt.webChannelTransport, function(channel) { |