Update web-platform-tests to revision 346d5b51a122f7bb1c7747064499ef281a0200f7

This commit is contained in:
Ms2ger 2016-06-24 10:13:49 +02:00
parent 581c8ba1c8
commit 79b1e6c40c
1728 changed files with 20243 additions and 5349 deletions

View file

@ -0,0 +1,41 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>PresentationConnection.onclose</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="author" title="He Yue" href="mailto:yue.he@intel.com">
<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnection">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h2>Description</h2>
<p>
This test validates that after connection close,<br/>
the connection state is set closed,<br/>
the onclose EventHandler is triggered.
</p>
<br/>
<p>Click the button below to start the test.</p>
<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
<script>
setup({explicit_timeout: true});
var startPresentation = function () {
async_test(function(t) {
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
var url = "support/presentation.html#__castAppId__=C2335F62/__castClientId__="+ client_id;
var request = new PresentationRequest(url);
request.start()
.then(function(connection) {
assert_true(connection instanceof PresentationConnection, 'the connection is setup');
connection.onclose = t.step_func_done(function(evt) {
assert_equals(evt.type, "close");
assert_equals(connection.state, "closed");
});
connection.close();
})
.catch(function(ex) {
assert_unreached(ex.name + ":" + ex.message);
});
}, "the onclose is fired and the connection state is closed.");
}
</script>

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>PresentationConnection.onconnect</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="author" title="He Yue" href="mailto:yue.he@intel.com">
<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnection">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h2>Description</h2>
<p>
This test validates that after connection starts,<br/>
the onconnect EventHandler is triggered and connection state is connected.
</p>
<br/>
<p>Click the button below to start the test.</p>
<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
<script>
setup({explicit_timeout: true});
var startPresentation = function () {
async_test(function(t) {
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
var url = "support/presentation.html#__castAppId__=C2335F62/__castClientId__="+ client_id;
var request = new PresentationRequest(url);
request.start()
.then(function(connection) {
assert_true(connection instanceof PresentationConnection);
connection.onconnect = t.step_func_done(function() {
assert_equals(connection.state, "connected");
});
connection.close();
})
.catch(function(ex) {
assert_unreached(ex.name + ":" + ex.message);
});
}, "the onconnect is fired and the connection state is connected");
}
</script>

View file

@ -0,0 +1,44 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>PresentationConnection.onterminate</title>
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="author" title="Chunyan Wang" href="mailto:chunyanx.wang@intel.com">
<link rel="help" href="http://w3c.github.io/presentation-api/#starting-a-presentation">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<h2>Description</h2>
<p>
This test validates that after connection terminate,<br/>
the connection state is set terminated,<br/>
the onterminate EventHandler is triggered.
</p>
<br/>
<p>Click the button below to start the test.</p>
<button id="presentStartBtn" onclick="startPresentation()">Start Presentation Test</button>
<script>
setup({explicit_timeout: true});
var startPresentation = function () {
async_test(function(t) {
var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
var url = "support/presentation.html#__castAppId__=C2335F62/__castClientId__="+ client_id;
var request = new PresentationRequest(url);
request.start()
.then(function(connection) {
assert_true(connection instanceof PresentationConnection);
connection.onterminate = t.step_func_done(function(evt) {
assert_equals(evt.type, "terminate");
assert_equals(connection.state, "terminated");
});
connection.onclose = t.step_func_done(function(evt) {
assert_unreached("Wrong, the onclose shouldn't be triggered!");
});
connection.terminate();
})
.catch(function(ex) {
assert_unreached(ex.name + ":" + ex.message);
});
}, "the onterminate is fired and the connection state is terminated");
}
</script>

View file

@ -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>

View file

@ -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>

View file

@ -0,0 +1,83 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API - monitor screen availability tests for Controlling User Agent</title>
<link rel="author" title="Marius Wessel" 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>
// ---------------------------------
// Helper Function
// ---------------------------------
var createRequestObject = function () {
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
presUrl = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=" + validUnixDate,
request = new PresentationRequest(presUrl);
return request;
}
// ---------------------------------
// Screen Availability Tests - begin
// ---------------------------------
// Instance of Promise Test
test(function () {
var request = createRequestObject();
assert_true(request.getAvailability() instanceof Promise);
}, 'The request is an Promise.')
// Instance of PresentationRequest Test
test(function () {
var request = createRequestObject();
assert_true(request instanceof PresentationRequest);
}, 'The request is an instance of PresentationRequest.')
// Instance of PresentationAvailability Test
promise_test(function () {
var request = createRequestObject();
return request.getAvailability()
.then(function (availability) {
assert_true(availability instanceof PresentationAvailability);
});
}, "The promise is an instance of PresentationAvailability");
// Availability.value is set Test
promise_test(function () {
var request = createRequestObject();
return request.getAvailability()
.then(function (availability) {
assert_true(typeof availability.value == 'boolean');
});
}, "The availability has an boolean value.");
// Best Case Scenario Test
// -----------------------
promise_test(function () {
var request = createRequestObject();
return request.getAvailability()
.then(function (availability) {
assert_true(availability.value);
});
}, "There is an availability.");
// Invalid Presentation URL Test
promise_test(function () {
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
invalidPresUrl = "../receiving-ua/idlharness.html#__castAppId__=3445E44B/__castClientId__=" + validUnixDate,
request = new PresentationRequest(invalidPresUrl);
return request.getAvailability()
.then(function (availability) {
assert_false(availability.value);
});
}, "There is no availability for an invalid presentation URL.");
// -------------------------------
// Screen Availability Tests - end
// -------------------------------
</script>

