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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/resources/override_assert_object_equals.js

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // .body attribute of Request and Response object are experimental feture. It is
2 // enabled when --enable-experimental-web-platform-features flag is set.
3 // Touching this attribute can change the behavior of the objects. To avoid
4 // touching it while comparing the objects in LayoutTest, we overwrite
5 // assert_object_equals method.
6
7 (function() {
8 var original_assert_object_equals = self.assert_object_equals;
9 function _brand(object) {
10 return Object.prototype.toString.call(object).match(/^\[object (.*)\]$/)[1];
11 }
12 var assert_request_equals = function(actual, expected, prefix) {
13 if (typeof actual !== 'object') {
14 assert_equals(actual, expected, prefix);
15 return;
16 }
17 assert_true(actual instanceof Request, prefix);
18 assert_true(expected instanceof Request, prefix);
19 assert_equals(actual.bodyUsed, expected.bodyUsed, prefix + '.bodyUsed');
20 assert_equals(actual.method, expected.method, prefix + '.method');
21 assert_equals(actual.url, expected.url, prefix + '.url');
22 original_assert_object_equals(actual.headers, expected.headers,
23 prefix + '.headers');
24 assert_equals(actual.context, expected.context, prefix + '.context');
25 assert_equals(actual.referrer, expected.referrer, prefix + '.referrer');
26 assert_equals(actual.mode, expected.mode, prefix + '.mode');
27 assert_equals(actual.credentials, expected.credentials,
28 prefix + '.credentials');
29 assert_equals(actual.cache, expected.cache, prefix + '.cache');
30 };
31 var assert_response_equals = function(actual, expected, prefix) {
32 if (typeof actual !== 'object') {
33 assert_equals(actual, expected, prefix);
34 return;
35 }
36 assert_true(actual instanceof Response, prefix);
37 assert_true(expected instanceof Response, prefix);
38 assert_equals(actual.bodyUsed, expected.bodyUsed, prefix + '.bodyUsed');
39 assert_equals(actual.type, expected.type, prefix + '.type');
40 assert_equals(actual.url, expected.url, prefix + '.url');
41 assert_equals(actual.status, expected.status, prefix + '.status');
42 assert_equals(actual.statusText, expected.statusText,
43 prefix + '.statusText');
44 original_assert_object_equals(actual.headers, expected.headers,
45 prefix + '.headers');
46 };
47 var assert_object_equals = function(actual, expected, description) {
48 var prefix = (description ? description + ': ' : '') + _brand(expected);
49 if (expected instanceof Request) {
50 assert_request_equals(actual, expected, prefix);
51 } else if (expected instanceof Response) {
52 assert_response_equals(actual, expected, prefix);
53 } else {
54 original_assert_object_equals(actual, expected, description);
55 }
56 };
57 self.assert_object_equals = assert_object_equals;
58 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698