Commit 2b12b54cba86b7080174c81461edccd2e243e1aa
1 parent
8e325507
Exists in
master
and in
1 other branch
Correção de comportamento 1
git-svn-id: https://svn.bento.ifrs.edu.br/default/ASES/ASES%20-%20Web/ASES%20-%20Web/Fontes/avaliador-api@10201 c2178572-b5ca-4887-91d2-9e3a90c7d55b
Showing
2 changed files
with
79 additions
and
28 deletions
Show diff stats
src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java
... | ... | @@ -6,6 +6,7 @@ import java.util.List; |
6 | 6 | import net.htmlparser.jericho.Attribute; |
7 | 7 | import net.htmlparser.jericho.Element; |
8 | 8 | import net.htmlparser.jericho.Source; |
9 | +import net.htmlparser.jericho.Tag; | |
9 | 10 | import br.com.checker.emag.Occurrence; |
10 | 11 | import br.com.checker.emag.OccurrenceClassification; |
11 | 12 | import br.com.checker.emag.core.SpecificRecommendation.BehaviorRecommendation; |
... | ... | @@ -80,7 +81,7 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
80 | 81 | onmouseup = null, onkeyup = null, |
81 | 82 | onclick = null, onkeypress = null, |
82 | 83 | onmouseover = null,onfocus = null, |
83 | - onmouseout = null, onblur = null,dbclick = null; | |
84 | + onmouseout = null, onblur = null,dbclick = null, ondblclick = null; | |
84 | 85 | |
85 | 86 | if (element.getAttributes() != null) { |
86 | 87 | onmousedown = element.getAttributes().get("onmousedown"); |
... | ... | @@ -99,29 +100,52 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
99 | 100 | onblur = element.getAttributes().get("onblur"); |
100 | 101 | |
101 | 102 | dbclick = element.getAttributes().get("dbclick"); |
103 | + ondblclick = element.getAttributes().get("ondblclick"); | |
102 | 104 | } |
103 | 105 | |
104 | 106 | if(dbclick!=null){ |
105 | - occurrences.add(this.buildOccurrence("2.1", false, element.toString(), element, "2")); | |
107 | + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "2")); | |
108 | + } | |
109 | + | |
110 | + if(ondblclick!=null){ | |
111 | + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "2")); | |
106 | 112 | } |
107 | 113 | |
108 | 114 | if (onmousedown != null && onkeydown == null) { |
109 | 115 | occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1")); |
110 | - | |
111 | - } else if (onmouseup != null && onkeyup == null) { | |
116 | + } | |
117 | + | |
118 | + if (onmouseup != null && onkeyup == null) { | |
112 | 119 | occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1")); |
113 | - | |
114 | - } else if (onclick != null && onkeypress == null) { | |
120 | + } | |
121 | + /*if (onclick != null && onkeypress == null) { | |
115 | 122 | occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1")); |
116 | - | |
117 | - } else if (onmouseover != null && onfocus == null) { | |
123 | + }*/ | |
124 | + if (onmouseover != null && onfocus == null) { | |
118 | 125 | occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1")); |
119 | - | |
120 | - } else if (onmouseout != null && onblur == null) { | |
126 | + } | |
127 | + if (onmouseout != null && onblur == null) { | |
121 | 128 | occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "1")); |
122 | 129 | } |
123 | 130 | } |
124 | 131 | |
132 | + String attributes[] = {"onafterprint","onbeforeprint","onbeforeunload","onerror", "onhashchange", "onload", "onmessage", "onoffline","ononline", "onpagehide","onpageshow","onpopstate", | |
133 | + "onresize", "onstorage", "onunloadnblur", "onblur","onchange", "oncontextmenu", "onfocus", "oninput","oninvalid","onreset","onsearch","onselect","onsubmit","onkeydown","onkeypress", | |
134 | + "onkeyup", "onclick","ondblclick", "ondrag","ondragend","ondragenter", "ondragleave", "ondragover", "ondragstart","ondrop","onmousedown", "onmousemove","onmouseout","onmouseover","onmouseup", | |
135 | + "onmousewheel", "onscroll", "onwheel", "oncopy", "oncut","onpaste", "onabort", "oncanplay", "oncanplaythrough","oncuechange","ondurationchange","onemptied","onended","onerror", | |
136 | + "onloadeddata","onloadedmetadata","onloadstart","onpause","onplay","onplaying","onprogress","onratechange","onseeked","onseeking","onstalled","onsuspend","ontimeupdate", | |
137 | + "onvolumechange","onwaiting","onerror","onshow","ontoggle"}; | |
138 | + | |
139 | + for(Element element : getDocument().getAllElements()){ | |
140 | + if(element != null){ | |
141 | + for(String attribute : attributes){ | |
142 | + if (element.getAttributeValue(attribute) != null) { | |
143 | + occurrences.add(this.buildOccurrence("2.1", true, element.toString(), element, "3")); | |
144 | + } | |
145 | + } | |
146 | + } | |
147 | + } | |
148 | + | |
125 | 149 | return occurrences; |
126 | 150 | } |
127 | 151 | |
... | ... | @@ -130,18 +154,43 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
130 | 154 | private List<Occurrence> checkRecommendation11() { |
131 | 155 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
132 | 156 | |
133 | - boolean script = false; | |
134 | - boolean contAlter = false; | |
157 | + //boolean script = false; | |
158 | + //boolean contAlter = false; | |
135 | 159 | |
136 | - if(!getDocument().getAllElements("script").isEmpty()) | |
160 | + /*if(!getDocument().getAllElements("script").isEmpty()) | |
137 | 161 | script = true; |
138 | 162 | |
139 | 163 | if(script) |
140 | 164 | if(getDocument().getAllElements("noscript").isEmpty()) |
141 | - occurrences.add(this.buildOccurrence("2.2", true, getDocument().getFirstElement("html").toString(), getDocument().getFirstElement("html"), "1")); | |
165 | + occurrences.add(this.buildOccurrence("2.2", true, getDocument().getFirstElement("html").toString(), getDocument().getFirstElement("html"), "1"));*/ | |
166 | + | |
167 | + for(Element elementScript : getDocument().getAllElements("script")){ | |
168 | + if((!elementScript.isEmpty()) && (elementScript.getAttributeValue("noscript") == null)) | |
169 | + occurrences.add(this.buildOccurrence("2.2", true, elementScript.toString(), elementScript, "1")); | |
170 | + } | |
142 | 171 | |
172 | + | |
173 | + if(!getDocument().getAllElements("embed").isEmpty()){ | |
174 | + for(Element embed : getDocument().getAllElements("embed")) | |
175 | + occurrences.add(this.buildOccurrence("2.2", false, embed.toString(), embed, "3")); | |
176 | + } | |
177 | + | |
178 | + if(!getDocument().getAllElements("applet").isEmpty()){ | |
179 | + for(Element applet : getDocument().getAllElements("applet")) | |
180 | + occurrences.add(this.buildOccurrence("2.2", false, applet.toString(), applet, "4")); | |
181 | + } | |
182 | + | |
143 | 183 | |
144 | 184 | for (Element object : getDocument().getAllElements("object")) { |
185 | + for(Element elemnet : object.getChildElements()){ | |
186 | + if(!elemnet.getName().equals("param")){ | |
187 | + occurrences.add(this.buildOccurrence("2.2", true, object.toString(), object, "2")); | |
188 | + } | |
189 | + } | |
190 | + } | |
191 | + | |
192 | + | |
193 | + /*for (Element object : getDocument().getAllElements("object")) { | |
145 | 194 | |
146 | 195 | for(Element elemnet : object.getChildElements()){ |
147 | 196 | if(!elemnet.getName().equals("param")){ |
... | ... | @@ -154,17 +203,7 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
154 | 203 | contAlter = false; |
155 | 204 | } |
156 | 205 | |
157 | - } | |
158 | - | |
159 | - if(!getDocument().getAllElements("embed").isEmpty()){ | |
160 | - for(Element embed : getDocument().getAllElements("embed")) | |
161 | - occurrences.add(this.buildOccurrence("2.2", false, embed.toString(), embed, "3")); | |
162 | - } | |
163 | - | |
164 | - if(!getDocument().getAllElements("applet").isEmpty()){ | |
165 | - for(Element applet : getDocument().getAllElements("applet")) | |
166 | - occurrences.add(this.buildOccurrence("2.2", false, applet.toString(), applet, "4")); | |
167 | - } | |
206 | + }*/ | |
168 | 207 | |
169 | 208 | return occurrences; |
170 | 209 | } |
... | ... | @@ -220,8 +259,9 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
220 | 259 | hasMarquee = true; |
221 | 260 | } |
222 | 261 | |
223 | - if (!hasBlink && !hasMarquee) | |
262 | + if (!hasBlink && !hasMarquee){ | |
224 | 263 | occurrences.add(new Occurrence("2.5", false, getDocument().getFirstElement().toString(),OccurrenceClassification.BEHAVIOR,"1")); |
264 | + } | |
225 | 265 | |
226 | 266 | return occurrences; |
227 | 267 | } |
... | ... | @@ -229,11 +269,22 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
229 | 269 | private List<Occurrence> checkRecommendation15() { |
230 | 270 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
231 | 271 | |
272 | + | |
232 | 273 | for (Element blink : getDocument().getAllElements("blink")) { |
233 | 274 | occurrences.add(this.buildOccurrence("2.6", true, blink.toString(), blink, "1")); |
234 | 275 | } |
235 | 276 | |
236 | 277 | for(Element marquee : getDocument().getAllElements("marquee")) { |
278 | + | |
279 | + | |
280 | + /* for(Element img : marquee.getAllElements("img")) { | |
281 | + Attribute src = img.getAttributes().get("src"); | |
282 | + if(src != null) | |
283 | + if(img.getAttributeValue("src").contains(".gif")){ | |
284 | + occurrences.add(this.buildOccurrence("2.6", false,marquee.toString(), marquee, "3")); | |
285 | + } | |
286 | + }*/ | |
287 | + | |
237 | 288 | occurrences.add(this.buildOccurrence("2.6", true, marquee.toString(), marquee, "2")); |
238 | 289 | } |
239 | 290 | ... | ... |
src/main/java/br/com/checker/emag/core/MultimediaEvaluation.java
... | ... | @@ -122,10 +122,10 @@ public class MultimediaEvaluation extends Evaluation{ |
122 | 122 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
123 | 123 | |
124 | 124 | for (Element video : getDocument().getAllElements("object")) |
125 | - occurrences.add(this.buildOccurrence("5.3", false, video.toString(), video, "1")); | |
125 | + occurrences.add(this.buildOccurrence("5.3", true, video.toString(), video, "1")); | |
126 | 126 | |
127 | 127 | for (Element video : getDocument().getAllElements("embed")) |
128 | - occurrences.add(this.buildOccurrence("5.3", false, video.toString(), video, "1")); | |
128 | + occurrences.add(this.buildOccurrence("5.3", true, video.toString(), video, "1")); | |
129 | 129 | |
130 | 130 | return occurrences; |
131 | 131 | } | ... | ... |