Skip to content

Commit

Permalink
New presentation start tests that trigger a mixed content error (#3590)
Browse files Browse the repository at this point in the history
* New start presentation tests that trigger a mixed content error

The tests need to run over HTTPS, hence the ".https.html" extension. They
create a PresentationRequest with an HTTP URL and ensure that "start" reports
a SecurityError exception.

* Disable button once clicked and use document.title for test name

The tests are semi-manual and the test harness gets confused if the button
gets clicked more than once. Disabling the button ensures the user will only
run the test once.

Also, since the page only contains one test, it is good practice to use the
title of the page to convey the name of the test.

* New mixed content tests for Presentation API

The tests check "reconnect" and "getAvailability" mixed content steps.
  • Loading branch information
tidoust authored and louaybassbouss committed Aug 29, 2016
1 parent 038f2db commit f9ee769
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "getAvailability" with an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-getavailability">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function getAvailability() {
var request = new PresentationRequest('http://example.org/presentation.html');
return request.getAvailability();
}

promise_test(function (t) {
return promise_rejects(t, 'SecurityError', getAvailability());
});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "reconnect" with an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-reconnect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function reconnectToPresentation() {
var request = new PresentationRequest('http://example.org/presentation.html');
return request.reconnect('someid');
}

promise_test(function (t) {
return promise_rejects(t, 'SecurityError', reconnectToPresentation());
});
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "start" with an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<p>Click the button below to start the manual test. If prompted to select a device, please dismiss the dialog box. The test passes if a "PASS" result appears.</p>
<button id="presentBtn" onclick="startPresentationTest()">Start Presentation Test</button>

<script>
setup({explicit_timeout: true});

var presentBtn = document.getElementById("presentBtn");

function startPresentation() {
var request = new PresentationRequest('http://example.org/presentation.html');
return request.start();
};

function startPresentationTest() {
presentBtn.disabled = true;
promise_test(function (t) {
return promise_rejects(t, 'SecurityError', startPresentation());
});
}
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Calling "start" with a set of URLs containing an a priori unauthenticated URL in an HTTPS context throws a SecurityError exception.</title>
<link rel="author" title="Francois Daoust" href="https://www.w3.org/People/#fd">
<link rel="help" href="http://w3c.github.io/presentation-api/#dom-presentationrequest-start">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<p>Click the button below to start the manual test. If prompted to select a device, please dismiss the dialog box. The test passes if a "PASS" result appears.</p>
<button id="presentBtn" onclick="startPresentationTest()">Start Presentation Test</button>

<script>
setup({explicit_timeout: true});

var presentBtn = document.getElementById("presentBtn");

function startPresentation() {
var request = new PresentationRequest([
'presentation.html',
'http://example.org/presentation.html'
]);
return request.start();
};

function startPresentationTest() {
presentBtn.disabled = true;
promise_test(function (t) {
return promise_rejects(t, 'SecurityError', startPresentation());
});
}
</script>

0 comments on commit f9ee769

Please sign in to comment.