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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/clear-site-data/support/test_utils.js

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 | « third_party/WebKit/LayoutTests/external/wpt/clear-site-data/navigation.https.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var TestUtils = (function() { 1 var TestUtils = (function() {
2 function randomString() { 2 function randomString() {
3 var result = ""; 3 var result = "";
4 for (var i = 0; i < 5; i++) 4 for (var i = 0; i < 5; i++)
5 result += String.fromCharCode(97 + Math.floor(Math.random() * 26)); 5 result += String.fromCharCode(97 + Math.floor(Math.random() * 26));
6 return result; 6 return result;
7 }; 7 };
8 8
9 /** 9 /**
10 * Representation of one datatype. 10 * Representation of one datatype.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (mask & (1 << datatype)) 68 if (mask & (1 << datatype))
69 combination.push(TestUtils.DATATYPES[datatype]); 69 combination.push(TestUtils.DATATYPES[datatype]);
70 } 70 }
71 71
72 combinations.push(combination); 72 combinations.push(combination);
73 } 73 }
74 return combinations; 74 return combinations;
75 })(); 75 })();
76 76
77 /** 77 /**
78 * Ensures that all datatypes are nonempty. Should be called in the test
79 * setup phase.
80 */
81 TestUtils.populateDatatypes = function() {
82 return Promise.all(TestUtils.DATATYPES.map(function(datatype) {
83 return new Promise(function(resolve, reject) {
84 datatype.add().then(function() {
85 datatype.isEmpty().then(function(isEmpty) {
86 assert_false(
87 isEmpty,
88 datatype.name +
89 " has to be nonempty before the test starts.");
90 resolve();
91 });
92 });
93 });
94 }));
95 };
96
97 /**
78 * Get the support server URL that returns a Clear-Site-Data header 98 * Get the support server URL that returns a Clear-Site-Data header
79 * to clear |datatypes|. 99 * to clear |datatypes|.
80 * @param{Array.<Datatype>} datatypes The list of datatypes to be deleted. 100 * @param{Array.<Datatype>} datatypes The list of datatypes to be deleted.
81 * @return string The URL to be queried. 101 * @return string The URL to be queried.
82 */ 102 */
83 TestUtils.getClearSiteDataUrl = function(datatypes) { 103 TestUtils.getClearSiteDataUrl = function(datatypes) {
84 names = datatypes.map(function(e) { return e.name }); 104 names = datatypes.map(function(e) { return e.name });
85 return "support/echo-clear-site-data.py?" + names.join("&"); 105 return "support/echo-clear-site-data.py?" + names.join("&");
86 } 106 }
87 107
88 return TestUtils; 108 return TestUtils;
89 })(); 109 })();
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/external/wpt/clear-site-data/navigation.https.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698