b1a53f122999671a4045c9c462aedd1f5ce82ec1
[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
8     preferences {
9         javascriptEnabled: true
10         localStorageEnabled: true
11         pluginsEnabled: true
12     }
13
14     SignalSpy {
15         id: spy
16         target: webView
17         signalName: "loadSucceeded"
18     }
19
20     TestCase {
21         name: "WebViewPreferences"
22
23         function init() {
24             webView.preferences.javascriptEnabled = true
25             webView.preferences.localStorageEnabled = true
26             webView.preferences.pluginsEnabled = true
27             spy.clear()
28         }
29
30         function test_javascriptEnabled() {
31             webView.preferences.javascriptEnabled = true
32             var testUrl = Qt.resolvedUrl("../common/javascript.html")
33             webView.load(testUrl)
34             spy.wait()
35             compare(webView.title, "New Title")
36         }
37
38         function test_javascriptDisabled() {
39             webView.preferences.javascriptEnabled = false
40             var testUrl = Qt.resolvedUrl("../common/javascript.html")
41             webView.load(testUrl)
42             spy.wait()
43             compare(webView.title, "Original Title")
44         }
45
46         function test_localStorageDisabled() {
47             webView.preferences.localStorageEnabled = false
48             var testUrl = Qt.resolvedUrl("../common/localStorage.html")
49             webView.load(testUrl)
50             spy.wait()
51             compare(webView.title, "Original Title")
52         }
53
54         function test_localStorageEnabled() {
55             webView.preferences.localStorageEnabled = true
56             var testUrl = Qt.resolvedUrl("../common/localStorage.html")
57             webView.load(testUrl)
58             spy.wait()
59             spy.clear()
60             webView.load(testUrl)
61             spy.wait()
62             compare(webView.title, "New Title")
63         }
64     }
65 }