Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/clear-site-data/navigation.https.html

Issue 2913553004: Add the 'cache' datatype to the clear-site-data WPT (Closed)
Patch Set: Rebase, syntax, cache busting. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script> 5 <script src="/resources/testharnessreport.js"></script>
6 <script src="support/test_utils.js"></script> 6 <script src="support/test_utils.js"></script>
7 </head> 7 </head>
8 8
9 <body> 9 <body>
10 <script> 10 <script>
11 /** Ensures that all datatypes are nonempty. */ 11 /** Ensures that all datatypes are nonempty. */
12 function populateDatatypes() { 12 function populateDatatypes() {
13 return Promise.all(TestUtils.DATATYPES.map(function(datatype) { 13 return Promise.all(TestUtils.DATATYPES.map(function(datatype) {
14 return datatype.add().then(datatype.isEmpty().then(function(isEmpty) { 14 return new Promise(function(resolve, reject) {
15 assert_false( 15 datatype.add().then(function() {
16 isEmpty, 16 datatype.isEmpty().then(function(isEmpty) {
17 datatype.name + " has to be nonempty before the test starts."); 17 assert_false(
18 })); 18 isEmpty,
19 datatype.name +
20 " has to be nonempty before the test starts.");
21 resolve();
22 });
23 });
24 });
19 })); 25 }));
20 } 26 }
21 27
22 /** 28 /**
23 * @param Array.<Array.<Datatype>> combination A combination of datatypes. 29 * @param Array.<Array.<Datatype>> combination A combination of datatypes.
24 * @param Dict.<string, boolean> report A map between a datatype name and 30 * @param Dict.<string, boolean> report A map between a datatype name and
25 * whether it is empty. 31 * whether it is empty.
26 * @return boolean Whether all datatypes are empty if and only if they are 32 * @return boolean Whether all datatypes are empty if and only if they are
27 * included in the |combination|. 33 * included in the |combination|.
28 */ 34 */
29 function verifyDatatypes(combination, report) { 35 function verifyDatatypes(combination, report) {
30 TestUtils.DATATYPES.forEach(function(datatype) { 36 TestUtils.DATATYPES.forEach(function(datatype) {
31 if (combination.indexOf(datatype) != -1) { 37 if (combination.indexOf(datatype) != -1) {
32 assert_true( 38 assert_true(
33 report[datatype.name], 39 report[datatype.name],
34 datatype.name + " should have been cleared."); 40 datatype.name + " should have been cleared.");
35 } else { 41 } else {
36 assert_false( 42 assert_false(
37 report[datatype.name], 43 report[datatype.name],
38 datatype.name + " should NOT have been cleared."); 44 datatype.name + " should NOT have been cleared.");
39 } 45 }
40 }) 46 });
41 } 47 }
42 48
43 TestUtils.COMBINATIONS.forEach(function(combination) { 49 TestUtils.COMBINATIONS.forEach(function(combination) {
44 var test_name = 50 var test_name =
45 "Clear datatypes on navigation: " + 51 "Clear datatypes on navigation: " +
46 combination.map(function(e) { return e.name; }).join(", "); 52 combination.map(function(e) { return e.name; }).join(", ");
47 53
48 promise_test(function(test) { 54 promise_test(function(test) {
49 return populateDatatypes() 55 TestUtils.bustCache();
50 .then(function() { 56 return new Promise(function(resolve_test, reject_test) {
51 // Navigate to a resource with a Clear-Site-Data header in an 57 populateDatatypes()
52 // iframe, then verify that the correct types have been deleted. 58 .then(function() {
53 return new Promise(function(resolve, reject) { 59 // Navigate to a resource with a Clear-Site-Data header in
54 window.addEventListener("message", resolve); 60 // an iframe, then verify that the correct types have been
55 var iframe = document.createElement("iframe"); 61 // deleted.
56 iframe.src = TestUtils.getClearSiteDataUrl(combination); 62 return new Promise(function(resolve, reject) {
57 document.body.appendChild(iframe); 63 window.addEventListener("message", resolve);
58 }).then(function(messageEvent) { 64 var iframe = document.createElement("iframe");
59 verifyDatatypes(combination, messageEvent.data); 65 iframe.src = TestUtils.getClearSiteDataUrl(combination);
66 document.body.appendChild(iframe);
67 }).then(function(messageEvent) {
68 verifyDatatypes(combination, messageEvent.data);
69 resolve_test();
70 });
60 }); 71 });
61 }); 72 });
62 }, test_name); 73 }, test_name);
63 }); 74 });
64 </script> 75 </script>
65 </body> 76 </body>
66 </html> 77 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698