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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/clear-site-data/navigation-insecure.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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/clear-site-data/navigation.https.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 still nonempty.
33 * included in the |combination|.
34 */ 16 */
35 function verifyDatatypes(combination, report) { 17 function verifyDatatypes(report) {
36 TestUtils.DATATYPES.forEach(function(datatype) { 18 TestUtils.DATATYPES.forEach(function(datatype) {
37 if (combination.indexOf(datatype) != -1) { 19 assert_false(
38 assert_true( 20 report[datatype.name],
39 report[datatype.name], 21 datatype.name + " should NOT have been cleared.");
40 datatype.name + " should have been cleared.");
41 } else {
42 assert_false(
43 report[datatype.name],
44 datatype.name + " should NOT have been cleared.");
45 }
46 }); 22 });
47 } 23 }
48 24
49 TestUtils.COMBINATIONS.forEach(function(combination) { 25 TestUtils.COMBINATIONS.forEach(function(combination) {
50 var test_name = 26 var test_name =
51 "Clear datatypes on navigation: " + 27 "Do not clear datatypes on insecure navigation (header: " +
52 combination.map(function(e) { return e.name; }).join(", "); 28 combination.map(function(e) { return e.name; }).join(", ") +
29 ")";
53 30
54 promise_test(function(test) { 31 promise_test(function(test) {
55 return new Promise(function(resolve_test, reject_test) { 32 return new Promise(function(resolve_test, reject_test) {
56 populateDatatypes() 33 TestUtils.populateDatatypes()
57 .then(function() { 34 .then(function() {
58 // Navigate to a resource with a Clear-Site-Data header in 35 // Navigate to a resource with a Clear-Site-Data header in
59 // an iframe, then verify that the correct types have been 36 // an iframe, then verify that no data have been deleted.
60 // deleted.
61 return new Promise(function(resolve, reject) { 37 return new Promise(function(resolve, reject) {
62 window.addEventListener("message", resolve); 38 window.addEventListener("message", resolve);
63 var iframe = document.createElement("iframe"); 39 var iframe = document.createElement("iframe");
64 iframe.src = TestUtils.getClearSiteDataUrl(combination); 40 iframe.src = TestUtils.getClearSiteDataUrl(combination);
65 document.body.appendChild(iframe); 41 document.body.appendChild(iframe);
66 }).then(function(messageEvent) { 42 }).then(function(messageEvent) {
67 verifyDatatypes(combination, messageEvent.data); 43 verifyDatatypes(messageEvent.data);
68 resolve_test(); 44 resolve_test();
69 }); 45 });
70 }); 46 });
71 }); 47 });
72 }, test_name); 48 }, test_name);
73 }); 49 });
74 </script> 50 </script>
75 </body> 51 </body>
76 </html> 52 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/clear-site-data/navigation.https.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698