import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 import QtWebKit.experimental 3.0 WebView { id: webView width: 400 height: 300 experimental { urlSchemeDelegates: [ UrlSchemeDelegate { scheme: "applicationScheme" onReceivedRequest: { reply.data = "Test Application SchemeA test page." reply.send() } }, UrlSchemeDelegate { scheme: "scheme1" onReceivedRequest: { reply.data = "Scheme1 ReplyA test page." reply.send() } }, UrlSchemeDelegate { scheme: "scheme2" onReceivedRequest: { reply.data = "Scheme2 ReplyA test page." reply.send() } }, UrlSchemeDelegate { scheme: "scheme3" onReceivedRequest: { if (request.url == "scheme3://url1") reply.data = "Scheme3 Reply1A test page." else if (request.url == "scheme3://url2") reply.data = "Scheme3 Reply2A test page." else reply.data = "Should not happenA test page." reply.send() } } ] } SignalSpy { id: spyTitle target: webView signalName: "titleChanged" } TestCase { name: "WebViewApplicationSchemes" function test_applicationScheme() { spyTitle.clear() compare(spyTitle.count, 0) var testUrl = "applicationScheme://something" webView.load(testUrl) spyTitle.wait() compare(webView.title, "Test Application Scheme") } function test_multipleSchemes() { // Test if we receive the right reply when defining multiple schemes. spyTitle.clear() compare(spyTitle.count, 0) var testUrl = "scheme2://some-url-string" webView.load(testUrl) spyTitle.wait() compare(webView.title, "Scheme2 Reply") testUrl = "scheme1://some-url-string" webView.load(testUrl) spyTitle.wait() compare(webView.title, "Scheme1 Reply") compare(spyTitle.count, 2) } function test_multipleUrlsForScheme() { spyTitle.clear() compare(spyTitle.count, 0) var testUrl = "scheme3://url1" webView.load(testUrl) spyTitle.wait() compare(webView.title, "Scheme3 Reply1") testUrl = "scheme3://url2" webView.load(testUrl) spyTitle.wait() compare(webView.title, "Scheme3 Reply2") compare(spyTitle.count, 2) } } }