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

Side by Side Diff: LayoutTests/http/tests/resources/testharness-helpers.js

Issue 704043002: [ServiceWorker] Update cache.match/matchAll tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cleanup-formatting
Patch Set: Created 6 years, 1 month 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 /* 1 /*
2 * testharness-helpers contains various useful extensions to testharness.js to 2 * testharness-helpers contains various useful extensions to testharness.js to
3 * allow them to be used across multiple tests before they have been 3 * allow them to be used across multiple tests before they have been
4 * upstreamed. This file is intended to be usable from both document and worker 4 * upstreamed. This file is intended to be usable from both document and worker
5 * environments, so code should for example not rely on the DOM. 5 * environments, so code should for example not rely on the DOM.
6 */ 6 */
7 7
8 // A testharness test that simplifies testing with promises. 8 // A testharness test that simplifies testing with promises.
9 // 9 //
10 // * The |func| argument should be a reference to a function that optionally 10 // * The |func| argument should be a reference to a function that optionally
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 }); 101 });
102 102
103 object_stack.pop(); 103 object_stack.pop();
104 } 104 }
105 105
106 function _brand(object) { 106 function _brand(object) {
107 return Object.prototype.toString.call(object).match(/^\[object (.*)\]$/)[1]; 107 return Object.prototype.toString.call(object).match(/^\[object (.*)\]$/)[1];
108 } 108 }
109 109
110 _is_equal(actual, expected, 110 _is_equal(actual, expected,
111 (description ? description + ': ' : '') + _brand(actual)); 111 (description ? description + ': ' : '') + _brand(expected));
112 }; 112 };
113 113
114 // Equivalent to assert_in_array, but uses a weaker equivalence relation 114 // Equivalent to assert_in_array, but uses a weaker equivalence relation
115 // (assert_object_equals) than '==='. 115 // (assert_object_equals) than '==='.
116 function assert_object_in_array(actual, expected_array, description) { 116 function assert_object_in_array(actual, expected_array, description) {
117 assert_true(expected_array.some(function(element) { 117 assert_true(expected_array.some(function(element) {
118 try { 118 try {
119 assert_object_equals(actual, element); 119 assert_object_equals(actual, element);
120 return true; 120 return true;
121 } catch (e) { 121 } catch (e) {
(...skipping 23 matching lines...) Expand all
145 // elements as determined by assert_object_equals(). The corresponding elements 145 // elements as determined by assert_object_equals(). The corresponding elements
146 // must occupy corresponding indices in their respective arrays. 146 // must occupy corresponding indices in their respective arrays.
147 function assert_array_objects_equals(actual, expected, description) { 147 function assert_array_objects_equals(actual, expected, description) {
148 assert_true(Array.isArray(actual), description); 148 assert_true(Array.isArray(actual), description);
149 assert_equals(actual.length, expected.length, description); 149 assert_equals(actual.length, expected.length, description);
150 actual.forEach(function(value, index) { 150 actual.forEach(function(value, index) {
151 assert_object_equals(value, expected[index], 151 assert_object_equals(value, expected[index],
152 description + ' : object[' + index + ']'); 152 description + ' : object[' + index + ']');
153 }); 153 });
154 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698