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

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

Issue 1295633003: Cache Storage: replace assert_object_equals w/ assert_response_equals (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback and rebased Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/resources/testharness-helpers.js
diff --git a/LayoutTests/http/tests/resources/testharness-helpers.js b/LayoutTests/http/tests/resources/testharness-helpers.js
index a8322d0cbfdfa8d2e8cf62de94810523ecb40ad7..12960e30ac8ce9423dc11c7bea9841cec950f012 100644
--- a/LayoutTests/http/tests/resources/testharness-helpers.js
+++ b/LayoutTests/http/tests/resources/testharness-helpers.js
@@ -32,78 +32,6 @@ function assert_promise_rejects(promise, code, description) {
});
}
-// Equivalent to testharness.js's assert_object_equals(), but correctly
-// tests that property ownership is the same.
-// TODO(jsbell): Upstream this to assert_object_equals and remove.
-function assert_object_equals_fixed(actual, expected, description)
-{
- function check_equal(actual, expected, stack)
- {
- stack.push(actual);
- var p;
- for (p in actual) {
- assert_equals(expected.hasOwnProperty(p), actual.hasOwnProperty(p),
- "different property ownership: " + p + " - " + description);
-
- if (typeof actual[p] === "object" && actual[p] !== null) {
- if (stack.indexOf(actual[p]) === -1) {
- check_equal(actual[p], expected[p], stack);
- }
- } else {
- assert_equals(actual[p], expected[p], description);
- }
- }
- for (p in expected) {
- assert_equals(expected.hasOwnProperty(p), actual.hasOwnProperty(p),
- "different property ownership: " + p + " - " + description);
- }
- stack.pop();
- }
- check_equal(actual, expected, []);
-}
-
-// Equivalent to assert_in_array, but uses the object-aware equivalence relation
-// provided by assert_object_equals_fixed().
-function assert_object_in_array(actual, expected_array, description) {
- assert_true(expected_array.some(function(element) {
- try {
- assert_object_equals_fixed(actual, element);
- return true;
- } catch (e) {
- return false;
- }
- }), description);
-}
-
-// Assert that the two arrays |actual| and |expected| contain the same set of
-// elements as determined by assert_object_equals_fixed. The order is not significant.
-//
-// |expected| is assumed to not contain any duplicates as determined by
-// assert_object_equals_fixed().
-function assert_array_equivalent(actual, expected, description) {
- assert_true(Array.isArray(actual), description);
- assert_equals(actual.length, expected.length, description);
- expected.forEach(function(expected_element) {
- // assert_in_array treats the first argument as being 'actual', and the
- // second as being 'expected array'. We are switching them around because
- // we want to be resilient against the |actual| array containing
- // duplicates.
- assert_object_in_array(expected_element, actual, description);
- });
-}
-
-// Asserts that two arrays |actual| and |expected| contain the same set of
-// elements as determined by assert_object_equals(). The corresponding elements
-// must occupy corresponding indices in their respective arrays.
-function assert_array_objects_equals(actual, expected, description) {
- assert_true(Array.isArray(actual), description);
- assert_equals(actual.length, expected.length, description);
- actual.forEach(function(value, index) {
- assert_object_equals(value, expected[index],
- description + ' : object[' + index + ']');
- });
-}
-
// Asserts that |object| that is an instance of some interface has the attribute
// |attribute_name| following the conditions specified by WebIDL, but it's
// acceptable that the attribute |attribute_name| is an own property of the
« no previous file with comments | « LayoutTests/http/tests/cachestorage/script-tests/cache-storage-match.js ('k') | LayoutTests/resources/testharness-helpers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698