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

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

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

Powered by Google App Engine
This is Rietveld 408576698