View file

@ -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>

View file

@ -0,0 +1,73 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API, reconnect to presentation tests for Controlling User Agent (success - manual test)</title>
<link rel="author" title="Marius Wessel" 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>
<ol>
<li>Start the presentation with the blue button.</li>
<li>After the presentation ist running successfully, disconnect the connected device.</li>
<li>Reconnect the device and press the green button, to start the reconnection process.</li>
</ol>
<button id="startBtn" onclick="startPresentation()" style="background-color: #2aabd2;">Start Presentation</button>
<button id="reconnectBtn" onclick="reconnectToPresentation()" style="background-color: #5cb85c;">Reconnect Presentation
Test
</button>
<script>
// disable the timeout function for the tests
// and call 'done()' when the tests cases are finished.
setup({explicit_timeout: true});
// ----------
// DOM Object
// ----------
var startBtn = document.getElementById("startBtn"),
reconnectBtn = document.getElementById("reconnectBtn");
// ------------
// Request init
// ------------
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
request = new PresentationRequest(validPresURL);
// ----------------------------------------
// Helper Function - start the presentation
// ----------------------------------------
var startPresentation = function () {
return request.start()
.then(function (connection) {
// save the presentation id within the
// local storage of the browser
localStorage["presId"] = connection.id;
});
}
// ------------------------------------------------
// Reconnect to Presentation Test (success) - begin
// ------------------------------------------------
var reconnectToPresentation = function () {
promise_test(function () {
// get the saved presentation id
// for the reconnect function if exist
if (localStorage["presId"]) var presId = localStorage["presId"];
return request.reconnect(presId)
.then(function (connection) {
assert_true(connection instanceof PresentationConnection);
done();
});
}, 'The reconnection was successful.');
}
// ----------------------------------------------
// Reconnect to Presentation Test (success) - end
// ----------------------------------------------
</script>

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API, start new presentation tests for Controlling User Agent (error - manual test)</title>
<link rel="author" title="Marius Wessel" 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>
<p>Click the button below and abort the selection for an device, to start the manual test.</p>
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
<script>
// ----------
// DOM Object
// ----------
var presentBtn = document.getElementById("presentBtn");
// ------------
// Request init
// ------------
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
request = new PresentationRequest(validPresURL);
// -------------------------------------------
// Start New Presentation Test (error) - begin
// -------------------------------------------
var startPresentation = function () {
promise_test(function () {
return request.start()
.catch(function (err) {
test(function () {
assert_true(err.code == 20, 'The error code is equal to 20.');
}, 'Check, if the error code is correct.')
test(function () {
assert_true(err.message === 'Dialog closed.', 'The error message is equal to "Dialog closed."');
}, 'Check, if the error message is correct.')
assert_true(err.name === 'AbortError', 'The error name is AbortError.');
});
}, "The starting process for the presentation has been aborted.");
}
// -----------------------------------------
// Start New Presentation Test (error) - end
// -----------------------------------------
</script>

View file

@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API, start new presentation tests for Controlling User Agent (error)</title>
<link rel="author" title="Marius Wessel" 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>
// ------------
// Request init
// ------------
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
request = new PresentationRequest(validPresURL);
// -----------------------------------
// Start New Presentation Test - begin
// -----------------------------------
promise_test(function () {
return request.start()
.catch(function (error) {
assert_true(error instanceof InvalidAccessError);
});
}, "The presentation could not start, because a user gesture is required.");
// ----------------------------------
// Launch New Presentation Test - end
// ----------------------------------
</script>

View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API, start new presentation tests for Controlling User Agent (success - manual test)</title>
<link rel="author" title="Marius Wessel" 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>
<p>Click the button below and select the available casting device, to start the manual test.</p>
<button id="presentBtn" onclick="startPresentation()">Start Presentation Test</button>
<script>
// ----------
// DOM Object
// ----------
var presentBtn = document.getElementById("presentBtn");
// ------------
// Request init
// ------------
var validUnixDate = new Date().getTime() + String(Math.floor(Math.random() * 1e5)),
validPresURL = '../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__=' + validUnixDate,
request = new PresentationRequest(validPresURL);
// ---------------------------------------------
// Start New Presentation Test (success) - begin
// ---------------------------------------------
var startPresentation = function () {
promise_test(function () {
return request.start()
.then(function (connection) {
// assert case for the promise_test
assert_equals(connection.state, "connected", "The presentation has an connected state.");
// Check, if the connection ID is set
test(function () {
assert_true(!!connection.id);
}, 'The connection ID is set.');
// Check the type of the connection.id
test(function () {
assert_true(typeof connection.id === 'string');
}, 'The connection ID is a string.');
// Check the instance of the connection
test(function () {
assert_true(connection instanceof PresentationConnection);
}, 'The connection is an instance of PresentationConnection.');
});
}, "The presentation was started successfully.");
}
// -------------------------------------------
// Start New Presentation Test (success) - end
// -------------------------------------------
</script>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Intel" href="http://www.intel.com">
<link rel="author" title="He Yue" href="mailto:yue.he@intel.com">
<link rel="help" href="http://w3c.github.io/presentation-api/#interface-presentationconnectionlist">
<script>
var addConnection = function(connection) {
connection.onconnected = function () {
this.onmessage = function (evt) {
this.send(evt.data);
};
};
navigator.receiver.connectionList
.then(function(list) {
list.onconnectionavailable = function(connections) {
addConnection(connections[connections.length - 1]);
};
list.connections.map(function(connection) {
addConnection(connection);
});
});
}
</script>