Chromium Code Reviews| 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.
|
| +} |