diff --git a/build/HTMLCS.js b/build/HTMLCS.js index 49aad4ef..397cee1d 100644 --- a/build/HTMLCS.js +++ b/build/HTMLCS.js @@ -1,4 +1,4 @@ -/*! silktide-html-codesniffer - v2.2.0 - 2021-01-14 */ +/*! silktide-html-codesniffer - v3.0.0 - 2023-06-20 */ /** * +--------------------------------------------------------------------+ * | This HTML_CodeSniffer file is Copyright (c) | @@ -20,9 +20,7 @@ var _global = { translation: {} }; - _global.translation["en"] = { - //HTMLCSAuditor.js auditor_name: "HTML_CodeSniffer by Squiz", auditor_using_standard: "Using standard", auditor_standards: "Standards", @@ -234,18 +232,6 @@ _global.translation["en"] = { "4_1_2_value_exposed_using_element": "A value is exposed using the {{requiredValue}} element." }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508 = { name: "Section508", description: "U.S. Section 508 Standard", @@ -258,36 +244,10 @@ _global.HTMLCS_Section508 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_A = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top", "img", "object", "bgsound", "audio" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { this.addNullAltTextResults(top); @@ -295,26 +255,10 @@ _global.HTMLCS_Section508_Sniffs_A = { } else { var nodeName = element.nodeName.toLowerCase(); if (nodeName === "object" || nodeName === "bgsound" || nodeName === "audio") { - // Audio transcript notice. Yes, this is in A rather than B, since - // audio is not considered "multimedia" (roughly equivalent to a - // "synchronised media" presentation in WCAG 2.0). It is non-text, - // though, so a transcript is required. HTMLCS.addMessage(HTMLCS.NOTICE, element, "For multimedia containing audio only, ensure an alternative is available, such as a full text transcript.", "Audio"); } } }, - /** - * Test for missing or null alt text in certain elements. - * - * Tested elements are: - * - IMG elements - * - INPUT elements with type="image" (ie. image submit buttons). - * - AREA elements (ie. in client-side image maps). - * - * @param {DOMNode} element The element to test. - * - * @returns {Object} A structured list of errors. - */ testNullAltText: function(top) { var errors = { img: { @@ -348,7 +292,6 @@ _global.HTMLCS_Section508_Sniffs_A = { if (element.parentNode.textContent !== undefined) { var textContent = element.parentNode.textContent; } else { - // Keep IE8 happy. var textContent = element.parentNode.innerText; } if (HTMLCS.util.isStringEmpty(textContent) === true) { @@ -356,26 +299,19 @@ _global.HTMLCS_Section508_Sniffs_A = { } } } - //end if if (element.hasAttribute("alt") === false) { missingAlt = true; } else if (!element.getAttribute("alt") || HTMLCS.util.isStringEmpty(element.getAttribute("alt")) === true) { nullAlt = true; } - // Now determine which test(s) should fire. switch (nodeName) { case "img": if (linkOnlyChild === true && (missingAlt === true || nullAlt === true)) { - // Img tags cannot have an empty alt text if it is the - // only content in a link (as the link would not have a text - // alternative). errors.img.emptyAltInLink.push(element.parentNode); } else if (missingAlt === true) { errors.img.missingAlt.push(element); } else if (nullAlt === true) { if (element.hasAttribute("title") === true && HTMLCS.util.isStringEmpty(element.getAttribute("title")) === false) { - // Title attribute present and not empty. This is wrong when - // an image is marked as ignored. errors.img.nullAltWithTitle.push(element); } else { errors.img.ignored.push(element); @@ -386,7 +322,6 @@ _global.HTMLCS_Section508_Sniffs_A = { break; case "input": - // Image submit buttons. if (missingAlt === true || nullAlt === true) { errors.inputImage.missingAlt.push(element); } else { @@ -395,7 +330,6 @@ _global.HTMLCS_Section508_Sniffs_A = { break; case "area": - // Area tags in a client-side image map. if (missingAlt === true || nullAlt === true) { errors.area.missingAlt.push(element); } else { @@ -404,22 +338,11 @@ _global.HTMLCS_Section508_Sniffs_A = { break; default: - // No other tags defined. break; } } - //end for return errors; }, - /** - * Driver function for the null alt text tests. - * - * This takes the generic result given by the alt text testing functions - * (located in WCAG 2.0 SC 1.1.1), and converts them into Section 508-specific - * messages. - * - * @param {DOMNode} element The element to test. - */ addNullAltTextResults: function(top) { var errors = this.testNullAltText(top); for (var i = 0; i < errors.img.emptyAltInLink.length; i++) { @@ -467,8 +390,6 @@ _global.HTMLCS_Section508_Sniffs_A = { var element = elements[el]; var nodeName = element.nodeName.toLowerCase(); var childObject = element.querySelector("object"); - // If we have an object as our alternative, skip it. Pass the blame onto - // the child. if (childObject === null) { var textAlt = HTMLCS.util.getElementTextContent(element, true); if (textAlt === "") { @@ -478,15 +399,10 @@ _global.HTMLCS_Section508_Sniffs_A = { } } } - //end if var elements = HTMLCS.util.getAllElements(top, "applet"); for (var el = 0; el < elements.length; el++) { - // Test firstly for whether we have an object alternative. var childObject = element.querySelector("object"); var hasError = false; - // If we have an object as our alternative, skip it. Pass the blame onto - // the child. (This is a special case: those that don't understand APPLET - // may understand OBJECT, but APPLET shouldn't be nested.) if (childObject === null) { var textAlt = HTMLCS.util.getElementTextContent(element, true); if (HTMLCS.util.isStringEmpty(textAlt) === true) { @@ -494,29 +410,17 @@ _global.HTMLCS_Section508_Sniffs_A = { hasError = true; } } - //end if var altAttr = element.getAttribute("alt") || ""; if (HTMLCS.util.isStringEmpty(altAttr) === true) { errors.applet.missingAlt.push(element); hasError = true; } if (hasError === false) { - // No error? Remind of obligations about equivalence of alternatives. errors.applet.generalAlt.push(element); } } - //end if return errors; }, - /** - * Driver function for the media alternative (object/applet) tests. - * - * This takes the generic result given by the media alternative testing function - * (located in WCAG 2.0 SC 1.1.1), and converts them into Section - * 508-specific messages. - * - * @param {DOMNode} element The element to test. - */ addMediaAlternativesResults: function(top) { var errors = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1.testMediaTextAlternatives(top); for (var i = 0; i < errors.object.missingBody.length; i++) { @@ -537,36 +441,10 @@ _global.HTMLCS_Section508_Sniffs_A = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_B = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "applet", "embed", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var nodeName = element.nodeName.toLowerCase(); HTMLCS.addMessage(HTMLCS.NOTICE, element, "For multimedia containing video, ensure a synchronised audio description or text alternative for the video portion is provided.", "Video"); @@ -574,91 +452,30 @@ _global.HTMLCS_Section508_Sniffs_B = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_C = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that any information conveyed using colour alone is also available without colour, such as through context or markup.", "Colour"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_D = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that content is ordered in a meaningful sequence when linearised, such as when style sheets are disabled.", "Linearised"); this.testPresentationMarkup(top); this.testHeadingOrder(top); - // Look for any script elements, and fire off another notice regarding - // potentially hidden text (eg. "click to expand" sections). For instance, - // such text should be stored semantically in the page, not loaded into - // a container through AJAX (and thus not accessible with scripting off). var hasScript = HTMLCS.util.getAllElements(top, 'script, link[rel="stylesheet"]'); if (hasScript.length > 0) { HTMLCS.addMessage(HTMLCS.NOTICE, top, 'If content is hidden and made visible using scripting (such as "click to expand" sections), ensure this content is readable when scripts and style sheets are disabled.', "HiddenText"); } } }, - /** - * Test for the use of presentational elements. - * - * @param [DOMNode] top The top element of the tested code. - */ testPresentationMarkup: function(top) { _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1.testPresentationMarkup(top); }, @@ -670,8 +487,6 @@ _global.HTMLCS_Section508_Sniffs_D = { if (headingNum - lastHeading > 1) { var exampleMsg = "should be an h" + (lastHeading + 1) + " to be properly nested"; if (lastHeading === 0) { - // If last heading is empty, we are at document top and we are - // expecting a H1, generally speaking. exampleMsg = "appears to be the primary document heading, so should be an h1 element"; } HTMLCS.addMessage(HTMLCS.ERROR, headings[i], "The heading structure is not logically nested. This h" + headingNum + " element " + exampleMsg + ".", "HeadingOrder"); @@ -681,91 +496,33 @@ _global.HTMLCS_Section508_Sniffs_D = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_G = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "table" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // If no table headers, emit notice about the table. if (HTMLCS.util.isLayoutTable(element) === true) { HTMLCS.addMessage(HTMLCS.NOTICE, element, "This table has no headers. If this is a data table, ensure row and column headers are identified using th elements.", "TableHeaders"); } } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_H = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "table" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(table, top) { var headersAttr = HTMLCS.util.testTableHeaders(table); - // Incorrect usage of headers - error; emit always. for (var i = 0; i < headersAttr.wrongHeaders.length; i++) { HTMLCS.addMessage(HTMLCS.ERROR, headersAttr.wrongHeaders[i].element, 'Incorrect headers attribute on this td element. Expected "' + headersAttr.wrongHeaders[i].expected + '" but found "' + headersAttr.wrongHeaders[i].actual + '"', "IncorrectHeadersAttr"); } - // Errors where headers are compulsory. if (headersAttr.required === true && headersAttr.allowScope === false) { if (headersAttr.used === false) { - // Headers not used at all, and they are mandatory. HTMLCS.addMessage(HTMLCS.ERROR, table, "The relationship between td elements and their associated th elements is not defined. As this table has multiple levels of th elements, you must use the headers attribute on td elements.", "MissingHeadersAttrs"); } else { - // Missing TH IDs - error; emit at this stage only if headers are compulsory. if (headersAttr.missingThId.length > 0) { HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all th elements in this table contain an id attribute. These cells should contain ids so that they may be referenced by td elements' headers attributes.", "MissingHeaderIds"); } - // Missing TD headers attributes - error; emit at this stage only if headers are compulsory. if (headersAttr.missingTd.length > 0) { HTMLCS.addMessage(HTMLCS.ERROR, table, "Not all td elements in this table contain a headers attribute. Each headers attribute should list the ids of all th elements associated with that cell.", "IncompleteHeadersAttrs"); } @@ -774,36 +531,10 @@ _global.HTMLCS_Section508_Sniffs_H = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_I = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "frame", "iframe", "object" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var nodeName = element.nodeName.toLowerCase(); var hasTitle = element.hasAttribute("title"); @@ -817,107 +548,28 @@ _global.HTMLCS_Section508_Sniffs_I = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_J = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // The term in Sec. 508 is "flicker" rather than flash. HTMLCS.addMessage(HTMLCS.NOTICE, top, "Check that no component of the content flickers at a rate of greater than 2 and less than 55 times per second.", "Flicker"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_K = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, "If this page cannot be made compliant, a text-only page with equivalent information or functionality should be provided. The alternative page needs to be updated in line with this page's content.", "AltVersion"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_L = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { this.addProcessLinksMessages(top); @@ -960,13 +612,7 @@ _global.HTMLCS_Section508_Sniffs_L = { hrefFound = true; } if (hrefFound === false) { - // No href. We don't want these because, although they are commonly used - // to create targets, they can be picked up by screen readers and - // displayed to the user as empty links. A elements are defined by H91 as - // having an (ARIA) role of "link", and using them as targets are - // essentially misusing them. Place an ID on a parent element instead. if (/^\s*$/.test(content) === true) { - // Also no content. (eg. or ) if (element.hasAttribute("id") === true) { errors.empty.push(element); } else if (element.hasAttribute("name") === true) { @@ -975,42 +621,23 @@ _global.HTMLCS_Section508_Sniffs_L = { errors.emptyNoId.push(element); } } else { - // Giving a benefit of the doubt here - if a link has text and also - // an ID, but no href, it might be because it is being manipulated by - // a script. if (element.hasAttribute("id") === true || element.hasAttribute("name") === true) { errors.noHref.push(element); } else { - // HTML5 allows A elements with text but no href, "for where a - // link might otherwise have been placed, if it had been relevant". - // Hence, thrown as a warning, not an error. errors.placeholder.push(element); } } } else { if (/^\s*$/.test(content) === true) { - // Href provided, but no content. - // We only fire this message when there are no images in the content. - // A link around an image with no alt text is already covered in SC - // 1.1.1 (test H30). if (element.querySelectorAll("img").length === 0) { errors.noContent.push(element); } } } } - //end for return errors; }, - /** - * Process mouse-specific functions. - * - * @param {DOMNode} top The top element of the tested code. - */ testKeyboard: function(top) { - // Testing for elements that have explicit attributes for mouse-specific - // events. Note: onclick is considered keyboard accessible, as it is actually - // tied to the default action of a link or button - not merely a click. var dblClickEls = HTMLCS.util.getAllElements(top, "*[ondblclick]"); for (var i = 0; i < dblClickEls.length; i++) { HTMLCS.addMessage(HTMLCS.WARNING, dblClickEls[i], "Ensure the functionality provided by double-clicking on this element is available through the keyboard.", "DblClick"); @@ -1038,71 +665,19 @@ _global.HTMLCS_Section508_Sniffs_L = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_M = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "applet", "bgsound", "embed", "audio", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, "If external media requires a plugin or application to view, ensure a link is provided to a plugin or application that complies with Section 508 accessibility requirements for applications.", "PluginLink"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_N = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var nodeName = element.nodeName.toLowerCase(); if (nodeName === "form") { @@ -1113,36 +688,10 @@ _global.HTMLCS_Section508_Sniffs_N = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_O = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top", "a", "area" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, "Ensure that any common navigation elements can be bypassed; for instance, by use of skip links, header elements, or ARIA landmark roles.", "SkipLinks"); @@ -1157,8 +706,6 @@ _global.HTMLCS_Section508_Sniffs_O = { if (doc.ownerDocument) { doc = doc.ownerDocument; } - // First search for an element with the appropriate ID, then search for a - // named anchor using the name attribute. var target = doc.getElementById(id); if (target === null) { target = doc.querySelector('a[name="' + id + '"]'); @@ -1177,36 +724,10 @@ _global.HTMLCS_Section508_Sniffs_O = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_Section508_Sniffs_P = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top", "meta" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, "If a timed response is required on this page, alert the user and provide sufficient time to allow them to indicate that more time is required.", "TimeLimit"); @@ -1215,10 +736,8 @@ _global.HTMLCS_Section508_Sniffs_P = { if (String(element.getAttribute("http-equiv")).toLowerCase() === "refresh") { if (/^[1-9]\d*/.test(element.getAttribute("content").toLowerCase()) === true) { if (/url=/.test(element.getAttribute("content").toLowerCase()) === true) { - // Redirect. HTMLCS.addMessage(HTMLCS.ERROR, element, "Meta refresh tag used to redirect to another page, with a time limit that is not zero. Users cannot control this time limit.", "MetaRedirect"); } else { - // Just a refresh. HTMLCS.addMessage(HTMLCS.ERROR, element, "Meta refresh tag used to refresh the current page. Users cannot control the time limit for this refresh.", "MetaRefresh"); } } @@ -1228,18 +747,6 @@ _global.HTMLCS_Section508_Sniffs_P = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2A = { name: "WCAG2A", description: "Web Content Accessibility Guidelines (WCAG) 2.0 A", @@ -1252,18 +759,6 @@ _global.HTMLCS_WCAG2A = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AA = { name: "WCAG2AA", description: "Web Content Accessibility Guidelines (WCAG) 2.0 AA", @@ -1276,18 +771,6 @@ _global.HTMLCS_WCAG2AA = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA = { name: "WCAG2AAA", description: "Web Content Accessibility Guidelines (WCAG) 2.0 AAA", @@ -1311,13 +794,6 @@ _global.HTMLCS_WCAG2AAA = { link: "http://www.w3.org/TR/WCAG20/#robust" } }; - /** - * List of success criteria, their links in the WCAG20 doc, and their - * "priority" (to use a WCAG1 term)... priority 1 = single-A, 3 = triple-A. - * - * Priority 0 indicates a conformance requirement. CR1 isn't shown because - * all it says is "to conform to each level, it must pass all at that level". - */ var successCritList = { CR2: { name: "Full pages", @@ -1661,36 +1137,10 @@ _global.HTMLCS_WCAG2AAA = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top", "img" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { this.addNullAltTextResults(top); @@ -1705,14 +1155,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { } } }, - /** - * Driver function for the null alt text tests. - * - * This takes the generic result given by the alt text testing functions, - * and converts them into WCAG 2.0-specific messages. - * - * @param {DOMNode} element The element to test. - */ addNullAltTextResults: function(top) { var errors = this.testNullAltText(top); for (var i = 0; i < errors.img.emptyAltInLink.length; i++) { @@ -1743,18 +1185,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { HTMLCS.addMessage(HTMLCS.NOTICE, errors.area.generalAlt[i], _global.HTMLCS.getTranslation("1_1_1_H24.2"), "H24.2"); } }, - /** - * Test for missing or null alt text in certain elements. - * - * Tested elements are: - * - IMG elements - * - INPUT elements with type="image" (ie. image submit buttons). - * - AREA elements (ie. in client-side image maps). - * - * @param {DOMNode} element The element to test. - * - * @returns {Object} A structured list of errors. - */ testNullAltText: function(top) { var errors = { img: { @@ -1788,7 +1218,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { if (element.parentNode.textContent !== undefined) { var textContent = element.parentNode.textContent; } else { - // Keep IE8 happy. var textContent = element.parentNode.innerText; } if (HTMLCS.util.isStringEmpty(textContent) === true) { @@ -1796,19 +1225,14 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { } } } - //end if if (element.hasAttribute("alt") === false) { missingAlt = true; } else if (!element.getAttribute("alt") || HTMLCS.util.isStringEmpty(element.getAttribute("alt")) === true) { nullAlt = true; } - // Now determine which test(s) should fire. switch (nodeName) { case "img": if (linkOnlyChild === true && (missingAlt === true || nullAlt === true)) { - // Img tags cannot have an empty alt text if it is the - // only content in a link (as the link would not have a text - // alternative). errors.img.emptyAltInLink.push(element.parentNode); } else if (missingAlt === true) { errors.img.missingAlt.push(element); @@ -1824,12 +1248,8 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { width = computedWidth; } if (element.hasAttribute("title") === true && HTMLCS.util.isStringEmpty(element.getAttribute("title")) === false) { - // Title attribute present and not empty. This is wrong when - // an image is marked as ignored. errors.img.nullAltWithTitle.push(element); } else if (height > 1 || width > 1) { - // Do the > 1 checks as if we have any 0x0 or 1x1 pixel images, let's ignore them. - // 99.9% of the time they're just tracking pixels. errors.img.ignored.push(element); } } else { @@ -1838,7 +1258,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { break; case "input": - // Image submit buttons. if (missingAlt === true || nullAlt === true) { errors.inputImage.missingAlt.push(element); } else { @@ -1847,7 +1266,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { break; case "area": - // Area tags in a client-side image map. if (missingAlt === true || nullAlt === true) { errors.area.missingAlt.push(element); } else { @@ -1856,46 +1274,17 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { break; default: - // No other tags defined. break; } } - //end for return errors; }, - /** - * Test for longdesc attributes on images (technique H45). - * - * We throw a notice to ensure that a longdesc is available in an accessible - * way - ie. using body text or a link. Longdesc is specifically ignored as it - * is not accessible to sighted users. - * - * @param {DOMNode} element The element to test. - * - * @returns void - */ testLongdesc: function(element) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_1_1_G73,G74"), "G73,G74"); }, - /** - * Test for link stutter with adjacent images and text (technique H2). - * - * Only runs on IMG elements contained inside an anchor (A) element. We test that - * its alt text does not duplicate the text content of a link directly beside it. - * We also test that the technique hasn't been applied incorrectly (Failure - * Examples 4 and 5 in technique H2). - * - * Error messages are given codes in the form "H2.EG5", meaning it is a case of - * the applicable failure example (3, 4, or 5). - * - * @param {DOMNode} element The image element to test. - */ testLinkStutter: function(element) { if (element.parentNode.nodeName.toLowerCase() === "a") { var anchor = element.parentNode; - // If contained by an "a" link, check that the alt text does not duplicate - // the link text, or if no link text, check an adjacent link does not - // duplicate it. var nodes = { anchor: { href: anchor.getAttribute("href"), @@ -1908,19 +1297,9 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { } if (nodes.anchor.alt !== null && nodes.anchor.alt !== "") { if (HTMLCS.util.trim(nodes.anchor.alt).toLowerCase() === HTMLCS.util.trim(nodes.anchor.text).toLowerCase()) { - // H2 "Failure Example 5": they're in one link, but the alt text - // duplicates the link text. Trimmed and lowercased because they - // would sound the same to a screen reader. HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("1_1_1_H2.EG5"), "H2.EG5"); } } - // If there is no supplementary text, try to catch H2 "Failure Examples" - // in cases where there are adjacent links with the same href: - // 3 - img text that duplicates link text in an adjacent link. (Screen - // readers will stutter.) - // 4 - img text is blank when another link adjacent contains link text. - // (This leaves one link with no text at all - the two should be - // combined into one link.) if (nodes.anchor.text === "") { var prevLink = HTMLCS.util.getPreviousSiblingElement(anchor, "a", true); var nextLink = HTMLCS.util.getNextSiblingElement(anchor, "a", true); @@ -1944,7 +1323,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { nodes.next.alt = ""; } } - // Test against the following link, if any. if (nodes.next && nodes.next.href !== "" && nodes.next.href !== null && nodes.anchor.href === nodes.next.href) { if (nodes.next.text !== "" && nodes.anchor.alt === "") { HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("1_1_1_H2.EG4"), "H2.EG4"); @@ -1952,7 +1330,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("1_1_1_H2.EG3"), "H2.EG3"); } } - // Test against the preceding link, if any. if (nodes.previous && nodes.previous.href !== "" && nodes.previous.href !== null && nodes.anchor.href === nodes.previous.href) { if (nodes.previous.text !== "" && nodes.anchor.alt === "") { HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("1_1_1_H2.EG4"), "H2.EG4"); @@ -1963,14 +1340,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { } } }, - /** - * Driver function for the media alternative (object/applet) tests. - * - * This takes the generic result given by the media alternative testing function, - * and converts them into WCAG 2.0-specific messages. - * - * @param {DOMNode} element The element to test. - */ addMediaAlternativesResults: function(top) { var errors = this.testMediaTextAlternatives(top); for (var i = 0; i < errors.object.missingBody.length; i++) { @@ -2006,8 +1375,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { var element = elements[el]; var nodeName = element.nodeName.toLowerCase(); var childObject = element.querySelector("object"); - // If we have an object as our alternative, skip it. Pass the blame onto - // the child. if (childObject === null) { if (HTMLCS.util.isStringEmpty(HTMLCS.util.getElementTextContent(element, true)) === true) { if (HTMLCS.util.hasValidAriaLabel(element) === false) { @@ -2020,15 +1387,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { } } } - //end if var elements = HTMLCS.util.getAllElements(top, "applet"); for (var el = 0; el < elements.length; el++) { - // Test firstly for whether we have an object alternative. var childObject = element.querySelector("object"); var hasError = false; - // If we have an object as our alternative, skip it. Pass the blame onto - // the child. (This is a special case: those that don't understand APPLET - // may understand OBJECT, but APPLET shouldn't be nested.) if (childObject === null) { var textAlt = HTMLCS.util.getElementTextContent(element, true); if (HTMLCS.util.isStringEmpty(textAlt) === true) { @@ -2036,31 +1398,20 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { hasError = true; } } - //end if var altAttr = element.getAttribute("alt") || ""; if (HTMLCS.util.isStringEmpty(altAttr) === true) { errors.applet.missingAlt.push(element); hasError = true; } - // Catch anything with a valid aria label. if (HTMLCS.util.hasValidAriaLabel(element) === true) { hasError = false; } if (hasError === false) { - // No error? Remind of obligations about equivalence of alternatives. errors.applet.generalAlt.push(element); } } - //end if return errors; }, - /** - * Gets just the alt text from any images on a link. - * - * @param {DOMNode} anchor The link element being inspected. - * - * @returns {String} The alt text. - */ _getLinkAltText: function(anchor) { var anchor = anchor.cloneNode(true); var nodes = []; @@ -2070,7 +1421,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { var alt = null; while (nodes.length > 0) { var node = nodes.shift(); - // If it's an element, add any sub-nodes to the process list. if (node.nodeType === 1) { if (node.nodeName.toLowerCase() === "img") { if (node.hasAttribute("alt") === true) { @@ -2078,7 +1428,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { if (!alt) { alt = ""; } else { - // Trim the alt text. alt = alt.replace(/^\s+|\s+$/g, ""); } break; @@ -2090,36 +1439,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_1_1_1_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "bgsound", "audio", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var nodeName = element.nodeName.toLowerCase(); if (nodeName !== "video") { @@ -2131,310 +1454,83 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_2_G87,G93"), "G87,G93"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_3_G69,G78,G173,G8"), "G69,G78,G173,G8"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_4 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_4_G9,G87,G93"), "G9,G87,G93"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_5 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_5_G78,G173,G8"), "G78,G173,G8"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_6 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_6_G54,G81"), "G54,G81"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_7 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Check for elements that could potentially contain video. HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_7_G8"), "G8"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_8 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_8_G69,G159"), "G69,G159"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_2_1_2_9 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "bgsound", "audio" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_2_9_G150,G151,G157"), "G150,G151,G157"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1_A = { _labelNames: null, register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var sniff = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1; if (element === top) { @@ -2443,29 +1539,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1_A = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1_AAA = { _labelNames: null, register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var sniff = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1; if (element === top) { @@ -2474,29 +1552,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1_AAA = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { _labelNames: null, register: function() { return [ "_top", "p", "div", "input", "select", "textarea", "button", "table", "fieldset", "form", "h1", "h2", "h3", "h4", "h5", "h6" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var nodeName = element.nodeName.toLowerCase(); if (element === top) { @@ -2547,11 +1607,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } }, - /** - * Test elements for presentation roles that also contain semantic child elements. - * - * @param {DOMNode} element The element to test. - */ testSemanticPresentationRole: function(element) { if (HTMLCS.util.isAriaHidden(element) === false && element.hasAttribute("role") && element.getAttribute("role") === "presentation") { var permitted = [ "div", "span", "b", "i" ]; @@ -2564,11 +1619,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } }, - /** - * Top-level test for labels that have no for attribute, or duplicate ones. - * - * @param {DOMNode} top The top element of the tested code. - */ testEmptyDupeLabelForAttrs: function(top) { this._labelNames = {}; var labels = top.getElementsByTagName("label"); @@ -2604,38 +1654,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } }, - /** - * Test for appropriate labels on inputs. - * - * The appropriate WCAG2 techniques test is failure F68. - * This test uses the September 2014 version of the technique: - * http://www.w3.org/TR/2014/NOTE-WCAG20-TECHS-20140916/F68 - * - * For all input elements of type "radio", "checkbox", "text", "file" or "password", - * and all textarea and select elements in the Web page: - * - * 1. Check that the visual design uses a text label that identifies the purpose of the control - * 2. Check that these input elements have a programmatically determined label associated in one - * of the following ways: - * (a) the text label is contained in a label element that is correctly associated to the - * respective input element via the label's for attribute (the id given as value in the - * for attribute matches the id of the input element). - * (b) the control is contained within a label element that contains the label text. - * (c) the text label is correctly programmatically associated with the input element via the - * aria-labelledby attribute (the id given as value in the aria-labelledby attribute - * matches the id of the input element). - * (d) the [label] is programmatically determined through the value of either its - * aria-label or title attributes. - * - * This changed in March 2014. Before then, only 2(a) was permitted or 2(d) (title attribute only). - * Notably, labels made through wrapping an element in a label attribute were not permitted. - * - * Associated techniques: H44 (LABEL element), H65 (title attribute), - * ARIA6/ARIA14 (aria-label), ARIA9/ARIA16 (aria-labelledby). - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ testLabelsOnInputs: function(element, top, muteErrors) { var nodeName = element.nodeName.toLowerCase(); var inputType = nodeName; @@ -2651,7 +1669,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { if (!hasLabel) hasLabel = {}; hasLabel[found] = true; }; - // Firstly, work out whether it needs a label. var needsLabel = false; var labelPos = "left"; var inputType = inputType.toLowerCase(); @@ -2663,12 +1680,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { if (element.getAttribute("hidden") !== null) { needsLabel = false; } - // Find an explicit label. var explicitLabel = element.ownerDocument.querySelector('label[for="' + element.id + '"]'); if (explicitLabel) { addToLabelList("explicit"); } - // Find an implicit label. var foundImplicit = false; if (element.parentNode) { HTMLCS.util.eachParentNode(element, function(parent) { @@ -2680,7 +1695,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { if (foundImplicit === true) { addToLabelList("implicit"); } - // Find a title attribute. var title = element.getAttribute("title"); if (title !== null) { if (/^\s*$/.test(title) === true && needsLabel === true) { @@ -2689,7 +1703,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { addToLabelList("title"); } } - // Find an aria-label attribute. if (element.hasAttribute("aria-label") === true) { if (HTMLCS.util.hasValidAriaLabel(element) === false) { HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("1_3_1_ARIA6"), "ARIA6"); @@ -2697,7 +1710,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { addToLabelList("aria-label"); } } - // Find an aria-labelledby attribute. if (element.hasAttribute("aria-labelledby") === true) { if (HTMLCS.util.hasValidAriaLabel(element) === false) { HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("1_3_1_ARIA16,ARIA9").replace(/\{\{id\}\}/g, element.getAttribute("aria-labelledby")), "ARIA16,ARIA9"); @@ -2707,39 +1719,18 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } if (!(muteErrors === true)) { if (hasLabel !== false && needsLabel === false) { - // Note that it is okay for buttons to have aria-labelledby or - // aria-label, or title. The former two override the button text, - // while title is a lower priority than either: the button text, - // and in submit/reset cases, the localised name for the words - // "Submit" and "Reset". - // http://www.w3.org/TR/html-aapi/#accessible-name-and-description-calculation if (inputType === "hidden") { HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("1_3_1_F68.Hidden"), "F68.Hidden"); } else if (element.getAttribute("hidden") !== null) { HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("1_3_1_F68.HiddenAttr"), "F68.HiddenAttr"); } } else if (hasLabel === false && needsLabel === true) { - // Needs label. HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("1_3_1_F68"), "F68"); } } return hasLabel; }, - /** - * Test for the use of presentational elements (technique H49). - * - * In HTML4, certain elements are considered presentational code. In HTML5, they - * are redefined (based on "they are being used, so they shouldn't be - * deprecated") so they can be considered "somewhat" semantic. They should still - * be considered a last resort. - * - * @param [DOMNode] top The top element of the tested code. - */ testPresentationMarkup: function(top) { - // In HTML4, the following were marked as presentational: - // b, i, u, s, strike, tt, big, small, center, font - // In HTML5, the following were repurposed as pseudo-semantic: - // b, i, u, s, small var _doc = HTMLCS.util.getElementWindow(top).document; var doctype = HTMLCS.util.getDocumentType(_doc); if (doctype && (doctype === "html5" || doctype === "xhtml5")) { @@ -2748,7 +1739,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { var msgCode = "H49." + tags[i].nodeName.substr(0, 1).toUpperCase() + tags[i].nodeName.substr(1).toLowerCase(); HTMLCS.addMessage(HTMLCS.ERROR, tags[i], _global.HTMLCS.getTranslation("1_3_1_H49."), msgCode); } - // Align attributes, too. var tags = HTMLCS.util.getAllElements(top, "*[align]"); for (var i = 0; i < tags.length; i++) { var msgCode = "H49.AlignAttr"; @@ -2760,7 +1750,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { var msgCode = "H49." + tags[i].nodeName.substr(0, 1).toUpperCase() + tags[i].nodeName.substr(1).toLowerCase(); HTMLCS.addMessage(HTMLCS.WARNING, tags[i], _global.HTMLCS.getTranslation("1_3_1_H49.Semantic"), msgCode); } - // Align attributes, too. var tags = HTMLCS.util.getAllElements(top, "*[align]"); for (var i = 0; i < tags.length; i++) { var msgCode = "H49.AlignAttr"; @@ -2768,19 +1757,7 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } }, - /** - * Test for the possible use of non-semantic headings (technique H42). - * - * Test for P|DIV > STRONG|EM|other inline styling, when said inline - * styling tag is the only element in the tag. It could possibly be a header - * that should be using h1..h6 tags instead. - * - * @param [DOMNode] element The paragraph or DIV element to test. - */ testNonSemanticHeading: function(element) { - // Test for P|DIV > STRONG|EM|other inline styling, when said inline - // styling tag is the only element in the tag. It could possibly a header - // that should be using h1..h6 tags instead. var tag = element.nodeName.toLowerCase(); if (tag === "p" || tag === "div") { var children = element.childNodes; @@ -2792,44 +1769,17 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } }, - /** - * Test for the correct association of table data cells with their headers. - * - * This is actually a two-part test, using either the scope attribute (H63) or - * the headers attribute (H43). Which one(s) are required or appropriate - * depend on the types of headings available: - * - If only one row or one column header, no association is required. - * - If one row AND one column headers, scope or headers is suitable. - * - If multi-level headers of any type, use of headers (only) is required. - * - * This test takes the results of two tests - one of headers and one of scope - - * and works out which error messages should apply given the above type of table. - * - * Invalid or incorrect usage of scope or headers are always reported when used, - * and cases where scope/headers are used on some of the table but not all is - * also thrown. - * - * @param {DOMNode} table The table element to evaluate. - * - * @return void - */ testTableHeaders: function(table) { var headersAttr = HTMLCS.util.testTableHeaders(table); var scopeAttr = this._testTableScopeAttrs(table); - // Invalid scope attribute - emit always if scope tested. for (var i = 0; i < scopeAttr.invalid.length; i++) { HTMLCS.addMessage(HTMLCS.ERROR, scopeAttr.invalid[i], _global.HTMLCS.getTranslation("1_3_1_H63.3"), "H63.3"); } - // TDs with scope attributes are obsolete in HTML5 - emit warnings if - // scope tested, but not as errors as they are valid HTML4. for (var i = 0; i < scopeAttr.obsoleteTd.length; i++) { HTMLCS.addMessage(HTMLCS.WARNING, scopeAttr.obsoleteTd[i], _global.HTMLCS.getTranslation("1_3_1_H63.2"), "H63.2"); } if (headersAttr.allowScope === true) { if (scopeAttr.missing.length === 0) { - // If all scope attributes are set, let them be used, even if the - // attributes are in error. If the scope attrs are fixed, the table - // will be legitimate. headersAttr.required === false; } } else { @@ -2838,80 +1788,43 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { scopeAttr = null; } } - //end if - // Incorrect usage of headers - error; emit always. for (var i = 0; i < headersAttr.wrongHeaders.length; i++) { HTMLCS.addMessage(HTMLCS.ERROR, headersAttr.wrongHeaders[i].element, _global.HTMLCS.getTranslation("1_3_1_H43.IncorrectAttr").replace(/\{\{expected\}\}/g, headersAttr.wrongHeaders[i].expected).replace(/\{\{actual\}\}/g, headersAttr.wrongHeaders[i].actual), "H43.IncorrectAttr"); } - // Errors where headers are compulsory. if (headersAttr.required === true && headersAttr.allowScope === false) { if (headersAttr.used === false) { - // Headers not used at all, and they are mandatory. HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H43.HeadersRequired"), "H43.HeadersRequired"); } else { - // Missing TH IDs - error; emit at this stage only if headers are compulsory. if (headersAttr.missingThId.length > 0) { HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H43.MissingHeaderIds"), "H43.MissingHeaderIds"); } - // Missing TD headers attributes - error; emit at this stage only if headers are compulsory. if (headersAttr.missingTd.length > 0) { HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H43.MissingHeadersAttrs"), "H43.MissingHeadersAttrs"); } } } - //end if - // Errors where either is permitted, but neither are done properly (missing - // certain elements). - // If they've only done it one way, presume that that is the way they want - // to continue. Otherwise provide a generic message if none are done or - // both have been done incorrectly. if (headersAttr.required === true && headersAttr.allowScope === true && headersAttr.correct === false && scopeAttr.correct === false) { if (scopeAttr.used === false && headersAttr.used === false) { - // Nothing used at all. HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H43,H63"), "H43,H63"); } else if (scopeAttr.used === false && (headersAttr.missingThId.length > 0 || headersAttr.missingTd.length > 0)) { - // Headers attribute is used, but not all th elements have ids. if (headersAttr.missingThId.length > 0) { HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H43.MissingHeaderIds"), "H43.MissingHeaderIds"); } - // Headers attribute is used, but not all td elements have headers attrs. if (headersAttr.missingTd.length > 0) { HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H43.MissingHeadersAttrs"), "H43.MissingHeadersAttrs"); } } else if (scopeAttr.missing.length > 0 && headersAttr.used === false) { - // Scope is used rather than headers, but not all th elements have them. HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H63.1"), "H63.1"); } else if (scopeAttr.missing.length > 0 && (headersAttr.missingThId.length > 0 || headersAttr.missingTd.length > 0)) { - // Both are used and both were done incorrectly. Provide generic message. HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H43,H63"), "H43,H63"); } } }, - /** - * Test for the correct scope attributes on table cell elements. - * - * Return value contains the following elements: - * - used (Boolean): Whether scope has been used on at least one cell. - * - correct (Boolean): Whether scope has been correctly used (obsolete - * elements do not invalidate this). - * - missing (Array): Array of th elements that have no scope attribute. - * - invalid (Array): Array of elements with incorrect scope attributes. - * - obsoleteTd (Array): Array of elements where we should throw a warning - * about scope on td being obsolete in HTML5. - * - * @param {DOMNode} element Table element to test upon. - * - * @return {Object} The above return value structure. - */ _testTableScopeAttrs: function(table) { var elements = { th: table.getElementsByTagName("th"), td: table.getElementsByTagName("td") }; - // Types of errors: - // - missing: Errors that a th does not contain a scope attribute. - // - invalid: Errors that the scope attribute is not a valid value. - // - obsoleteTd: Warnings that scopes on tds are obsolete in HTML5. var retval = { used: false, correct: true, @@ -2931,20 +1844,15 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } if (element.nodeName.toLowerCase() === "th") { if (/^\s*$/.test(scope) === true) { - // Scope empty or just whitespace. retval.correct = false; retval.missing.push(element); } else if (/^(row|col|rowgroup|colgroup)$/.test(scope) === false) { - // Invalid scope value. retval.correct = false; retval.invalid.push(element); } } else { if (scope !== "") { - // Scope attribute found on TD element. This is obsolete in - // HTML5. Does not make it incorrect. retval.obsoleteTd.push(element); - // Test for an invalid scope value regardless. if (/^(row|col|rowgroup|colgroup)$/.test(scope) === false) { retval.correct = false; retval.invalid.push(element); @@ -2953,14 +1861,8 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } } - //end for return retval; }, - /** - * Test table captions and summaries (techniques H39, H73). - * - * @param {DOMNode} table Table element to test upon. - */ testTableCaptionSummary: function(table) { var summary = table.getAttribute("summary") || ""; var captionEl = table.getElementsByTagName("caption"); @@ -2968,7 +1870,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { if (captionEl.length > 0) { caption = captionEl[0].innerHTML.trim(); } - // In HTML5, Summary no longer exists, so only run this for older versions. var doctype = HTMLCS.util.getDocumentType(table.ownerDocument); if (doctype && doctype.indexOf("html5") === -1) { summary = summary.trim(); @@ -2987,7 +1888,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } } - //end if if (caption !== "") { if (HTMLCS.util.isLayoutTable(table) === true) { HTMLCS.addMessage(HTMLCS.ERROR, table, _global.HTMLCS.getTranslation("1_3_1_H39.3.LayoutTable"), "H39.3.LayoutTable"); @@ -3000,41 +1900,18 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } }, - /** - * Test for fieldsets without legends (technique H71) - * - * @param {DOMNode} fieldset Fieldset element to test upon. - */ testFieldsetLegend: function(fieldset) { var legend = fieldset.querySelector("legend"); if (legend === null || legend.parentNode !== fieldset) { HTMLCS.addMessage(HTMLCS.ERROR, fieldset, _global.HTMLCS.getTranslation("1_3_1_H71.NoLegend"), "H71.NoLegend"); } }, - /** - * Test for select fields without optgroups (technique H85). - * - * It won't always be appropriate, so the error is emitted as a warning. - * - * @param {DOMNode} select Select element to test upon. - */ testOptgroup: function(select) { var optgroup = select.querySelector("optgroup"); if (optgroup === null) { - // Optgroup isn't being used. HTMLCS.addMessage(HTMLCS.WARNING, select, _global.HTMLCS.getTranslation("1_3_1_H85.2"), "H85.2"); } }, - /** - * Test for radio buttons and checkboxes with same name in a fieldset. - * - * One error will be fired at a form level, rather than firing one for each - * violating group of inputs (as there could be many). - * - * @param {DOMNode} form The form to test. - * - * @returns void - */ testRequiredFieldsets: function(form) { var optionInputs = form.querySelectorAll("input[type=radio], input[type=checkbox]"); var usedNames = {}; @@ -3042,42 +1919,27 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { var option = optionInputs[i]; if (option.hasAttribute("name") === true) { var optionName = option.getAttribute("name"); - // Now find if we are in a fieldset. Stop at the top of the DOM, or - // at the form element. var fieldset = option.parentNode; while (fieldset.nodeName.toLowerCase() !== "fieldset" && fieldset !== null && fieldset !== form) { fieldset = fieldset.parentNode; } if (fieldset.nodeName.toLowerCase() !== "fieldset") { - // Record that this name is used, but there is no fieldset. fieldset = null; } } - //end if if (usedNames[optionName] === undefined) { usedNames[optionName] = fieldset; } else if (fieldset === null || fieldset !== usedNames[optionName]) { - // Multiple names detected = should be in a fieldset. - // Either first instance or this one wasn't in a fieldset, or they - // are in different fieldsets. HTMLCS.addMessage(HTMLCS.WARNING, form, _global.HTMLCS.getTranslation("1_3_1_H71.SameName"), "H71.SameName"); break; } } }, - /** - * Test for paragraphs that appear manually bulleted or numbered (technique H48). - * - * @param {DOMNode} element The element to test upon. - */ testListsWithBreaks: function(element) { var firstBreak = element.querySelector("br"); var items = []; - // If there is a br tag, go break up the element and see what each line - // starts with. if (firstBreak !== null) { var nodes = []; - // Convert child nodes NodeList into an array. for (var i = 0; i < element.childNodes.length; i++) { nodes.push(element.childNodes[i]); } @@ -3085,34 +1947,27 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { while (nodes.length > 0) { var subel = nodes.shift(); if (subel.nodeType === 1) { - // Element node. if (subel.nodeName.toLowerCase() === "br") { - // Line break. Join and trim what we have now. items.push(thisItem.join(" ").trim()); thisItem = []; } else { - // Shift the contents of the sub element in, but in reverse. for (var i = subel.childNodes.length - 1; i >= 0; --i) { nodes.unshift(subel.childNodes[i]); } } } else if (subel.nodeType === 3) { - // Text node. thisItem.push(subel.nodeValue); } } - //end while if (thisItem.length > 0) { items.push(thisItem.join(" ").trim()); } for (var i = 0; i < items.length; i++) { if (/^[\-*]\s+/.test(items[0]) === true) { - // Test for "- " or "* " cases. HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("1_3_1_H48.1"), "H48.1"); break; } if (/^\d+[:\/\-.]?\s+/.test(items[0]) === true) { - // Test for "1 " cases (or "1. ", "1: ", "1- "). HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("1_3_1_H48.2"), "H48.2"); break; } @@ -3127,8 +1982,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { if (headingNum - lastHeading > 1) { var exampleMsg = "should be an h" + (lastHeading + 1) + " to be properly nested"; if (lastHeading === 0) { - // If last heading is empty, we are at document top and we are - // expecting a H1, generally speaking. HTMLCS.addMessage(level, headings[i], _global.HTMLCS.getTranslation("1_3_1_G141_a").replace(/\{\{headingNum\}\}/g, headingNum), "G141"); } HTMLCS.addMessage(level, headings[i], _global.HTMLCS.getTranslation("1_3_1_G141_b").replace(/\{\{headingNum\}\}/g, headingNum).replace(/\{\{properHeadingNum\}\}/g, lastHeading + 1), "G141"); @@ -3136,26 +1989,12 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { lastHeading = headingNum; } }, - /** - * Test for headings with no text, which should either be filled, or tags removed. - * - * @param {DOMNode} element The element to test. - * - * @returns void - */ testEmptyHeading: function(element) { var text = HTMLCS.util.getElementTextContent(element, true); if (/^\s*$/.test(text) === true) { HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("1_3_1_H42.2"), "H42.2"); } }, - /** - * Test for the presence of a list around common navigation links (H48). - * - * @param {DOMNode} element The element to test. - * - * @returns void - */ testUnstructuredNavLinks: function(element) { var nodeName = element.nodeName.toLowerCase(); var linksLength = 0; @@ -3168,11 +2007,7 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } } - //end for if (linksLength > 1) { - // Going to throw a warning here, mainly because we cannot easily tell - // whether it is just a paragraph with multiple links, or a navigation - // structure. var parent = element.parentNode; while (parent !== null && parent.nodeName.toLowerCase() !== "ul" && parent.nodeName.toLowerCase() !== "ol") { parent = parent.parentNode; @@ -3182,14 +2017,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } } }, - /** - * Provide generic messages for tables depending on what type of table they - * are - layout or data. - * - * @param {DOMNode} table The table element to test. - * - * @returns void - */ testGeneralTable: function(table) { if (HTMLCS.util.isLayoutTable(table) === true) { HTMLCS.addMessage(HTMLCS.NOTICE, table, _global.HTMLCS.getTranslation("1_3_1_LayoutTable"), "LayoutTable"); @@ -3199,158 +2026,42 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_3_2_G57"), "G57"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_3_3_G96"), "G96"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_4_1_G14,G18"), "G14,G182"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "bgsound", "audio", "video" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_4_2_F23"), "F23"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Australia Pty Ltd ABN 53 131 581 247 | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { testContrastRatio: function(top, minContrast, minLargeContrast) { var startDate = new Date(); @@ -3364,13 +2075,9 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { } while (toProcess.length > 0) { var node = toProcess.shift(); - // This is an element. - // Note we check for elements that are not _explicitly_ hidden, see isVisuallyHidden() if (node && node.nodeType === 1 && HTMLCS.util.isVisuallyHidden(node) === false && HTMLCS.util.isHiddenText(node) === false && HTMLCS.util.isDisabled(node) === false) { var processNode = false; for (var i = 0; i < node.childNodes.length; i++) { - // Load up new nodes, but also only process this node when - // there are direct text elements. if (node.childNodes[i].nodeType === 1) { toProcess.push(node.childNodes[i]); } else if (node.childNodes[i].nodeType === 3) { @@ -3391,9 +2098,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { var bgElement = node; var hasBgImg = false; var backgrounds = []; - // For compatibility with CS, we retain their name for this variable, but - // it now extends beyond just "absolute" to mean "is positioned outside of parent". - // Essentially it means we can't reliably know our background colour. var isAbsolute = false; if (style.backgroundImage !== "none" && style.backgroundImage.startsWith("url")) { hasBgImg = true; @@ -3401,14 +2105,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { if (style.position === "absolute") { isAbsolute = true; } - // Calculate font size. Note that CSS 2.1 fixes a reference pixel - // as 96 dpi (hence "pixel ratio" workarounds for Hi-DPI devices) - // so this calculation should be safe. var fontSize = parseFloat(style.fontSize, 10) * (72 / 96); var fontSizePixels = parseInt(style.fontSize); var fontWeight = parseInt(style.fontWeight); var minLargeSize = 18; - // Exclude text with no font size, this is a common screen reader hack. if (!fontSizePixels) { continue; } @@ -3418,7 +2118,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { var reqRatio = fontSize >= minLargeSize ? minLargeContrast : minContrast; var currentNode = node; var currentStyle = style; - // Calculate our background colour(s) and image(s) while (true) { bgColour = currentStyle.backgroundColor; if (HTMLCS.util.isColorFullyTransparent(bgColour)) { @@ -3446,7 +2145,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { bgColor: bgColour, isAbsolute: HTMLCS.util.isPositionedOutsideParent(currentStyle) }); - // Exit if the background is not even slightly transparent if (!HTMLCS.util.isColorTransparent(bgColour)) { break; } @@ -3454,15 +2152,12 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { if (HTMLCS.util.isPositionedOutsideParent(currentStyle)) { isAbsolute = true; } - // Up one node, if we can currentNode = currentNode.parentNode; if (!currentNode || !currentNode.ownerDocument) { break; } currentStyle = HTMLCS.util.style(currentNode); } - // Calculate the combined background colour from all of our - // relevant parents, by considering their alpha bgColour = null; for (var b = 0; b < backgrounds.length; b++) { var thisBgColour = backgrounds[b].bgColor; @@ -3475,8 +2170,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { } } if (hasBgImg === true) { - // If we have a background image, skip the contrast ratio checks, - // and push a warning instead. failures.push({ element: node, colour: foreColour, @@ -3511,9 +2204,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { }); continue; } else if (!bgColour || bgColour === "transparent" || bgColour === "rgba(0, 0, 0, 0)") { - // If the background colour is still transparent, this is probably - // a fragment with which we cannot reliably make a statement about - // contrast ratio. Skip the element. continue; } var contrastRatio = HTMLCS.util.contrastRatio(bgColour, style.color); @@ -3538,34 +2228,22 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { } } } - //end while return failures; }, - /** - * Parse a string of format: url("foo") or similar - * - * @param style - * @returns {*|string} - */ getUrlFromStyle: function(style) { if (style === "none") { return ""; } - // Data URLs could be ridiculous, ignore them if (style.match(/^data:/i)) { return ""; } - // In format "url(...)" var matches = style.match(/url\(["']?([^"']*)["']?\)/); if (matches instanceof Array && matches.length > 0) { return matches[1]; } - // Otherwise we could be a string like "linear-gradient(rgb(230, 100, 101), rgb(145, 152, 229))". - // Return this so we can parse it. return style; }, recommendColour: function(back, fore, target) { - // Canonicalise the colours. var fore = HTMLCS.util.RGBtoColourStr(HTMLCS.util.colourStrToRGB(fore)); var back = HTMLCS.util.RGBtoColourStr(HTMLCS.util.colourStrToRGB(back)); var cr = HTMLCS.util.contrastRatio(fore, back); @@ -3573,8 +2251,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { var backDiff = Math.abs(HTMLCS.util.relativeLum(back) - .5); var recommendation = null; if (cr < target) { - // Work out which colour has more room to move. - // If they are the same, prefer changing the foreground colour. var multiplier = 1 + 1 / 400; if (foreDiff <= backDiff) { var change = "back"; @@ -3597,10 +2273,7 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { var i = 0; while (cr < target) { if (newCol === "#fff" || newCol === "#000") { - // Couldn't go far enough. Reset and try the other colour. if (changed === true) { - // We've already switched colours, so we have to start - // winding back the other colour. if (change === "fore") { var oldBack = newBack; var j = 1; @@ -3642,7 +2315,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { } var cr = HTMLCS.util.contrastRatio(newFore, newBack); } - //end while recommendation = { fore: { from: fore, @@ -3654,13 +2326,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { } }; } - //end if return recommendation; }, multiplyColour: function(colour, multiplier) { var hsvColour = HTMLCS.util.sRGBtoHSV(colour); var chroma = hsvColour.saturation * hsvColour.value; - // If we are starting from black, start it from #010101 instead. if (hsvColour.value === 0) { hsvColour.value = 1 / 255; } @@ -3677,64 +2347,16 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_F24 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Test for background/foreground stuff. var elements = HTMLCS.util.getAllElements(top, "*"); for (var i = 0; i < elements.length; i++) { this.testColourComboFail(elements[i]); } }, - /** - * Tests for setting foreground without background, or vice versa (failure F24). - * - * It is a failure for a background colour to be set without a foreground colour, - * or vice versa. A user agent style sheet could try and set both, and because - * one is overridden, the result could be unreadable. - * - * This is being thrown as a warning, not an error. The failure allows the FG - * and BG colours to be set further up the chain, as long as the content has both - * foreground and background colours set by the time. - - * Further, we can only test inline styles (either through attributes, CSS, or - * JavaScript setting through eg. jQuery) because computed styles cause issues. - * For instance, if no user style sheet is set, the default stylesheet (in - * Firefox) at least is "transparent background/black text", and this would show - * up in the computed style (and fail, since transparent is "not set"). The F24 - * description (by my reading) allows the colours to be set further up the chain, - * as long as the content has -a- BG and -a- FG colour. - * - * @param Node element The element to test. - */ testColourComboFail: function(element) { var hasFg = element.hasAttribute("color"); hasFg = hasFg || element.hasAttribute("link"); @@ -3751,7 +2373,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_F24 = { hasBg = true; } } - //end if if (hasBg !== hasFg) { if (hasBg === true) { HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("1_4_3_F24.BGColour"), "F24.BGColour"); @@ -3762,36 +2383,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_F24 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { var failures = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast.testContrastRatio(top, 4.5, 3); @@ -3814,7 +2409,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3 = { var fontWeight = failures[i].fontWeight; var minLargeSize = failures[i].minLargeSize; var backgrounds = failures[i].backgrounds; - // If the values would look identical, add decimals to the value. while (required === value) { decimals++; value = Math.round(failures[i].value * Math.pow(10, decimals)) / Math.pow(10, decimals); @@ -3833,7 +2427,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3 = { recommendText.push(_global.HTMLCS.getTranslation("1_4_3_G18_or_G145.Fail.Recomendation.Background") + " " + recommend.back.to); } } - //end if if (recommendText.length > 0) { recommendText = " " + _global.HTMLCS.getTranslation("1_4_3_G18_or_G145.Fail.Recomendation") + " " + recommendText.join(", ") + "."; } @@ -3903,71 +2496,19 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_4 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_4_4_G142"), "G142"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_5 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var imgObj = top.querySelector("img"); if (imgObj !== null) { @@ -3976,36 +2517,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_5 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_6 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { var failures = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_3_Contrast.testContrastRatio(top, 7, 4.5); @@ -4028,7 +2543,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_6 = { var fontSizePixels = failures[i].fontSizePixels; var minLargeSize = failures[i].minLargeSize; var backgrounds = failures[i].backgrounds; - // If the values would look identical, add decimals to the value. while (required === value) { decimals++; value = Math.round(failures[i].value * Math.pow(10, decimals)) / Math.pow(10, decimals); @@ -4048,7 +2562,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_6 = { recommendText.push(_global.HTMLCS.getTranslation("1_4_6_G18_or_G17.Fail.Recomendation.Background") + recommend.back.to); } } - //end if if (recommendText.length > 0) { recommendText = " " + _global.HTMLCS.getTranslation("1_4_6_G18_or_G17.Fail.Recomendation") + " " + recommendText.join(", ") + "."; } @@ -4117,74 +2630,20 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_6 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_7 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "embed", "applet", "bgsound", "audio" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("1_4_7_G56"), "G56"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_8 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // This Success Criterion has five prongs, and each should be thrown as a - // separate notice as separate techniques apply to each. HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_4_8_G148,G156,G175"), "G148,G156,G175"); HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_4_8_H87,C20"), "H87,C20"); HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("1_4_8_C19,G172,G169"), "C19,G172,G169"); @@ -4193,36 +2652,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_8 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_9 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var imgObj = top.querySelector("img"); if (imgObj !== null) { @@ -4231,42 +2664,12 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_4_1_4_9 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_1_2_1_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Testing for elements that have explicit attributes for mouse-specific - // events. Note: onclick is considered keyboard accessible, as it is actually - // tied to the default action of a link or button - not merely a click. if (element === top) { - // Cannot detect event listeners here so only onclick attributes are checked. var keyboardTriggers = HTMLCS.util.getAllElements(top, "*[onclick], *[onkeyup], *[onkeydown], *[onkeypress], *[onfocus], *[onblur]"); keyboardTriggers.forEach(function(elem) { if (HTMLCS.util.isKeyboardNavigable(elem) === false) { @@ -4301,84 +2704,26 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_1_2_1_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_1_2_1_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "object", "applet", "embed" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.WARNING, element, _global.HTMLCS.getTranslation("2_1_2_F10"), "F10"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "meta" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Meta refresh testing under H76/F41. Fails if a non-zero timeout is provided. - // NOTE: H76 only lists criterion 3.2.5, but F41 also covers refreshes to - // same page (no URL content), which is covered by non-adjustable timeouts - // in criterion 2.2.1. if (element.hasAttribute("http-equiv") === true) { if (String(element.getAttribute("http-equiv")).toLowerCase() === "refresh") { if (/^[1-9]\d*/.test(element.getAttribute("content").toLowerCase()) === true) { if (/url=/.test(element.getAttribute("content").toLowerCase()) === true) { - // Redirect. HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("2_2_1_F40.2"), "F40.2"); } else { - // Just a refresh. HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("2_2_1_F41.2"), "F41.2"); } } @@ -4387,36 +2732,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top", "blink" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_2_2_SCR33,SCR22,G187,G152,G186,G191"), "SCR33,SCR22,G187,G152,G186,G191"); @@ -4435,218 +2754,55 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_2 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_2_3_G5"), "G5"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_4 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_2_4_SCR14"), "SCR14"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_2_2_2_5 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_2_5_G105,G181"), "G105,G181"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_3_2_3_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // The "small" flashing area is deliberately vague - users should see - // technique G176 for more details, as the threshold depends on both the - // size and resolution of a screen. - // The technique gives a baseline (based on a 15-17 inch monitor read at - // 22-26 inches, at 1024 x 768 resolution). A 10-degree field of vision is - // approximately 341 x 256 pixels in this environment, and a flashing area - // needs to be no more than 25% of this (not necessarily rectangular). HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("2_3_1_G19,G176"), "G19,G176"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_3_2_3_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("2_3_2_G19"), "G19"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "iframe", "a", "area", "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { this.testGenericBypassMsg(top); @@ -4664,13 +2820,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_1 = { } } }, - /** - * Test for the presence of title attributes on the iframe element (technique H64). - * - * @param {DOMNode} element The element to test. - * - * @returns void - */ testIframeTitle: function(element) { var nodeName = element.nodeName.toLowerCase(); if (nodeName === "iframe") { @@ -4689,28 +2838,9 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_1 = { } } }, - /** - * Throw a generic bypass blocks message. - * - * @param {DOMNode} top Top element of the testing source. - * - * @returns void - */ testGenericBypassMsg: function(top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("2_4_1_G1,G123,G124,H69"), "G1,G123,G124,H69"); }, - /** - * Test for document fragment links to IDs that do not exist. - * - * These are links of the form "", where the ID "content" does - * not exist. Area elements in image maps are also tested, as they are also - * likely to contain these attributes. - * - * @param {DOMNode} element The element to test. - * @param {DOMNode} top Top element of the testing source. - * - * @returns void - */ testSameDocFragmentLinks: function(element, top) { if (element.hasAttribute("href") === true) { var href = element.getAttribute("href"); @@ -4722,8 +2852,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_1 = { if (doc.ownerDocument) { doc = doc.ownerDocument; } - // First search for an element with the appropriate ID, then search for a - // named anchor using the name attribute. var target = doc.getElementById(id); if (target === null) { var _doc = HTMLCS.util.getElementWindow(top).document; @@ -4747,38 +2875,11 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "html" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Find a head first. var children = element.childNodes; var head = null; for (var i = 0; i < children.length; i++) { @@ -4811,36 +2912,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_2 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { var tabIndexExists = top.querySelector("*[tabindex]"); @@ -4851,36 +2926,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_3 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_4 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "a" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element.hasAttribute("title") === true) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_4_4_H77,H78,H79,H80,H81,H33"), "H77,H78,H79,H80,H81,H33"); @@ -4890,110 +2939,29 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_4 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_5 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_4_5_G125,G64,G63,G161,G126,G185"), "G125,G64,G63,G161,G126,G185"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_6 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_4_6_G130,G131"), "G130,G131"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_7 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Fire this notice if there appears to be an input field or link on the page - // (which will be just about anything). Links are important because they can - // still be tabbed to. var inputField = top.querySelector("input, textarea, button, select, a"); if (inputField !== null) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("2_4_7_G149,G165,G195,C15,SCR31"), "G149,G165,G195,C15,SCR31"); @@ -5001,45 +2969,15 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_7 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_8 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "link" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var linkParentName = element.parentNode.nodeName.toLowerCase(); - // Check for the correct location. HTML4 states "it may only appear in the - // HEAD element". HTML5 states it appears "wherever metadata content is - // expected", which only includes the head element. if (linkParentName !== "head") { HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("2_4_8_H59.1"), "H59.1"); } - // Check for mandatory elements. if (element.hasAttribute("rel") === false || !element.getAttribute("rel") || /^\s*$/.test(element.getAttribute("rel")) === true) { HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("2_4_8_H59.2a"), "H59.2a"); } @@ -5049,75 +2987,21 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_8 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle2_Guideline2_4_2_4_9 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "a" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_4_9_H30"), "H30"); - } -}; - -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ + HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("2_4_9_H30"), "H30"); + } +}; + _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "html" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element.hasAttribute("lang") === false && element.hasAttribute("xml:lang") === false) { - // TODO: if we can tell whether it's HTML or XHTML, we should split this - // into two - one asking for "lang", the other for "xml:lang". HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("3_1_1_H57.2"), "H57.2"); } else { if (element.hasAttribute("lang") === true) { @@ -5138,43 +3022,16 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_1 = { } } }, - /** - * Test for well-formed language tag as per IETF BCP 47. - * - * Note that this checks only for well-formedness, not whether the subtags are - * actually on the registered subtags list. - * - * @param {String} langTag The language tag to test. - * - * @returns {Boolean} the result of the regex test. - */ isValidLanguageTag: function(langTag) { - // Allow irregular or private-use tags starting with 'i' or 'x'. - // Values after it are 1-8 alphanumeric characters. var regexStr = "^([ix](-[a-z0-9]{1,8})+)$|"; - // Core language tags - 2 to 8 letters regexStr += "^[a-z]{2,8}"; - // Extlang subtags - three letters, repeated 0 to 3 times regexStr += "(-[a-z]{3}){0,3}"; - // Script subtag - four letters, optional. regexStr += "(-[a-z]{4})?"; - // Region subtag - two letters for a country or a three-digit region; optional. regexStr += "(-[a-z]{2}|-[0-9]{3})?"; - // Variant subtag - either digit + 3 alphanumeric, or - // 5-8 alphanumeric where it doesn't start with a digit; optional - // but repeatable. regexStr += "(-[0-9][a-z0-9]{3}|-[a-z0-9]{5,8})*"; - // Extension subtag - one single alphanumeric character (but not "x"), - // followed by at least one value of 2-8 alphanumeric characters. - // The whole thing is optional but repeatable (for different extensions). regexStr += "(-[a-wy-z0-9](-[a-z0-9]{2,8})+)*"; - // Private use subtag, starting with an "x" and containing at least one - // value of 1-8 alphanumeric characters. It must come last. regexStr += "(-x(-[a-z0-9]{1,8})+)?$"; - // Make a regex out of it, and make it all case-insensitive. var regex = new RegExp(regexStr, "i"); - // Throw the correct lang code depending on whether this is a document - // element or not. var valid = true; if (regex.test(langTag) === false) { valid = false; @@ -5183,45 +3040,13 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Generic message for changes in language. HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("3_1_2_H58"), "H58"); - // Alias the SC 3.1.1 object, which contains our "valid language tag" test. var sc3_1_1 = HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_1; - // Note, going one element beyond the end, so we can test the top element - // (which doesn't get picked up by the above query). Instead of going off the - // cliff of the collection, the last loop (i === langEls.length) checks the - // top element. var langEls = HTMLCS.util.getAllElements(top, "*[lang]"); for (var i = 0; i <= langEls.length; i++) { if (i === langEls.length) { @@ -5229,8 +3054,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_2 = { } else { var langEl = langEls[i]; } - // Skip html nodes, they are covered by 3.1.1. - // Also skip if the top element is the document element. if (!langEl.documentElement && langEl.nodeName.toLowerCase() !== "html") { if (langEl.hasAttribute("lang") === true) { var lang = langEl.getAttribute("lang"); @@ -5249,148 +3072,41 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_2 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("3_1_3_H40,H54,H60,G62,G70"), "H40,H54,H60,G62,G70"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_4 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("3_1_4_G102,G55,G62,H28,G97"), "G102,G55,G62,H28,G97"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_5 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("3_1_5_G86,G103,G79,G153,G160"), "G86,G103,G79,G153,G160"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_6 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "ruby" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var rb = element.querySelectorAll("rb"); var rt = element.querySelectorAll("rt"); if (rt.length === 0) { - // Vary the message depending on whether an rb element exists. If it doesn't, - // the presumption is that we are using HTML5 that uses the body of the ruby - // element for the same purpose (otherwise, assume XHTML 1.1 with rb element). if (rb.length === 0) { HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("3_1_6_H62.1.HTML5"), "H62.1.HTML5"); } else { @@ -5399,223 +3115,76 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_1_3_1_6 = { } var rp = element.querySelectorAll("rp"); if (rp.length === 0) { - // No "ruby parentheses" tags for those user agents that don't support - // ruby at all. HTMLCS.addMessage(HTMLCS.ERROR, element, _global.HTMLCS.getTranslation("3_1_6_H62.2"), "H62.2"); } } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "input", "textarea", "button", "select" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("3_2_1_G107"), "G107"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var nodeName = element.nodeName.toLowerCase(); if (nodeName === "form") { this.checkFormSubmitButton(element); } }, - /** - * Test for forms that don't have a submit button of some sort (technique H32). - * - * @param {DOMNode} form The form to test. - */ checkFormSubmitButton: function(form) { var ok = false; - // Test for INPUT-based submit buttons. The type must be specified, as - // the default for INPUT is text. var inputButtons = form.querySelectorAll("input[type=submit], input[type=image]"); if (inputButtons.length > 0) { ok = true; } else { - // Check for BUTTONs that aren't reset buttons, or normal buttons. - // If they're blank or invalid, they are submit buttons. var buttonButtons = form.querySelectorAll("button"); var nonSubmitButtons = form.querySelectorAll("button[type=reset], button[type=button]"); if (buttonButtons.length > nonSubmitButtons.length) { ok = true; } } - //end if if (ok === false) { HTMLCS.addMessage(HTMLCS.ERROR, form, _global.HTMLCS.getTranslation("3_2_2_H32.2"), "H32.2"); } } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("3_2_3_G61"), "G61"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_4 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, top, _global.HTMLCS.getTranslation("3_2_4_G197"), "G197"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_5 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "a" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { var nodeName = element.nodeName.toLowerCase(); if (nodeName === "a") { this.checkNewWindowTarget(element); } }, - /** - * Test for links that open in new windows but don't warn users (technique H83). - * - * @param {DOMNode} link The link to test. - */ checkNewWindowTarget: function(link) { var hasTarget = link.hasAttribute("target"); if (hasTarget === true) { @@ -5627,251 +3196,64 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_2_3_2_5 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("3_3_1_G83,G84,G85"), "G83,G84,G85"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Only the generic message will be displayed here. If there were problems - // with input boxes not having labels, it will be pulled up as errors in - // other Success Criteria (eg. 1.3.1, 4.1.2). HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("3_3_2_G131,G89,G184,H90"), "G131,G89,G184,H90"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_3 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { - // Only G177 (about providing suggestions) is flagged as a technique. - // The techniques in 3.3.1 are also listed in this Success Criterion. HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("3_3_3_G177"), "G177"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_4 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("3_3_4_G98,G99,G155,G164,G168.LegalForms"), "G98,G99,G155,G164,G168.LegalForms"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_5 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("3_3_5_G71,G184,G193"), "G71,G184,G193"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle3_Guideline3_3_3_3_6 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "form" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { HTMLCS.addMessage(HTMLCS.NOTICE, element, _global.HTMLCS.getTranslation("3_3_6_G98,G99,G155,G164,G168.AllForms"), "G98,G99,G155,G164,G168.AllForms"); } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_1 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { var elsWithIds = HTMLCS.util.getAllElements(top, "*[id]"); @@ -5882,8 +3264,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_1 = { continue; } if (usedIds[id] !== undefined) { - // F77 = "Failure of SC 4.1.1 due to duplicate values of type ID". - // Appropriate technique in HTML is H93. HTMLCS.addMessage(HTMLCS.ERROR, elsWithIds[i], _global.HTMLCS.getTranslation("4_1_1_F77").replace(/\{\{id\}\}/g, id), "F77"); } else { usedIds[id] = true; @@ -5893,36 +3273,10 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_1 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { - /** - * Determines the elements to register for processing. - * - * Each element of the returned array can either be an element name, or "_top" - * which is the top element of the tested code. - * - * @returns {Array} The list of elements. - */ register: function() { return [ "_top" ]; }, - /** - * Process the registered element. - * - * @param {DOMNode} element The element registered. - * @param {DOMNode} top The top element of the tested code. - */ process: function(element, top) { if (element === top) { var messages = this.processFormControls(top); @@ -5980,13 +3334,7 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { hrefFound = true; } if (hrefFound === false) { - // No href. We don't want these because, although they are commonly used - // to create targets, they can be picked up by screen readers and - // displayed to the user as empty links. A elements are defined by H91 as - // having an (ARIA) role of "link", and using them as targets are - // essentially misusing them. Place an ID on a parent element instead. if (/^\s*$/.test(content) === true) { - // Also no content. (eg. or ) if (element.hasAttribute("id") === true) { errors.empty.push(element); } else if (element.hasAttribute("name") === true) { @@ -5995,31 +3343,20 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { errors.emptyNoId.push(element); } } else { - // Giving a benefit of the doubt here - if a link has text and also - // an ID, but no href, it might be because it is being manipulated by - // a script. if (element.hasAttribute("id") === true || element.hasAttribute("name") === true) { errors.noHref.push(element); } else { - // HTML5 allows A elements with text but no href, "for where a - // link might otherwise have been placed, if it had been relevant". - // Hence, thrown as a warning, not an error. errors.placeholder.push(element); } } } else { if (nameFound === false) { - // Href provided, but no content, title or valid aria label. - // We only fire this message when there are no images in the content. - // A link around an image with no alt text is already covered in SC - // 1.1.1 (test H30). if (element.querySelectorAll("img").length === 0 && HTMLCS.util.hasValidAriaLabel(element) === false) { errors.noContent.push(element); } } } } - //end for return errors; }, processFormControls: function(top) { @@ -6052,44 +3389,34 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { var msgSubCode = element.nodeName.substr(0, 1).toUpperCase() + element.nodeName.substr(1).toLowerCase(); if (nodeName === "input") { if (element.hasAttribute("type") === false) { - // If no type attribute, default to text. nodeName += "_text"; } else { nodeName += "_" + element.getAttribute("type").toLowerCase(); } - // Treat all input buttons as the same if (nodeName === "input_submit" || nodeName === "input_reset") { nodeName = "input_button"; } - // Get a format like "InputText". var msgSubCode = "Input" + nodeName.substr(6, 1).toUpperCase() + nodeName.substr(7).toLowerCase(); } - //end if var matchingRequiredNames = requiredNames[nodeName]; var requiredValue = requiredValues[nodeName]; - // Any element that doesn't have specific handling must have content or aria labels. if (!matchingRequiredNames && nodeName !== "input_hidden") { matchingRequiredNames = [ "_content", "@aria-label", "@aria-labelledby" ]; } - // Check all possible combinations of names to ensure that one exists. if (matchingRequiredNames) { for (var i = 0; i < matchingRequiredNames.length; i++) { var requiredName = matchingRequiredNames[i]; if (requiredName === "_content") { - // Work with content. var content = HTMLCS.util.getElementTextContent(element); if (/^\s*$/.test(content) === false) { break; } } else if (requiredName === "label") { - // Label element. Re-use the label associating - // functions in SC 1.3.1. var hasLabel = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1.testLabelsOnInputs(element, top, true); if (hasLabel !== false) { break; } } else if (requiredName.charAt(0) === "@") { - // Attribute. requiredName = requiredName.substr(1, requiredName.length); if ((requiredName === "aria-label" || requiredName === "aria-labelledby") && HTMLCS.util.hasValidAriaLabel(element)) { break; @@ -6098,7 +3425,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { break; } } else { - // Sub-element contents. var subEl = element.querySelector(requiredName); if (subEl !== null) { var content = HTMLCS.util.getElementTextContent(subEl); @@ -6108,7 +3434,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { } } } - //end for if (i === matchingRequiredNames.length) { var msgNodeType = nodeName + " " + _global.HTMLCS.getTranslation("4_1_2_element"); if (nodeName.substr(0, 6) === "input_") { @@ -6135,38 +3460,29 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { }); } } - //end if var valueFound = false; if (requiredValue === undefined) { - // Nothing required of us. valueFound = true; } else if (requiredValue === "_content") { - // Work with content. var content = HTMLCS.util.getElementTextContent(element); if (/^\s*$/.test(content) === false) { valueFound = true; } } else if (requiredValue === "option_selected") { - // Select lists are recommended to have a selected Option element. if (element.hasAttribute("multiple") === false) { var selected = element.querySelector("option[selected]"); if (selected !== null) { valueFound = true; } } else { - // Allow zero element selection to be valid where the SELECT - // element has been declared as a multiple selection. valueFound = true; } } else if (requiredValue.charAt(0) === "@") { - // Attribute. requiredValue = requiredValue.substr(1, requiredValue.length); if (element.hasAttribute(requiredValue) === true) { valueFound = true; } } - //end if - // Check for valid aria labels. if (valueFound === false) { valuFound = HTMLCS.util.hasValidAriaLabel(element); } @@ -6181,9 +3497,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { if (requiredValue === "_content") { builtAttr = " " + _global.HTMLCS.getTranslation("4_1_2_msg_add_one"); } else if (requiredValue === "option_selected") { - // Change the message instead. The value is only undefined in HTML 4/XHTML 1; - // in HTML5 the first option in a single select dropdown is automatically selected. - // Because of this, it should also be sent out as a warning, not an error. warning = true; msg = _global.HTMLCS.getTranslation("4_1_2_msg_pattern2").replace(/\{\{msgNodeType\}\}/g, msgNodeType); } else if (requiredValue.charAt(0) === "@") { @@ -6207,7 +3520,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { } } } - //end for return { errors: errors, warnings: warnings @@ -6215,18 +3527,6 @@ _global.HTMLCS_WCAG2AAA_Sniffs_Principle4_Guideline4_1_4_1_2 = { } }; -/** - * +--------------------------------------------------------------------+ - * | This HTML_CodeSniffer file is Copyright (c) | - * | Squiz Pty Ltd (ABN 77 084 670 600) | - * +--------------------------------------------------------------------+ - * | IMPORTANT: Your use of this Software is subject to the terms of | - * | the Licence provided in the file licence.txt. If you cannot find | - * | this file please contact Squiz (www.squiz.com.au) so we may | - * | provide you a copy. | - * +--------------------------------------------------------------------+ - * - */ _global.HTMLCS = new function() { var _standards = {}; var _sniffs = []; @@ -6235,25 +3535,11 @@ _global.HTMLCS = new function() { var _currentSniff = null; var _messages = []; var _msgOverrides = {}; - /* - Message type constants. - */ this.ERROR = 1; this.WARNING = 2; this.NOTICE = 3; - // The current language to use. this.lang = "en"; - /** - * Loads the specified standard and run the sniffs. - * - * @param {String} standard The name of the standard to load. - * @param {String|Node} content An HTML string or a DOM node object. - * @param {Function} callback The function that will be called when the testing is completed. - * @param {Function} failCallback The fail callback which will be called if the standard load has failed. - * @param {String} language The language to use for text output. - */ this.process = function(standard, content, callback, failCallback, language) { - // Clear previous runs. _standards = {}; _sniffs = []; _tags = {}; @@ -6261,7 +3547,6 @@ _global.HTMLCS = new function() { if (!content) { return false; } - // Set a language to use. var languages = Object.keys(_global.translation); if (language && languages.indexOf(language) !== -1) { this.lang = language; @@ -6274,13 +3559,6 @@ _global.HTMLCS = new function() { }, failCallback); } }; - /** - * Gets a translation for a text value. - * - * @param {String} text The text to get the translation for. - * - * @return {String} - */ this.getTranslation = function(text) { try { return _global.translation[this.lang][text]; @@ -6288,12 +3566,6 @@ _global.HTMLCS = new function() { throw new Error('Translation for "' + text + '" does not exist in current language ' + this.lang); } }; - /** - * Loads the specified standard and its sniffs. - * - * @param {String} standard The name of the standard to load. - * @param {Function} callback The function to call once the standard is loaded. - */ this.loadStandard = function(standard, callback, failCallback) { if (!standard) { return false; @@ -6303,12 +3575,6 @@ _global.HTMLCS = new function() { callback.call(this); }, failCallback); }; - /** - * Runs the sniffs for the loaded standard. - * - * @param {Function} callback The function to call once all sniffs are completed. - * @param {String|Node} content An HTML string or a DOM node object. - */ this.run = function(callback, content) { var element = null; var loadingFrame = false; @@ -6337,7 +3603,6 @@ _global.HTMLCS = new function() { elements.unshift(element); _run(elements, element, callback); }; - // Satisfy IE which doesn't like onload being set dynamically. elementFrame.onreadystatechange = function() { if (/^(complete|loaded)$/.test(this.readyState) === true) { this.onreadystatechange = null; @@ -6360,26 +3625,12 @@ _global.HTMLCS = new function() { } callback = callback || function() {}; _messages = []; - // Get all the elements in the parent element. - // Add the parent element too, which will trigger "_top" element codes. var elements = HTMLCS.util.getAllElements(element); elements.unshift(element); - // Run the sniffs. if (loadingFrame === false) { _run(elements, element, callback); } }; - /** - * Returns true if the content passed appears to be from a full document. - * - * With string content, we consider a full document as the presence of , - * or
+ elements. For an element, only the 'html' element (the - * document element) is accepted. - * - * @param {String|Node} content An HTML string or a DOM node object. - * - * @returns {Boolean} - */ this.isFullDoc = function(content) { var fullDoc = false; if (typeof content === "string") { @@ -6389,22 +3640,12 @@ _global.HTMLCS = new function() { fullDoc = true; } } else { - // If we are the document, or the document element. if (content.nodeName.toLowerCase() === "html" || content.documentElement) { fullDoc = true; } } return fullDoc; }; - /** - * Adds a message. - * - * @param {Number} type The type of the message. - * @param {Node} element The element that the message is related to. - * @param {String} msg The message string. - * @param {String} code Unique code for the message. - * @param {Object} [data] Extra data to store for the message. - */ this.addMessage = function(type, element, msg, code, data) { code = _getMessageCode(code); _messages.push({ @@ -6415,24 +3656,9 @@ _global.HTMLCS = new function() { data: data }); }; - /** - * Returns all the messages for the last run. - * - * Return a copy of the array so the class variable doesn't get modified by - * future modification (eg. splicing). - * - * @returns {Array} Array of message objects. - */ this.getMessages = function() { return _messages.concat([]); }; - /** - * Runs the sniffs in the loaded standard for the specified element. - * - * @param {Node} element The element to test. - * @param {Node} topElement The top element of the processing. - * @param {Function} [callback] The function to call once all tests are run. - */ var _run = function(elements, topElement, callback) { var topMsgs = []; while (elements.length > 0) { @@ -6442,8 +3668,6 @@ _global.HTMLCS = new function() { } else { var tagName = element.tagName.toLowerCase(); } - // First check whether any "top" messages need to be shifted off for this - // element. If so, dump off into the main messages. for (var i = 0; i < topMsgs.length; ) { if (element === topMsgs[i].element) { _messages.push(topMsgs[i]); @@ -6452,21 +3676,15 @@ _global.HTMLCS = new function() { i++; } } - //end for if (_tags[tagName] && _tags[tagName].length > 0) { _processSniffs(element, _tags[tagName].concat([]), topElement); - // Save "top" messages, and reset the messages array. if (tagName === "_top") { topMsgs = _messages; _messages = []; } } } - //end while _messages = _messages.concat(topMsgs); - // Due to filtering of presentation roles for general sniffing these need to be handled - // separately. The 1.3.1 sniff needs to run to detect any incorrect usage of the presentation - // role. var presentationElems = topElement.querySelectorAll('[role="presentation"]'); _currentSniff = HTMLCS_WCAG2AAA_Sniffs_Principle1_Guideline1_3_1_3_1; [].forEach.call(presentationElems, function(element) { @@ -6476,74 +3694,39 @@ _global.HTMLCS = new function() { callback.call(this); } }; - /** - * Process the sniffs. - * - * @param {Node} element The element to test. - * @param {Array} sniffs Array of sniffs. - * @param {Node} topElement The top element of the processing. - * @param {Function} [callback] The function to call once the processing is completed. - */ var _processSniffs = function(element, sniffs, topElement, callback) { while (sniffs.length > 0) { var sniff = sniffs.shift(); _currentSniff = sniff; if (sniff.useCallback === true) { - // If the useCallback property is set: - // - Process the sniff. - // - Recurse into ourselves with remaining sniffs, with no callback. - // - Clear out the list of sniffs (so they aren't run again), so the - // callback (if not already recursed) can run afterwards. sniff.process(element, topElement, function() { _processSniffs(element, sniffs, topElement); sniffs = []; }); } else { - // Process the sniff. sniff.process(element, topElement); } } - //end while if (callback instanceof Function === true) { callback.call(this); } }; - /** - * Includes the specified standard file. - * - * @param {String} standard The name of the standard. - * @param {Function} callback The function to call once the standard is included. - * @param {Object} options The options for the standard (e.g. exclude sniffs). - */ var _includeStandard = function(standard, callback, failCallback, options) { if (standard.indexOf("http") !== 0) { standard = _getStandardPath(standard); } - //end id - // See if the ruleset object is already included (eg. if minified). var parts = standard.split("/"); var ruleSet = _global["HTMLCS_" + parts[parts.length - 2]]; if (ruleSet) { - // Already included. _registerStandard(standard, callback, failCallback, options); } else { _includeScript(standard, function() { - // Script is included now register the standard. _registerStandard(standard, callback, failCallback, options); }, failCallback); } }; - /** - * Registers the specified standard and its sniffs. - * - * @param {String} standard The name of the standard. - * @param {Function} callback The function to call once the standard is registered. - * @param {Object} options The options for the standard (e.g. exclude sniffs). - */ var _registerStandard = function(standard, callback, failCallback, options) { - // Get the object name. var parts = standard.split("/"); - // Get a copy of the ruleset object. var oldRuleSet = _global["HTMLCS_" + parts[parts.length - 2]]; var ruleSet = {}; for (var x in oldRuleSet) { @@ -6555,13 +3738,10 @@ _global.HTMLCS = new function() { return false; } _standards[standard] = ruleSet; - // Process the options. if (options) { if (options.include && options.include.length > 0) { - // Included sniffs. ruleSet.sniffs = options.include; } else if (options.exclude) { - // Excluded sniffs. for (var i = 0; i < options.exclude.length; i++) { var index = ruleSet.sniffs.find(options.exclude[i]); if (index >= 0) { @@ -6570,37 +3750,19 @@ _global.HTMLCS = new function() { } } } - //end if - // Register the sniffs for this standard. var sniffs = ruleSet.sniffs.slice(0, ruleSet.sniffs.length); _registerSniffs(standard, sniffs, callback, failCallback); }; - /** - * Registers the sniffs for the specified standard. - * - * @param {String} standard The name of the standard. - * @param {Array} sniffs List of sniffs to register. - * @param {Function} callback The function to call once the sniffs are registered. - */ var _registerSniffs = function(standard, sniffs, callback, failCallback) { if (sniffs.length === 0) { callback.call(this); return; } - // Include and register sniffs. var sniff = sniffs.shift(); _loadSniffFile(standard, sniff, function() { _registerSniffs(standard, sniffs, callback, failCallback); }, failCallback); }; - /** - * Includes the sniff's JS file and registers it. - * - * @param {String} standard The name of the standard. - * @param {String|Object} sniff The sniff to register, can be a string or - * and object specifying another standard. - * @param {Function} callback The function to call once the sniff is included and registered. - */ var _loadSniffFile = function(standard, sniff, callback, failCallback) { if (typeof sniff === "string") { var sniffObj = _getSniff(standard, sniff); @@ -6608,17 +3770,14 @@ _global.HTMLCS = new function() { _registerSniff(standard, sniff); callback.call(this); }; - // Already loaded. if (sniffObj) { cb(); } else { _includeScript(_getSniffPath(standard, sniff), cb, failCallback); } } else { - // Including a whole other standard. _includeStandard(sniff.standard, function() { if (sniff.messages) { - // Add message overrides. for (var msg in sniff.messages) { _msgOverrides[msg] = sniff.messages[msg]; } @@ -6630,19 +3789,11 @@ _global.HTMLCS = new function() { }); } }; - /** - * Registers the specified sniff. - * - * @param {String} standard The name of the standard. - * @param {String} sniff The name of the sniff. - */ var _registerSniff = function(standard, sniff) { - // Get the sniff object. var sniffObj = _getSniff(standard, sniff); if (!sniffObj) { return false; } - // Call the register method of the sniff, it should return an array of tags. if (sniffObj.register) { var watchedTags = sniffObj.register(); for (var i = 0; i < watchedTags.length; i++) { @@ -6654,40 +3805,19 @@ _global.HTMLCS = new function() { } _sniffs.push(sniffObj); }; - /** - * Returns the path to the sniff file. - * - * @param {String} standard The name of the standard. - * @param {String} sniff The name of the sniff. - * - * @returns {String} The path to the JS file of the sniff. - */ var _getSniffPath = function(standard, sniff) { var parts = standard.split("/"); parts.pop(); var path = parts.join("/") + "/Sniffs/" + sniff.replace(/\./g, "/") + ".js"; return path; }; - /** - * Returns the path to a local standard. - * - * @param {String} standard The name of the standard. - * - * @returns {String} The path to the local standard. - */ var _getStandardPath = function(standard) { - // Get the include path of a local standard. var scripts = document.getElementsByTagName("script"); var path = null; - // Loop through all the script tags that exist in the document and find the one - // that has included this file. for (var i = 0; i < scripts.length; i++) { if (scripts[i].src) { if (scripts[i].src.match(/HTMLCS\.js/)) { - // We have found our appropriate