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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/cache-match-worker.js

Issue 927723003: Removing prefixMatch attribute of CacheQueryOptions- Blink Side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: After rebase Created 5 years, 9 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
1 importScripts('worker-testharness.js'); 1 importScripts('worker-testharness.js');
2 importScripts('/resources/testharness-helpers.js'); 2 importScripts('/resources/testharness-helpers.js');
3 importScripts('override_assert_object_equals.js'); 3 importScripts('override_assert_object_equals.js');
4 4
5 // A set of Request/Response pairs to be used with prepopulated_cache_test(). 5 // A set of Request/Response pairs to be used with prepopulated_cache_test().
6 var simple_entries = [ 6 var simple_entries = [
7 { 7 {
8 name: 'a', 8 name: 'a',
9 request: new Request('http://example.com/a'), 9 request: new Request('http://example.com/a'),
10 response: new Response('') 10 response: new Response('')
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 return cache.match('http') 305 return cache.match('http')
306 .then(function(result) { 306 .then(function(result) {
307 assert_equals( 307 assert_equals(
308 result, undefined, 308 result, undefined,
309 'Cache.match should treat query as a URL and not ' + 309 'Cache.match should treat query as a URL and not ' +
310 'just a string fragment.'); 310 'just a string fragment.');
311 }); 311 });
312 }, 'Cache.match with string fragment "http" as query'); 312 }, 'Cache.match with string fragment "http" as query');
313 313
314 prepopulated_cache_test(simple_entries, function(cache, entries) { 314 prepopulated_cache_test(simple_entries, function(cache, entries) {
315 return cache.matchAll('http://example.com/cat',
316 {prefixMatch: true})
317 .then(function(result) {
318 assert_array_equivalent(
319 result,
320 [
321 entries.cat.response,
322 entries.catmandu.response,
323 entries.cat_num_lives.response,
324 entries.cat_in_the_hat.response
325 ],
326 'Cache.matchAll should honor prefixMatch.');
327 });
328 }, 'Cache.matchAll with prefixMatch option');
329
330 prepopulated_cache_test(simple_entries, function(cache, entries) {
331 return cache.match('http://example.com/cat',
332 {prefixMatch: true})
333 .then(function(result) {
334 assert_object_in_array(
335 result,
336 [
337 entries.cat.response,
338 entries.catmandu.response,
339 entries.cat_num_lives.response,
340 entries.cat_in_the_hat.response
341 ],
342 'Cache.match should honor prefixMatch.');
343 });
344 }, 'Cache.match with prefixMatch option');
345
346 prepopulated_cache_test(simple_entries, function(cache, entries) {
347 return cache.matchAll('http://example.com/cat/',
348 {prefixMatch: true})
349 .then(function(result) {
350 assert_array_equivalent(
351 result, [entries.cat_in_the_hat.response],
352 'Cache.matchAll should honor prefixMatch.');
353 });
354 }, 'Cache.matchAll with prefixMatch option (URL ending with path delimiter)');
355
356 prepopulated_cache_test(simple_entries, function(cache, entries) {
357 return cache.match('http://example.com/cat/',
358 {prefixMatch: true})
359 .then(function(result) {
360 assert_object_equals(
361 result, entries.cat_in_the_hat.response,
362 'Cache.match should honor prefixMatch.');
363 });
364 }, 'Cache.match with prefixMatch option (URL ending with path delimiter)');
365
366 prepopulated_cache_test(simple_entries, function(cache, entries) {
367 return cache.matchAll('http://tom:jerry@example.com', {prefixMatch: true})
368 .then(function(result) {
369 assert_array_equivalent(
370 result,
371 [
372 entries.secret_cat.response,
373 ],
374 'Cache.matchAll should honor prefixMatch.');
375 });
376 }, 'Cache.matchAll with prefixMatch option (URL with embedded credentials)');
377
378 prepopulated_cache_test(simple_entries, function(cache, entries) {
379 return cache.match('http://tom:jerry@example.com', {prefixMatch: true})
380 .then(function(result) {
381 assert_object_equals(
382 result, entries.secret_cat.response,
383 'Cache.match should honor prefixMatch.');
384 });
385 }, 'Cache.match with prefixMatch option (URL with embedded credentials)');
386
387 prepopulated_cache_test(simple_entries, function(cache, entries) {
388 // The string 'http://tom' should be converted to a URL and then serialized
389 // yielding 'http://tom/'. The trailing slash prevents the URL from matching
390 // the embedded credentials in the entries already in the cache.
391 return cache.matchAll('http://tom', {prefixMatch: true})
392 .then(function(result) {
393 assert_array_equivalent(
394 result, [],
395 'Cache.matchAll should honor prefixMatch.');
396 });
397 },
398 'Cache.matchAll with prefixMatch option (URL matching embedded credentials)');
399
400 prepopulated_cache_test(simple_entries, function(cache, entries) {
401 // The string 'http://tom' should be converted to a URL and then serialized
402 // yielding 'http://tom/'. The trailing slash prevents the URL from matching
403 // the embedded credentials in the entries already in the cache.
404 return cache.match('http://tom', {prefixMatch: true})
405 .then(function(result) {
406 assert_equals(result, undefined,
407 'Cache.match should honor prefixMatch.');
408 });
409 },
410 'Cache.match with prefixMatch option (URL matching embedded credentials)');
411
412 prepopulated_cache_test(simple_entries, function(cache, entries) {
413 return cache.matchAll(entries.secret_cat.request.url) 315 return cache.matchAll(entries.secret_cat.request.url)
414 .then(function(result) { 316 .then(function(result) {
415 assert_array_equivalent( 317 assert_array_equivalent(
416 result, [entries.secret_cat.response], 318 result, [entries.secret_cat.response],
417 'Cache.matchAll should not ignore embedded credentials'); 319 'Cache.matchAll should not ignore embedded credentials');
418 }); 320 });
419 }, 'Cache.matchAll with URL containing credentials'); 321 }, 'Cache.matchAll with URL containing credentials');
420 322
421 prepopulated_cache_test(simple_entries, function(cache, entries) { 323 prepopulated_cache_test(simple_entries, function(cache, entries) {
422 return cache.match(entries.secret_cat.request.url) 324 return cache.match(entries.secret_cat.request.url)
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 }); 488 });
587 p = p.then(function() { 489 p = p.then(function() {
588 assert_equals(Object.keys(hash).length, entries.length); 490 assert_equals(Object.keys(hash).length, entries.length);
589 }); 491 });
590 492
591 return p.then(function() { 493 return p.then(function() {
592 return test_function(cache, hash); 494 return test_function(cache, hash);
593 }); 495 });
594 }, description); 496 }, description);
595 } 497 }
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/cache-delete-worker.js ('k') | Source/modules/serviceworkers/Cache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698