-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
content wtf chrome/content/ | |||
overlay chrome://yslow/content/browser.xul chrome://wtf/content/browser.xul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" id="yslow-wtf-overlay"> | |||
|
|||
<script type="application/x-javascript" src="chrome://wtf/content/wtf.js"></script> | |||
|
|||
</overlay> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,195 @@ | |||
/*global YSLOW */ | |||
YSLOW.registerRule({ | |||
id: 'wtf-blink', | |||
name: '<blink>', | |||
info: ""There's a lady who knows, all that blinkers is gold" - Led Zeppelin", | |||
category: ['general'], | |||
config: {}, | |||
|
|||
lint: function (doc, cset, config) { | |||
var count = doc.getElementsByTagName('blink').length, | |||
message = ''; | |||
|
|||
if (count) { | |||
message = YSLOW.util.plural('Oh my, %num% blink tag%s%, <blink style="color:red">seriously?</blink>', count); | |||
} | |||
|
|||
return { | |||
score: count ? 1 : 100, | |||
message: message | |||
}; | |||
} | |||
}); | |||
|
|||
|
|||
|
|||
YSLOW.registerRule({ | |||
id: 'wtf-marquee', | |||
name: '<marquee>', | |||
info: ""Hello" - Marqueez de Sade", | |||
category: ['general'], | |||
config: {}, | |||
|
|||
lint: function (doc, cset, config) { | |||
var count = doc.getElementsByTagName('marquee').length, | |||
message = ''; | |||
|
|||
if (count) { | |||
message = YSLOW.util.plural('Ah-ha, %num% marquee tag%s%, impressive!', count); | |||
} | |||
|
|||
return { | |||
score: count ? 1 : 100, | |||
message: message | |||
}; | |||
} | |||
}); | |||
|
|||
YSLOW.registerRule({ | |||
id: 'wtf-font', | |||
name: '<font>', | |||
info: "Once upon a time, a long time a ago, before the @font-face has even been imagined, there was the <font> tag", | |||
category: ['general'], | |||
config: { | |||
points: 21 | |||
}, | |||
|
|||
lint: function (doc, cset, config) { | |||
var count = doc.getElementsByTagName('font').length, | |||
message = ''; | |||
|
|||
if (count) { | |||
message = YSLOW.util.plural('%num% font tag%s% - must be one hell of a web page', count); | |||
} | |||
|
|||
return { | |||
score: count ? 100 - count * config.points : 100, | |||
message: message | |||
}; | |||
} | |||
}); | |||
|
|||
YSLOW.registerRule({ | |||
id: 'wtf-doctype', | |||
name: 'Use a doctype', | |||
info: "Without a DOCTYPE, the page renders in quirks mode. The shortest doctype you can put at the very top of the page is <code><!doctype html></code>", | |||
category: ['general'], | |||
config: {}, | |||
|
|||
lint: function (doc, cset, config) { | |||
var dtype = doc.doctype, | |||
message = ''; | |||
|
|||
if (!dtype) { | |||
message = "The page doesn't have a doctype"; | |||
} | |||
|
|||
return { | |||
score: !dtype ? 1 : 100, | |||
message: message | |||
}; | |||
} | |||
}); | |||
|
|||
|
|||
YSLOW.registerRule({ | |||
id: 'wtf-spacer', | |||
name: 'No more spacer.gif', | |||
info: "For layout purposes, use CSS instead of spacer images", | |||
category: ['general'], | |||
config: { | |||
hints: ['spacer', 'dot', 'clear', 'pixel', '1x1'], | |||
points: 21 | |||
}, | |||
|
|||
lint: function (doc, cset, config) { | |||
var images = doc.images, | |||
i = 0, max = images.length, | |||
message = '', | |||
count = 0, | |||
url, | |||
img, | |||
re = new RegExp(config.hints.join('|'), 'i'); | |||
|
|||
|
|||
for (i = 0; i < max; i += 1) { | |||
img = images[i]; | |||
url = img.src; | |||
url = url.split('/').pop(); | |||
if (re.test(url) && img.naturalWidth === 1 && img.naturalHeight === 1) { | |||
count += 1; | |||
} | |||
} | |||
|
|||
|
|||
if (count) { | |||
message = YSLOW.util.plural('%num% spacer GIF%s% found', count); | |||
} | |||
|
|||
return { | |||
score: count ? 100 - count * config.points : 100, | |||
message: message | |||
}; | |||
} | |||
}); | |||
|
|||
|
|||
|
|||
YSLOW.registerRule({ | |||
id: 'wtf-hashlinks', | |||
name: 'Semantic link hrefs', | |||
info: "Links should be links. Links with href such as href=# and href="javascript:" should be avoided like the plague", | |||
category: ['general'], | |||
config: { | |||
points: 21 | |||
}, | |||
|
|||
lint: function (doc, cset, config) { | |||
|
|||
var links = doc.links, | |||
i, max = links.length, | |||
href, | |||
message = '', | |||
count = 0; | |||
|
|||
for (i = 0; i < max; i += 1) { | |||
href = links[i].getAttribute('href').toString(); | |||
if (href === "#" || href.indexOf('javascript:') === 0) { | |||
count += 1; | |||
} | |||
} | |||
|
|||
if (count) { | |||
message = YSLOW.util.plural('Found %num% link%s% with non-semantic href attributes', count); | |||
} | |||
|
|||
return { | |||
score: count ? 100 - count * config.points : 100, | |||
message: message | |||
}; | |||
} | |||
}); | |||
|
|||
|
|||
|
|||
YSLOW.registerRuleset({ | |||
id: 'wtf', | |||
name: 'Web Testing Framework', | |||
rules: { | |||
'wtf-blink': {}, | |||
'wtf-marquee': {}, | |||
'wtf-font': {}, | |||
'wtf-doctype': {}, | |||
'wtf-spacer': {}, | |||
'wtf-hashlinks': {} | |||
}, | |||
weights: { | |||
'wtf-blink': 1, | |||
'wtf-marquee': 1, | |||
'wtf-font': 1, | |||
'wtf-doctype': 1, | |||
'wtf-spacer': 1, | |||
'wtf-hashlinks': 1 | |||
} | |||
}); | |||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
<?xml version="1.0"?> | |||
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#" | |||
xmlns:NC="http://home.netscape.com/NC-rdf#" | |||
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> | |||
<RDF:Description RDF:about="rdf:#$41y0G2" | |||
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" | |||
em:minVersion="2" | |||
em:maxVersion="3.*" /> | |||
<RDF:Description RDF:about="urn:mozilla:install-manifest" | |||
em:id="wtf@phpied.com" | |||
em:name="Web Testing Framework" | |||
em:version="0.0.1" | |||
em:creator="Stoyan Stefanov" | |||
em:description="A YSlow extension for inspecting shady webdev practices" | |||
em:homepageURL="http://phpied.com/wtf/" | |||
em:iconURL="chrome://wtf/content/icon.png"> | |||
<em:targetApplication RDF:resource="rdf:#$41y0G2"/> | |||
</RDF:Description> | |||
</RDF:RDF> |