Commit 7b0fcfc2 authored by jsbell@chromium.org's avatar jsbell@chromium.org

Service Workers: Improve object equality assertion errors

Use Object.prototype.toString.call() to get a name for the object
being tested, rather than '[object]', to make the error more readable.

BUG=374802
R=asanka@chromium.org

Review URL: https://codereview.chromium.org/667423005

git-svn-id: svn://svn.chromium.org/blink/trunk@184381 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 6008870a
...@@ -103,8 +103,12 @@ self.assert_object_equals = function(actual, expected, description) { ...@@ -103,8 +103,12 @@ self.assert_object_equals = function(actual, expected, description) {
object_stack.pop(); object_stack.pop();
} }
function _brand(object) {
return Object.prototype.toString.call(object).match(/^\[object (.*)\]$/)[1];
}
_is_equal(actual, expected, _is_equal(actual, expected,
(description ? description + ' :' : '') + '[object]'); (description ? description + ': ' : '') + _brand(actual));
}; };
// Equivalent to assert_in_array, but uses a weaker equivalence relation // Equivalent to assert_in_array, but uses a weaker equivalence relation
......
...@@ -16,7 +16,7 @@ FAIL Cache.matchAll with prefixMatch option Entry was not found. ...@@ -16,7 +16,7 @@ FAIL Cache.matchAll with prefixMatch option Entry was not found.
FAIL Cache.matchAll with responses containing "Vary" header Entry already exists. FAIL Cache.matchAll with responses containing "Vary" header Entry already exists.
FAIL Cache.match with responses containing "Vary" header Entry was not found. FAIL Cache.match with responses containing "Vary" header Entry was not found.
FAIL Cache.matchAll with "ignoreVary" parameter Entry was not found. FAIL Cache.matchAll with "ignoreVary" parameter Entry was not found.
FAIL Cache.match with Request and Response objects with different URLs assert_equals: Cache.match should reutrn a Response object that has the same properties as the stored response. :[object].url expected "http://127.0.0.1:8000/serviceworker/resources/simple.txt" but got "http://example.com/" FAIL Cache.match with Request and Response objects with different URLs assert_equals: Cache.match should reutrn a Response object that has the same properties as the stored response.: Response.url expected "http://127.0.0.1:8000/serviceworker/resources/simple.txt" but got "http://example.com/"
PASS Cache.match invoked multiple times for the same Request/Response PASS Cache.match invoked multiple times for the same Request/Response
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -3,14 +3,14 @@ PASS Service Worker: Cache.put ...@@ -3,14 +3,14 @@ PASS Service Worker: Cache.put
PASS Cache.put called with simple Request and Response PASS Cache.put called with simple Request and Response
PASS Cache.put called with Request and Response from fetch() PASS Cache.put called with Request and Response from fetch()
FAIL Cache.put with Request containing a body assert_false: Cache.put should not consume Request body. expected false got true FAIL Cache.put with Request containing a body assert_false: Cache.put should not consume Request body. expected false got true
FAIL Cache.put with a Response containing an empty URL assert_equals: Cache.put should update the cache with new Request and Response. :[object].url expected "" but got "https://example.com/foo" FAIL Cache.put with a Response containing an empty URL assert_equals: Cache.put should update the cache with new Request and Response.: Response.url expected "" but got "https://example.com/foo"
PASS Cache.put with an empty response body PASS Cache.put with an empty response body
PASS Cache.put with HTTP 500 response PASS Cache.put with HTTP 500 response
FAIL Cache.put called twice with same Request and different Responses Entry already exists. FAIL Cache.put called twice with same Request and different Responses Entry already exists.
PASS Cache.put with an string request PASS Cache.put with an string request
PASS Cache.put with an invalid response PASS Cache.put with an invalid response
PASS Cache.put with a non-HTTP/HTTPS request PASS Cache.put with a non-HTTP/HTTPS request
FAIL Cache.put with a relative URL assert_equals: Cache.put should accept a relative URL as the request. :[object].url expected "" but got "http://127.0.0.1:8000/serviceworker/resources/relative-url" FAIL Cache.put with a relative URL assert_equals: Cache.put should accept a relative URL as the request.: Response.url expected "" but got "http://127.0.0.1:8000/serviceworker/resources/relative-url"
PASS Cache.put with a non-GET request PASS Cache.put with a non-GET request
PASS Cache.put with an empty response PASS Cache.put with an empty response
Harness: the test ran to completion. Harness: the test ran to completion.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment