blob: 5626237dcccbf279029ca072b8a0bc9e845fbb1c [file] [log] [blame]
<!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/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="resources/test-helpers.sub.js"></script>
'use strict';
var host_info = get_host_info();
// Loads a non-secure url in a new window, 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 = host_info.HTTP_REMOTE_ORIGIN + base_path() +
var child = + encodeURIComponent(target_url));
return new Promise(resolve => {
window.addEventListener('message', e => resolve(;
.then(function(result) {
return result;
promise_test(function(t) {
var target_url = window.location.origin + base_path() +
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 = host_info.HTTP_REMOTE_ORIGIN + base_path() +
return redirect_and_register(target_url)
.then(result => {
assert_equals(result, 'FAIL: navigator.serviceWorker is undefined');
}, 'register on a non-secure page after redirect from an non-secure url');