Index: LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
diff --git a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
index 2a8e7122565b9f9b7ed39d424b7d3f284bc56c5f..5f9cc5936e34a697d2a32f8974e43acc12b434dc 100644 |
--- a/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
+++ b/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
@@ -205,3 +205,26 @@ function login_https(test) { |
'username2s', 'password2s', 'cookie2'); |
}); |
} |
+ |
+// Helper for testing with ServiceWorkerRegistration objects. Compares simple |
+// attributes defined on the interfaces. |
+function assert_registration_equals(actual, expected, description) { |
+ assert_class_string(actual, 'ServiceWorkerRegistration', description); |
+ ['scope', 'installing', 'waiting', 'active'].forEach(function(attribute) { |
+ assert_equals(actual[attribute], expected[attribute], |
+ description + ' Attributes differ: ' + attribute + '.'); |
+ }); |
+} |
+ |
+// Asserts that two arrays |actual| and |expected| contain the same set of |
+// ServiceWorkerRegistration as determined by assert_registration_equals(). The |
+// corresponding elements must occupy corresponding indices in their respective |
+// arrays. |
+function assert_registration_array_equals(actual, expected, description) { |
+ assert_true(Array.isArray(actual), description); |
+ assert_equals(actual.length, expected.length, description); |
+ actual.forEach(function(value, index) { |
+ assert_registration_equals(value, expected[index], |
+ description + ' : object[' + index + ']'); |
+ }); |
+} |