Merge lp:~abreu-alexandre/unity-webapps-qml/fix-local-script-handling into lp:unity-webapps-qml

Proposed by Alexandre Abreu on 2015-01-09
Status: Merged
Approved by: Alexandre Abreu on 2015-01-12
Approved revision: 143
Merged at revision: 143
Proposed branch: lp:~abreu-alexandre/unity-webapps-qml/fix-local-script-handling
Merge into: lp:unity-webapps-qml
Diff against target: 590 lines (+161/-85)
17 files modified
debian/control (+1/-1)
src/Ubuntu/UnityWebApps/UnityWebApps.js (+14/-15)
src/Ubuntu/UnityWebApps/UnityWebApps.qml (+2/-2)
src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js (+42/-24)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp (+0/-3)
tests/autopilot/data/all-in-same-folder/script.user.js (+3/-1)
tests/autopilot/data/all-in-same-folder/webapp-properties.json (+2/-2)
tests/autopilot/data/unity-webapps-normal/manifest.json (+6/-4)
tests/autopilot/data/unity-webapps-normal/script.user.js (+3/-1)
tests/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json (+3/-3)
tests/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js (+3/-1)
tests/autopilot/qml/FullWebViewApp.qml (+2/-1)
tests/autopilot/qml/WebviewBackendOxide.qml (+3/-2)
tests/autopilot/unity_webapps_qml/tests/__init__.py (+41/-11)
tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py (+27/-5)
tests/autopilot/unity_webapps_qml/tests/test_launcher.py (+9/-7)
tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py (+0/-2)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-webapps-qml/fix-local-script-handling
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2015-01-09
WebApps 2015-01-09 Pending
Review via email: mp+245969@code.launchpad.net

Commit message

When using a webapp-properties file for an unamed webapp the user script does not get injected.

Description of the change

