~ubuntu-branches/ubuntu/vivid/unity-webapps-qml/vivid

« back to all changes in this revision

Viewing changes to tests/integration/autopilot/qml/FullWebViewApp.qml

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Alexandre Abreu
  • Date: 2014-07-09 20:05:56 UTC
  • mfrom: (1.1.34)
  • Revision ID: package-import@ubuntu.com-20140709200556-9jn0dwr8grb7364a
Tags: 0.1+14.10.20140709-0ubuntu1
[ Alexandre Abreu ]
Fix issue with qmlplugindump using 100% cpu Fix and expanded AP
tests to properly test the installed webapps case (LP: #1300957)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import QtQuick 2.0
20
20
import QtQuick.Window 2.0
21
 
import QtWebKit 3.0
22
 
import QtWebKit.experimental 1.0
23
21
import Ubuntu.Unity.Action 1.0 as UnityActions
24
22
import Ubuntu.UnityWebApps 0.1
 
23
import "."
25
24
 
26
25
import "dom-introspection-utils.js" as DomIntrospectionUtils
27
26
 
36
35
    signal resultUpdated(string message)
37
36
 
38
37
    function evalInPageUnsafe(expr) {
39
 
        var tid = DomIntrospectionUtils.gentid();
40
 
        console.log(DomIntrospectionUtils.wrapJsCommands(expr))
41
 
        webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr),
42
 
            function(result) { console.log('Result: ' + result); root.resultUpdated(DomIntrospectionUtils.createResult(result)); });
 
38
        if (webView && webView.experimental) {
 
39
            webView.experimental.evaluateJavaScript(DomIntrospectionUtils.wrapJsCommands(expr),
 
40
                function(result) {
 
41
                    console.log('Result: ' + result);
 
42
                    root.resultUpdated(DomIntrospectionUtils.createResult(result));
 
43
                });
 
44
        }
 
45
        else {
 
46
            root.resultUpdated(DomIntrospectionUtils.createResult(webView.evaluateCode("return navigator.userAgent", true)))
 
47
        }
43
48
    }
44
49
 
45
 
    property alias url: webView.url
 
50
    property var webView: null
 
51
 
 
52
    property bool useOxide: false
 
53
    property string url: ""
46
54
    property string webappName: ""
47
55
    property string webappSearchPath: ""
 
56
    property string webappHomepage: ""
48
57
 
49
58
    UnityActions.ActionManager {
50
59
        localContexts: [webappsActionsContext]
54
63
        active: true
55
64
    }
56
65
 
57
 
    WebView {
58
 
        id: webView
59
 
        objectName: "webview"
60
 
 
 
66
    Loader {
 
67
        id: webviewLoader
 
68
        onLoaded: {
 
69
            webView = webviewLoader.item
 
70
        }
 
71
    }
 
72
 
 
73
    Component.onCompleted: {
 
74
        var webviewSource = useOxide ?
 
75
                    Qt.resolvedUrl("WebviewBackendOxide.qml")
 
76
                  : Qt.resolvedUrl("WebviewBackendWebkit.qml");
 
77
        var override =  webappName && webappModel.exists(webappName) ?
 
78
                    webappModel.userAgentOverrideFor(webappName) : ""
 
79
        webviewLoader.setSource(webviewSource,
 
80
            { url: root.url,
 
81
            localUserAgentOverride: override})
 
82
    }
 
83
 
 
84
    Loader {
 
85
        id: unityWebappsComponentLoader
61
86
        anchors.fill: parent
62
 
        width: parent.width
63
 
        height: parent.height
64
 
 
65
 
        experimental.userScripts: []
66
 
        experimental.preferences.navigatorQtObjectEnabled: true
67
 
        experimental.preferences.developerExtrasEnabled: true
68
 
 
69
 
        function getUnityWebappsProxies() {
70
 
            return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);
71
 
        }
 
87
        sourceComponent: webView !== null && webappName.length !== 0 ? unityWebappsComponent : null
 
88
    }
 
89
 
 
90
    UnityWebappsAppModel {
 
91
        id: webappModel
 
92
        searchPath: root.webappSearchPath
 
93
    }
 
94
 
 
95
    Component {
 
96
        id: unityWebappsComponent
72
97
 
73
98
        UnityWebApps {
74
99
            id: webapps
76
101
            actionsContext: webappsActionsContext
77
102
            name: root.webappName
78
103
            bindee: webView
79
 
            //searchPath: '/home/alex/dev/work/webapps/branches/webapps-qml/latest/examples/data/userscripts'
80
 
            model: UnityWebappsAppModel { }
 
104
            _opt_homepage: root.webappHomepage
 
105
            model: webappModel
81
106
        }
82
107
    }
83
108
}