Merge lp:~justinmcp/unity-webapps-gmail/validation-update into lp:unity-webapps-gmail

Proposed by Justin McPherson
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 90
Merged at revision: 88
Proposed branch: lp:~justinmcp/unity-webapps-gmail/validation-update
Merge into: lp:unity-webapps-gmail
Diff against target: 207 lines (+75/-57)
3 files modified
GMail.user.js (+73/-55)
debian/control (+1/-1)
manifest.json (+1/-1)
To merge this branch: bzr merge lp:~justinmcp/unity-webapps-gmail/validation-update
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Alexandre Abreu (community) Needs Fixing
Maxim Ermilov (community) Disapprove
Review via email: mp+199407@code.launchpad.net

Description of the change

Make use of node validations functions.

To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

LGTFM

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Maxim Ermilov (zaspire) wrote :

> +// @require validate.js
require newer version of unity-webapps-common.
SRU will not allow dependency between updated packages

review: Disapprove
Revision history for this message
David Barth (dbarth) wrote :

Le 18/12/2013 16:57, Maxim Ermilov a écrit :
> Review: Disapprove
>
>> +// @require validate.js
> require newer version of unity-webapps-common.
> SRU will not allow dependency between updated packages
I have the impression you meant "needs fixing" rather than a strict
"disapprove", so would you have recommendations to make this compatible
with the SRU process?

If not, then we should limit that to the upcoming LTS, for which those
changes are made anyway.

David

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

> > +// @require validate.js
> require newer version of unity-webapps-common.
> SRU will not allow dependency between updated packages

