| OLD | NEW |
| 1 importScripts('worker-testharness.js'); | 1 if (self.importScripts) { |
| 2 importScripts('/resources/testharness-helpers.js'); | 2 importScripts('/resources/testharness.js'); |
| 3 importScripts('override_assert_object_equals.js'); | 3 importScripts('/resources/testharness-helpers.js'); |
| 4 importScripts('../resources/test-helpers.js'); |
| 5 } |
| 4 | 6 |
| 5 // A set of Request/Response pairs to be used with prepopulated_cache_test(). | 7 // A set of Request/Response pairs to be used with prepopulated_cache_test(). |
| 6 var simple_entries = [ | 8 var simple_entries = [ |
| 7 { | 9 { |
| 8 name: 'a', | 10 name: 'a', |
| 9 request: new Request('http://example.com/a'), | 11 request: new Request('http://example.com/a'), |
| 10 response: new Response('') | 12 response: new Response('') |
| 11 }, | 13 }, |
| 12 | 14 |
| 13 { | 15 { |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 entries.vary_cookie_absent.response, | 400 entries.vary_cookie_absent.response, |
| 399 entries.vary_wildcard.response | 401 entries.vary_wildcard.response |
| 400 ], | 402 ], |
| 401 'Cache.matchAll should honor "ignoreVary" parameter.'); | 403 'Cache.matchAll should honor "ignoreVary" parameter.'); |
| 402 }); | 404 }); |
| 403 }, 'Cache.matchAll with "ignoreVary" parameter'); | 405 }, 'Cache.matchAll with "ignoreVary" parameter'); |
| 404 | 406 |
| 405 cache_test(function(cache) { | 407 cache_test(function(cache) { |
| 406 var request = new Request('http://example.com'); | 408 var request = new Request('http://example.com'); |
| 407 var response; | 409 var response; |
| 408 var request_url = new URL('simple.txt', location.href).href; | 410 var request_url = new URL('../resources/simple.txt', location.href).href; |
| 409 return fetch(request_url) | 411 return fetch(request_url) |
| 410 .then(function(fetch_result) { | 412 .then(function(fetch_result) { |
| 411 response = fetch_result; | 413 response = fetch_result; |
| 412 assert_equals( | 414 assert_equals( |
| 413 response.url, request_url, | 415 response.url, request_url, |
| 414 '[https://fetch.spec.whatwg.org/#dom-response-url] ' + | 416 '[https://fetch.spec.whatwg.org/#dom-response-url] ' + |
| 415 'Reponse.url should return the URL of the response.'); | 417 'Reponse.url should return the URL of the response.'); |
| 416 return cache.put(request, response.clone()); | 418 return cache.put(request, response.clone()); |
| 417 }) | 419 }) |
| 418 .then(function() { | 420 .then(function() { |
| 419 return cache.match(request.url); | 421 return cache.match(request.url); |
| 420 }) | 422 }) |
| 421 .then(function(result) { | 423 .then(function(result) { |
| 422 assert_object_equals( | 424 assert_object_equals( |
| 423 result, response, | 425 result, response, |
| 424 'Cache.match should return a Response object that has the same ' + | 426 'Cache.match should return a Response object that has the same ' + |
| 425 'properties as the stored response.'); | 427 'properties as the stored response.'); |
| 426 return cache.match(response.url); | 428 return cache.match(response.url); |
| 427 }) | 429 }) |
| 428 .then(function(result) { | 430 .then(function(result) { |
| 429 assert_equals( | 431 assert_equals( |
| 430 result, undefined, | 432 result, undefined, |
| 431 'Cache.match should not match cache entry based on response URL.'); | 433 'Cache.match should not match cache entry based on response URL.'); |
| 432 }); | 434 }); |
| 433 }, 'Cache.match with Request and Response objects with different URLs'); | 435 }, 'Cache.match with Request and Response objects with different URLs'); |
| 434 | 436 |
| 435 cache_test(function(cache) { | 437 cache_test(function(cache) { |
| 436 var request_url = new URL('simple.txt', location.href).href; | 438 var request_url = new URL('../resources/simple.txt', location.href).href; |
| 437 return fetch(request_url) | 439 return fetch(request_url) |
| 438 .then(function(fetch_result) { | 440 .then(function(fetch_result) { |
| 439 return cache.put(new Request(request_url), fetch_result); | 441 return cache.put(new Request(request_url), fetch_result); |
| 440 }) | 442 }) |
| 441 .then(function() { | 443 .then(function() { |
| 442 return cache.match(request_url); | 444 return cache.match(request_url); |
| 443 }) | 445 }) |
| 444 .then(function(result) { | 446 .then(function(result) { |
| 445 return result.text(); | 447 return result.text(); |
| 446 }) | 448 }) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 }); | 490 }); |
| 489 p = p.then(function() { | 491 p = p.then(function() { |
| 490 assert_equals(Object.keys(hash).length, entries.length); | 492 assert_equals(Object.keys(hash).length, entries.length); |
| 491 }); | 493 }); |
| 492 | 494 |
| 493 return p.then(function() { | 495 return p.then(function() { |
| 494 return test_function(cache, hash); | 496 return test_function(cache, hash); |
| 495 }); | 497 }); |
| 496 }, description); | 498 }, description); |
| 497 } | 499 } |
| 500 |
| 501 done(); |
| OLD | NEW |