mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-06-25 20:29:33 +00:00
84 lines
3.0 KiB
HTML
84 lines
3.0 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!-- Any copyright is dedicated to the Public Domain.
|
|
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for connection establishing timeout of B2G Presentation API at receiver side</title>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1069230">Test for connection establishing timeout of B2G Presentation API at receiver side</a>
|
|
<script type="application/javascript;version=1.8">
|
|
|
|
'use strict';
|
|
|
|
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('PresentationSessionChromeScript.js'));
|
|
|
|
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
|
.getService(SpecialPowers.Ci.nsIObserverService);
|
|
|
|
function setup() {
|
|
return new Promise(function(aResolve, aReject) {
|
|
gScript.sendAsyncMessage('trigger-device-add');
|
|
|
|
var promise = new Promise(function(aResolve, aReject) {
|
|
// In order to trigger timeout, do not resolve the promise.
|
|
});
|
|
obs.notifyObservers(promise, 'setup-request-promise', null);
|
|
|
|
aResolve();
|
|
});
|
|
}
|
|
|
|
function testIncomingSessionRequestReceiverLaunchTimeout() {
|
|
return new Promise(function(aResolve, aReject) {
|
|
gScript.addMessageListener('receiver-launching', function launchReceiverHandler(aSessionId) {
|
|
gScript.removeMessageListener('receiver-launching', launchReceiverHandler);
|
|
info("Trying to launch receiver page.");
|
|
});
|
|
|
|
gScript.addMessageListener('control-channel-closed', function controlChannelClosedHandler(aReason) {
|
|
gScript.removeMessageListener('control-channel-closed', controlChannelClosedHandler);
|
|
is(aReason, 0x80530017 /* NS_ERROR_DOM_TIMEOUT_ERR */, "The control channel is closed due to timeout.");
|
|
aResolve();
|
|
});
|
|
|
|
gScript.sendAsyncMessage('trigger-incoming-session-request', 'http://example.com');
|
|
});
|
|
}
|
|
|
|
function teardown() {
|
|
gScript.addMessageListener('teardown-complete', function teardownCompleteHandler() {
|
|
gScript.removeMessageListener('teardown-complete', teardownCompleteHandler);
|
|
gScript.destroy();
|
|
SimpleTest.finish();
|
|
});
|
|
|
|
gScript.sendAsyncMessage('teardown');
|
|
}
|
|
|
|
function runTests() {
|
|
setup().
|
|
then(testIncomingSessionRequestReceiverLaunchTimeout).
|
|
then(teardown);
|
|
}
|
|
|
|
SimpleTest.expectAssertions(0, 5);
|
|
SimpleTest.waitForExplicitFinish();
|
|
SpecialPowers.pushPermissions([
|
|
{type: 'presentation-device-manage', allow: false, context: document},
|
|
{type: 'presentation', allow: true, context: document},
|
|
], function() {
|
|
SpecialPowers.pushPrefEnv({ 'set': [["dom.presentation.enabled", true],
|
|
["dom.presentation.test.enabled", true],
|
|
["dom.presentation.test.stage", 0],
|
|
["presentation.receiver.loading.timeout", 10]]},
|
|
runTests);
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|