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

Side by Side Diff: LayoutTests/http/tests/serviceworker/appcache-ordering-main.html

Issue 671583002: Test: Pages controlled by ServiceWorkers should not participate in AppCaching (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script>
5 <body>
6 <script>
7
8 var INSTALL_APPCACHE_URL = "resources/appcache-ordering.install.html";
9 var IS_APPCACHED_URL = "resources/appcache-ordering.is-appcached.html";
10 var SERVICE_WORKER_SCOPE = "resources/appcache-ordering";
11 var SERVICE_WORKER_SCRIPT = "resources/empty-worker.js";
12
13 var resolve_install_appcache = undefined;
14 var reject_install_appcache = undefined;
15
16 // Called by the INSTALL_APPCACHE_URL child frame.
17 function notify_appcache_installed(success) {
18 if (success)
19 resolve_install_appcache();
20 else
21 reject_install_appcache();
22 }
23
24 function install_appcache() {
25 return new Promise(function(resolve, reject) {
26 var frame = document.createElement('iframe');
27 frame.src = INSTALL_APPCACHE_URL;
28 document.body.appendChild(frame);
29 resolve_install_appcache = function() {
30 unload_iframe(frame);
31 resolve();
32 };
33 reject_install_appcache = function() {
34 unload_iframe(frame);
35 reject();
36 };
37 });
38 }
39
40 var resolve_is_appcached = undefined;
41
42 // Called by the IS_APPCACHED_URL child frame.
43 function notify_is_appcached(is) {
44 resolve_is_appcached(is);
45 }
46
47 function is_appcached() {
48 return new Promise(function(resolve) {
49 var frame = document.createElement('iframe');
50 frame.src = IS_APPCACHED_URL;
51 document.body.appendChild(frame);
52 resolve_is_appcached = function(is) {
53 unload_iframe(frame);
54 resolve(is);
55 };
56 });
57 }
58
59 async_test(function(t) {
60 install_appcache()
61 .then(function() {
62 return is_appcached();
63 })
64 .then(function(result) {
65 assert_true(result, 'appcache should initially be utilized');
66 return service_worker_unregister_and_register(
67 t, SERVICE_WORKER_SCRIPT, SERVICE_WORKER_SCOPE);
68 })
69 .then(function() {
70 return is_appcached();
71 })
72 .then(function(result) {
73 assert_false(result, 'but serviceworkers should take priority');
74 service_worker_unregister_and_done(t, SERVICE_WORKER_SCOPE);
75 })
76 .catch(unreached_rejection(t));
77 }, 'serviceworkers take priority over appcaches');
78
79 </script>
80 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698