Index: LayoutTests/http/tests/serviceworker/fetch-frame-resource.html |
diff --git a/LayoutTests/http/tests/serviceworker/fetch-frame-resource.html b/LayoutTests/http/tests/serviceworker/fetch-frame-resource.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..451ec20adb6ec55b1046dd560bb5d4a28921d392 |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/fetch-frame-resource.html |
@@ -0,0 +1,154 @@ |
+<!DOCTYPE html> |
+<title>Service Worker: Fetch for the frame loading.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="resources/test-helpers.js"></script> |
+<body> |
+<script> |
+var worker = 'resources/fetch-rewrite-worker.js'; |
+var path = base_path() + 'resources/fetch-access-control.php'; |
+var host_info = get_host_info(); |
+ |
+if (window.testRunner) { |
+ testRunner.setCanOpenWindows(); |
+} |
+ |
+async_test(function(t) { |
falken
2014/10/03 03:43:47
It's burdensome, but can you put each test in its
horo
2014/10/03 04:14:26
I think we don't need to split.
Because async_test
falken
2014/10/03 06:06:39
Acknowledged.
|
+ var scope = 'resources/fetch-frame-resource/frame-basic'; |
+ service_worker_unregister_and_register(t, worker, scope) |
+ .then(function(reg) { return wait_for_activated(t, reg); }) |
+ .then(function() { |
+ return with_iframe( |
+ scope + '?url=' + |
+ encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); |
+ }) |
+ .then(function(frame) { |
+ assert_not_equals( |
+ frame.contentDocument.body.textContent, |
+ '', |
+ 'Basic type response could be loaded in the iframe.'); |
+ unload_iframe(frame); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Basic type response could be loaded in the iframe.'); |
+ |
+async_test(function(t) { |
+ var scope = 'resources/fetch-frame-resource/frame-cors'; |
+ service_worker_unregister_and_register(t, worker, scope) |
+ .then(function(reg) { return wait_for_activated(t, reg); }) |
+ .then(function() { |
+ return with_iframe( |
+ scope + '?mode=cors&url=' + |
+ encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + |
+ '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); |
+ }) |
+ .then(function(frame) { |
+ assert_not_equals( |
+ frame.contentDocument.body.textContent, |
+ '', |
+ 'CORS type response could be loaded in the iframe.'); |
+ unload_iframe(frame); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'CORS type response could be loaded in the iframe.'); |
+ |
+async_test(function(t) { |
+ var scope = 'resources/fetch-frame-resource/frame-opaque'; |
+ service_worker_unregister_and_register(t, worker, scope) |
+ .then(function(reg) { return wait_for_activated(t, reg); }) |
+ .then(function() { |
+ var frame = document.createElement('iframe'); |
+ frame.src = |
+ scope + '?mode=no-cors&url=' + |
+ encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path); |
+ document.body.appendChild(frame); |
+ // We can't catch the network error on iframe. So we use the timer. |
+ return new Promise(function(resolve) { |
+ setTimeout(function() { resolve(frame); }, 1000); |
falken
2014/10/03 03:43:47
Especially with this timeout, we'll want separate
|
+ }); |
+ }) |
+ .then(function(frame) { |
+ assert_equals( |
+ frame.contentDocument.body.textContent, |
+ '', |
+ 'Opaque type response could not be loaded in the iframe.'); |
+ unload_iframe(frame); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Opaque type response could not be loaded in the iframe.'); |
+ |
+async_test(function(t) { |
+ var scope = 'resources/fetch-frame-resource/window-basic'; |
+ service_worker_unregister_and_register(t, worker, scope) |
+ .then(function(reg) { return wait_for_activated(t, reg); }) |
+ .then(function() { |
+ return new Promise(function(resolve) { |
+ var win = window.open( |
+ scope + '?url=' + |
+ encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); |
+ win.onload = function() { resolve(win); }; |
+ }); |
+ }) |
+ .then(function(win) { |
+ assert_not_equals( |
+ win.document.body.textContent, |
+ '', |
+ 'Basic type response could be loaded in the new window.'); |
+ win.close(); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Basic type response could be loaded in the new window.'); |
+ |
+async_test(function(t) { |
+ var scope = 'resources/fetch-frame-resource/window-cors'; |
+ service_worker_unregister_and_register(t, worker, scope) |
+ .then(function(reg) { return wait_for_activated(t, reg); }) |
+ .then(function() { |
+ return new Promise(function(resolve) { |
+ var win = window.open( |
+ scope + '?mode=cors&url=' + |
+ encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + |
+ '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); |
+ win.onload = function() { resolve(win); }; |
+ }); |
+ }) |
+ .then(function(win) { |
+ assert_not_equals( |
+ win.document.body.textContent, |
+ '', |
+ 'CORS type response could be loaded in the new window.'); |
+ win.close(); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'CORS type response could be loaded in the new window.'); |
+ |
+async_test(function(t) { |
+ var scope = 'resources/fetch-frame-resource/window-opaque'; |
+ service_worker_unregister_and_register(t, worker, scope) |
+ .then(function(reg) { return wait_for_activated(t, reg); }) |
+ .then(function() { |
+ var win = window.open( |
+ scope + '?mode=no-cors&url=' + |
+ encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path)); |
+ // We can't catch the network error on window. So we use the timer. |
+ return new Promise(function(resolve) { |
+ setTimeout(function() { resolve(win); }, 1000); |
falken
2014/10/03 03:43:47
and this one
|
+ }); |
+ }) |
+ .then(function(win) { |
+ assert_equals( |
+ win.document.body.textContent, |
+ '', |
+ 'CORS type response could not be loaded in the new window.'); |
+ win.close(); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Opaque type response could not be loaded in the new window.'); |
+</script> |
+</body> |