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

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

Issue 1311103002: ServiceWorker: Make APIs that return ServiceWorkerRegistration coin a new JS object (3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/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..38d4a00ae34c707ec76f7cd07dd960880ececc16 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);
falken 2015/08/25 03:28:29 double quotes should be single quotes (and in seve
nhiroki 2015/08/25 06:28:07 Done.
+ ["scope", "installing", "waiting", "active"].forEach(function(attribute) {
+ assert_equals(actual[attribute], expected[attribute],
+ description + " Attributes differ: " + attribute + ".");
+ });
falken 2015/08/25 03:28:29 indent additional two spaces
nhiroki 2015/08/25 06:28:07 Done.
+}
+
+// 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 + "]");
+ });
falken 2015/08/25 03:28:29 indent additional two spaces
nhiroki 2015/08/25 06:28:07 Done.
+}

Powered by Google App Engine
This is Rietveld 408576698