Update web-platform-tests to revision 3137d1d2d7757366a69f8a449b458b5057e0e81e

This commit is contained in:
Ms2ger 2016-12-28 09:51:21 +01:00
parent 81ca858678
commit d6ba94ca28
2339 changed files with 89274 additions and 9328 deletions

View file

@ -0,0 +1,78 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Monitoring the list of available presentation displays.</title>
<link rel="author" title="Tomoyuki Shimizu" href="https://github.com/tomoyukilabs">
<link rel="help" href="http://w3c.github.io/presentation-api/#monitoring-the-list-of-available-presentation-displays">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="common.js"></script>
<p id="notice">Please wait for a moment...</p>
<p>The test passes if a "PASS" result appears.<br></p>
<script>
// prevent the default timeout
setup({explicit_timeout: true});
var notice = document.getElementById('notice');
promise_test(function(t) {
// clean up the instruction notice when the test ends
t.add_cleanup(function() {
notice.parentNode.removeChild(notice);
});
// initialize a presentation request
var request = new PresentationRequest(presentationUrls);
var availability, previousState, timeout;
function wait() {
notice.textContent = 'Please wait for a moment... (It might take long time)';
// set timeout to observe the presentation availability
timeout = t.step_timeout(function() {
t.force_timeout();
t.done();
}, 90000);
}
function setup() {
// save the current value of the presentation availability
previousState = availability.value;
// show an instruction notice
notice.textContent = 'Please make your presentation displays '
+ (previousState ? 'unavailable' : 'available')
+ ' and click this button: ';
var button = document.createElement('button');
button.textContent = 'Start Monitoring';
button.onclick = wait;
notice.appendChild(button);
}
var check = t.step_func(function(a) {
availability = a;
setup();
availability.onchange = t.step_func(function(evt) {
clearTimeout(timeout);
timeout = undefined;
// check the event and its attributes
assert_true(evt.isTrusted && !evt.bubbles && !evt.cancelable && evt instanceof Event, 'A simple event is fired.');
assert_equals(evt.type, 'change', 'The event name is "change".');
assert_equals(evt.target, availability, 'event.target is the presentation availability.');
assert_not_equals(previousState, availability.value, 'Value of the presentation availability is changed.');
setup();
});
// wait until a "change" event is fired twice
var eventWatcher = new EventWatcher(t, availability, 'change');
return eventWatcher.wait_for(['change', 'change']);
});
// check the change of PresentationAvailability.value twice; "true to false" and "false to true"
return request.getAvailability().then(check);
});
</script>

View file

@ -26,6 +26,13 @@
var request = new PresentationRequest(presentationUrls);
request.start()
.then(function(connection) {
// Enable timeout again, cause no user action is needed from here.
t.step_timeout(function() {
t.force_timeout();
t.done();
}, 5000);
assert_true(connection instanceof PresentationConnection, 'the connection is setup');
connection.onclose = t.step_func_done(function(evt) {
assert_equals(evt.type, "close");

View file

@ -25,11 +25,18 @@
var request = new PresentationRequest(presentationUrls);
request.start()
.then(function(connection) {
// Enable timeout again, cause no user action is needed from here.
t.step_timeout(function() {
t.force_timeout();
t.done();
}, 5000);
assert_true(connection instanceof PresentationConnection);
connection.onconnect = t.step_func_done(function() {
assert_equals(connection.state, "connected");
connection.terminate();
});
connection.close();
})
.catch(function(ex) {
assert_unreached(ex.name + ":" + ex.message);

View file

@ -26,9 +26,16 @@
var request = new PresentationRequest(presentationUrls);
request.start()
.then(function(connection) {
// Enable timeout again, cause no user action is needed from here.
t.step_timeout(function() {
t.force_timeout();
t.done();
}, 5000);
assert_true(connection instanceof PresentationConnection);
connection.onconnected = t.step_func(function(evt) {
assert_equals(evt.state, "connected");
connection.onconnect = t.step_func(function(evt) {
assert_equals(connection.state, "connected");
connection.terminate();
});
connection.onterminate = t.step_func_done(function(evt) {

View file

@ -48,7 +48,7 @@
var connection = evt.connection;
// check the presentation connection and its attributes
assert_equals(connection.state, 'connecting', 'The initial state of the presentation connection is "connecting".');
assert_true(!connection.id, 'The connection ID is set.');
assert_true(!!connection.id, 'The connection ID is set.');
assert_true(typeof connection.id === 'string', 'The connection ID is a string.');
assert_true(connection instanceof PresentationConnection, 'The connection is an instance of PresentationConnection.');
});

View file

@ -1,72 +1,45 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API, reconnect to presentation tests for Controlling User Agent (success - manual test)</title>
<title>Reconnect to presentation 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">
<link rel="author" title="Louay Bassbouss" href="http://www.fokus.fraunhofer.de">
<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 src="common.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>
<p>Click the button below to start the manual test. Select a presentation device after the selection dialog is prompted.
The test assumes that at least one presentation device is available. The test passes if a "PASS" result appears.</p>
<button id="startBtn">Start Test</button>
<script>
// disable the timeout function for the tests
// and call 'done()' when the tests cases are finished.
// disable timeout for manual tests
setup({explicit_timeout: true});
var startBtn = document.getElementById("startBtn");
startBtn.onclick = function () {
startBtn.disabled = true;
promise_test(function (t) {
var request = new PresentationRequest(presentationUrls);
var presentationId = null;
return request.start().then(function (connection) {
presentationId = connection.id;
// ----------
// DOM Object
// ----------
var startBtn = document.getElementById("startBtn"),
reconnectBtn = document.getElementById("reconnectBtn");
// ------------
// Request init
// ------------
var request = new PresentationRequest(presentationUrls);
// ----------------------------------------
// 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
// ----------------------------------------------
// No more user input needed, re-enable test timeout
t.step_timeout(function () {
t.force_timeout();
t.done();
}, 5000);
// Close connection and wait for "close" event
connection.close();
var eventWatcher = new EventWatcher(t, connection, 'close');
return eventWatcher.wait_for('close');
}).then(function () {
// Connection now closed, let's reconnect to it
return request.reconnect(presentationId);
}).then(function (connection) {
assert_equals(connection.state, "connecting", "connection should be in 'connecting' state");
assert_equals(connection.id, presentationId, "Ids of old and new connections must be equal");
});
});
};
</script>

View file

@ -11,7 +11,7 @@
// -----------------------------------
promise_test(function (t) {
var request = new PresentationRequest('presentation.html');
promise_rejects(t, 'InvalidAccessError', request.start());
return promise_rejects(t, 'InvalidAccessError', request.start());
}, "The presentation could not start, because a user gesture is required.");
// ----------------------------------
// Launch New Presentation Test - end

View file

@ -10,15 +10,16 @@
this.onmessage = function (evt) {
this.send(evt.data);
};
};
};
navigator.receiver.connectionList
navigator.presentation.receiver.connectionList
.then(function(list) {
list.onconnectionavailable = function(connections) {
addConnection(connections[connections.length - 1]);
list.onconnectionavailable = function(evt) {
addConnection(evt.connection);
};
list.connections.map(function(connection) {
addConnection(connection);
});
});
}
</script>