navigation-insecure.html (1936B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="support/test_utils.sub.js"></script> 7 </head> 8 9 <body> 10 <script> 11 /** 12 * @param Array.<Array.<Datatype>> combination A combination of datatypes. 13 * @param Dict.<string, boolean> report A map between a datatype name and 14 * whether it is empty. 15 * @return boolean Whether all datatypes are still nonempty. 16 */ 17 function verifyDatatypes(report) { 18 TestUtils.DATATYPES.forEach(function(datatype) { 19 assert_false( 20 report[datatype.name], 21 datatype.name + " should NOT have been cleared."); 22 }); 23 } 24 25 TestUtils.COMBINATIONS.forEach(function(combination) { 26 var test_name = 27 "Do not clear datatypes on insecure navigation (header: " + 28 combination.map(function(e) { return e.name; }).join(", ") + 29 ")"; 30 31 promise_test(function(test) { 32 return new Promise(function(resolve_test, reject_test) { 33 TestUtils.populateDatatypes() 34 .then(function() { 35 // Navigate to a resource with a Clear-Site-Data header in 36 // an iframe, then verify that no data have been deleted. 37 return new Promise(function(resolve, reject) { 38 window.addEventListener("message", resolve); 39 var iframe = document.createElement("iframe"); 40 iframe.src = TestUtils.getClearSiteDataUrl(combination); 41 document.body.appendChild(iframe); 42 }).then(function(messageEvent) { 43 verifyDatatypes(messageEvent.data); 44 resolve_test(); 45 }); 46 }); 47 }); 48 }, test_name); 49 }); 50 </script> 51 </body> 52 </html>