[Qt][WK2] Fix zero sized views in all QML tests
[WebKit.git] / Source / WebKit2 / UIProcess / API / qt / tests / qmltests / WebView / tst_preferences.qml
1 import QtQuick 2.0
2 import QtTest 1.0
3 import QtWebKit 3.0
4
5 WebView {
6     id: webView
7     width: 400
8     height: 300
9
10     preferences {
11         javascriptEnabled: true
12         localStorageEnabled: true
13         pluginsEnabled: true
14     }
15
16     SignalSpy {
17         id: spy
18         target: webView
19         signalName: "loadSucceeded"
20     }
21
22     TestCase {
23         name: "WebViewPreferences"
24
25         function init() {
26             webView.preferences.javascriptEnabled = true
27             webView.preferences.localStorageEnabled = true
28             webView.preferences.pluginsEnabled = true
29             spy.clear()
30         }
31
32         function test_javascriptEnabled() {
33             webView.preferences.javascriptEnabled = true
34             var testUrl = Qt.resolvedUrl("../common/javascript.html")
35             webView.load(testUrl)
36             spy.wait()
37             compare(webView.title, "New Title")
38         }
39
40         function test_javascriptDisabled() {
41             webView.preferences.javascriptEnabled = false
42             var testUrl = Qt.resolvedUrl("../common/javascript.html")
43             webView.load(testUrl)
44             spy.wait()
45             compare(webView.title, "Original Title")
46         }
47
48         function test_localStorageDisabled() {
49             webView.preferences.localStorageEnabled = false
50             var testUrl = Qt.resolvedUrl("../common/localStorage.html")
51             webView.load(testUrl)
52             spy.wait()
53             compare(webView.title, "Original Title")
54         }
55
56         function test_localStorageEnabled() {
57             webView.preferences.localStorageEnabled = true
58             var testUrl = Qt.resolvedUrl("../common/localStorage.html")
59             webView.load(testUrl)
60             spy.wait()
61             spy.clear()
62             webView.load(testUrl)
63             spy.wait()
64             compare(webView.title, "New Title")
65         }
66     }
67 }