parser/htmlparser/tests/mochitest/test_compatmode.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
michael@0 5 <title>Mochitest for DOCTYPE parsing</title>
michael@0 6
michael@0 7 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 9 </head>
michael@0 10 <body>
michael@0 11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=363883">Mozilla Bug 363883</a>
michael@0 12
michael@0 13 <p id="display"></p>
michael@0 14 <div id="content" style="display: none">
michael@0 15
michael@0 16 </div>
michael@0 17
michael@0 18 <pre id="test">
michael@0 19 <script class="testbody" type="text/javascript">
michael@0 20
michael@0 21 var doctypes = [
michael@0 22 /* from bug 363883 */
michael@0 23 'BackCompat' , '<!DOCTYPE>',
michael@0 24 'BackCompat' , '<!DOCTYPEz>',
michael@0 25 'BackCompat' , '<! DOCTYPE>',
michael@0 26 'BackCompat' , '<!zDOCTYPE>',
michael@0 27 'CSS1Compat' , '<!DOCTYPEHTML>',
michael@0 28 'BackCompat' , '<!DOCTYPEz HTML>',
michael@0 29 'CSS1Compat' , '<!DOCTYPE HTML>',
michael@0 30 'BackCompat' , '<!zDOCTYPE HTML>',
michael@0 31 'BackCompat' , '<!DOCTYPE HTMLz>',
michael@0 32 'BackCompat' , '<!DOCTYPE zHTML>',
michael@0 33 'BackCompat' , '<!DOCTYPE XHTML>',
michael@0 34 'BackCompat' , '<!DOCTYPE zzHTML>',
michael@0 35 'BackCompat' , '<!DOCTYPEzHTML>',
michael@0 36 'BackCompat' , '<!DOCTYPEzzHTML>',
michael@0 37 'BackCompat' , '<!DOCTYPE "bla">',
michael@0 38 'BackCompat' , '<!DOCTYPE HTML "bla">',
michael@0 39 'BackCompat' , '<!DOCTYPE HTML "html">',
michael@0 40 'BackCompat' , '<!DOCTYPE PUBLIC>',
michael@0 41 'BackCompat' , '<!DOCTYPE PUBLIC "bla">',
michael@0 42 'BackCompat' , '<!DOCTYPE PUBLIC "html">',
michael@0 43 'CSS1Compat' , '<!DOCTYPE HTML PUBLIC "bla">',
michael@0 44 'BackCompat' , '<!DOCTYPE HTML PUBLIC "html">',
michael@0 45 'BackCompat' , '<!DOCTYPEz HTML PUBLIC "html">',
michael@0 46 'BackCompat' , '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//en">',
michael@0 47 'BackCompat' , '<!DOCTYPEz HTML PUBLIC "-//IETF//DTD HTML 3.2//en">',
michael@0 48 'BackCompat' , '<!DOCTYPE HTMLz PUBLIC "DTD HTML 3.2">',
michael@0 49 'BackCompat' , '<!DOCTYPE "DTD HTML 3.2">',
michael@0 50 /* end from bug 363883 */
michael@0 51 // from bug 502600
michael@0 52 'BackCompat' , '<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">',
michael@0 53 ];
michael@0 54
michael@0 55 function test(mode,i){
michael@0 56 is(mode,doctypes[i],doctypes[i+1]);
michael@0 57 if (i == doctypes.length - 2) {
michael@0 58 SimpleTest.finish();
michael@0 59 }
michael@0 60 }
michael@0 61
michael@0 62 ////
michael@0 63 // Insert a hidden iframe into the document, with the src
michael@0 64 // containing the test doctype. The iframe's onload
michael@0 65 // function is set to call the test's verification step.
michael@0 66 //
michael@0 67 function insert_iframe(doctype,expected) {
michael@0 68 var elm = document.createElement('iframe');
michael@0 69 elm.setAttribute('src', 'data:text/html,' + doctype +
michael@0 70 '<html><body onload="parent.test(document.compatMode,'+i+')"></body>');
michael@0 71 elm.setAttribute('style', 'display:none');
michael@0 72 document.getElementsByTagName('body')[0].appendChild(elm);
michael@0 73 }
michael@0 74
michael@0 75 ////
michael@0 76 // Iterate over the tests
michael@0 77 //
michael@0 78 function doTest() {
michael@0 79 for (i=0; i < doctypes.length; i+=2) {
michael@0 80 insert_iframe(doctypes[i+1],doctypes[i]);
michael@0 81 }
michael@0 82 }
michael@0 83
michael@0 84 ////
michael@0 85 // Run the compatbility mode tests.
michael@0 86 //
michael@0 87 SimpleTest.waitForExplicitFinish();
michael@0 88 doTest();
michael@0 89
michael@0 90 </script>
michael@0 91 </pre>
michael@0 92 </body>
michael@0 93 </html>

mercurial