forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic tests for Presentation API (web-platform-tests#3063)
* PresentationRequest constructor test with incorrect url * PresentationRequest test with correct url * reconnect() test with wrong Presentation ID
- Loading branch information
1 parent
30fc10b
commit d3b639f
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
presentation-api/controlling-ua/PresentationRequest_error.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Presentation API PresentationRequest for Controlling User Agent (Error)</title> | ||
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de"> | ||
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
var wrong_presentation_url = null; | ||
|
||
/** | ||
* Test if PresentationRequest constructor returns a TypeError() by missing presentation URL | ||
*/ | ||
|
||
test(function() { | ||
assert_throws(new TypeError(), function() { | ||
new PresentationRequest(); | ||
}); | ||
}, 'Call PresentationRequest() constructor without presentation URL. TypeError Exception expected.'); | ||
|
||
/** | ||
* Test if PresentationRequest constructor returns a TypeError() by wrong presentation URL | ||
*/ | ||
|
||
test(function() { | ||
assert_throws(new TypeError(), function() { | ||
new PresentationRequest(wrong_presentation_url); | ||
}); | ||
}, 'Call PresentationRequest() constructor with null presentation URL. TypeError Exception expected.'); | ||
|
||
</script> |
29 changes: 29 additions & 0 deletions
29
presentation-api/controlling-ua/PresentationRequest_success.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Presentation API PresentationRequest for Controlling User Agent (Success)</title> | ||
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de"> | ||
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
|
||
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5)); | ||
//relative presentation URL | ||
var presentation_url = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__="+ client_id; | ||
|
||
/** | ||
* Test if PresentationRequest constructor returns a SyntaxError() by missing presentation URL | ||
*/ | ||
|
||
test(function() { | ||
try{ | ||
var request = new PresentationRequest(presentation_url); | ||
assert_true(request instanceof PresentationRequest); | ||
} | ||
catch (ex){ | ||
assert_unreached("Call PresentationRequest() constructor with valid presentation URL....????"); | ||
} | ||
}, 'Call PresentationRequest() constructor with valid presentation URL. No Exception expected.'); | ||
|
||
</script> |
36 changes: 36 additions & 0 deletions
36
presentation-api/controlling-ua/reconnectToPresentation_error-manual.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>Presentation API reconnect a presentation for Controlling User Agent (Error - manual test)</title> | ||
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de"> | ||
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
|
||
/** | ||
* | ||
* Test if reconnect returns a NotFoundError() by wrong presentation ID | ||
*/ | ||
|
||
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5)); | ||
//relative presentation URL | ||
var presentation_url = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__="+ client_id; | ||
var request = new PresentationRequest(presentation_url); | ||
var wrong_presentationId = null; | ||
|
||
var reconnect = function () { | ||
promise_test(function () { | ||
|
||
var presId = "presId"; | ||
// presId is mandatory when reconnecting to a presentation. | ||
return request.reconnect(presId) | ||
.then(function (setConnection) { | ||
assert_unreached("reconnect should not return a Promise resolve by wrong presentation ID"); | ||
}) | ||
}, "Check that the promise is rejected by wrong presentation Id"); | ||
}; | ||
|
||
setup({explicit_timeout: true}) | ||
</script> | ||
<p>click on the button to the perfom the test</p> | ||
<button id="reconnectBtn" onclick="reconnect()">Reconnect</button> |