This is a review for the *trunk* series (which should be called "14.04
") not for 13.10 or before ... so the SRU doe snot apply, I see no reason to Disapprove this ...

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

> > > +// @require validate.js
> > require newer version of unity-webapps-common.
> > SRU will not allow dependency between updated packages
>
> This is a review for the *trunk* series (which should be called "14.04
> ") not for 13.10 or before ... so the SRU doe snot apply, I see no reason to
> Disapprove this ...

... and we are focusing on 14.04 ....

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

This MR can only be further approved once this one lands:

https://code.launchpad.net/~justinmcp/webapps-applications/webapp-support/+merge/199408

review: Needs Fixing
Revision history for this message
Robert Bruce Park (robru) wrote :

It's true this can't be SRU'd but it looks fine to me for Trusty at least.

review: Approve
Revision history for this message
Robert Bruce Park (robru) wrote :

Ok Justin, I have a lesson in dependency tracking for you ;-)

So I landed both of your webapps-application merges and built them in the PPA, where it received version number 2.4.17+14.04.20140122-0ubuntu1. So now on this branch, go into debian/control and set the required version in the dependencies. So that means change line 16 from this:

Depends: unity-webapps-common,

to this:

Depends: unity-webapps-common (>= 2.4.17+14.04.20140122-0ubuntu1),

Then once you commit and push that to this branch, jenkins will re-review automatically and it should pass.

review: Approve
90. By Justin McPherson

Specifiy version of unity-webapps-common.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Bruce Park (robru) wrote :

Ok, so, I finally had some extra time to get my testing VMs back up to speed here (they'd bitrotted somewhat over the holidays).

Using a fresh trusty VM, I was able to test your branches much more thoroughly.

First, I installed webapps-applications from the PPA (eg, the latest unreleased version that contains your last two branches that merged), then I branched this branch, built and installed it.

I played around with it a bit, and saw that it is working well. The launcher has the correct 'active pip', switching works as expected, etc, looks like a good app.

So I'm going to approve this one.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GMail.user.js'
2--- GMail.user.js 2013-11-06 00:52:12 +0000
3+++ GMail.user.js 2014-01-23 02:06:05 +0000
4@@ -1,6 +1,7 @@
5 // ==UserScript==
6 // @include https://mail.google.com/*
7 // @require utils.js
8+// @require validate.js
9 // @require google-common.js
10 // ==/UserScript==
11
12@@ -10,11 +11,7 @@
13 ));
14
15 window.Unity = external.getUnityObject(1);
16-var pane = null;
17
18-function getComposeMessageNode() {
19- return document.evaluate('//div[@role="navigation"]/div[1]/div[1]/div[1][@role="button"]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
20-}
21
22 function getNumber(str) {
23 try {
24@@ -26,40 +23,86 @@
25 }
26 }
27
28+
29+var interestNodes = {
30+ login: {
31+ name: 'login',
32+ query: '//div[@role="navigation"]//*[contains(text(), "@")]',
33+ validator: function (node) {
34+ return node.textContent.match(/^.*@.*\.{1}.*$/) !== null;
35+ },
36+ fragment: '<div role="navigation"><span>example@example.com</span></div>'
37+ },
38+ compose: {
39+ name: "compose button",
40+ query: '//div[@role="navigation"]/div[1]/div[1]/div[1][@role="button"]',
41+ fragment: ''
42+ },
43+ labels: {
44+ name: 'Labels',
45+ query: '//div[@role="navigation"]/div[2]//a[contains(@href, "#label")]',
46+ fragment: '',
47+ value: function (node) {
48+ return getNumber(node.textContent);
49+ }
50+ },
51+ inbox: {
52+ name: "Inbox",
53+ query: '//div[@role="navigation"]/div[2]//a[contains(@href, "#inbox")]',
54+ fragment: '',
55+ value: function (node) {
56+ return getNumber(node.text);
57+ }
58+ },
59+ pane: {
60+ name: 'pane',
61+ query: '//div[@role="navigation"]'
62+ }
63+};
64+
65+function getComposeMessageNode() {
66+ return validatedNode(interestNodes.compose);
67+}
68+
69+
70 function getLabels() {
71 var i, res = [];
72
73- var snapshot = document.evaluate('//div[@role="navigation"]/div[2]//a[contains(@href, "#label")]',
74- document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
75-
76- for (i = 0; i < snapshot.snapshotLength; i++) {
77- var node = snapshot.snapshotItem(i);
78-
79- res.push({ name: unescape(node.href.match(/#label\/(.+)$/)[1]),
80- count: getNumber(node.textContent),
81- link: node.href });
82+ var labelNodes = validatedNodes(interestNodes.labels);
83+
84+ for (i = 0; i < labelNodes.length; i++) {
85+ var node = labelNodes[i];
86+
87+ try {
88+ res.push({ name: unescape(node.href.match(/#label\/(.+)$/)[1]),
89+ count: validatedNodeValue(interestNodes.labels, node),
90+ link: node.href });
91+ } catch (labels_error) {
92+ }
93 }
94
95 return res;
96 }
97
98 function checkMessagesCount() {
99-
100 var indicators = [];
101
102- var inboxLink = document.evaluate('//div[@role="navigation"]/div[2]//a[contains(@href, "#inbox")]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
103-
104- if (!inboxLink || !inboxLink.href || !inboxLink.text) {
105- return indicators;
106- }
107- var numMessages = getNumber(inboxLink.text);
108-
109- indicators.push({ name: _("Inbox"),
110- count: numMessages,
111- callback: makeRedirector(inboxLink.href) });
112- var i, labels = getLabels();
113- for (i = 0; i < labels.length; i++) {
114- indicators.push({ name: trim(labels[i].name), count: labels[i].count, callback: makeRedirector(labels[i].link) });
115+ try {
116+ var inboxNode = validatedNodeValue(interestNodes.inbox);
117+ if (inboxNode === null) {
118+ return indicators;
119+ }
120+
121+ indicators.push({ name: _("Inbox"),
122+ count: validatedNodeValue(interestNodes.inbox, inboxNode),
123+ callback: makeRedirector(inboxNode.href) });
124+
125+ var i, labels = getLabels();
126+ for (i = 0; i < labels.length; i++) {
127+ indicators.push({ name: trim(labels[i].name), count: labels[i].count, callback: makeRedirector(labels[i].link) });
128+ }
129+
130+ } catch (messages_error) {
131 }
132
133 return indicators;
134@@ -80,23 +123,6 @@
135 reportTestState('PASS SELF TEST');
136 }
137
138-function validatedNode(nodeInfo) {
139- var resultSet = document.evaluate(nodeInfo.query,
140- document,
141- null,
142- XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
143- null);
144- if (!nodeInfo.validator(resultSet.snapshotItem(0))) {
145- var testNode = document.createElement("div");
146- testNode.innerHTML = nodeInfo.fragment;
147- resultSet = document.evaluate(nodeInfo.query, testNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
148- var fragmentOk = resultSet.snapshotLength > 0 && nodeInfo.validator(resultSet.snapshotItem(0));
149- reportTestState("REPORT: ERROR: Failed to validate node " + nodeInfo.name + " fragment check " + (fragmentOk ? "OK" : "failed"));
150- return null;
151- }
152- return resultSet.snapshotItem(0);
153-}
154-
155 function isCorrectPage() {
156 var i, ids = ['hist_frame', 'js_frame'];
157
158@@ -149,10 +175,10 @@
159 selfTest();
160 }
161
162+
163 if (isCorrectPage()) {
164 setTimeout(wrapCallback(function wait() {
165- pane = document.evaluate('//div[@role="navigation"]',
166- document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
167+ var pane = validatedNode(interestNodes.pane);
168
169 if (!pane || !document.getElementsByClassName("nU")) {
170 setTimeout(wait, 1000);
171@@ -160,15 +186,7 @@
172 }
173 var login = null;
174 try {
175- var loginNode = validatedNode({
176- name: 'login query',
177- query: '//div[@role="navigation"]//*[contains(text(), "@")]',
178- validator: function (node) {
179- return node.textContent.match(/^.*@.*\.{1}.*$/) !== null;
180- },
181- fragment: '<div role="navigation"><span>example@example.com</span></div>'
182- });
183-
184+ var loginNode = validatedNode(interestNodes.login);
185 if (loginNode !== null) {
186 login = loginNode.textContent;
187 }
188
189=== modified file 'debian/control'
190--- debian/control 2013-09-17 06:50:06 +0000
191+++ debian/control 2014-01-23 02:06:05 +0000
192@@ -13,7 +13,7 @@
193
194 Package: unity-webapps-gmail
195 Architecture: all
196-Depends: unity-webapps-common,
197+Depends: unity-webapps-common (>= 2.4.17+14.04.20140122-0ubuntu1),
198 xdg-utils,
199 ${misc:Depends},
200 XB-Ubuntu-Webapps-Includes: https://mail.google.com/*
201
202=== modified file 'manifest.json'
203--- manifest.json 2013-11-05 01:16:47 +0000
204+++ manifest.json 2014-01-23 02:06:05 +0000
205@@ -1,1 +1,1 @@
206-{"includes":["https://mail.google.com/*", "https://accounts.google.*/*", "https://www.google.com/a/*"],"requires":["utils.js","google-common.js"],"name":"Gmail","scripts":["GMail.user.js"],"maintainer":"Webapps Team <webapps@lists.launchpad.net>","license":"GPL-3","manifest-version":"1.0","integration-version":"2.4.8","package-name":"Gmail","description":"Unity Webapp for Gmail","icons":{"128":"128/unity-webapps-gmail.png","48":"48/unity-webapps-gmail.png","52":"52/unity-webapps-gmail.png","64":"64/unity-webapps-gmail.png"},"domain":"mail.google.com","homepage":"https://mail.google.com"}
207+{"includes":["https://mail.google.com/*", "https://accounts.google.*/*", "https://www.google.com/a/*"],"requires":["utils.js","google-common.js","validate.js"],"name":"Gmail","scripts":["GMail.user.js"],"maintainer":"Webapps Team <webapps@lists.launchpad.net>","license":"GPL-3","manifest-version":"1.0","integration-version":"2.4.8","package-name":"Gmail","description":"Unity Webapp for Gmail","icons":{"128":"128/unity-webapps-gmail.png","48":"48/unity-webapps-gmail.png","52":"52/unity-webapps-gmail.png","64":"64/unity-webapps-gmail.png"},"domain":"mail.google.com","homepage":"https://mail.google.com"}

Subscribers

People subscribed via source and target branches

to all changes: