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

Unified Diff: LayoutTests/http/tests/serviceworker/http-to-https-redirect-and-register.html

Issue 1312723002: Service workers: Add test for HTTP to HTTPS redirect (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: wait for unregister Created 5 years, 4 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/resources/register.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/http-to-https-redirect-and-register.html
diff --git a/LayoutTests/http/tests/serviceworker/http-to-https-redirect-and-register.html b/LayoutTests/http/tests/serviceworker/http-to-https-redirect-and-register.html
new file mode 100644
index 0000000000000000000000000000000000000000..50dff5507d2edc763b4dcaebd08d40612f872dba
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/http-to-https-redirect-and-register.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<title>register on a secure page after redirect from an non-secure url</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharness-helpers.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>
+
+// Loads a non-secure url in an iframe, which redirects to |target_url|.
+// That page then registers a service worker, and messages back with the result.
+// Returns a promise that resolves with the result.
+function redirect_and_register(target_url) {
+ var redirect_url = get_host_info()['UNAUTHENTICATED_ORIGIN'] +
+ '/serviceworker/resources/redirect.php?Redirect=';
+ var frame;
+
+ return with_iframe(redirect_url + encodeURIComponent(target_url))
+ .then(f => {
+ frame = f;
+ return new Promise(resolve => {
+ window.addEventListener('message', e => {resolve(e.data);});
+ });
+ })
+ .then(result => {
+ frame.remove();
+ return result;
+ });
+}
+
+promise_test(function(t) {
+ var target_url = window.location.origin +
+ '/serviceworker/resources/register.html';
+
+ return redirect_and_register(target_url)
+ .then(result => { assert_equals(result, 'OK'); });
+ }, 'register on a secure page after redirect from an non-secure url');
+
+promise_test(function(t) {
+ var target_url = get_host_info()['UNAUTHENTICATED_ORIGIN'] +
+ '/serviceworker/resources/register.html';
+
+ return redirect_and_register(target_url)
+ .then(result => {assert_equals(result, 'FAIL: NotSupportedError');});
+ }, 'register on a non-secure page after redirect from an non-secure url');
+</script>
+</body>
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/resources/register.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698