| OLD | NEW |
| (Empty) |
| 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.js"></script> | |
| 7 </head> | |
| 8 | |
| 9 <body> | |
| 10 <script> | |
| 11 /** Ensures that all datatypes are nonempty. */ | |
| 12 function populateDatatypes() { | |
| 13 return Promise.all(TestUtils.DATATYPES.map(function(datatype) { | |
| 14 return datatype.add().then(datatype.isEmpty().then(function(isEmpty) { | |
| 15 assert_false( | |
| 16 isEmpty, | |
| 17 datatype.name + " has to be nonempty before the test starts."); | |
| 18 })); | |
| 19 })); | |
| 20 } | |
| 21 | |
| 22 /** | |
| 23 * @param Array.<Array.<Datatype>> combination A combination of datatypes. | |
| 24 * @param Dict.<string, boolean> report A map between a datatype name and | |
| 25 * whether it is empty. | |
| 26 * @return boolean Whether all datatypes are empty if and only if they are | |
| 27 * included in the |combination|. | |
| 28 */ | |
| 29 function verifyDatatypes(combination, report) { | |
| 30 TestUtils.DATATYPES.forEach(function(datatype) { | |
| 31 if (combination.indexOf(datatype) != -1) { | |
| 32 assert_true( | |
| 33 report[datatype.name], | |
| 34 datatype.name + " should have been cleared."); | |
| 35 } else { | |
| 36 assert_false( | |
| 37 report[datatype.name], | |
| 38 datatype.name + " should NOT have been cleared."); | |
| 39 } | |
| 40 }) | |
| 41 } | |
| 42 | |
| 43 TestUtils.COMBINATIONS.forEach(function(combination) { | |
| 44 var test_name = | |
| 45 "Clear datatypes on navigation: " + | |
| 46 combination.map(function(e) { return e.name; }).join(", "); | |
| 47 | |
| 48 promise_test(function(test) { | |
| 49 return populateDatatypes() | |
| 50 .then(function() { | |
| 51 // Navigate to a resource with a Clear-Site-Data header in an | |
| 52 // iframe, then verify that the correct types have been deleted. | |
| 53 return new Promise(function(resolve, reject) { | |
| 54 window.addEventListener("message", resolve); | |
| 55 var iframe = document.createElement("iframe"); | |
| 56 iframe.src = TestUtils.getClearSiteDataUrl(combination); | |
| 57 document.body.appendChild(iframe); | |
| 58 }).then(function(messageEvent) { | |
| 59 verifyDatatypes(combination, messageEvent.data); | |
| 60 }); | |
| 61 }); | |
| 62 }, test_name); | |
| 63 }); | |
| 64 </script> | |
| 65 </body> | |
| 66 </html> | |
| OLD | NEW |