browsing-context.html (2612B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>HTML Test: Browsing context is first created</title> 5 <link rel="author" title="Intel" href="http://www.intel.com/" /> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 </head> 9 <body> 10 <div id="log"></div> 11 <script> 12 var doc, iframe; 13 14 setup(function () { 15 // Create new browsing context via iframe 16 iframe = document.createElement("iframe"); 17 document.body.appendChild(iframe); 18 doc = iframe.contentDocument; 19 }); 20 21 test(function () { 22 assert_equals(doc.compatMode, "BackCompat", "The compatMode of a document without a document type declaration should be 'BackCompat'."); // Quirksmode 23 assert_equals(doc.contentType, "text/html", "The document should be an HTML document."); 24 assert_equals(doc.readyState, "complete", "The readyState attribute should be 'complete'."); 25 // Document metadata... 26 assert_equals(doc.documentURI, "about:blank", "The document's address should be 'about:blank'."); 27 assert_equals(doc.URL, "about:blank", "The document's address should be 'about:blank'."); 28 assert_equals(doc.doctype, null, "The docType of a document without a document type declaration should be null."); 29 assert_equals(doc.characterSet, "UTF-8", "The document's encoding should be 'UTF-8'."); 30 }, "Check that browsing context has new, ready HTML document"); 31 32 test(function () { 33 assert_equals(doc.childNodes.length, 1, "The document must have only one child."); 34 assert_equals(doc.documentElement.tagName, "HTML"); 35 assert_equals(doc.documentElement.childNodes.length, 2, "The HTML element should have 2 children."); 36 assert_equals(doc.documentElement.childNodes[0].tagName, "HEAD", "The first child of HTML element should be a HEAD element."); 37 assert_false(doc.documentElement.childNodes[0].hasChildNodes(), "The HEAD element should not have children."); 38 assert_equals(doc.documentElement.childNodes[1].tagName, "BODY", "The second child of HTML element should be a BODY element."); 39 assert_false(doc.documentElement.childNodes[1].hasChildNodes(), "The BODY element should not have children."); 40 }, "Check that new document nodes extant, empty"); 41 42 test(function () { 43 assert_equals(doc.referrer, document.URL, "The document's referrer should be its creator document's URL."); 44 assert_equals(iframe.contentWindow.parent.document, document); 45 }, "Check the document properties corresponding to the creator browsing context"); 46 </script> 47 </body> 48 </html>