Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / fetch-frame-resource.html
blob239527866df758e22a3c11a4cf6d03918d912d10
1 <!DOCTYPE html>
2 <title>Service Worker: Fetch for the frame loading.</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="../resources/get-host-info.js"></script>
6 <script src="resources/test-helpers.js"></script>
7 <body>
8 <script>
9 var worker = 'resources/fetch-rewrite-worker.js';
10 var path = base_path() + 'resources/fetch-access-control.php';
11 var host_info = get_host_info();
13 if (window.testRunner) {
14 testRunner.setCanOpenWindows();
17 async_test(function(t) {
18 var scope = 'resources/fetch-frame-resource/frame-basic';
19 service_worker_unregister_and_register(t, worker, scope)
20 .then(function(reg) {
21 return wait_for_state(t, reg.installing, 'activated');
23 .then(function() {
24 return with_iframe(
25 scope + '?url=' +
26 encodeURIComponent(host_info['HTTP_ORIGIN'] + path));
28 .then(function(frame) {
29 assert_equals(
30 frame.contentDocument.body.textContent.substr(0, 7),
31 'report(',
32 'Basic type response could be loaded in the iframe.');
33 frame.remove();
34 return service_worker_unregister_and_done(t, scope);
36 .catch(unreached_rejection(t));
37 }, 'Basic type response could be loaded in the iframe.');
39 async_test(function(t) {
40 var scope = 'resources/fetch-frame-resource/frame-cors';
41 service_worker_unregister_and_register(t, worker, scope)
42 .then(function(reg) {
43 return wait_for_state(t, reg.installing, 'activated');
45 .then(function() {
46 return with_iframe(
47 scope + '?mode=cors&url=' +
48 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path +
49 '?ACAOrigin=' + host_info['HTTP_ORIGIN']));
51 .then(function(frame) {
52 assert_equals(
53 frame.contentDocument.body.textContent.substr(0, 7),
54 'report(',
55 'CORS type response could be loaded in the iframe.');
56 frame.remove();
57 return service_worker_unregister_and_done(t, scope);
59 .catch(unreached_rejection(t));
60 }, 'CORS type response could be loaded in the iframe.');
62 async_test(function(t) {
63 var scope = 'resources/fetch-frame-resource/frame-opaque';
64 service_worker_unregister_and_register(t, worker, scope)
65 .then(function(reg) {
66 return wait_for_state(t, reg.installing, 'activated');
68 .then(function() {
69 var frame = document.createElement('iframe');
70 frame.src =
71 scope + '?mode=no-cors&url=' +
72 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path);
73 document.body.appendChild(frame);
74 // We can't catch the network error on iframe. So we use the timer.
75 return new Promise(function(resolve) {
76 setTimeout(function() { resolve(frame); }, 1000);
77 });
79 .then(function(frame) {
80 assert_equals(
81 frame.contentDocument.body.textContent,
82 '',
83 'Opaque type response could not be loaded in the iframe.');
84 frame.remove();
85 return service_worker_unregister_and_done(t, scope);
87 .catch(unreached_rejection(t));
88 }, 'Opaque type response could not be loaded in the iframe.');
90 async_test(function(t) {
91 var scope = 'resources/fetch-frame-resource/window-basic';
92 service_worker_unregister_and_register(t, worker, scope)
93 .then(function(reg) {
94 return wait_for_state(t, reg.installing, 'activated');
96 .then(function() {
97 return new Promise(function(resolve) {
98 var win = window.open(
99 scope + '?url=' +
100 encodeURIComponent(host_info['HTTP_ORIGIN'] + path));
101 win.onload = function() { resolve(win); };
104 .then(function(win) {
105 assert_equals(
106 win.document.body.textContent.substr(0, 7),
107 'report(',
108 'Basic type response could be loaded in the new window.');
109 win.close();
110 return service_worker_unregister_and_done(t, scope);
112 .catch(unreached_rejection(t));
113 }, 'Basic type response could be loaded in the new window.');
115 async_test(function(t) {
116 var scope = 'resources/fetch-frame-resource/window-cors';
117 service_worker_unregister_and_register(t, worker, scope)
118 .then(function(reg) {
119 return wait_for_state(t, reg.installing, 'activated');
121 .then(function() {
122 return new Promise(function(resolve) {
123 var win = window.open(
124 scope + '?mode=cors&url=' +
125 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path +
126 '?ACAOrigin=' + host_info['HTTP_ORIGIN']));
127 win.onload = function() { resolve(win); };
130 .then(function(win) {
131 assert_equals(
132 win.document.body.textContent.substr(0, 7),
133 'report(',
134 'CORS type response could be loaded in the new window.');
135 win.close();
136 return service_worker_unregister_and_done(t, scope);
138 .catch(unreached_rejection(t));
139 }, 'CORS type response could be loaded in the new window.');
141 async_test(function(t) {
142 var scope = 'resources/fetch-frame-resource/window-opaque';
143 service_worker_unregister_and_register(t, worker, scope)
144 .then(function(reg) {
145 return wait_for_state(t, reg.installing, 'activated');
147 .then(function() {
148 var win = window.open(
149 scope + '?mode=no-cors&url=' +
150 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path));
151 // We can't catch the network error on window. So we use the timer.
152 return new Promise(function(resolve) {
153 setTimeout(function() { resolve(win); }, 1000);
156 .then(function(win) {
157 assert_equals(
158 win.document.body.textContent,
160 'Opaque type response could not be loaded in the new window.');
161 win.close();
162 return service_worker_unregister_and_done(t, scope);
164 .catch(unreached_rejection(t));
165 }, 'Opaque type response could not be loaded in the new window.');
166 </script>
167 </body>