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

Unified 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: s/getJSON/getJSONP 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/memory-cache.jsonp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/chromium/memory-cache.html
diff --git a/LayoutTests/http/tests/serviceworker/chromium/memory-cache.html b/LayoutTests/http/tests/serviceworker/chromium/memory-cache.html
new file mode 100644
index 0000000000000000000000000000000000000000..5567c2b3b368b9546b65a3de4d013fc0d3c5ece4
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/chromium/memory-cache.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+<title>Service Worker: Memory Cache</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../resources/test-helpers.js"></script>
+<script>
+var callback;
+
+function getJSONP(url) {
+ var sc = document.createElement('script');
+ sc.src = url;
+ document.body.appendChild(sc);
+ return new Promise(function(resolve) {
+ // This callback function is called by appending a script element.
+ callback = function(data) { resolve(data); }
+ });
+}
+
+async_test(function(t) {
+ var scope = 'resources/memory-cache-controlled.html';
+ var worker = 'resources/memory-cache-worker.js';
+ var json_url = '/serviceworker/chromium/resources/memory-cache.jsonp';
+ var registration;
+ var frame;
+ var promises = [];
+
+ service_worker_unregister_and_register(t, worker, scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_activated(t, registration);
+ })
+ .then(function() { return with_iframe(scope); })
+ .then(function(f) {
+ frame = f;
+ // Request a json file from controlled page.
+ promises.push(frame.contentWindow.getJSONP(json_url));
+ // Request a json file from non-controlled page.
+ promises.push(getJSONP(json_url));
+ return Promise.all(promises);
+ })
+ .then(function(results) {
+ assert_equals(
+ results[0].src,
+ 'service worker',
+ 'Response for controlled page should be served by Service Worker');
+ assert_equals(
+ results[1].src,
+ 'network',
+ 'Response for non-controlled page should be served by network');
+ unload_iframe(frame);
+ return registration.unregister();
+ })
+ .then(function() {
+ t.done();
+ })
+ .catch(unreached_rejection(t));
+ }, 'Non-controlled page should not use a cache filled by Service Worker');
+</script>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/chromium/resources/memory-cache.jsonp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698