Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Make HTTPS tests fail if they are loaded over HTTP #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions testharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,18 @@ policies and contribution forms [3].
return 'ServiceWorker' in self && worker instanceof ServiceWorker;
}

function enforce_https() {
var pos = 0;
if (location && location.pathname) {
pos = location.pathname.indexOf(".https.");
if ((pos !== -1) && (location.protocol !== "https:")) {
assert(false, "enforce_https", "Test page must be loaded over HTTPS.",
"Protocol is ${protocol}", {protocol:location.protocol});
}
}
}


/*
* API functions
*/
Expand All @@ -513,6 +525,7 @@ policies and contribution forms [3].
var test_name = name ? name : test_environment.next_default_test_name();
properties = properties ? properties : {};
var test_obj = new Test(test_name, properties);
test_obj.step(enforce_https, test_obj, test_obj);
test_obj.step(func, test_obj, test_obj);
if (test_obj.phase === test_obj.phases.STARTED) {
test_obj.done();
Expand All @@ -529,6 +542,7 @@ policies and contribution forms [3].
var test_name = name ? name : test_environment.next_default_test_name();
properties = properties ? properties : {};
var test_obj = new Test(test_name, properties);
test_obj.step(enforce_https, test_obj, test_obj);
if (func) {
test_obj.step(func, test_obj, test_obj);
}
Expand Down