mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1475004 - Enable ESLint for dom/presentation - manual fixes. r=mccr8
MozReview-Commit-ID: 8UGertZYKk --HG-- extra : rebase_source : ca00ad17ef23739d62e8e9e1336cb0fe07a7c379
This commit is contained in:
parent
a0026662dd
commit
d0d3486293
@ -229,10 +229,6 @@ dom/permission/**
|
||||
dom/plugins/test/mochitest/**
|
||||
dom/plugins/test/unit/**
|
||||
dom/power/**
|
||||
dom/presentation/Presentation*.js
|
||||
dom/presentation/provider/**
|
||||
dom/presentation/tests/mochitest/**
|
||||
dom/presentation/tests/xpcshell/**
|
||||
dom/promise/**
|
||||
dom/push/**
|
||||
dom/quota/**
|
||||
|
@ -3,15 +3,10 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* jshint esnext:true, globalstrict:true, moz:true, undef:true, unused:true */
|
||||
/* globals Components, dump */
|
||||
"use strict";
|
||||
|
||||
// globals XPCOMUtils
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
// globals Services
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
// globals EventDispatcher
|
||||
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
|
||||
|
||||
function log(str) {
|
||||
@ -328,9 +323,7 @@ ChromecastRemoteDisplayDevice.prototype = {
|
||||
},
|
||||
|
||||
isRequestedUrlSupported: function CRDD_isRequestedUrlSupported(aUrl) {
|
||||
let url = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService)
|
||||
.newURI(aUrl);
|
||||
let url = Services.io.newURI(aUrl);
|
||||
return url.scheme == "http" || url.scheme == "https";
|
||||
},
|
||||
|
||||
|
@ -1,24 +1,16 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
/* jshint esnext:true, globalstrict:true, moz:true, undef:true, unused:true */
|
||||
/* globals Components, dump */
|
||||
"use strict";
|
||||
|
||||
/* globals XPCOMUtils */
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
/* globals Services */
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
/* globals NetUtil */
|
||||
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
/* globals setTimeout, clearTimeout */
|
||||
ChromeUtils.import("resource://gre/modules/Timer.jsm");
|
||||
|
||||
/* globals ControllerStateMachine */
|
||||
ChromeUtils.defineModuleGetter(this, "ControllerStateMachine", // jshint ignore:line
|
||||
ChromeUtils.defineModuleGetter(this, "ControllerStateMachine",
|
||||
"resource://gre/modules/presentation/ControllerStateMachine.jsm");
|
||||
/* global ReceiverStateMachine */
|
||||
ChromeUtils.defineModuleGetter(this, "ReceiverStateMachine", // jshint ignore:line
|
||||
ChromeUtils.defineModuleGetter(this, "ReceiverStateMachine",
|
||||
"resource://gre/modules/presentation/ReceiverStateMachine.jsm");
|
||||
|
||||
const kProtocolVersion = 1; // need to review isCompatibleServer while fiddling the version number.
|
||||
@ -859,7 +851,7 @@ TCPControlChannel.prototype = {
|
||||
DEBUG && log("TCPControlChannel - reconnect with role: " +
|
||||
this._direction); // jshint ignore:line
|
||||
if (this._direction != "sender") {
|
||||
return Cr.NS_ERROR_FAILURE;
|
||||
throw Cr.NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
this._stateMachine.reconnect(aPresentationId, aUrl);
|
||||
|
7
dom/presentation/tests/mochitest/.eslintrc.js
Normal file
7
dom/presentation/tests/mochitest/.eslintrc.js
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"plugin:mozilla/mochitest-test"
|
||||
]
|
||||
};
|
@ -3,7 +3,9 @@
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||
|
||||
const manager = Cc["@mozilla.org/presentation-device/manager;1"]
|
||||
.getService(Ci.nsIPresentationDeviceManager);
|
||||
|
@ -3,6 +3,8 @@
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
const Cm = Components.manager;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
@ -124,11 +126,11 @@ const mockedControlChannel = {
|
||||
var isValid = false;
|
||||
if (aSDP.type == Ci.nsIPresentationChannelDescription.TYPE_TCP) {
|
||||
try {
|
||||
var addresses = aSDP.tcpAddress;
|
||||
if (addresses.length > 0) {
|
||||
for (var i = 0; i < addresses.length; i++) {
|
||||
var sdpAddresses = aSDP.tcpAddress;
|
||||
if (sdpAddresses.length > 0) {
|
||||
for (var i = 0; i < sdpAddresses.length; i++) {
|
||||
// Ensure CString addresses are used. Otherwise, an error will be thrown.
|
||||
addresses.queryElementAt(i, Ci.nsISupportsCString);
|
||||
sdpAddresses.queryElementAt(i, Ci.nsISupportsCString);
|
||||
}
|
||||
|
||||
isValid = true;
|
||||
@ -255,11 +257,11 @@ const mockedSessionTransport = {
|
||||
this._listener = listener;
|
||||
this._role = Ci.nsIPresentationService.ROLE_RECEIVER;
|
||||
|
||||
var addresses = description.QueryInterface(Ci.nsIPresentationChannelDescription).tcpAddress;
|
||||
var tcpAddresses = description.QueryInterface(Ci.nsIPresentationChannelDescription).tcpAddress;
|
||||
this._selfAddress = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsINetAddr]),
|
||||
address: (addresses.length > 0) ?
|
||||
addresses.queryElementAt(0, Ci.nsISupportsCString).data : "",
|
||||
address: (tcpAddresses.length > 0) ?
|
||||
tcpAddresses.queryElementAt(0, Ci.nsISupportsCString).data : "",
|
||||
port: description.QueryInterface(Ci.nsIPresentationChannelDescription).tcpPort,
|
||||
};
|
||||
|
||||
@ -464,10 +466,8 @@ addMessageListener("restore-control-channel-listener", function(message) {
|
||||
controlChannelListener = null;
|
||||
});
|
||||
|
||||
var obs = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
obs.addObserver(function observer(aSubject, aTopic, aData) {
|
||||
obs.removeObserver(observer, aTopic);
|
||||
Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(observer, aTopic);
|
||||
|
||||
requestPromise = aSubject;
|
||||
}, "setup-request-promise");
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
const Cm = Components.manager;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
@ -251,8 +253,6 @@ function initMockAndListener() {
|
||||
originalFactory };
|
||||
}
|
||||
// Register mock factories.
|
||||
const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"]
|
||||
.getService(Ci.nsIUUIDGenerator);
|
||||
originalFactoryData.push(registerMockFactory("@mozilla.org/presentation-device/prompt;1",
|
||||
uuidGenerator.generateUUID(),
|
||||
mockDevicePrompt));
|
||||
@ -326,10 +326,9 @@ function initMockAndListener() {
|
||||
|
||||
addMessageListener("teardown", teardown);
|
||||
|
||||
var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
obs.addObserver(function setupRequestPromiseHandler(aSubject, aTopic, aData) {
|
||||
Services.obs.addObserver(function setupRequestPromiseHandler(aSubject, aTopic, aData) {
|
||||
debug("Got observer: setup-request-promise");
|
||||
obs.removeObserver(setupRequestPromiseHandler, aTopic);
|
||||
Services.obs.removeObserver(setupRequestPromiseHandler, aTopic);
|
||||
mockRequestUIGlue.promise = aSubject;
|
||||
sendAsyncMessage("promise-setup-ready");
|
||||
}, "setup-request-promise");
|
||||
|
@ -2,6 +2,8 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
function loadPrivilegedScriptTest() {
|
||||
/**
|
||||
* The script is loaded as
|
||||
@ -34,6 +36,7 @@ function loadPrivilegedScriptTest() {
|
||||
handlers[type].forEach(handler => handler.apply(null, args));
|
||||
};
|
||||
var handlers = {};
|
||||
/* eslint-disable-next-line no-native-reassign */
|
||||
addMessageListener = function(message, handler) {
|
||||
if (handlers.hasOwnProperty(message)) {
|
||||
handlers[message].push(handler);
|
||||
@ -41,6 +44,7 @@ function loadPrivilegedScriptTest() {
|
||||
handlers[message] = [handler];
|
||||
}
|
||||
};
|
||||
/* eslint-disable-next-line no-native-reassign */
|
||||
removeMessageListener = function(message, handler) {
|
||||
if (!handler || !handlers.hasOwnProperty(message)) {
|
||||
return;
|
||||
@ -55,6 +59,7 @@ function loadPrivilegedScriptTest() {
|
||||
const Cm = Components.manager;
|
||||
|
||||
const mockedChannelDescription = {
|
||||
/* eslint-disable-next-line mozilla/use-chromeutils-generateqi */
|
||||
QueryInterface(iid) {
|
||||
const interfaces = [Ci.nsIPresentationChannelDescription];
|
||||
|
||||
@ -64,6 +69,7 @@ function loadPrivilegedScriptTest() {
|
||||
return this;
|
||||
},
|
||||
get type() {
|
||||
/* global Services */
|
||||
if (Services.prefs.getBoolPref("dom.presentation.session_transport.data_channel.enable")) {
|
||||
return Ci.nsIPresentationChannelDescription.TYPE_DATACHANNEL;
|
||||
}
|
||||
@ -83,6 +89,7 @@ function loadPrivilegedScriptTest() {
|
||||
}
|
||||
|
||||
const mockedSessionTransport = {
|
||||
/* eslint-disable-next-line mozilla/use-chromeutils-generateqi */
|
||||
QueryInterface(iid) {
|
||||
const interfaces = [Ci.nsIPresentationSessionTransport,
|
||||
Ci.nsIPresentationDataChannelSessionTransportBuilder,
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
function ok(a, msg) {
|
||||
alert((a ? "OK " : "KO ") + msg);
|
||||
function is(a, b, msg) {
|
||||
alert((a === b ? "OK " : "KO ") + msg);
|
||||
}
|
||||
|
||||
function testConnectionAvailable() {
|
||||
|
@ -85,7 +85,7 @@ function testConnectionUnavailableDiffOriginInnerIframe() {
|
||||
function testConnectionListSameObject() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
is(navigator.presentation.receiver.connectionList, navigator.presentation.receiver.connectionList, "The promise should be the same object.");
|
||||
var promise = navigator.presentation.receiver.connectionList.then(
|
||||
navigator.presentation.receiver.connectionList.then(
|
||||
function(aList) {
|
||||
is(connection, aList.connections[0], "The connection from list and the one from |connectionavailable| event should be the same.");
|
||||
aResolve();
|
||||
|
@ -55,7 +55,6 @@ function testStartRequest() {
|
||||
},
|
||||
function(aError) {
|
||||
ok(false, "Error occurred when establishing a connection: " + aError);
|
||||
teardown();
|
||||
aReject();
|
||||
}
|
||||
);
|
||||
|
@ -65,8 +65,7 @@ function setup() {
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
});
|
||||
|
||||
|
@ -74,8 +74,7 @@ function setup() {
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
});
|
||||
|
||||
|
@ -87,13 +87,13 @@ function testOnChangeEvent() {
|
||||
}
|
||||
|
||||
function testConsecutiveGetAvailability() {
|
||||
let request = new PresentationRequest("https://example.org");
|
||||
let presRequest = new PresentationRequest("https://example.org");
|
||||
let firstAvailabilityResolved = false;
|
||||
return Promise.all([
|
||||
request.getAvailability().then(function() {
|
||||
presRequest.getAvailability().then(function() {
|
||||
firstAvailabilityResolved = true;
|
||||
}),
|
||||
request.getAvailability().then(function() {
|
||||
presRequest.getAvailability().then(function() {
|
||||
ok(firstAvailabilityResolved, "getAvailability() should be resolved in sequence");
|
||||
})
|
||||
]).catch(function(aError) {
|
||||
@ -105,8 +105,8 @@ function testConsecutiveGetAvailability() {
|
||||
function testUnsupportedDeviceAvailability() {
|
||||
return Promise.race([
|
||||
new Promise(function(aResolve, aReject) {
|
||||
let request = new PresentationRequest("https://test.com");
|
||||
request.getAvailability().then(function(aAvailability) {
|
||||
let presRequest = new PresentationRequest("https://test.com");
|
||||
presRequest.getAvailability().then(function(aAvailability) {
|
||||
availability = aAvailability;
|
||||
aAvailability.onchange = function() {
|
||||
availability.onchange = null;
|
||||
|
@ -30,8 +30,8 @@ var serverTransport;
|
||||
const clientMessage = "Client Message";
|
||||
const serverMessage = "Server Message";
|
||||
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
|
||||
|
||||
var isClientReady = false;
|
||||
var isServerReady = false;
|
||||
|
@ -20,8 +20,7 @@
|
||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("PresentationSessionChromeScript.js"));
|
||||
var receiverUrl = SimpleTest.getTestFileURL("file_presentation_receiver.html");
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
|
||||
function setup() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
@ -51,10 +50,10 @@ function setup() {
|
||||
}
|
||||
});
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
var promise = new Promise(function(aInnerResolve, aInnerReject) {
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
aResolve(iframe);
|
||||
aInnerResolve(iframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
|
||||
|
@ -25,8 +25,7 @@ var nonReceiverUrl = SimpleTest.getTestFileURL("file_presentation_non_receiver.h
|
||||
var isReceiverFinished = false;
|
||||
var isNonReceiverFinished = false;
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
var receiverIframe;
|
||||
|
||||
function setup() {
|
||||
@ -69,14 +68,14 @@ function setup() {
|
||||
}
|
||||
});
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
var promise = new Promise(function(aInnerResolve, aInnerReject) {
|
||||
document.body.appendChild(receiverIframe);
|
||||
receiverIframe.addEventListener("mozbrowserloadstart", function() {
|
||||
var mm = SpecialPowers.getBrowserFrameMessageManager(receiverIframe);
|
||||
mm.loadFrameScript("data:,(" + loadPrivilegedScriptTest.toString() + ")();", false);
|
||||
}, {once: true});
|
||||
|
||||
aResolve(receiverIframe);
|
||||
aInnerResolve(receiverIframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
|
||||
|
@ -78,12 +78,12 @@ let testRequestAndReceiver = (request) => new Promise((resolve, reject) => {
|
||||
resolve(iframe);
|
||||
}, {once: true});
|
||||
|
||||
let promise = new Promise((resolve) => {
|
||||
let promise = new Promise((aInnerResolve) => {
|
||||
document.body.appendChild(iframe);
|
||||
resolve(iframe);
|
||||
aInnerResolve(iframe);
|
||||
});
|
||||
|
||||
let obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"].getService(SpecialPowers.Ci.nsIObserverService);
|
||||
let obs = SpecialPowers.Services.obs;
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
});
|
||||
|
||||
|
@ -3,49 +3,44 @@
|
||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("PresentationSessionChromeScript.js"));
|
||||
var receiverUrl = SimpleTest.getTestFileURL("file_presentation_receiver_auxiliary_navigation.html");
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
|
||||
function setup() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("mozbrowser", "true");
|
||||
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||
var oop = !location.pathname.includes("_inproc");
|
||||
iframe.setAttribute("remote", oop);
|
||||
iframe.setAttribute("src", receiverUrl);
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("mozbrowser", "true");
|
||||
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||
var oop = !location.pathname.includes("_inproc");
|
||||
iframe.setAttribute("remote", oop);
|
||||
iframe.setAttribute("src", receiverUrl);
|
||||
|
||||
// This event is triggered when the iframe calls "postMessage".
|
||||
iframe.addEventListener("mozbrowsershowmodalprompt", function listener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
iframe.removeEventListener("mozbrowsershowmodalprompt", listener);
|
||||
// This event is triggered when the iframe calls "postMessage".
|
||||
iframe.addEventListener("mozbrowsershowmodalprompt", function listener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
iframe.removeEventListener("mozbrowsershowmodalprompt", listener);
|
||||
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
aResolve(iframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
|
||||
aResolve();
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
aResolve(iframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
@ -59,7 +54,7 @@ function teardown() {
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setup().then();
|
||||
setup();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -20,71 +20,66 @@
|
||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("PresentationSessionChromeScript.js"));
|
||||
var receiverUrl = SimpleTest.getTestFileURL("file_presentation_receiver.html");
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
|
||||
function setup() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("mozbrowser", "true");
|
||||
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||
iframe.setAttribute("src", receiverUrl);
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("mozbrowser", "true");
|
||||
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||
iframe.setAttribute("src", receiverUrl);
|
||||
|
||||
// This event is triggered when the iframe calls "postMessage".
|
||||
iframe.addEventListener("mozbrowsershowmodalprompt", function listener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
iframe.removeEventListener("mozbrowsershowmodalprompt", listener);
|
||||
// This event is triggered when the iframe calls "postMessage".
|
||||
iframe.addEventListener("mozbrowsershowmodalprompt", function listener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
iframe.removeEventListener("mozbrowsershowmodalprompt", listener);
|
||||
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(iframe);
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
aResolve(iframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
aResolve(iframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
|
||||
gScript.addMessageListener("offer-received", function offerReceivedHandler() {
|
||||
gScript.removeMessageListener("offer-received", offerReceivedHandler);
|
||||
info("An offer is received.");
|
||||
});
|
||||
gScript.addMessageListener("offer-received", function offerReceivedHandler() {
|
||||
gScript.removeMessageListener("offer-received", offerReceivedHandler);
|
||||
info("An offer is received.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("answer-sent", function answerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener("answer-sent", answerSentHandler);
|
||||
ok(aIsValid, "A valid answer is sent.");
|
||||
});
|
||||
gScript.addMessageListener("answer-sent", function answerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener("answer-sent", answerSentHandler);
|
||||
ok(aIsValid, "A valid answer is sent.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("control-channel-closed", function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("control-channel-closed", controlChannelClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The control channel is closed normally.");
|
||||
});
|
||||
gScript.addMessageListener("control-channel-closed", function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("control-channel-closed", controlChannelClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The control channel is closed normally.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("data-transport-notification-enabled", function dataTransportNotificationEnabledHandler() {
|
||||
gScript.removeMessageListener("data-transport-notification-enabled", dataTransportNotificationEnabledHandler);
|
||||
info("Data notification is enabled for data transport channel.");
|
||||
});
|
||||
gScript.addMessageListener("data-transport-notification-enabled", function dataTransportNotificationEnabledHandler() {
|
||||
gScript.removeMessageListener("data-transport-notification-enabled", dataTransportNotificationEnabledHandler);
|
||||
info("Data notification is enabled for data transport channel.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("data-transport-closed", function dataTransportClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("data-transport-closed", dataTransportClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The data transport should be closed normally.");
|
||||
});
|
||||
|
||||
aResolve();
|
||||
gScript.addMessageListener("data-transport-closed", function dataTransportClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("data-transport-closed", dataTransportClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The data transport should be closed normally.");
|
||||
});
|
||||
}
|
||||
|
||||
@ -114,8 +109,8 @@ function teardown() {
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setup().
|
||||
then(testIncomingSessionRequest);
|
||||
setup();
|
||||
testIncomingSessionRequest();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -17,50 +17,45 @@
|
||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("PresentationSessionChromeScript.js"));
|
||||
var receiverUrl = SimpleTest.getTestFileURL("file_presentation_receiver_establish_connection_error.html");
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
|
||||
function setup() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("src", receiverUrl);
|
||||
iframe.setAttribute("mozbrowser", "true");
|
||||
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.setAttribute("src", receiverUrl);
|
||||
iframe.setAttribute("mozbrowser", "true");
|
||||
iframe.setAttribute("mozpresentation", receiverUrl);
|
||||
|
||||
// This event is triggered when the iframe calls "alert".
|
||||
iframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(evt) {
|
||||
var message = evt.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, message.replace(/^OK /, ""));
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, message.replace(/^KO /, ""));
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info(message.replace(/^INFO /, ""));
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
iframe.removeEventListener("mozbrowsershowmodalprompt",
|
||||
receiverListener);
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
// This event is triggered when the iframe calls "alert".
|
||||
iframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(evt) {
|
||||
var message = evt.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, message.replace(/^OK /, ""));
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, message.replace(/^KO /, ""));
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info(message.replace(/^INFO /, ""));
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
iframe.removeEventListener("mozbrowsershowmodalprompt",
|
||||
receiverListener);
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(iframe);
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
aResolve(iframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
aResolve(iframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
|
||||
gScript.addMessageListener("control-channel-closed", function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("control-channel-closed", controlChannelClosedHandler);
|
||||
is(aReason, 0x80004004 /* NS_ERROR_ABORT */, "The control channel is closed abnormally.");
|
||||
});
|
||||
|
||||
aResolve();
|
||||
gScript.addMessageListener("control-channel-closed", function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("control-channel-closed", controlChannelClosedHandler);
|
||||
is(aReason, 0x80004004 /* NS_ERROR_ABORT */, "The control channel is closed abnormally.");
|
||||
});
|
||||
}
|
||||
|
||||
@ -88,8 +83,8 @@ function teardown() {
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setup().
|
||||
then(testIncomingSessionRequest);
|
||||
setup();
|
||||
testIncomingSessionRequest();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -16,20 +16,15 @@
|
||||
|
||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("PresentationSessionChromeScript.js"));
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
|
||||
function setup() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
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");
|
||||
|
||||
aResolve();
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
// In order to trigger timeout, do not resolve the promise.
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
}
|
||||
|
||||
function testIncomingSessionRequestReceiverLaunchTimeout() {
|
||||
@ -60,8 +55,8 @@ function teardown() {
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setup().
|
||||
then(testIncomingSessionRequestReceiverLaunchTimeout).
|
||||
setup();
|
||||
testIncomingSessionRequestReceiverLaunchTimeout().
|
||||
then(teardown);
|
||||
}
|
||||
|
||||
|
@ -3,31 +3,26 @@
|
||||
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("PresentationSessionChromeScript.js"));
|
||||
var receiverUrl = SimpleTest.getTestFileURL("file_presentation_unknown_content_type.test");
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
|
||||
var receiverIframe;
|
||||
|
||||
function setup() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
|
||||
receiverIframe = document.createElement("iframe");
|
||||
receiverIframe.setAttribute("mozbrowser", "true");
|
||||
receiverIframe.setAttribute("mozpresentation", receiverUrl);
|
||||
receiverIframe.setAttribute("src", receiverUrl);
|
||||
var oop = !location.pathname.includes("_inproc");
|
||||
receiverIframe.setAttribute("remote", oop);
|
||||
receiverIframe = document.createElement("iframe");
|
||||
receiverIframe.setAttribute("mozbrowser", "true");
|
||||
receiverIframe.setAttribute("mozpresentation", receiverUrl);
|
||||
receiverIframe.setAttribute("src", receiverUrl);
|
||||
var oop = !location.pathname.includes("_inproc");
|
||||
receiverIframe.setAttribute("remote", oop);
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(receiverIframe);
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(receiverIframe);
|
||||
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
|
||||
aResolve();
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
}
|
||||
|
||||
function testIncomingSessionRequestReceiverLaunchUnknownContentType() {
|
||||
@ -67,9 +62,9 @@ function teardown() {
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setup().
|
||||
then(testIncomingSessionRequestReceiverLaunchUnknownContentType).
|
||||
then(teardown);
|
||||
setup();
|
||||
|
||||
testIncomingSessionRequestReceiverLaunchUnknownContentType().then(teardown);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -24,109 +24,104 @@ var nonReceiverUrl = SimpleTest.getTestFileURL("file_presentation_non_receiver.h
|
||||
var isReceiverFinished = false;
|
||||
var isNonReceiverFinished = false;
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
|
||||
function setup() {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
gScript.sendAsyncMessage("trigger-device-add");
|
||||
|
||||
// Create a receiver OOP iframe.
|
||||
var receiverIframe = document.createElement("iframe");
|
||||
receiverIframe.setAttribute("remote", "true");
|
||||
receiverIframe.setAttribute("mozbrowser", "true");
|
||||
receiverIframe.setAttribute("mozpresentation", receiverUrl);
|
||||
receiverIframe.setAttribute("src", receiverUrl);
|
||||
// Create a receiver OOP iframe.
|
||||
var receiverIframe = document.createElement("iframe");
|
||||
receiverIframe.setAttribute("remote", "true");
|
||||
receiverIframe.setAttribute("mozbrowser", "true");
|
||||
receiverIframe.setAttribute("mozpresentation", receiverUrl);
|
||||
receiverIframe.setAttribute("src", receiverUrl);
|
||||
|
||||
// This event is triggered when the iframe calls "alert".
|
||||
receiverIframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
receiverIframe.removeEventListener("mozbrowsershowmodalprompt", receiverListener);
|
||||
// This event is triggered when the iframe calls "alert".
|
||||
receiverIframe.addEventListener("mozbrowsershowmodalprompt", function receiverListener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
receiverIframe.removeEventListener("mozbrowsershowmodalprompt", receiverListener);
|
||||
|
||||
isReceiverFinished = true;
|
||||
isReceiverFinished = true;
|
||||
|
||||
if (isNonReceiverFinished) {
|
||||
teardown();
|
||||
}
|
||||
if (isNonReceiverFinished) {
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(receiverIframe);
|
||||
var promise = new Promise(function(aResolve, aReject) {
|
||||
document.body.appendChild(receiverIframe);
|
||||
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
|
||||
// Create a non-receiver OOP iframe.
|
||||
var nonReceiverIframe = document.createElement("iframe");
|
||||
nonReceiverIframe.setAttribute("remote", "true");
|
||||
nonReceiverIframe.setAttribute("mozbrowser", "true");
|
||||
nonReceiverIframe.setAttribute("src", nonReceiverUrl);
|
||||
// Create a non-receiver OOP iframe.
|
||||
var nonReceiverIframe = document.createElement("iframe");
|
||||
nonReceiverIframe.setAttribute("remote", "true");
|
||||
nonReceiverIframe.setAttribute("mozbrowser", "true");
|
||||
nonReceiverIframe.setAttribute("src", nonReceiverUrl);
|
||||
|
||||
// This event is triggered when the iframe calls "alert".
|
||||
nonReceiverIframe.addEventListener("mozbrowsershowmodalprompt", function nonReceiverListener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
nonReceiverIframe.removeEventListener("mozbrowsershowmodalprompt", nonReceiverListener);
|
||||
// This event is triggered when the iframe calls "alert".
|
||||
nonReceiverIframe.addEventListener("mozbrowsershowmodalprompt", function nonReceiverListener(aEvent) {
|
||||
var message = aEvent.detail.message;
|
||||
if (/^OK /.exec(message)) {
|
||||
ok(true, "Message from iframe: " + message);
|
||||
} else if (/^KO /.exec(message)) {
|
||||
ok(false, "Message from iframe: " + message);
|
||||
} else if (/^INFO /.exec(message)) {
|
||||
info("Message from iframe: " + message);
|
||||
} else if (/^COMMAND /.exec(message)) {
|
||||
var command = JSON.parse(message.replace(/^COMMAND /, ""));
|
||||
gScript.sendAsyncMessage(command.name, command.data);
|
||||
} else if (/^DONE$/.exec(message)) {
|
||||
ok(true, "Messaging from iframe complete.");
|
||||
nonReceiverIframe.removeEventListener("mozbrowsershowmodalprompt", nonReceiverListener);
|
||||
|
||||
isNonReceiverFinished = true;
|
||||
isNonReceiverFinished = true;
|
||||
|
||||
if (isReceiverFinished) {
|
||||
teardown();
|
||||
}
|
||||
if (isReceiverFinished) {
|
||||
teardown();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
document.body.appendChild(nonReceiverIframe);
|
||||
document.body.appendChild(nonReceiverIframe);
|
||||
|
||||
gScript.addMessageListener("offer-received", function offerReceivedHandler() {
|
||||
gScript.removeMessageListener("offer-received", offerReceivedHandler);
|
||||
info("An offer is received.");
|
||||
});
|
||||
gScript.addMessageListener("offer-received", function offerReceivedHandler() {
|
||||
gScript.removeMessageListener("offer-received", offerReceivedHandler);
|
||||
info("An offer is received.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("answer-sent", function answerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener("answer-sent", answerSentHandler);
|
||||
ok(aIsValid, "A valid answer is sent.");
|
||||
});
|
||||
gScript.addMessageListener("answer-sent", function answerSentHandler(aIsValid) {
|
||||
gScript.removeMessageListener("answer-sent", answerSentHandler);
|
||||
ok(aIsValid, "A valid answer is sent.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("control-channel-closed", function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("control-channel-closed", controlChannelClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The control channel is closed normally.");
|
||||
});
|
||||
gScript.addMessageListener("control-channel-closed", function controlChannelClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("control-channel-closed", controlChannelClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The control channel is closed normally.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("data-transport-notification-enabled", function dataTransportNotificationEnabledHandler() {
|
||||
gScript.removeMessageListener("data-transport-notification-enabled", dataTransportNotificationEnabledHandler);
|
||||
info("Data notification is enabled for data transport channel.");
|
||||
});
|
||||
gScript.addMessageListener("data-transport-notification-enabled", function dataTransportNotificationEnabledHandler() {
|
||||
gScript.removeMessageListener("data-transport-notification-enabled", dataTransportNotificationEnabledHandler);
|
||||
info("Data notification is enabled for data transport channel.");
|
||||
});
|
||||
|
||||
gScript.addMessageListener("data-transport-closed", function dataTransportClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("data-transport-closed", dataTransportClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The data transport should be closed normally.");
|
||||
});
|
||||
|
||||
aResolve();
|
||||
gScript.addMessageListener("data-transport-closed", function dataTransportClosedHandler(aReason) {
|
||||
gScript.removeMessageListener("data-transport-closed", dataTransportClosedHandler);
|
||||
is(aReason, SpecialPowers.Cr.NS_OK, "The data transport should be closed normally.");
|
||||
});
|
||||
}
|
||||
|
||||
@ -154,8 +149,8 @@ function teardown() {
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setup().
|
||||
then(testIncomingSessionRequest);
|
||||
setup();
|
||||
testIncomingSessionRequest();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -65,8 +65,7 @@ function setup() {
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
});
|
||||
|
||||
|
@ -70,8 +70,7 @@ function setup() {
|
||||
aResolve(receiverIframe);
|
||||
});
|
||||
|
||||
var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(SpecialPowers.Ci.nsIObserverService);
|
||||
var obs = SpecialPowers.Services.obs;
|
||||
obs.notifyObservers(promise, "setup-request-promise");
|
||||
});
|
||||
|
||||
|
@ -248,7 +248,7 @@ function registerService() {
|
||||
serviceRegistered: 0,
|
||||
serviceUnregistered: 0
|
||||
};
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
|
||||
Assert.equal(mockObj.serviceRegistered, 0);
|
||||
@ -291,7 +291,7 @@ function noRegisterService() {
|
||||
resolveService(serviceInfo, listener) {},
|
||||
};
|
||||
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
|
||||
// Try register
|
||||
@ -337,7 +337,7 @@ function registerServiceDynamically() {
|
||||
serviceRegistered: 0,
|
||||
serviceUnregistered: 0
|
||||
};
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
|
||||
Assert.equal(mockObj.serviceRegistered, 0);
|
||||
@ -407,7 +407,7 @@ function addDevice() {
|
||||
}
|
||||
};
|
||||
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = new TestPresentationDeviceListener();
|
||||
Assert.equal(listener.count(), 0);
|
||||
@ -457,7 +457,7 @@ function filterDevice() {
|
||||
}
|
||||
};
|
||||
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
|
||||
@ -493,8 +493,6 @@ function handleSessionRequest() {
|
||||
Services.prefs.setBoolPref(PREF_DISCOVERY, true);
|
||||
Services.prefs.setBoolPref(PREF_DISCOVERABLE, false);
|
||||
|
||||
const testUrl = "http://example.com";
|
||||
const testPresentationId = "test-presentation-id";
|
||||
const testDeviceName = "test-device-name";
|
||||
|
||||
Services.prefs.setCharPref(PREF_DEVICENAME, testDeviceName);
|
||||
@ -542,8 +540,8 @@ function handleSessionRequest() {
|
||||
}
|
||||
};
|
||||
|
||||
let contractHookSD = new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
let contractHookServer = new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
|
||||
@ -555,7 +553,7 @@ function handleSessionRequest() {
|
||||
|
||||
provider.listener = listener;
|
||||
|
||||
let controlChannel = listener.device.establishControlChannel();
|
||||
listener.device.establishControlChannel();
|
||||
|
||||
Assert.equal(mockServerObj.request.deviceInfo.id, mockDevice.host);
|
||||
Assert.equal(mockServerObj.request.deviceInfo.address, mockDevice.host);
|
||||
@ -608,8 +606,8 @@ function handleOnSessionRequest() {
|
||||
listener: null,
|
||||
};
|
||||
|
||||
let contractHookSD = new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
let contractHookServer = new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
|
||||
@ -675,8 +673,8 @@ function handleOnSessionRequestFromUnknownDevice() {
|
||||
listener: null,
|
||||
};
|
||||
|
||||
let contractHookSD = new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
let contractHookServer = new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
|
||||
@ -729,7 +727,6 @@ function handleOnSessionRequestFromUnknownDevice() {
|
||||
function noAddDevice() {
|
||||
Services.prefs.setBoolPref(PREF_DISCOVERY, false);
|
||||
|
||||
let mockDevice = createDevice("device.local", 12345, "service.name", SERVICE_TYPE);
|
||||
let mockObj = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIDNSServiceDiscovery]),
|
||||
startDiscovery(serviceType, listener) {
|
||||
@ -739,7 +736,7 @@ function noAddDevice() {
|
||||
resolveService(serviceInfo, listener) {
|
||||
}
|
||||
};
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = {
|
||||
@ -820,8 +817,8 @@ function ignoreIncompatibleDevice() {
|
||||
listener: null,
|
||||
};
|
||||
|
||||
let contractHookSD = new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
let contractHookServer = new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = new TestPresentationDeviceListener();
|
||||
|
||||
@ -905,8 +902,8 @@ function ignoreSelfDevice() {
|
||||
listener: null,
|
||||
};
|
||||
|
||||
let contractHookSD = new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
let contractHookServer = new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = new TestPresentationDeviceListener();
|
||||
|
||||
@ -957,7 +954,7 @@ function addDeviceDynamically() {
|
||||
}
|
||||
};
|
||||
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = new TestPresentationDeviceListener();
|
||||
provider.listener = listener;
|
||||
@ -1022,7 +1019,7 @@ function updateDevice() {
|
||||
}
|
||||
};
|
||||
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
|
||||
@ -1113,7 +1110,7 @@ function diffDiscovery() {
|
||||
}
|
||||
};
|
||||
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = new TestPresentationDeviceListener();
|
||||
Assert.equal(listener.count(), 0);
|
||||
@ -1192,7 +1189,7 @@ function serverClosed() {
|
||||
serviceRegistered: 0,
|
||||
serviceUnregistered: 0
|
||||
};
|
||||
let contractHook = new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
|
||||
Assert.equal(mockObj.serviceRegistered, 0);
|
||||
@ -1272,8 +1269,8 @@ function serverRetry() {
|
||||
listener: null,
|
||||
};
|
||||
|
||||
let contractHookSD = new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
let contractHookServer = new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
new ContractHook(SD_CONTRACT_ID, mockSDObj);
|
||||
new ContractHook(SERVER_CONTRACT_ID, mockServerObj);
|
||||
let provider = Cc[PROVIDER_CONTRACT_ID].createInstance(Ci.nsIPresentationDeviceProvider);
|
||||
let listener = {
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceListener,
|
||||
@ -1293,7 +1290,7 @@ function run_test() {
|
||||
// Ensure PSM is initialized
|
||||
Cc["@mozilla.org/psm;1"].getService(Ci.nsISupports);
|
||||
|
||||
let infoHook = new ContractHook(INFO_CONTRACT_ID, MockDNSServiceInfo);
|
||||
new ContractHook(INFO_CONTRACT_ID, MockDNSServiceInfo);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref(PREF_DISCOVERY);
|
||||
|
@ -155,7 +155,6 @@ function sessionRequest() {
|
||||
}
|
||||
|
||||
function terminateRequest() {
|
||||
let testUrl = "http://www.example.org/";
|
||||
let testPresentationId = "test-presentation-id";
|
||||
let testControlChannel = new TestPresentationControlChannel();
|
||||
let testIsFromReceiver = true;
|
||||
|
@ -67,9 +67,9 @@ function launch() {
|
||||
Assert.equal(presentationId, testPresentationId, "expected presentationId received");
|
||||
Assert.equal(url, testUrl, "expected url received");
|
||||
|
||||
mockControllerChannel.notifyLaunch = function(presentationId) {
|
||||
mockControllerChannel.notifyLaunch = function(presId) {
|
||||
Assert.equal(controllerState.state, State.CONNECTED, "controller in connected state");
|
||||
Assert.equal(presentationId, testPresentationId, "expected presentationId received from ack");
|
||||
Assert.equal(presId, testPresentationId, "expected presentationId received from ack");
|
||||
|
||||
run_next_test();
|
||||
};
|
||||
@ -85,9 +85,9 @@ function terminateByController() {
|
||||
Assert.equal(receiverState.state, State.CONNECTED, "receiver in connected state");
|
||||
Assert.equal(presentationId, testPresentationId, "expected presentationId received");
|
||||
|
||||
mockControllerChannel.notifyTerminate = function(presentationId) {
|
||||
mockControllerChannel.notifyTerminate = function(presId) {
|
||||
Assert.equal(controllerState.state, State.CONNECTED, "controller in connected state");
|
||||
Assert.equal(presentationId, testPresentationId, "expected presentationId received from ack");
|
||||
Assert.equal(presId, testPresentationId, "expected presentationId received from ack");
|
||||
|
||||
run_next_test();
|
||||
};
|
||||
@ -105,9 +105,9 @@ function terminateByReceiver() {
|
||||
Assert.equal(controllerState.state, State.CONNECTED, "controller in connected state");
|
||||
Assert.equal(presentationId, testPresentationId, "expected presentationId received");
|
||||
|
||||
mockReceiverChannel.notifyTerminate = function(presentationId) {
|
||||
mockReceiverChannel.notifyTerminate = function(presId) {
|
||||
Assert.equal(receiverState.state, State.CONNECTED, "receiver in connected state");
|
||||
Assert.equal(presentationId, testPresentationId, "expected presentationId received from ack");
|
||||
Assert.equal(presId, testPresentationId, "expected presentationId received from ack");
|
||||
run_next_test();
|
||||
};
|
||||
|
||||
@ -135,8 +135,8 @@ function exchangeSDP() {
|
||||
Assert.equal(candidate, testIceCandidate, "expected ice candidate received in receiver");
|
||||
|
||||
receiverState.updateIceCandidate(testIceCandidate);
|
||||
mockControllerChannel.notifyIceCandidate = function(candidate) {
|
||||
Assert.equal(candidate, testIceCandidate, "expected ice candidate received in controller");
|
||||
mockControllerChannel.notifyIceCandidate = function(controllerCandidate) {
|
||||
Assert.equal(controllerCandidate, testIceCandidate, "expected ice candidate received in controller");
|
||||
|
||||
run_next_test();
|
||||
};
|
||||
@ -157,8 +157,8 @@ function disconnect() {
|
||||
receiverState.onChannelClosed(Cr.NS_OK, true);
|
||||
Assert.equal(receiverState.state, State.CLOSED, "receiver in closed state");
|
||||
|
||||
mockControllerChannel.notifyDisconnected = function(reason) {
|
||||
Assert.equal(reason, Cr.NS_OK, "receive close reason");
|
||||
mockControllerChannel.notifyDisconnected = function(disconnectReason) {
|
||||
Assert.equal(disconnectReason, Cr.NS_OK, "receive close reason");
|
||||
Assert.equal(controllerState.state, State.CLOSED, "controller in closed state");
|
||||
|
||||
run_next_test();
|
||||
@ -183,8 +183,8 @@ function receiverDisconnect() {
|
||||
controllerState.onChannelClosed(Cr.NS_OK, true);
|
||||
Assert.equal(controllerState.state, State.CLOSED, "controller in closed state");
|
||||
|
||||
mockReceiverChannel.notifyDisconnected = function(reason) {
|
||||
Assert.equal(reason, Cr.NS_OK, "receive close reason");
|
||||
mockReceiverChannel.notifyDisconnected = function(disconnectReason) {
|
||||
Assert.equal(disconnectReason, Cr.NS_OK, "receive close reason");
|
||||
Assert.equal(receiverState.state, State.CLOSED, "receiver in closed state");
|
||||
|
||||
run_next_test();
|
||||
@ -210,8 +210,8 @@ function abnormalDisconnect() {
|
||||
receiverState.onChannelClosed(Cr.NS_OK, true);
|
||||
Assert.equal(receiverState.state, State.CLOSED, "receiver in closed state");
|
||||
|
||||
mockControllerChannel.notifyDisconnected = function(reason) {
|
||||
Assert.equal(reason, testErrorReason, "receive abnormal close reason");
|
||||
mockControllerChannel.notifyDisconnected = function(disconnectReason) {
|
||||
Assert.equal(disconnectReason, testErrorReason, "receive abnormal close reason");
|
||||
Assert.equal(controllerState.state, State.CLOSED, "controller in closed state");
|
||||
|
||||
run_next_test();
|
||||
|
Loading…
Reference in New Issue
Block a user