OLD | NEW |
1 var TEST_ALLOWED_TIMING_DELTA = 20; | 1 var TEST_ALLOWED_TIMING_DELTA = 20; |
2 | 2 |
3 var waitTimer; | 3 var waitTimer; |
4 var expectedEntries = {}; | 4 var expectedEntries = {}; |
5 | 5 |
6 var initiatorTypes = ["iframe", "img", "link", "script", "xmlhttprequest"]; | 6 var initiatorTypes = ["iframe", "img", "link", "script", "xmlhttprequest"]; |
7 | 7 |
8 var tests = {}; | 8 var tests = {}; |
9 setup(function() { | 9 setup(function() { |
10 for (var i in initiatorTypes) { | 10 for (var i in initiatorTypes) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 { | 155 { |
156 var t = tests[expected.initiatorType]; | 156 var t = tests[expected.initiatorType]; |
157 | 157 |
158 t["entry"].step(function() { | 158 t["entry"].step(function() { |
159 var entries_by_name = window.performance.getEntriesByName(expected.name)
; | 159 var entries_by_name = window.performance.getEntriesByName(expected.name)
; |
160 assert_equals(entries_by_name.length, 1, "should have a single entry for
each resource (without type)"); | 160 assert_equals(entries_by_name.length, 1, "should have a single entry for
each resource (without type)"); |
161 var entries_by_name_type = window.performance.getEntriesByName(expected.
name, "resource"); | 161 var entries_by_name_type = window.performance.getEntriesByName(expected.
name, "resource"); |
162 assert_equals(entries_by_name_type.length, 1, "should have a single entr
y for each resource (with type)"); | 162 assert_equals(entries_by_name_type.length, 1, "should have a single entr
y for each resource (with type)"); |
163 assert_not_equals(entries_by_name, entries_by_name_type, "values should
be copies"); | 163 assert_not_equals(entries_by_name, entries_by_name_type, "values should
be copies"); |
164 for (p in entries_by_name[0]) { | 164 for (p in entries_by_name[0]) { |
165 assert_equals(entries_by_name[0][p], entries_by_name_type[0][p], "Pr
operty " + p + " should match"); | 165 var assertMethod = assert_equals |
| 166 if (Array.isArray(entries_by_name[0][p]) && Array.isArray(entries_by
_name_type[0][p])) { |
| 167 assertMethod = assert_array_equals |
| 168 } |
| 169 assertMethod(entries_by_name[0][p], entries_by_name_type[0][p], "Pro
perty " + p + " should match"); |
166 } | 170 } |
167 this.done(); | 171 this.done(); |
168 }); | 172 }); |
169 | 173 |
170 t["simple_attrs"].step(function() { | 174 t["simple_attrs"].step(function() { |
171 var actual = window.performance.getEntriesByName(expected.name)[0]; | 175 var actual = window.performance.getEntriesByName(expected.name)[0]; |
172 var expected_type = expected.initiatorType; | 176 var expected_type = expected.initiatorType; |
173 assert_equals(actual.name, expected.name); | 177 assert_equals(actual.name, expected.name); |
174 assert_equals(actual.initiatorType, expected_type); | 178 assert_equals(actual.initiatorType, expected_type); |
175 assert_equals(actual.entryType, "resource"); | 179 assert_equals(actual.entryType, "resource"); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 this.done(); | 218 this.done(); |
215 }); | 219 }); |
216 | 220 |
217 t["protocol"].step(function() { | 221 t["protocol"].step(function() { |
218 var actual = window.performance.getEntriesByName(expected.name)[0]; | 222 var actual = window.performance.getEntriesByName(expected.name)[0]; |
219 assert_equals(actual.nextHopProtocol, "http/1.1", "expected protocol"); | 223 assert_equals(actual.nextHopProtocol, "http/1.1", "expected protocol"); |
220 this.done(); | 224 this.done(); |
221 }); | 225 }); |
222 | 226 |
223 } | 227 } |
OLD | NEW |