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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/cachestorage/serviceworker/ignore-search-with-credentials.html

Issue 1578363009: CacheStorage: Add ignoreSearch option to cache.matchAll(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 <!DOCTYPE html>
2 <title>Cache Storage: ignore search with credentials</title>
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script src="../resources/test-helpers.js"></script>
6 <script src="../../serviceworker/resources/test-helpers.js"></script>
7 <script>
8
9 var request;
nhiroki 2016/02/10 07:35:33 Probably you can move this global variable to pro
zino 2016/02/11 03:35:05 Done.
10
11 function remove_query(url_string) {
12 return url_string.split('?')[0];
13 }
14
15 function find_request_object(str) {
16 return caches.open('ignore-search')
17 .then(function(cache) {
18 return cache.keys();
19 })
20 .then(function(requests) {
21 for (var i = 0; i < requests.length; i++)
nhiroki 2016/02/10 07:35:33 "Array.prototype.find()" may work?
zino 2016/02/11 03:35:05 Done.
22 if (requests[i].url.indexOf(str) > 0)
23 return requests[i];
24 return undefined;
25 })
26 }
27
28 promise_test(function(test) {
29 var service_worker;
30 var script_url = '../resources/ignore-search-with-credentials-worker.js';
31 var scope = '../resources/ignore-search-with-credentials-iframe.html';
32 return caches.delete('ignore-search')
33 .then(function() {
34 return service_worker_unregister_and_register(
35 test, script_url, scope)
36 })
37 .then(function(registration) {
38 service_worker = registration.installing;
39 return wait_for_state(test, service_worker, 'activated');
40 })
41 .then(function(state) {
42 return with_iframe(scope);
43 })
44 .then(function(frame) {
45 // The following xhr requests will be cached in service worker.
46 return Promise.all([
47 frame.contentWindow.xhr('simple.txt?query=test', 'abc', 'def'),
48 frame.contentWindow.xhr('simple.txt', 'abc', 'def'),
49 frame.contentWindow.xhr('simple.txt?query_without_credential=test' )
nhiroki 2016/02/10 07:35:32 nit: can you wrap this line at the 80 column?
zino 2016/02/11 03:35:05 Done.
50 ]);
51 })
52 .then(function() {
nhiroki 2016/02/10 07:35:33 Can you add a comment about the reason why we need
zino 2016/02/11 03:35:05 Done.
53 return find_request_object('abc:def');
54 })
55 .then(function(r) {
56 request = r;
57 return caches.open('ignore-search')
nhiroki 2016/02/10 07:35:32 The cache is already opened in find_request_object
zino 2016/02/11 03:35:05 Done.
58 .then(function(cache) {
59 return cache.matchAll(request, { ignoreSearch : true });
60 });
61 })
62 .then(function(result) {
nhiroki 2016/02/10 07:35:33 s/result/results/
zino 2016/02/11 03:35:05 Done.
63 assert_equals(result.length, 2);
64 assert_equals(remove_query(request.url), remove_query(result[0].url));
65 assert_equals(remove_query(request.url), remove_query(result[1].url));
nhiroki 2016/02/10 07:35:32 assert_equals() receives 'actual' and 'expected' a
zino 2016/02/11 03:35:05 Done.
66 })
67 });
68
69 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698