Merge lp:~justinmcp/unity-webapps-gmail/heuristics-update into lp:unity-webapps-gmail
- heuristics-update
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Robert Bruce Park |
Proposed branch: | lp:~justinmcp/unity-webapps-gmail/heuristics-update |
Merge into: | lp:unity-webapps-gmail |
Diff against target: |
318 lines (+104/-178) 2 files modified
GMail.test.js (+1/-20) GMail.user.js (+103/-158) |
To merge this branch: | bzr merge lp:~justinmcp/unity-webapps-gmail/heuristics-update |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Bruce Park (community) | Needs Fixing | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+199409@code.launchpad.net |
Commit message
Description of the change
Change to use the WebApp class.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 90. By Justin McPherson
-
Fix loaded support, add missing name.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:90
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Robert Bruce Park (robru) wrote : | # |
Your diff introduces '@require validate.js', which causes the jslint checker to fail because it cannot find validate.js in the userscripts directory. What is this file and where did you get it from? The jenkins failure can most easily be resolved by not requiring validate.js, assuming that it can be easily removed from the code...
Justin McPherson (justinmcp) wrote : | # |
My fault, I mistakenly believed there was some dependency tracking between
projects. This should work when some changes to webapps-application go
through (webapp-support).
On Tue, Jan 7, 2014 at 11:06 AM, Robert Bruce Park <
<email address hidden>> wrote:
> Your diff introduces '@require validate.js', which causes the jslint
> checker to fail because it cannot find validate.js in the userscripts
> directory. What is this file and where did you get it from? The jenkins
> failure can most easily be resolved by not requiring validate.js, assuming
> that it can be easily removed from the code...
> --
>
> https:/
> You are the owner of lp:~justinmcp/unity-webapps-gmail/heuristics-update.
>
Justin McPherson (justinmcp) wrote : | # |
(for completeness)
webapp-support requires changes in node-validation (which is where
validate.js lives).
On Tue, Jan 7, 2014 at 11:22 AM, Justin McPherson <
<email address hidden>> wrote:
> My fault, I mistakenly believed there was some dependency tracking between
> projects. This should work when some changes to webapps-application go
> through (webapp-support).
>
>
>
>
> On Tue, Jan 7, 2014 at 11:06 AM, Robert Bruce Park <
> <email address hidden>> wrote:
>
>> Your diff introduces '@require validate.js', which causes the jslint
>> checker to fail because it cannot find validate.js in the userscripts
>> directory. What is this file and where did you get it from? The jenkins
>> failure can most easily be resolved by not requiring validate.js, assuming
>> that it can be easily removed from the code...
>> --
>>
>> https:/
>> You are the owner of lp:~justinmcp/unity-webapps-gmail/heuristics-update.
>>
>
>
Robert Bruce Park (robru) wrote : | # |
There is dependency tracking. When the necessary changes to webapps-
Robert Bruce Park (robru) wrote : | # |
Ok, so I built and installed webapps-
style_checker.js: checking GMail.user.js
GMail.user.
(gjs:6492): Gjs-WARNING **: JS ERROR:
JS_EvaluateScript() failed
make[1]: *** [override_
make[1]: Leaving directory `/home/
make: *** [build] Error 2
So there's an unexpected space on line 107 of the userscript, please take care of that and then I can continue reviewing this.
- 91. By Justin McPherson
-
Fix whitespace inline with style guide (jslint).
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:91
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Robert Bruce Park (robru) wrote : | # |
Ok, so like I said on the other branch, I got my VMs back up and running, so I was able to test this much more thoroughly on a pristine system ;-)
What I found for was that with the latest webapps-
Unmerged revisions
- 91. By Justin McPherson
-
Fix whitespace inline with style guide (jslint).
- 90. By Justin McPherson
-
Fix loaded support, add missing name.
- 89. By Justin McPherson
-
Change to use the WebApp class.
Preview Diff
1 | === modified file 'GMail.test.js' |
2 | --- GMail.test.js 2013-11-06 01:42:59 +0000 |
3 | +++ GMail.test.js 2014-01-23 01:58:32 +0000 |
4 | @@ -29,26 +29,7 @@ |
5 | assertEquals('Gmail', log[0].args[0].name, 'Gmail'); |
6 | assertEquals('Unity.Launcher.addAction', log[2].func, 'Unity.Launcher.addAction'); |
7 | assertEquals('Unity.MessagingIndicator.addAction', log[1].func, 'Unity.MessagingIndicator.addAction'); |
8 | - assertEquals('Unity.MessagingIndicator.clearIndicators', log[3].func, 'Unity.MessagingIndicator.clearIndicators'); |
9 | - assertFalse('log.length', log.length < 20); |
10 | - |
11 | - var found = false, i; |
12 | - for (i = 0; i < out.length; i++) { |
13 | - if (out[i] === 'PASS SELF TEST') { |
14 | - found = true; |
15 | - } |
16 | - } |
17 | - assertTrue('PASS SELF TEST', found); |
18 | - |
19 | - // Process output to look for reporting information |
20 | - for (i = 0; i < out.length; i++) { |
21 | - var logEntry = out[i]; |
22 | - |
23 | - found = logEntry.match(/^REPORT: ((\w+): .*)/); |
24 | - if (found !== null) { |
25 | - assertFalse(found[1], found[2] === 'ERROR'); |
26 | - } |
27 | - } |
28 | + assertEquals('Unity.MessagingIndicator.clearIndicators', log[4].func, 'Unity.MessagingIndicator.clearIndicators'); |
29 | }, |
30 | |
31 | scriptName: 'GMail.user.js' |
32 | |
33 | === modified file 'GMail.user.js' |
34 | --- GMail.user.js 2013-11-06 00:52:12 +0000 |
35 | +++ GMail.user.js 2014-01-23 01:58:32 +0000 |
36 | @@ -1,6 +1,8 @@ |
37 | // ==UserScript== |
38 | // @include https://mail.google.com/* |
39 | // @require utils.js |
40 | +// @require validate.js |
41 | +// @require webapp.js |
42 | // @require google-common.js |
43 | // ==/UserScript== |
44 | |
45 | @@ -10,11 +12,7 @@ |
46 | )); |
47 | |
48 | window.Unity = external.getUnityObject(1); |
49 | -var pane = null; |
50 | |
51 | -function getComposeMessageNode() { |
52 | - return document.evaluate('//div[@role="navigation"]/div[1]/div[1]/div[1][@role="button"]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; |
53 | -} |
54 | |
55 | function getNumber(str) { |
56 | try { |
57 | @@ -26,160 +24,107 @@ |
58 | } |
59 | } |
60 | |
61 | -function getLabels() { |
62 | - var i, res = []; |
63 | - |
64 | - var snapshot = document.evaluate('//div[@role="navigation"]/div[2]//a[contains(@href, "#label")]', |
65 | - document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); |
66 | - |
67 | - for (i = 0; i < snapshot.snapshotLength; i++) { |
68 | - var node = snapshot.snapshotItem(i); |
69 | - |
70 | - res.push({ name: unescape(node.href.match(/#label\/(.+)$/)[1]), |
71 | - count: getNumber(node.textContent), |
72 | - link: node.href }); |
73 | - } |
74 | - |
75 | - return res; |
76 | -} |
77 | - |
78 | -function checkMessagesCount() { |
79 | - |
80 | - var indicators = []; |
81 | - |
82 | - var inboxLink = document.evaluate('//div[@role="navigation"]/div[2]//a[contains(@href, "#inbox")]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; |
83 | - |
84 | - if (!inboxLink || !inboxLink.href || !inboxLink.text) { |
85 | - return indicators; |
86 | - } |
87 | - var numMessages = getNumber(inboxLink.text); |
88 | - |
89 | - indicators.push({ name: _("Inbox"), |
90 | - count: numMessages, |
91 | - callback: makeRedirector(inboxLink.href) }); |
92 | - var i, labels = getLabels(); |
93 | - for (i = 0; i < labels.length; i++) { |
94 | - indicators.push({ name: trim(labels[i].name), count: labels[i].count, callback: makeRedirector(labels[i].link) }); |
95 | - } |
96 | - |
97 | - return indicators; |
98 | -} |
99 | - |
100 | -/** |
101 | - * Validates the page for functional tests. |
102 | - * |
103 | - */ |
104 | -function selfTest() { |
105 | - if (!getComposeMessageNode()) { |
106 | - return; |
107 | - } |
108 | - if (!checkMessagesCount().length) { |
109 | - return; |
110 | - } |
111 | - |
112 | - reportTestState('PASS SELF TEST'); |
113 | -} |
114 | - |
115 | -function validatedNode(nodeInfo) { |
116 | - var resultSet = document.evaluate(nodeInfo.query, |
117 | - document, |
118 | - null, |
119 | - XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, |
120 | - null); |
121 | - if (!nodeInfo.validator(resultSet.snapshotItem(0))) { |
122 | - var testNode = document.createElement("div"); |
123 | - testNode.innerHTML = nodeInfo.fragment; |
124 | - resultSet = document.evaluate(nodeInfo.query, testNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); |
125 | - var fragmentOk = resultSet.snapshotLength > 0 && nodeInfo.validator(resultSet.snapshotItem(0)); |
126 | - reportTestState("REPORT: ERROR: Failed to validate node " + nodeInfo.name + " fragment check " + (fragmentOk ? "OK" : "failed")); |
127 | - return null; |
128 | - } |
129 | - return resultSet.snapshotItem(0); |
130 | -} |
131 | - |
132 | -function isCorrectPage() { |
133 | - var i, ids = ['hist_frame', 'js_frame']; |
134 | - |
135 | - for (i = 0; i < ids.length; i++) { |
136 | - if (!document.getElementById(ids[i])) { |
137 | - return false; |
138 | - } |
139 | - } |
140 | - |
141 | - return true; |
142 | -} |
143 | - |
144 | -function doMatrixIntegration() { |
145 | - doMainMenuIntegration(document); |
146 | - |
147 | - var i, labels = getLabels(); |
148 | - for (i = 0; i < labels.length; i++) { |
149 | - Unity.addAction('/' + labels[i].name, makeRedirector(labels[i].link)); |
150 | - } |
151 | -} |
152 | - |
153 | -function unityLoaded() { |
154 | - var composeNewMessage = wrapCallback(function () { |
155 | - var compose = getComposeMessageNode(); |
156 | - click(compose); |
157 | - }); |
158 | - |
159 | - Unity.MessagingIndicator.addAction(_("Compose New Message"), |
160 | - composeNewMessage); |
161 | - Unity.Launcher.addAction(_("Compose New Message"), |
162 | - composeNewMessage); |
163 | - |
164 | - var indicatorsController = new Indicators(checkMessagesCount); |
165 | - |
166 | - window.onpopstate = function () { |
167 | - var hash = window.location.hash; |
168 | - var label = null; |
169 | - if (hash.match(/#label\/(.+)/)) { |
170 | - label = unescape(hash.match(/#label\/(.+)/)[1]); |
171 | - } else if (hash === '#inbox') { |
172 | - label = _("Inbox"); |
173 | - } else { |
174 | - return; |
175 | - } |
176 | - indicatorsController.visited(label); |
177 | - }; |
178 | - |
179 | - doMatrixIntegration(); |
180 | - |
181 | - selfTest(); |
182 | -} |
183 | - |
184 | -if (isCorrectPage()) { |
185 | - setTimeout(wrapCallback(function wait() { |
186 | - pane = document.evaluate('//div[@role="navigation"]', |
187 | - document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue; |
188 | - |
189 | - if (!pane || !document.getElementsByClassName("nU")) { |
190 | - setTimeout(wait, 1000); |
191 | - return; |
192 | - } |
193 | - var login = null; |
194 | - try { |
195 | - var loginNode = validatedNode({ |
196 | - name: 'login query', |
197 | - query: '//div[@role="navigation"]//*[contains(text(), "@")]', |
198 | - validator: function (node) { |
199 | - return node.textContent.match(/^.*@.*\.{1}.*$/) !== null; |
200 | - }, |
201 | - fragment: '<div role="navigation"><span>example@example.com</span></div>' |
202 | + |
203 | +var gmailApp = new WebApp({ |
204 | + name: 'Gmail', |
205 | + iconUrl: "icon://unity-webapps-gmail", |
206 | + homepage: 'https://mail.google.com', |
207 | + domain: 'mail.google.com', |
208 | + maxRetries: 5, |
209 | + validator: function (weight) { |
210 | + return weight >= 0.5; |
211 | + }, |
212 | + login: { |
213 | + name: "login", |
214 | + nodes: ['//div[@role="navigation"]//*[contains(text(), "@")]', |
215 | + '//div[@role="navigation"]/div/div[1]/div[3]/div/ol/li[4]/div/div/div/div[2]/span[2]', |
216 | + '//div[@role="navigation"]/div/div[1]/div[3]/div/ol/li[4]/div/div/div/div[3]/span[2]'], |
217 | + validator: function (node) { |
218 | + return node.textContent.match(/^.*@.*\.{1}.*$/) !== null; |
219 | + }, |
220 | + value: function (node) { |
221 | + return node.textContent; |
222 | + }, |
223 | + fragment: '<div role="navigation"><span>example@example.com</span></div>' |
224 | + }, |
225 | + items: [{ |
226 | + name: 'Compose Message', |
227 | + nodes: ['//div[@role="navigation"]/div[1]/div[1]/div[1][@role="button"]'], |
228 | + match: WebApp.match.FIRST, |
229 | + validator: function (node) { |
230 | + return node.textContent !== ''; |
231 | + }, |
232 | + install: function (nodeFunction) { |
233 | + var composeNewMessage = wrapCallback(function () { |
234 | + var node = nodeFunction(); |
235 | + click(node); |
236 | }); |
237 | |
238 | - if (loginNode !== null) { |
239 | - login = loginNode.textContent; |
240 | + Unity.MessagingIndicator.addAction(_("Compose New Message"), |
241 | + composeNewMessage); |
242 | + Unity.Launcher.addAction(_("Compose New Message"), |
243 | + composeNewMessage); |
244 | + }, |
245 | + weight: 0.5 |
246 | + }, { |
247 | + name: 'inbox', |
248 | + nodes: [ '//div[@role="navigation"]/div[2]//a[contains(@href, "#inbox")]', |
249 | + '//div[@role="navigation"]/div/div/div/div/div/div/div/div/div/span/a' ], |
250 | + match: WebApp.match.FIRST, |
251 | + validator: function (node) { |
252 | + return !isNaN(getNumber(node.textContent)); |
253 | + }, |
254 | + value: function (node) { |
255 | + return { |
256 | + name: _('Inbox'), |
257 | + value: getNumber(node.textContent), |
258 | + link: makeRedirector(node.href) |
259 | + }; |
260 | + }, |
261 | + install: function (nodeFunction) { |
262 | + Unity.addAction('/' + this.name, makeRedirector(nodeFunction())); |
263 | + }, |
264 | + weight: 0.5 |
265 | + }, { |
266 | + name: 'labels', |
267 | + nodes: [ '//div[@role="navigation"]/div[2]//a[contains(@href, "#label")]', |
268 | + '//div[@role="navigation"]/div[2]/div/div/div[7]/div/*/div/div/div[2]/span/a'], |
269 | + match: WebApp.match.ALL, |
270 | + validator: function (node) { |
271 | + return node.href || (node.text && isNaN(getNumber(node.textContent))); |
272 | + }, |
273 | + value: function (node) { |
274 | + return { |
275 | + name: unescape(node.href.match(/#label\/(.+)$/)[1]), |
276 | + value: getNumber(node.textContent), |
277 | + link: makeRedirector(node.href) |
278 | + }; |
279 | + }, |
280 | + weight: 0.0 |
281 | + }] |
282 | +}, { |
283 | + success: function (page) { Unity.init(page); }, |
284 | + loaded: function (indicatorsController) { |
285 | + window.onpopstate = function () { |
286 | + var hash = window.location.hash; |
287 | + var label = null; |
288 | + if (hash.match(/#label\/(.+)/)) { |
289 | + label = unescape(hash.match(/#label\/(.+)/)[1]); |
290 | + } else if (hash === '#inbox') { |
291 | + return; |
292 | } |
293 | - } catch (gmail_err) { |
294 | - } |
295 | - |
296 | - Unity.init({ name: "Gmail", |
297 | - login: login, |
298 | - iconUrl: "icon://unity-webapps-gmail", |
299 | - homepage: 'https://mail.google.com', |
300 | - domain: 'mail.google.com', |
301 | - onInit: wrapCallback(unityLoaded) }); |
302 | - }), 2000); |
303 | -} |
304 | + indicatorsController.visited(label); |
305 | + }; |
306 | + |
307 | + doMainMenuIntegration(document); |
308 | + }, |
309 | + report: window.reportTestState |
310 | +}); |
311 | + |
312 | + |
313 | +setTimeout(wrapCallback(function setupPage() { |
314 | + if (!gmailApp.setupPage()) { |
315 | + setTimeout(setupPage, 2000); |
316 | + } |
317 | +}), |
318 | + 2000); |
FAILED: Continuous integration, rev:89 jenkins. qa.ubuntu. com/job/ unity-webapps- gmail-ci/ 18/ jenkins. qa.ubuntu. com/job/ unity-webapps- gmail-trusty- amd64-ci/ 11/console jenkins. qa.ubuntu. com/job/ unity-webapps- gmail-trusty- armhf-ci/ 11/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- webapps- gmail-ci/ 18/rebuild
http://