Add test expectation for one more test having color space issues after r156793.
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / qt / tests / qmltests / WebView / tst_loadUrl.qml
1 import QtQuick 2.0
2 import QtTest 1.0
3 import QtWebKit 3.0
4 import "../common"
5
6 TestWebView {
7     id: webView
8     property variant lastUrl
9     property bool watchProgress: false
10     property int numLoadStarted: 0
11     property int numLoadSucceeded: 0
12
13     focus: true
14
15     onLoadProgressChanged: {
16         if (watchProgress && webView.loadProgress != 100) {
17             watchProgress = false
18             url = ''
19         }
20     }
21
22     onLoadingChanged: {
23         if (loadRequest.status == WebView.LoadStartedStatus)
24             ++numLoadStarted
25         if (loadRequest.status == WebView.LoadSucceededStatus)
26             ++numLoadSucceeded
27     }
28
29     TestCase {
30         id: test
31         name: "WebViewLoadUrl"
32         when: windowShown
33
34         function test_loadIgnoreEmptyUrl() {
35             var url = Qt.resolvedUrl("../common/test1.html")
36
37             webView.url = url
38             verify(webView.waitForLoadSucceeded())
39             compare(numLoadStarted, 1)
40             compare(numLoadSucceeded, 1)
41             compare(webView.url, url)
42
43             lastUrl = webView.url
44             webView.url = ''
45             wait(1000)
46             compare(numLoadStarted, 1)
47             compare(numLoadSucceeded, 1)
48             compare(webView.url, lastUrl)
49
50             webView.url = 'about:blank'
51             verify(webView.waitForLoadSucceeded())
52             compare(numLoadStarted, 2)
53             compare(numLoadSucceeded, 2)
54             compare(webView.url, 'about:blank')
55
56             // It shouldn't interrupt any ongoing load when an empty url is used.
57             watchProgress = true
58             webView.url = url
59             webView.waitForLoadSucceeded()
60             compare(numLoadStarted, 3)
61             compare(numLoadSucceeded, 3)
62             verify(!watchProgress)
63             compare(webView.url, url)
64         }
65
66         function test_urlProperty() {
67             var url = Qt.resolvedUrl("../common/test1.html")
68
69             webView.url = url
70             compare(webView.url, url)
71             verify(webView.waitForLoadSucceeded())
72             compare(webView.url, url)
73
74             var bogusSite = "http://www.somesitethatdoesnotexist.abc/"
75             webView.url = bogusSite
76             compare(webView.url, bogusSite)
77             verify(webView.waitForLoadFailed())
78             compare(webView.url, bogusSite)
79
80             webView.url = "about:blank" // Reset from previous test
81             verify(webView.waitForLoadSucceeded())
82
83             var handleLoadFailed = function(loadRequest) {
84                 if (loadRequest.status == WebView.LoadFailedStatus) {
85                     compare(webView.url, bogusSite)
86                     compare(loadRequest.url, bogusSite)
87                     webView.loadHtml("load failed", bogusSite, bogusSite)
88                 }
89             }
90             webView.loadingChanged.connect(handleLoadFailed)
91             webView.url = bogusSite
92             compare(webView.url, bogusSite)
93             verify(webView.waitForLoadSucceeded())
94             compare(webView.url, bogusSite)
95             webView.loadingChanged.disconnect(handleLoadFailed)
96
97             var dataUrl = "data:text/html,foo"
98             webView.url = dataUrl
99             compare(webView.url, dataUrl)
100
101             var redirectUrl = Qt.resolvedUrl("../common/redirect.html")
102             webView.url = redirectUrl
103             compare(webView.url, redirectUrl)
104             verify(webView.waitForLoadSucceeded())
105             compare(webView.url, redirectUrl)
106             verify(webView.waitForLoadSucceeded())
107             compare(webView.url, url)
108
109             var linkUrl = Qt.resolvedUrl("../common/link.html")
110             webView.url = linkUrl
111             compare(webView.url, linkUrl)
112             verify(webView.waitForLoadSucceeded())
113             compare(webView.url, linkUrl)
114             webView.loadingChanged.connect(function(loadRequest) {
115                 compare(webView.url, loadRequest.url)
116                 compare(webView.url, url)
117             })
118             webView.forceActiveFocus()
119             keyPress(Qt.Key_Return) // Link is focused
120             verify(webView.waitForLoadSucceeded())
121             compare(webView.url, url)
122         }
123
124         function test_stopStatus() {
125             var url = Qt.resolvedUrl("../common/test1.html")
126
127             webView.loadingChanged.connect(function(loadRequest) {
128                 if (loadRequest.status == WebView.LoadStopStatus) {
129                     compare(webView.url, url)
130                     compare(loadRequest.url, url)
131                 }
132             })
133
134             webView.url = url
135             compare(webView.url, url)
136             webView.stop()
137             verify(webView.waitForLoadStopped())
138             compare(webView.url, url)
139         }
140     }
141 }