Web Testing Framework

There's a new version and now hosted on AMO (addons.mozilla.org). Get the new version there and it will take care of auto-updates in the future.

WFT

Web Testing Framework (WTF) is an extension to YSlow that tests for the following shady web dev practices:

  • Use of <blink>
  • Use of <marquee>
  • Use of <font>
  • Missing doctype
  • Use of spacer GIFs
  • Use of <a href="#"..> and <a href="javascript:...>

Gimme!

Note that this extension requires Firebug and YSlow2

Help

Please report any bugs here and also suggestions for more checks for what you think is bad practice (and is technically possible to test by a tool, as opposed to a human)

Thanks!

Thanks to Ryan Grove for inspiration with the naming of the new tool :)

Motivation

The motivation is mainly to demonstrate how easy it is to create new extensions and new checks to YSlow. They don't even need to be performance-related.

There are two basic concepts. 1. A rule is a type of check like "use gzip". 2. The pool of available rules can be combined into rulesets. The API is therefore just:

YSLOW.registerRule({...});
YSLOW.registerRuleset({...});

The first takes an object containing name, id, info about the new check and a lint() function that performs the check. The second accepts a config object - which rules go into the ruleset.

Check this file - that's all it takes to do a new extension.

This entry was posted on Sunday, June 20th, 2010 and is filed under tools, Web1.0, yslow. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

29 Responses to “Web Testing Framework”

  1. Vlado Says:

    So why I should avoid # links? (Links should be links. Links with href such as href=# and href=”javascript:” should be avoided like the plague)

  2. Stoyan Says:

    well, then you turn off JavaScript what happens to those links?

  3. JokeyRhyme Says:

    Yeah, I’m quite guilty of making JavaScript links.

    I think the idea is to use JavaScript to add onclick events to parts of your website. Frameworks like jQuery make it fairly simple to add an onclick event and prevent the click from activating any hyperlinks in the same part of the page.

    The href parts should be written so that your website will work in a purely JavaScript-free fashion when a browser lacks or has disabled support.

    If I’m totally wrong about this then let me know. :)

  4. Javier Casares Says:

    It could be interesting to add some elements like “iframe”, “frames”, sites “designed with tables” and not css… if i’ve new ideas i’ll send you :) it’s a great tool.

  5. Sander Aarts Says:

    Does it only test static HTML, or generated HTML as well? I ask as JavaScript links are not really a problem of course when they’re inserted into the DOM by JavaScript itself.

    If I where not visiting this page on my Android I would have tested it myself of course :)

  6. Bruno Sabot Says:

    Your tool is really a great idea, here are my suggestions:

    Link such as <a href=”#” can be anchors, such as a “Back to the top” link, not only JavaScript links.
    Like Javier, I’d like to see iframes and designed with tables rules.
    And also, you can add rules for inline css and javascript.

    Good Luck!

  7. Stoyan Says:

    @Bruno, I think href=#top is fine (and the tool forgives), but not href=”#”

    @Sander, yes, the JS-modified DOM is inspected. Will think about inspecting the static HTML

    @Javier, @Bruno – tables for layout is something I thought about, just unsure how to check. Maybe require at least one TH in addition to TD?

    Not sure about iframes, ads and such still need them…

  8. Vlado Says:

    @Stoyan: what about if it have inside the table?

  9. Vlado Says:

    @Stoyan: what about if it have inside the table?

    P.S.: htmspecialchars($comment) :)

  10. Vlado Says:

    aaaaaaaa :)

    @Stoyan: what about if it have h1 inside the table?

    P.S.: htmspecialchars($comment)

  11. Duncan McDougall Says:

    This really has some potential. Few low weighted additions could be the presence of a favicon, and really just take advantage of YSlow’s interface with mark-up validation, in it’s simplest form missing closing tags etc. Do you know of any SEO YSlow mods as there’s definitely room for that?

  12. fpiat Says:

    Welcome to the Web police!
    You are not authorized to use href=”#”.
    You are not authorized to use spacer.
    You are not authorized to use frame.

    The next step : you are not authorized to use HTML

  13. NICCAI Says:

    I like the url of this page.

  14. NICCAI Says:

    One other thing…reminds me a bit of Inline Code Finder by Robert Nyman…which prompts me to ask, what about inline styling?

    https://addons.mozilla.org/en-US/firefox/addon/9640/

  15. Travi Says:

    Please add a check for onClick, onChange, etc attributes as well, at least as an option. Although better than JavaScript links, use of these attributes is still a discouraged practice. Adding JavaScript behavior should be fully unobtrusive. I would love to have a tool like this to help enforce that on projects that I work on with a team.

  16. Gonzo Says:

    You can borrow ideas from Eric Mayer’s diagnostic CSS: http://meyerweb.com/eric/tools/css/diagnostics/

    Event attributes (onThis and onThat) are a good idea, inline styles too. I think that the only valid method to catch presentational tables is to look for nested ones. Maybe a looser check for missing thead, th elements will be helpful.

    @Vlado, since you can use some HTML in the comment form, htmlspecialchars() is not a good idea.

  17. PlNG Says:

    I don’t know the full capabilities of yslow, but if it is possible, remove height and width styles and sizing from images, and if the dimensions turn out to be 1×1, then you can mark it as a spacer image.

  18. Stoyan Says:

    @Ping, that’s possible, but sometimes 1×1 images are used for tracking and not for layout

    That’s why I check for 1×1 dimensions and in addition look for hints in the image URL, such as “dot” and “spacer”

  19. Anthony Says:

    ‘#’ is perfectly fine and is normally used for ajax calls. Including that as spammy is a bit ridiculous.

  20. Travi Says:

    @Anthony ‘#’ by itself is not perfectly fine. Using the hash to point to a particular section of a page is acceptable, but the href attribute should never contain only ‘#’.

    Using progressive enhancement, the href should start out pointing to a vaild link. The click handler that is attached unobtrusively can override that, but the link should be functional before Ajax or any other dynamic behavior is added.

  21. Iouri Goussev Says:

    Thanks! Added it, to my collection of useful plugins.

  22. Bunch of useful firefox extensions for web designers. | websitecenter.ca Says:

    [...] Web Testing Framework http://phpied.com/wtf/ A YSlow extension for inspecting shady webdev practices [...]

  23. Installed FF plugins : 0xDEADBEEFCAFE Says:

    [...] Web Testing Framework 0.0.1http://phpied.com/wtf/ [...]

  24. Webby Dev Rob Says:

    Hash links are pretty common npwadays and I definately wouldn’t call them a shady practice. Hash links are required for a lot of banner rotators and for obvious users like navigating a very tall page.

  25. basekit Says:

    Very useful plugin – thank you!!

  26. hotels and travel resources Says:

    hotels and travel resources…

    [...]Web Testing Framework / Stoyan’s phpied.com[...]…

  27. Performance Calendar » All aboout YSlow Says:

    [...] YSlow can also be used as a framework to build extensions that talk to browser, refer to Stoyan Stefanov’s article for code samples: Web Testing Framework [...]

  28. emc testing lab Says:

    emc testing lab…

    [...]Web Testing Framework / Stoyan’s phpied.com[...]…

  29. Creative Business Labs Says:

    Thank you for the auspicious writeup. It in fact was a leisure account it. Glance complex to far added agreeable from you! By the way, how can we be in contact?

Leave a Reply