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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html

Issue 1612423002: Don't send the body of the redirected request to the ServiceWorker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add LayoutTest Created 4 years, 11 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
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html
new file mode 100644
index 0000000000000000000000000000000000000000..1c3845dc2fad53d5b312e8b91a3cc5030ce850e7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/navigation-redirect-body.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<title>Service Worker: Navigation redirection must clear body</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/get-host-info.js?pipe=sub"></script>
+<script src="resources/test-helpers.js"></script>
+<body>
+<script>
+promise_test(function(t) {
+ var scope = 'resources/navigation-redirect-body.php';
+ var script = 'resources/navigation-redirect-body-worker.js';
+ var registration;
+ var frame = document.createElement('frame');
+ frame.src = 'about:blank';
+ frame.name = 'target_frame';
+ frame.id = 'frame';
+ document.body.appendChild(frame);
+ var form = document.createElement('form');
+ form.method = 'POST';
+ form.action = scope;
+ form.target = 'target_frame';
+ var hiddenInput = document.createElement('input');
falken 2016/01/25 04:51:57 nit: snake_case here and throughout
horo 2016/01/25 05:14:51 Done.
+ hiddenInput.type = 'hidden';
+ hiddenInput.name = 'data';
+ hiddenInput.value = 'test data';
+ var submitButton = document.createElement('input');
+ submitButton.type = 'submit';
+ submitButton.value = 'submit';
+ form.appendChild(hiddenInput);
+ form.appendChild(submitButton);
+ document.body.appendChild(form);
+ return service_worker_unregister_and_register(t, script, scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() {
+ var frameLoadPromise = new Promise(function(resolve) {
falken 2016/01/25 04:51:57 I think function(resolve)'s body needs an addition
horo 2016/01/25 05:14:51 Done.
+ frame.addEventListener('load', function() {
falken 2016/01/25 04:51:57 same with this function()
horo 2016/01/25 05:14:51 Done.
+ resolve(frame.contentWindow.document.body.innerText);
+ }, false);
+ });
+ submitButton.click();
+ return frameLoadPromise;
+ })
+ .then(function(text) {
+ document.body.removeChild(form);
+ document.body.removeChild(frame);
+ var request_uri = decodeURIComponent(text);
+ assert_equals(
+ request_uri,
+ '/serviceworker/resources/navigation-redirect-body.php?redirect');
+ console.log(decodeURIComponent(text));
falken 2016/01/25 04:51:57 debug output?
horo 2016/01/25 05:14:51 Removed
+ return registration.unregister();
+ });
+ }, 'Navigation redirection must clear body');
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698