sandbox_011.htm (2865B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>HTML5 Sandbox: iframe sandbox attribute value support DOMTokenList interface.</title> 5 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /> 6 <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> 7 <link rel="help" href="http://dev.w3.org/html5/spec/Overview.html#the-iframe-element" /> 8 <meta name="assert" content="iframe sandbox attribute value support DOMTokenList interface." /> 9 <script src="/resources/testharness.js"></script> 10 <script src="/resources/testharnessreport.js"></script> 11 </head> 12 <body> 13 <div id=log></div> 14 <iframe id="iframe1" src="about:blank" sandbox="allow-scripts allow-same-origin allow-forms" style="display : none"></iframe> 15 <script type="text/javascript"> 16 17 test(function() { 18 var iframeEle = document.getElementById("iframe1"); 19 assert_equals(iframeEle.sandbox.length, 3) 20 }, "DOMTokenList length") 21 22 test(function() { 23 var iframeEle = document.getElementById("iframe1"); 24 assert_equals(iframeEle.sandbox.item(1), "allow-same-origin") 25 }, "DOMTokenList item(index)") 26 27 test(function() { 28 var iframeEle = document.getElementById("iframe1"); 29 assert_true(iframeEle.sandbox.contains("allow-forms")) 30 }, "DOMTokenList contains(DomString)") 31 32 test(function() { 33 var iframeEle = document.getElementById("iframe1"); 34 iframeEle.sandbox.add("ALLOW-SANDBOX"); 35 assert_true(iframeEle.sandbox.contains("ALLOW-SANDBOX")) 36 }, "DOMTokenList add(DomString)") 37 38 test(function() { 39 var iframeEle = document.getElementById("iframe1"); 40 iframeEle.sandbox.remove("ALLOW-SANDBOX"); 41 assert_false(iframeEle.sandbox.contains("ALLOW-SANDBOX")) 42 }, "DOMTokenList remove(DomString)") 43 44 test(function() { 45 var iframeEle = document.getElementById("iframe1"); 46 iframeEle.sandbox.remove("ALLOW-SANDBOX"); 47 assert_true( 48 iframeEle.sandbox.toggle("allow-top-navigation") && iframeEle.sandbox.contains("allow-top-navigation") && 49 !iframeEle.sandbox.toggle("allow-top-navigation") && !iframeEle.sandbox.contains("allow-top-navigation") 50 ) 51 }, "DOMTokenList toggle(DomString) - Returns true if token is now present (it was added); returns false if it is not (it was removed).") 52 53 test(function() { 54 var iframeEle = document.getElementById("iframe1"); 55 assert_equals(iframeEle.sandbox.value, iframeEle.sandbox.toString()) 56 }, "DOMTokenList sandbox.toString()") 57 58 test(function() { 59 var iframeEle = document.getElementById("iframe1"); 60 iframeEle.sandbox.remove("ALLOW-SANDBOX"); 61 assert_true(iframeEle.sandbox.contains("allow-scripts") != iframeEle.sandbox.contains("Allow-SCRIPTS")) 62 }, "DOMTokenList case sensitivity") 63 </script> 64 </body> 65 </html>