When using a webapp-properties file for an unamed webapp the user script does not get injected.

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-11-22 00:43:42 +0000
+++ debian/control 2015-01-09 15:55:30 +0000
@@ -28,7 +28,7 @@
2828
29Package: unity-webapps-qml29Package: unity-webapps-qml
30Architecture: any30Architecture: any
31Depends: liboxideqt-qmlplugin (>= 1.2.0) | qml-module-qtwebkit,31Depends: liboxideqt-qmlplugin (>= 1.3.0) | qml-module-qtwebkit,
32 qtdeclarative5-qtquick2-plugin,32 qtdeclarative5-qtquick2-plugin,
33 qtdeclarative5-unity-action-plugin,33 qtdeclarative5-unity-action-plugin,
34 qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles,34 qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles,
3535
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.js'
--- src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-11-21 21:12:26 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.js 2015-01-09 15:55:30 +0000
@@ -40,7 +40,6 @@
40 this._injected_unity_api_path = injected_api_path;40 this._injected_unity_api_path = injected_api_path;
41 this._bindeeProxies = bindeeProxies;41 this._bindeeProxies = bindeeProxies;
42 this._backends = null;42 this._backends = null;
43 this._userscripts = [];
44 this._accessPolicy = accessPolicy;43 this._accessPolicy = accessPolicy;
45 this._callbackManager = UnityWebAppsUtils.makeCallbackManager();44 this._callbackManager = UnityWebAppsUtils.makeCallbackManager();
4645
@@ -50,16 +49,22 @@
50 _UnityWebApps.prototype = {49 _UnityWebApps.prototype = {
5150
52 cleanup: function() {51 cleanup: function() {
53 if (this._bindeeProxies.cleanup && typeof(this._bindeeProxies.cleanup) == 'function')52 if (this._bindeeProxies.cleanup
53 && typeof(this._bindeeProxies.cleanup) == 'function') {
54 this._bindeeProxies.cleanup();54 this._bindeeProxies.cleanup();
55 }
55 },56 },
5657
57 proxies: function() {58 proxies: function() {
58 return this._bindeeProxies;59 return this._bindeeProxies;
59 },60 },
6061
61 setUserScriptsToInject: function(userscripts) {62 injectWebappUserScripts: function(userscripts) {
62 this._userscripts = userscripts;63 if (this._bindeeProxies) {
64 this._bindeeProxies.injectUserScripts(
65 userscripts.map(function(script) {
66 return Qt.resolvedUrl(script); }));
67 }
63 },68 },
6469
65 setBackends: function(backends) {70 setBackends: function(backends) {
@@ -75,24 +80,18 @@
75 var cb = this._onMessageReceivedCallback.bind(self);80 var cb = this._onMessageReceivedCallback.bind(self);
76 self._bindeeProxies.messageReceivedConnect(cb);81 self._bindeeProxies.messageReceivedConnect(cb);
7782
78 this._onLoadingStartedCallback();83 this._injectCoreBindingUserScripts();
79 },84 },
8085
81 /**86 /**
82 * \internal87 * \internal
83 *88 *
84 */89 */
85 _onLoadingStartedCallback: function () {90 _injectCoreBindingUserScripts: function () {
86 var scripts = [this._injected_unity_api_path];91 if (this._bindeeProxies) {
87 for(var i = 0; i < this._userscripts.length; ++i) {92 this._bindeeProxies.injectUserScripts(
88 scripts.push(Qt.resolvedUrl(this._userscripts[i]));93 [Qt.resolvedUrl(this._injected_unity_api_path)]);
89 }94 }
90
91 for (i = 0; i < scripts.length; ++i)
92 console.debug('Injecting webapps script[' + i + '] : '
93 + scripts[i]);
94
95 this._bindeeProxies.injectUserScripts(scripts);
96 },95 },
9796
98 /**97 /**
9998
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-11-25 19:38:40 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2015-01-09 15:55:30 +0000
@@ -234,7 +234,7 @@
234 __getPolicyForContent(settings),234 __getPolicyForContent(settings),
235 customClientApiFileUrl && customClientApiFileUrl.length !== 0235 customClientApiFileUrl && customClientApiFileUrl.length !== 0
236 ? customClientApiFileUrl236 ? customClientApiFileUrl
237 : Qt.resolvedUrl('unity-webapps-api.js'));237 : 'unity-webapps-api.js');
238238
239 internal.instance = instance;239 internal.instance = instance;
240240
@@ -374,7 +374,7 @@
374 if (__isValidWebAppForModel(name)) {374 if (__isValidWebAppForModel(name)) {
375 if (internal.instance) {375 if (internal.instance) {
376 var userScripts = __gatherWebAppUserscriptsIfAny(name);376 var userScripts = __gatherWebAppUserscriptsIfAny(name);
377 internal.instance.setUserScriptsToInject(userScripts);377 internal.instance.injectWebappUserScripts(userScripts);
378 }378 }
379 __navigateToWebappHomepageInBindee(name);379 __navigateToWebappHomepageInBindee(name);
380 }380 }
381381
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js'
--- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-11-22 00:43:42 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2015-01-09 15:55:30 +0000
@@ -63,14 +63,12 @@
63 this.webview = webview;63 this.webview = webview;
64 this.disposer = disposer;64 this.disposer = disposer;
65 this.makeSignalDisconnecter = makeSignalDisconnecter;65 this.makeSignalDisconnecter = makeSignalDisconnecter;
66 this._userScriptInjected = false;
67 this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://main-world";66 this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://main-world";
67 this._injectedUserScripts = [];
68 this._scriptMessageReceivedHandler = null;
68}69}
69OxideWebviewAdapter.prototype = {70OxideWebviewAdapter.prototype = {
70 injectUserScripts: function(userScriptUrls) {71 injectUserScripts: function(userScriptUrls) {
71 if (this._userScriptInjected)
72 return;
73
74 var context = this.webview.context;72 var context = this.webview.context;
75 if (!context) {73 if (!context) {
76 console.error('No context found for the current Oxide webview. Cannot inject user scripts.');74 console.error('No context found for the current Oxide webview. Cannot inject user scripts.');
@@ -78,25 +76,33 @@
78 }76 }
7977
80 for (var i = 0; i < userScriptUrls.length; ++i) {78 for (var i = 0; i < userScriptUrls.length; ++i) {
81 var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; Oxide.UserScript { context:";79 var script = userScriptUrls[i];
80 if (this._injectedUserScripts.some(
81 function(e) { return e === script; })) {
82 console.log('Skipping already injected script: ' + script)
83 continue;
84 }
85
86 var scriptStart = "import com.canonical.Oxide 1.0 as Oxide; \
87Oxide.UserScript { ";
82 var scriptEnd = " }";88 var scriptEnd = " }";
83 var statement = scriptStart +89 var statement = scriptStart
84 '"' +90 + 'context: "' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '";'
85 this._WEBAPPS_USER_SCRIPT_CONTEXT +91 + 'matchAllFrames: false;'
86 '"' +92 + 'emulateGreasemonkey: true;'
87 '; matchAllFrames: false; emulateGreasemonkey: true; url: "' +93 + 'url: "' + script + '";'
88 userScriptUrls[i] +
89 '";'
90 + scriptEnd;94 + scriptEnd;
9195
92 context.addUserScript(Qt.createQmlObject(statement, this.webview));96 context.addUserScript(
97 Qt.createQmlObject(statement, this.webview));
93 }98 }
9499 this._injectedUserScripts.push(script);
95 this._userScriptInjected = true;
96 },100 },
97 sendToPage: function (message) {101 sendToPage: function (message) {
98 this.webview.rootFrame.sendMessageNoReply(102 this.webview.rootFrame.sendMessageNoReply(
99 this._WEBAPPS_USER_SCRIPT_CONTEXT, "UnityWebappApi-Host-Message", JSON.parse(message));103 this._WEBAPPS_USER_SCRIPT_CONTEXT,
104 "UnityWebappApi-Host-Message",
105 JSON.parse(message));
100 },106 },
101 loadingStartedConnect: function (onLoadingStarted) {107 loadingStartedConnect: function (onLoadingStarted) {
102 function handler(loadEvent) {108 function handler(loadEvent) {
@@ -109,17 +115,24 @@
109 this.disposer.addDisposer(this.makeSignalDisconnecter(this.webview.loadingChanged, handler));115 this.disposer.addDisposer(this.makeSignalDisconnecter(this.webview.loadingChanged, handler));
110 },116 },
111 messageReceivedConnect: function (onMessageReceived) {117 messageReceivedConnect: function (onMessageReceived) {
112 function handler(msg, frame) {118 function _handler(msg, frame) {
113 onMessageReceived(msg.args);119 onMessageReceived(msg.args);
114 }120 }
115121
116 var script = 'import com.canonical.Oxide 1.0 as Oxide; ' +122 if ( ! this._scriptMessageReceivedHandler) {
117 ' Oxide.ScriptMessageHandler { msgId: "UnityWebappApi-Message"; contexts: ["' +123 var script = 'import com.canonical.Oxide 1.0 as Oxide; ' +
118 this._WEBAPPS_USER_SCRIPT_CONTEXT +124 ' Oxide.ScriptMessageHandler { '
119 '"]; ' +125 + 'msgId: "UnityWebappApi-Message"; '
120 '}';126 + 'contexts: ["' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '"]; ' +
121 var messageHandler = Qt.createQmlObject(script, this.webview);127 '}';
122 messageHandler.callback = handler;128 this._scriptMessageReceivedHandler =
129 Qt.createQmlObject(script, this.webview);
130 }
131
132 this._scriptMessageReceivedHandler.callback = _handler;
133 },
134 cleanupAdapterInternals: function() {
135 this._scriptMessageReceivedHandler.callback = function() {};
123 }136 }
124}137}
125138
@@ -203,6 +216,11 @@
203 // called from the UnityWebApps side216 // called from the UnityWebApps side
204 proxy.cleanup = function() {217 proxy.cleanup = function() {
205 disposer.disposeAndCleanupAll();218 disposer.disposeAndCleanupAll();
219
220 if (this.cleanupAdapterInternals
221 && typeof(this.cleanupAdapterInternals) === "function") {
222 this.cleanupAdapterInternals();
223 }
206 };224 };
207225
208 return proxy;226 return proxy;
209227
=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-11-25 14:54:02 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2015-01-09 15:55:30 +0000
@@ -198,8 +198,6 @@
198 QFileInfo manifestFileInfo =198 QFileInfo manifestFileInfo =
199 installationDir.absolutePath() + QDir::separator() + manifestFileName;199 installationDir.absolutePath() + QDir::separator() + manifestFileName;
200 if ( ! manifestFileInfo.isFile()) {200 if ( ! manifestFileInfo.isFile()) {
201 qDebug() << "Skipping" << manifestFileName << "as a webapp definition search: "
202 << manifestFileInfo.absoluteFilePath();
203 continue;201 continue;
204 }202 }
205203
@@ -347,7 +345,6 @@
347 installationSearchPath + QDir::separator() + _commonScriptsDirName;345 installationSearchPath + QDir::separator() + _commonScriptsDirName;
348 READ_USER_SCRIPT(requires,COMMON_BASE_PATH);346 READ_USER_SCRIPT(requires,COMMON_BASE_PATH);
349 READ_USER_SCRIPT(scripts,userscriptPath.absolutePath());347 READ_USER_SCRIPT(scripts,userscriptPath.absolutePath());
350
351 return script;348 return script;
352}349}
353350
354351
=== modified file 'tests/autopilot/data/all-in-same-folder/script.user.js'
--- tests/autopilot/data/all-in-same-folder/script.user.js 2014-07-08 20:49:12 +0000
+++ tests/autopilot/data/all-in-same-folder/script.user.js 2015-01-09 15:55:30 +0000
@@ -1,1 +1,3 @@
1document.getElementById('content').innerHTML="WebApp Script Injected"1window.onload = function() {
2 document.getElementById('content').innerHTML="WebApp Script Injected"
3}
24
=== modified file 'tests/autopilot/data/all-in-same-folder/webapp-properties.json'
--- tests/autopilot/data/all-in-same-folder/webapp-properties.json 2014-07-08 20:49:12 +0000
+++ tests/autopilot/data/all-in-same-folder/webapp-properties.json 2015-01-09 15:55:30 +0000
@@ -1,8 +1,8 @@
1{1{
2 "includes": ["http://localhost:*/*"],2 "includes": ["http://www.test.com/*"],
3 "name": "ExtendedWebappProperties",3 "name": "ExtendedWebappProperties",
4 "scripts": ["script.user.js"],4 "scripts": ["script.user.js"],
5 "domain":"",5 "domain":"",
6 "homepage":"",6 "homepage":"http://www.test.com/",
7 "user-agent-override": "My Override"7 "user-agent-override": "My Override"
8}8}
99
=== modified file 'tests/autopilot/data/unity-webapps-normal/manifest.json'
--- tests/autopilot/data/unity-webapps-normal/manifest.json 2014-07-08 20:49:12 +0000
+++ tests/autopilot/data/unity-webapps-normal/manifest.json 2015-01-09 15:55:30 +0000
@@ -1,7 +1,9 @@
1{1{
2 "includes": ["http://localhost:*/*"],
3 "name": "Normal",2 "name": "Normal",
4 "scripts": ["script.user.js"],3 "domain": "test.com",
5 "domain":"",4 "homepage": "http://www.test.com/",
6 "homepage":""5 "includes": [
6 "http://www.test.com/*"
7 ],
8 "scripts": [ "script.user.js" ]
7}9}
810
=== modified file 'tests/autopilot/data/unity-webapps-normal/script.user.js'
--- tests/autopilot/data/unity-webapps-normal/script.user.js 2014-07-08 20:49:12 +0000
+++ tests/autopilot/data/unity-webapps-normal/script.user.js 2015-01-09 15:55:30 +0000
@@ -1,1 +1,3 @@
1document.getElementById('content').innerHTML="WebApp Script Injected"1window.onload = function() {
2 document.getElementById('content').innerHTML="WebApp Script Injected"
3}
24
=== modified file 'tests/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json'
--- tests/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json 2014-07-08 20:49:12 +0000
+++ tests/autopilot/data/unity-webapps-with-altered-ua-string/manifest.json 2015-01-09 15:55:30 +0000
@@ -1,8 +1,8 @@
1{1{
2 "includes": ["http://localhost:*/*"],2 "includes": ["http://www.test.com/*"],
3 "name": "AlteredUAWebapp",3 "name": "AlteredUAWebapp",
4 "scripts": ["script.user.js"],4 "scripts": ["script.user.js"],
5 "domain":"",5 "domain":"test.com",
6 "homepage":"",6 "homepage":"http://www.test.com/",
7 "user-agent-override": "My Override"7 "user-agent-override": "My Override"
8}8}
99
=== modified file 'tests/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js'
--- tests/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js 2014-07-08 20:49:12 +0000
+++ tests/autopilot/data/unity-webapps-with-altered-ua-string/script.user.js 2015-01-09 15:55:30 +0000
@@ -1,1 +1,3 @@
1document.getElementById('content').innerHTML="WebApp Script Injected"1window.onload = function() {
2 document.getElementById('content').innerHTML="WebApp Script Injected"
3}
24
=== modified file 'tests/autopilot/qml/FullWebViewApp.qml'
--- tests/autopilot/qml/FullWebViewApp.qml 2014-11-19 20:23:07 +0000
+++ tests/autopilot/qml/FullWebViewApp.qml 2015-01-09 15:55:30 +0000
@@ -35,7 +35,8 @@
35 signal resultUpdated(string message)35 signal resultUpdated(string message)
3636
37 function evalInPageUnsafe(expr) {37 function evalInPageUnsafe(expr) {
38 return webView.evaluateCode(expr, true);38 var val = webView.evaluateCode(expr, true);
39 resultUpdated(DomIntrospectionUtils.createResult(val))
39 }40 }
4041
41 property string url: ""42 property string url: ""
4243
=== modified file 'tests/autopilot/qml/WebviewBackendOxide.qml'
--- tests/autopilot/qml/WebviewBackendOxide.qml 2014-11-21 21:12:26 +0000
+++ tests/autopilot/qml/WebviewBackendOxide.qml 2015-01-09 15:55:30 +0000
@@ -1,9 +1,10 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtTest 1.02import QtTest 1.0
3import com.canonical.Oxide 1.0 as Oxide3import com.canonical.Oxide 1.0 as Oxide
4import Ubuntu.Web 0.2
4import Ubuntu.UnityWebApps 0.15import Ubuntu.UnityWebApps 0.1
56
6Oxide.WebView {7WebView {
7 id: webView8 id: webView
8 objectName: "webview"9 objectName: "webview"
910
@@ -56,7 +57,7 @@
56 return value ? value.result : undefined;57 return value ? value.result : undefined;
57 }58 }
5859
59 context: Oxide.WebContext {60 context: WebContext {
60 userAgent: webView.localUserAgentOverride.length === 061 userAgent: webView.localUserAgentOverride.length === 0
61 ? "" : webView.localUserAgentOverride62 ? "" : webView.localUserAgentOverride
62 userScripts: [63 userScripts: [
6364
=== modified file 'tests/autopilot/unity_webapps_qml/tests/__init__.py'
--- tests/autopilot/unity_webapps_qml/tests/__init__.py 2014-11-19 20:23:07 +0000
+++ tests/autopilot/unity_webapps_qml/tests/__init__.py 2015-01-09 15:55:30 +0000
@@ -8,9 +8,10 @@
8"""unity-webapps-qml autopilot tests."""8"""unity-webapps-qml autopilot tests."""
99
10import os10import os
11import json
11import os.path12import os.path
1213
13from testtools.matchers import Equals14from testtools.matchers import Equals, GreaterThan
14from autopilot.matchers import Eventually15from autopilot.matchers import Eventually
15from unity_webapps_qml.tests import fake_servers16from unity_webapps_qml.tests import fake_servers
1617
@@ -80,9 +81,9 @@
80 # we are local81 # we are local
81 base_params.append(82 base_params.append(
82 '--import={}'.format(83 '--import={}'.format(
83 os.path.join(os.path.dirname(os.path.realpath(__file__))),84 os.path.join(
84 '../../../../src'))85 os.path.dirname(os.path.realpath(__file__)),
8586 '../../../../src')))
86 base_params += extra_params87 base_params += extra_params
8788
88 return base_params89 return base_params
@@ -101,7 +102,11 @@
101 extra_params))102 extra_params))
102 self.assert_url_eventually_loaded(url)103 self.assert_url_eventually_loaded(url)
103104
104 def launch_application(self, args):105 def launch_application(self, args, envvars={}):
106 if envvars:
107 for envvar_key in envvars:
108 self.patch_environment(envvar_key, envvars[envvar_key])
109
105 self.app = self.launch_test_application(110 self.app = self.launch_test_application(
106 self.get_qml_launcher_path(),111 self.get_qml_launcher_path(),
107 *args,112 *args,
@@ -133,17 +138,37 @@
133138
134 def eval_expression_in_page_unsafe(self, expr):139 def eval_expression_in_page_unsafe(self, expr):
135 webview = self.get_webviewContainer()140 webview = self.get_webviewContainer()
136 return webview.slots.evalInPageUnsafe(expr)141 p = self.watcher.num_emissions
142 webview.slots.evalInPageUnsafe(expr)
143 self.assertThat(
144 lambda: self.watcher.num_emissions,
145 Eventually(GreaterThan(p)))
146 results = json.loads(
147 webview.get_signal_emissions(
148 'resultUpdated(QString)')[-1][0])
149 return 'result' in results and results['result'] or None
137150
138151
139class WebappsTestCaseBaseWithLocalHttpContentBase(UnityWebappsTestCaseBase):152class WebappsTestCaseBaseWithLocalHttpContentBase(UnityWebappsTestCaseBase):
153 BASE_URL_SCHEME = 'http://'
154
140 def setUp(self):155 def setUp(self):
141 super(WebappsTestCaseBaseWithLocalHttpContentBase, self).setUp()156 super(WebappsTestCaseBaseWithLocalHttpContentBase, self).setUp()
142 self.http_server = fake_servers.WebappsQmlContentHttpServer()157 self.http_server = fake_servers.WebappsQmlContentHttpServer()
143 self.addCleanup(self.http_server.shutdown)158 self.addCleanup(self.http_server.shutdown)
144 self.base_url = "http://localhost:{}/".format(self.http_server.port)159 self.base_url = "{}localhost:{}".format(
145160 self.BASE_URL_SCHEME, self.http_server.port)
146 def launch_with_webapp(self, name, webapp_search_path, use_oxide=False):161
162 def get_base_url_hostname(self):
163 return self.base_url[len(self.BASE_URL_SCHEME):]
164
165 def launch_with_webapp(
166 self,
167 name,
168 webapp_search_path,
169 envvars={},
170 use_oxide=False,
171 expected_homepage=''):
147 self.use_oxide = use_oxide172 self.use_oxide = use_oxide
148 self.launch_application(173 self.launch_application(
149 self.get_launch_params(174 self.get_launch_params(
@@ -151,5 +176,10 @@
151 name,176 name,
152 webapp_search_path,177 webapp_search_path,
153 self.base_url,178 self.base_url,
154 use_oxide))179 use_oxide),
155 self.assert_url_eventually_loaded(self.base_url)180 envvars)
181
182 url = self.base_url
183 if expected_homepage:
184 url = expected_homepage
185 self.assert_url_eventually_loaded(url)
156186
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py'
--- tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2014-11-19 20:23:07 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_installedWebapp.py 2015-01-09 15:55:30 +0000
@@ -33,7 +33,13 @@
33 return INSTALLED_HTML_TEST_FILE33 return INSTALLED_HTML_TEST_FILE
3434
35 def test_normalWebappFound(self):35 def test_normalWebappFound(self):
36 self.launch_with_webapp('Normal', self.get_webapp_install_folder())36 rule = 'MAP *.test.com:80 ' + self.get_base_url_hostname()
37 self.launch_with_webapp(
38 'Normal',
39 self.get_webapp_install_folder(),
40 {'UBUNTU_WEBVIEW_HOST_MAPPING_RULES': rule},
41 False,
42 'http://www.test.com/')
3743
38 self.assertThat(44 self.assertThat(
39 lambda: self.eval_expression_in_page_unsafe(45 lambda: self.eval_expression_in_page_unsafe(
@@ -49,18 +55,26 @@
49 Eventually(Equals("WebApp Script Injected")))55 Eventually(Equals("WebApp Script Injected")))
5056
51 def test_webappWithUAOverrideFound(self):57 def test_webappWithUAOverrideFound(self):
58 rule = 'MAP *.test.com:80 ' + self.get_base_url_hostname()
52 self.launch_with_webapp(59 self.launch_with_webapp(
53 'AlteredUAWebapp',60 'AlteredUAWebapp',
54 self.get_webapp_install_folder(), True)61 self.get_webapp_install_folder(),
62 {'UBUNTU_WEBVIEW_HOST_MAPPING_RULES': rule},
63 True,
64 'http://www.test.com/')
55 self.assertThat(65 self.assertThat(
56 lambda: self.eval_expression_in_page_unsafe(66 lambda: self.eval_expression_in_page_unsafe(
57 'return navigator.userAgent;'),67 'return navigator.userAgent;'),
58 Eventually(Equals("My Override")))68 Eventually(Equals("My Override")))
5969
60 def test_webappFoundWithSpecialWebappPropertiesFile(self):70 def test_webappFoundWithSpecialWebappPropertiesFile(self):
71 rule = 'MAP *.test.com:80 ' + self.get_base_url_hostname()
61 self.launch_with_webapp(72 self.launch_with_webapp(
62 'ExtendedWebappProperties',73 'ExtendedWebappProperties',
63 self.get_webapp_install_folder() + '/all-in-same-folder')74 self.get_webapp_install_folder() + '/all-in-same-folder',
75 {'UBUNTU_WEBVIEW_HOST_MAPPING_RULES': rule},
76 False,
77 'http://www.test.com/')
6478
65 self.assertThat(79 self.assertThat(
66 lambda: self.eval_expression_in_page_unsafe(80 lambda: self.eval_expression_in_page_unsafe(
@@ -76,18 +90,26 @@
76 Eventually(Equals("WebApp Script Injected")))90 Eventually(Equals("WebApp Script Injected")))
7791
78 def test_webappPropertiesFileWithUA(self):92 def test_webappPropertiesFileWithUA(self):
93 rule = 'MAP *.test.com:80 ' + self.get_base_url_hostname()
79 self.launch_with_webapp(94 self.launch_with_webapp(
80 'ExtendedWebappProperties',95 'ExtendedWebappProperties',
81 self.get_webapp_install_folder() + '/all-in-same-folder', True)96 self.get_webapp_install_folder() + '/all-in-same-folder',
97 {'UBUNTU_WEBVIEW_HOST_MAPPING_RULES': rule},
98 True,
99 'http://www.test.com/')
82 self.assertThat(100 self.assertThat(
83 lambda: self.eval_expression_in_page_unsafe(101 lambda: self.eval_expression_in_page_unsafe(
84 'return navigator.userAgent;'),102 'return navigator.userAgent;'),
85 Eventually(Equals("My Override")))103 Eventually(Equals("My Override")))
86104
87 def test_webappPropertiesNameUpdated(self):105 def test_webappPropertiesNameUpdated(self):
106 rule = 'MAP *.test.com:80 ' + self.get_base_url_hostname()
88 self.launch_with_webapp(107 self.launch_with_webapp(
89 '',108 '',
90 self.get_webapp_install_folder() + '/all-in-same-folder')109 self.get_webapp_install_folder() + '/all-in-same-folder',
110 {'UBUNTU_WEBVIEW_HOST_MAPPING_RULES': rule},
111 False,
112 'http://www.test.com/')
91 self.assertThat(113 self.assertThat(
92 lambda: self.eval_expression_in_page_unsafe(114 lambda: self.eval_expression_in_page_unsafe(
93 'return window.external.getUnityObject("1.0") != null;'),115 'return window.external.getUnityObject("1.0") != null;'),
94116
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_launcher.py'
--- tests/autopilot/unity_webapps_qml/tests/test_launcher.py 2014-11-19 20:23:07 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_launcher.py 2015-01-09 15:55:30 +0000
@@ -7,8 +7,6 @@
77
8import os8import os
99
10from gi.repository import Unity
11
12from testtools.matchers import Equals, NotEquals10from testtools.matchers import Equals, NotEquals
13from testtools import skipUnless11from testtools import skipUnless
1412
@@ -38,13 +36,14 @@
3836
39 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")37 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
40 def test_checkCounts(self):38 def test_checkCounts(self):
39 from gi.repository import Unity
41 self.assertThat(40 self.assertThat(
42 lambda: self.eval_expression_in_page_unsafe(41 lambda: self.eval_expression_in_page_unsafe(
43 "return document.getElementById('status').innerHTML;"),42 "return document.getElementById('status').innerHTML;"),
44 Eventually(Equals('launcher-updated')))43 Eventually(Equals('launcher-updated')))
4544
46 launcher_icon = self.unity.launcher.model.get_icon(45 launcher_icon = Unity.LauncherEntry.get_for_desktop_id(
47 desktop_id='unitywebappsqmllauncher.desktop')46 'unitywebappsqmllauncher.desktop')
48 self.assertThat(launcher_icon, NotEquals(None))47 self.assertThat(launcher_icon, NotEquals(None))
4948
50 expr = """49 expr = """
@@ -70,17 +69,20 @@
70 "return document.getElementById('status').innerHTML;"),69 "return document.getElementById('status').innerHTML;"),
71 Eventually(Equals('42')))70 Eventually(Equals('42')))
7271
73 # self.assertThat(launcher.get_property('progress'), Equals(0.09375))72# self.assertThat(
73# lambda: launcher_icon.get_property("count"),
74# Eventually(Equals(42)))
7475
75 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")76 @skipUnless(platform.model() == 'Desktop', "Only runs on the Desktop")
76 def test_checkProgress(self):77 def test_checkProgress(self):
78 from gi.repository import Unity
77 self.assertThat(79 self.assertThat(
78 lambda: self.eval_expression_in_page_unsafe(80 lambda: self.eval_expression_in_page_unsafe(
79 "return document.getElementById('status').innerHTML;"),81 "return document.getElementById('status').innerHTML;"),
80 Eventually(Equals('launcher-updated')))82 Eventually(Equals('launcher-updated')))
8183
82 launcher_icon = self.unity.launcher.model.get_icon(84 launcher_icon = Unity.LauncherEntry.get_for_desktop_id(
83 desktop_id='unitywebappsqmllauncher.desktop')85 'unitywebappsqmllauncher.desktop')
84 self.assertThat(launcher_icon, NotEquals(None))86 self.assertThat(launcher_icon, NotEquals(None))
8587
86 expr = """88 expr = """
8789
=== modified file 'tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py'
--- tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py 2014-11-19 20:23:07 +0000
+++ tests/autopilot/unity_webapps_qml/tests/test_mediaplayer.py 2015-01-09 15:55:30 +0000
@@ -7,8 +7,6 @@
77
8import os8import os
99
10from gi.repository import Unity
11
12from testtools.matchers import Equals10from testtools.matchers import Equals
13from testtools import skipUnless11from testtools import skipUnless
1412

Subscribers

People subscribed via source and target branches

to all changes: