<html>
<head>
    <script src="resources/TestDoctype.js"></script>
    <script>
        if (window.testRunner)
            testRunner.dumpAsText();

        test = function(mode, doctype)
        {
            var doc = document.getElementsByTagName('iframe')[0].contentDocument
            doc.open();
            doc.write(doctype + "\n<html><body></body></html>")
            doc.close();
            testDoctype(doc, mode, doctype);
        }

        onload = function()
        {
            // Test No Doctype
            test('Quirks', '');

            // Test Doctypes that force Standards mode
            test('Standards', '<!DOCTYPE HTML>');
            test('Standards', '<!DOCTYPE HTML SYSTEM "http://www.w3.org/TR/REC-html40/strict.dtd">');
            test('Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">');
            test('Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">');
            test('Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">');
            test('Standards', '<!DOCTYPE HTML PUBLIC "ISO/IEC 15445:2000//DTD HyperText Markup Language//EN">');
            test('Standards', '<!DOCTYPE HTML PUBLIC "ISO/IEC 15445:2000//DTD HTML//EN">');
            test('Standards', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML i18n//EN">');
            test('Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">');

            // Test Doctypes that force Almost-Standards mode
            test('Almost Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">');
            test('Almost Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN">');
            test('Almost Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">');
            test('Almost Standards', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">');

            // Test Doctypes that force Quirks mode
            test('Quirks', '<!DOCTYPE HTML NOT UNDERSTOOD>');
            test('Quirks', '<!DOCTYPE HTML [ <!ELEMENT TEST - - (P) > ]>');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">');
            test('Quirks', '<!DOCTYPE html SYSTEM "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//3.0">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 3.0//EN//">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 3.0//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3 1995-03-24//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN//">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 3//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 3//EN//3.0">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN//3.0">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML Strict 3.0//EN//">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 3//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 3//EN//3.0">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "HTML">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//2.0">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 2//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 2//EN//2.0">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Level 2//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 1//EN">');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 1//EN//2.0".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Level 1//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 0//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Level 0//EN//2.0".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict//EN//2.0".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 2//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 2//EN//2.0".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 1//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 1//EN//2.0".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 1//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 0//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML Strict Level 0//EN//2.0".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//WebTechs//DTD Mozilla HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//WebTechs//DTD Mozilla HTML 2.0//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Netscape Comm. Corp.//DTD HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Netscape Comm. Corp.//DTD HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Netscape Comm. Corp.//DTD Strict HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Microsoft//DTD Internet Explorer 2.0 HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Microsoft//DTD Internet Explorer 2.0 Tables//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Microsoft//DTD Internet Explorer 3.0 HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Microsoft//DTD Internet Explorer 3.0 Tables//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Sun Microsystems Corp.//DTD HotJava HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Sun Microsystems Corp.//DTD HotJava Strict HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.1E//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//O\'Reilly and Associates//DTD HTML Extended 1.0//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//O\'Reilly and Associates//DTD HTML Extended Relaxed 1.0//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//O\'Reilly and Associates//DTD HTML 2.0//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//SQ//DTD HTML 2.0 HoTMetaL + extensions//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Spyglass//DTD HTML 2.0 Extended//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "+//Silmaril//DTD HTML Pro v0r11 19970101//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Experimental 19960712//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Draft//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML Experimental 970421//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2S Draft//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN".');
            test('Quirks', '<!DOCTYPE HTML PUBLIC "-//Metrius//DTD Metrius Presentational//EN".');

            // Test malformed Doctypes
            test('Quirks', '<!DOCTYPE>');
            test('Standards', '<!DOCTYPEhtml>');
            test('Quirks', '<!DOCTYPEfoo>');
            test('Standards', '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML Transitional 4.01//EN">');
            test('Quirks', '<!DOCTYPE html PUBLIC');
            test('Quirks', '<!DOCTYPE html PUBLIC \'');
            test('Quirks', '<!DOCTYPE html PUBLIC \'x');
            test('Standards', '<!DOCTYPE html SYSTEM "-//W3C//DTD HTML Transitional 4.01//EN">');
            test('Standards', '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML Transitional 4.01//EN" "-//W3C//DTD HTML Transitional 4.01//EN">');
            test('Quirks', '<!DOCTYPE html PUBLIC \">x');
            test('Quirks', '<!DOCTYPE html PUBLIC \'>x');
            test('Quirks', '<!DOCTYPE html PUBLIC "foo" \">x');
            test('Quirks', '<!DOCTYPE html PUBLIC \'foo\' \'>x');
            test('Quirks', '<!DOCTYPE html ');

            // Test Doctypes not at the beginning of the Document
            test('Quirks', '<html><body></body></html><!DOCTYPE html>');
            test('Quirks', '<html><body><!DOCTYPE html></body></html>');
            test('Standards', '<!-- comment --><!DOCTYPE html>');
        }
    </script>
</head>
<body>
    <pre id='console'></pre>
    <iframe src="resources/subframe.html"></iframe>
</body>
</html>
