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

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

Issue 2975463002: Enable Clear-Site-Data web platform tests. (Closed)
Patch Set: 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 return new Promise(function(resolve_test, reject_test) {
50 .then(function() { 56 populateDatatypes()
51 // Navigate to a resource with a Clear-Site-Data header in an 57 .then(function() {
52 // iframe, then verify that the correct types have been deleted. 58 // Navigate to a resource with a Clear-Site-Data header in
53 return new Promise(function(resolve, reject) { 59 // an iframe, then verify that the correct types have been
54 window.addEventListener("message", resolve); 60 // deleted.
55 var iframe = document.createElement("iframe"); 61 return new Promise(function(resolve, reject) {
56 iframe.src = TestUtils.getClearSiteDataUrl(combination); 62 window.addEventListener("message", resolve);
57 document.body.appendChild(iframe); 63 var iframe = document.createElement("iframe");
58 }).then(function(messageEvent) { 64 iframe.src = TestUtils.getClearSiteDataUrl(combination);
59 verifyDatatypes(combination, messageEvent.data); 65 document.body.appendChild(iframe);
66 }).then(function(messageEvent) {
67 verifyDatatypes(combination, messageEvent.data);
68 resolve_test();
69 });
60 }); 70 });
61 }); 71 });
62 }, test_name); 72 }, test_name);
63 }); 73 });
64 </script> 74 </script>
65 </body> 75 </body>
66 </html> 76 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698