summaryrefslogtreecommitdiffstats
path: root/dom/presentation/tests/mochitest/test_presentation_device_info.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/presentation/tests/mochitest/test_presentation_device_info.html')
-rw-r--r--dom/presentation/tests/mochitest/test_presentation_device_info.html144
1 files changed, 0 insertions, 144 deletions
diff --git a/dom/presentation/tests/mochitest/test_presentation_device_info.html b/dom/presentation/tests/mochitest/test_presentation_device_info.html
deleted file mode 100644
index 77253e41d..000000000
--- a/dom/presentation/tests/mochitest/test_presentation_device_info.html
+++ /dev/null
@@ -1,144 +0,0 @@
-<!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 B2G Presentation Device Info API</title>
- <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
- <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1080474">Test for B2G Presentation Device Info API</a>
-<script type="application/javascript;version=1.8">
-
-'use strict';
-
-SimpleTest.waitForExplicitFinish();
-
-var testDevice = {
- id: 'id',
- name: 'name',
- type: 'type',
-};
-
-var gUrl = SimpleTest.getTestFileURL('PresentationDeviceInfoChromeScript.js');
-var gScript = SpecialPowers.loadChromeScript(gUrl);
-
-function testSetup() {
- return new Promise(function(resolve, reject) {
- gScript.addMessageListener('setup-complete', function() {
- resolve();
- });
- gScript.sendAsyncMessage('setup');
- });
-}
-
-function testForceDiscovery() {
- info('test force discovery');
- return new Promise(function(resolve, reject) {
- gScript.addMessageListener('force-discovery', function() {
- ok(true, 'nsIPresentationDeviceProvider.forceDiscovery is invoked');
- resolve();
- });
- navigator.mozPresentationDeviceInfo.forceDiscovery();
- });
-}
-
-function testDeviceAdd() {
- info('test device add');
- return new Promise(function(resolve, reject) {
- navigator.mozPresentationDeviceInfo.addEventListener('devicechange', function deviceChangeHandler(e) {
- navigator.mozPresentationDeviceInfo.removeEventListener('devicechange', deviceChangeHandler);
- let detail = e.detail;
- is(detail.type, 'add', 'expected update type');
- is(detail.deviceInfo.id, testDevice.id, 'expected device id');
- is(detail.deviceInfo.name, testDevice.name, 'expected device name');
- is(detail.deviceInfo.type, testDevice.type, 'expected device type');
-
- navigator.mozPresentationDeviceInfo.getAll()
- .then(function(devices) {
- is(devices.length, 1, 'expected 1 available device');
- is(devices[0].id, testDevice.id, 'expected device id');
- is(devices[0].name, testDevice.name, 'expected device name');
- is(devices[0].type, testDevice.type, 'expected device type');
- resolve();
- });
- });
- gScript.sendAsyncMessage('trigger-device-add', testDevice);
- });
-}
-
-function testDeviceUpdate() {
- info('test device update');
- return new Promise(function(resolve, reject) {
- testDevice.name = 'name-update';
-
- navigator.mozPresentationDeviceInfo.addEventListener('devicechange', function deviceChangeHandler(e) {
- navigator.mozPresentationDeviceInfo.removeEventListener('devicechange', deviceChangeHandler);
- let detail = e.detail;
- is(detail.type, 'update', 'expected update type');
- is(detail.deviceInfo.id, testDevice.id, 'expected device id');
- is(detail.deviceInfo.name, testDevice.name, 'expected device name');
- is(detail.deviceInfo.type, testDevice.type, 'expected device type');
-
- navigator.mozPresentationDeviceInfo.getAll()
- .then(function(devices) {
- is(devices.length, 1, 'expected 1 available device');
- is(devices[0].id, testDevice.id, 'expected device id');
- is(devices[0].name, testDevice.name, 'expected device name');
- is(devices[0].type, testDevice.type, 'expected device type');
- resolve();
- });
- });
- gScript.sendAsyncMessage('trigger-device-update', testDevice);
- });
-}
-
-function testDeviceRemove() {
- info('test device remove');
- return new Promise(function(resolve, reject) {
- navigator.mozPresentationDeviceInfo.addEventListener('devicechange', function deviceChangeHandler(e) {
- navigator.mozPresentationDeviceInfo.removeEventListener('devicechange', deviceChangeHandler);
- let detail = e.detail;
- is(detail.type, 'remove', 'expected update type');
- is(detail.deviceInfo.id, testDevice.id, 'expected device id');
- is(detail.deviceInfo.name, testDevice.name, 'expected device name');
- is(detail.deviceInfo.type, testDevice.type, 'expected device type');
-
- navigator.mozPresentationDeviceInfo.getAll()
- .then(function(devices) {
- is(devices.length, 0, 'expected 0 available device');
- resolve();
- });
- });
- gScript.sendAsyncMessage('trigger-device-remove');
- });
-}
-
-function runTests() {
- testSetup()
- .then(testForceDiscovery)
- .then(testDeviceAdd)
- .then(testDeviceUpdate)
- .then(testDeviceRemove)
- .then(function() {
- info('test finished, teardown');
- gScript.sendAsyncMessage('teardown', '');
- gScript.destroy();
- SimpleTest.finish();
- });
-}
-
-window.addEventListener('load', function() {
- SpecialPowers.pushPrefEnv({
- 'set': [
- ['dom.presentation.enabled', true],
- ]
- }, runTests);
-});
-
-</script>
-</pre>
-</body>
-</html>