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

Side by Side Diff: LayoutTests/http/tests/serviceworker/chromium/memory-cache.html

Issue 632213002: Fetcher: Disable memory caching when Service Worker handles a request (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix test crash Created 6 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 <!DOCTYPE html>
2 <html>
3 <title>Service Worker: Memory Cache</title>
4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <script src="../resources/test-helpers.js"></script>
7 <script>
8 var callback;
horo 2014/10/10 02:25:12 Please write comments about |callback|. "This call
nhiroki 2014/10/10 06:20:37 Done.
9
10 function getJSON(url) {
11 var sc = document.createElement('script');
12 sc.src = url;
13 document.body.appendChild(sc);
14 return new Promise(function(resolve) {
15 callback = function(data) { resolve(data); }
16 });
17 }
18
19 async_test(function(t) {
20 var scope = 'resources/memory-cache-controlled.html';
21 var worker = 'resources/memory-cache-worker.js';
22 var json_url = '/serviceworker/chromium/resources/memory-cache.json';
23 var registration;
24 var frame;
25 var promises = [];
26
27 service_worker_unregister_and_register(t, worker, scope)
28 .then(function(r) {
29 registration = r;
30 return wait_for_activated(t, registration);
31 })
32 .then(function() { return with_iframe(scope); })
33 .then(function(f) {
34 frame = f;
35 var messageChannel = new MessageChannel();
jsbell 2014/10/09 16:47:51 Is this "ack" step actually necessary for the test
nhiroki 2014/10/10 06:20:37 This messaging mechanism seems no longer necessary
36 var promise = new Promise(function (resolve) {
37 messageChannel.port1.onmessage = function(e) {
38 resolve(e);
39 }
40 });
41 registration.active.postMessage(
42 {port: messageChannel.port2}, [messageChannel.port2]);
43 // Request a json file from controlled page.
44 promises.push(frame.contentWindow.getJSON(json_url));
45 return promise;
46 })
47 .then(function(e) {
48 assert_equals(e.data, 'ack');
49 // Request a json file from non-controlled page.
50 promises.push(getJSON(json_url));
51 registration.active.postMessage({ ping: true });
52 return Promise.all(promises);
53 })
54 .then(function(results) {
55 assert_equals(
56 results[0].src,
57 'service worker',
58 'Response for controlled page should be served by Service Worker');
59 assert_equals(
60 results[1].src,
61 'network',
62 'Response for non-controlled page should be served by network');
63 unload_iframe(frame);
64 return registration.unregister();
65 })
66 .then(function() {
67 t.done();
68 })
69 .catch(unreached_rejection(t));
70 }, 'Non-controlled page should not use a cache filled by Service Worker');
71 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698