diff --git a/dom/presentation/PresentationDataChannelSessionTransport.js b/dom/presentation/PresentationDataChannelSessionTransport.js index 6fa7739fd26e..94b2d5568a40 100644 --- a/dom/presentation/PresentationDataChannelSessionTransport.js +++ b/dom/presentation/PresentationDataChannelSessionTransport.js @@ -9,7 +9,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm"); // Bug 1228209 - plan to remove this eventually function log(aMsg) { - //dump("-*- PresentationDataChannelSessionTransport.js : " + aMsg + "\n"); + // dump("-*- PresentationDataChannelSessionTransport.js : " + aMsg + "\n"); } const PRESENTATIONTRANSPORT_CID = Components.ID("{dd2bbf2f-3399-4389-8f5f-d382afb8b2d6}"); @@ -50,7 +50,7 @@ PresentationTransportBuilder.prototype = { Ci.nsIPresentationDataChannelSessionTransportBuilder, Ci.nsITimerCallback]), - buildDataChannelTransport: function(aRole, aWindow, aListener) { + buildDataChannelTransport(aRole, aWindow, aListener) { if (!aRole || !aWindow || !aListener) { log("buildDataChannelTransport with illegal parameters"); throw Cr.NS_ERROR_ILLEGAL_VALUE; @@ -85,7 +85,7 @@ PresentationTransportBuilder.prototype = { .then(() => this._listener .sendOffer(new PresentationDataChannelDescription(this._peerConnection.localDescription))) .catch(e => this._reportError(e)); - } + }; switch (this._role) { case Ci.nsIPresentationService.ROLE_CONTROLLER: @@ -99,7 +99,7 @@ PresentationTransportBuilder.prototype = { // Ensure the binaryType of dataChannel is blob. this._dataChannel.binaryType = "blob"; this._setDataChannel(); - } + }; break; default: throw Cr.NS_ERROR_ILLEGAL_VALUE; @@ -114,18 +114,18 @@ PresentationTransportBuilder.prototype = { this._timer.initWithCallback(this, timeout, this._timer.TYPE_ONE_SHOT); }, - notify: function() { + notify() { if (!this._sessionTransport) { this._cleanup(Cr.NS_ERROR_NET_TIMEOUT); } }, - _reportError: function(aError) { + _reportError(aError) { log("report Error " + aError.name + ":" + aError.message); this._cleanup(Cr.NS_ERROR_FAILURE); }, - _setDataChannel: function() { + _setDataChannel() { this._dataChannel.onopen = () => { log("data channel is open, notify the listener, role " + this._role); @@ -146,10 +146,10 @@ PresentationTransportBuilder.prototype = { this._dataChannel.onerror = aError => { log("data channel onerror " + aError.name + ":" + aError.message); this._cleanup(Cr.NS_ERROR_FAILURE); - } + }; }, - _cleanup: function(aReason) { + _cleanup(aReason) { if (aReason != Cr.NS_OK) { this._listener.onError(aReason); } @@ -177,7 +177,7 @@ PresentationTransportBuilder.prototype = { }, // nsIPresentationControlChannelListener - onOffer: function(aOffer) { + onOffer(aOffer) { if (this._role !== Ci.nsIPresentationService.ROLE_RECEIVER || this._sessionTransport) { log("onOffer status error"); @@ -196,11 +196,11 @@ PresentationTransportBuilder.prototype = { .then(() => { this._isControlChannelNeeded = false; this._listener - .sendAnswer(new PresentationDataChannelDescription(this._peerConnection.localDescription)) + .sendAnswer(new PresentationDataChannelDescription(this._peerConnection.localDescription)); }).catch(e => this._reportError(e)); }, - onAnswer: function(aAnswer) { + onAnswer(aAnswer) { if (this._role !== Ci.nsIPresentationService.ROLE_CONTROLLER || this._sessionTransport) { log("onAnswer status error"); @@ -216,7 +216,7 @@ PresentationTransportBuilder.prototype = { this._isControlChannelNeeded = false; }, - onIceCandidate: function(aCandidate) { + onIceCandidate(aCandidate) { log("onIceCandidate: " + aCandidate + " with role " + this._role); if (!this._window || !this._peerConnection) { log("ignoring ICE candidate after connection"); @@ -226,7 +226,7 @@ PresentationTransportBuilder.prototype = { this._peerConnection.addIceCandidate(candidate).catch(e => this._reportError(e)); }, - notifyDisconnected: function(aReason) { + notifyDisconnected(aReason) { log("notifyDisconnected reason: " + aReason); if (aReason != Cr.NS_OK) { @@ -247,7 +247,7 @@ PresentationTransport.prototype = { contractID: PRESENTATIONTRANSPORT_CONTRACTID, QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationSessionTransport]), - init: function(aPeerConnection, aDataChannel, aWindow) { + init(aPeerConnection, aDataChannel, aWindow) { log("initWithDataChannel"); this._enableDataNotification = false; this._dataChannel = aDataChannel; @@ -264,7 +264,7 @@ PresentationTransport.prototype = { this._callback.notifyTransportClosed(this._closeReason); } this._cleanup(); - } + }; this._dataChannel.onmessage = aEvent => { log("data channel onmessage " + aEvent.data); @@ -283,7 +283,7 @@ PresentationTransport.prototype = { this._callback.notifyTransportClosed(Cr.NS_ERROR_FAILURE); } this._cleanup(); - } + }; }, // nsIPresentationTransport @@ -299,12 +299,12 @@ PresentationTransport.prototype = { this._callback = aCallback; }, - send: function(aData) { + send(aData) { log("send " + aData); this._dataChannel.send(aData); }, - sendBinaryMsg: function(aData) { + sendBinaryMsg(aData) { log("sendBinaryMsg"); let array = new Uint8Array(aData.length); @@ -315,13 +315,13 @@ PresentationTransport.prototype = { this._dataChannel.send(array); }, - sendBlob: function(aBlob) { + sendBlob(aBlob) { log("sendBlob"); this._dataChannel.send(aBlob); }, - enableDataNotification: function() { + enableDataNotification() { log("enableDataNotification"); if (this._enableDataNotification) { return; @@ -337,13 +337,13 @@ PresentationTransport.prototype = { this._messageQueue = []; }, - close: function(aReason) { + close(aReason) { this._closeReason = aReason; this._dataChannel.close(); }, - _cleanup: function() { + _cleanup() { this._dataChannel = null; if (this._peerConnection) { @@ -355,7 +355,7 @@ PresentationTransport.prototype = { this._window = null; }, - _doNotifyData: function(aData) { + _doNotifyData(aData) { if (!this._callback) { throw Cr.NS_ERROR_NOT_AVAILABLE; } diff --git a/dom/presentation/PresentationNetworkHelper.js b/dom/presentation/PresentationNetworkHelper.js index 068a582da890..db2dd32f3cbd 100644 --- a/dom/presentation/PresentationNetworkHelper.js +++ b/dom/presentation/PresentationNetworkHelper.js @@ -16,7 +16,7 @@ PresentationNetworkHelper.prototype = { classID: NETWORKHELPER_CID, QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationNetworkHelper]), - getWifiIPAddress: function(aListener) { + getWifiIPAddress(aListener) { EventDispatcher.instance.sendRequestForResult({type: "Wifi:GetIPAddress"}) .then(result => aListener.onGetWifiIPAddress(result), err => aListener.onError(err)); diff --git a/dom/presentation/provider/AndroidCastDeviceProvider.js b/dom/presentation/provider/AndroidCastDeviceProvider.js index a00949c19b7d..735b265fac39 100644 --- a/dom/presentation/provider/AndroidCastDeviceProvider.js +++ b/dom/presentation/provider/AndroidCastDeviceProvider.js @@ -22,7 +22,7 @@ function log(str) { function descriptionToString(aDescription) { let json = {}; json.type = aDescription.type; - switch(aDescription.type) { + switch (aDescription.type) { case Ci.nsIPresentationChannelDescription.TYPE_TCP: let addresses = aDescription.tcpAddress.QueryInterface(Ci.nsIArray); json.tcpAddress = []; diff --git a/dom/presentation/provider/ControllerStateMachine.jsm b/dom/presentation/provider/ControllerStateMachine.jsm index 65e736ddb9f1..6ddd235b4b7d 100644 --- a/dom/presentation/provider/ControllerStateMachine.jsm +++ b/dom/presentation/provider/ControllerStateMachine.jsm @@ -96,8 +96,8 @@ ControllerStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.LAUNCH, - presentationId: presentationId, - url: url, + presentationId, + url, }); } }, @@ -106,7 +106,7 @@ ControllerStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.TERMINATE, - presentationId: presentationId, + presentationId, }); } }, @@ -115,7 +115,7 @@ ControllerStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.TERMINATE_ACK, - presentationId: presentationId, + presentationId, }); } }, @@ -124,8 +124,8 @@ ControllerStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.RECONNECT, - presentationId: presentationId, - url: url, + presentationId, + url, }); } }, @@ -134,7 +134,7 @@ ControllerStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.OFFER, - offer: offer, + offer, }); } }, @@ -148,7 +148,7 @@ ControllerStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.ICE_CANDIDATE, - candidate: candidate, + candidate, }); } }, @@ -176,7 +176,7 @@ ControllerStateMachine.prototype = { } else { this._sendCommand({ type: CommandType.DISCONNECT, - reason: reason + reason }); this.state = State.CLOSING; this._closeReason = reason; @@ -203,7 +203,7 @@ ControllerStateMachine.prototype = { }, _notifyDeviceConnected: function _notifyDeviceConnected() { - //XXX trigger following command + // XXX trigger following command this._channel.notifyDeviceConnected(); }, diff --git a/dom/presentation/provider/PresentationControlService.js b/dom/presentation/provider/PresentationControlService.js index b35feab31683..7616277e3707 100644 --- a/dom/presentation/provider/PresentationControlService.js +++ b/dom/presentation/provider/PresentationControlService.js @@ -50,9 +50,9 @@ PresentationControlService.prototype = { */ _controlChannels: [], - startServer: function(aEncrypted, aPort) { + startServer(aEncrypted, aPort) { if (this._isServiceInit()) { - DEBUG && log("PresentationControlService - server socket has been initialized"); // jshint ignore:line + DEBUG && log("PresentationControlService - server socket has been initialized"); // jshint ignore:line throw Cr.NS_ERROR_FAILURE; } @@ -67,8 +67,8 @@ PresentationControlService.prototype = { let localCertService = Cc["@mozilla.org/security/local-cert-service;1"] .getService(Ci.nsILocalCertService); localCertService.getOrCreateCert(kLocalCertName, { - handleCert: function(aCert, aRv) { - DEBUG && log("PresentationControlService - handleCert"); // jshint ignore:line + handleCert(aCert, aRv) { + DEBUG && log("PresentationControlService - handleCert"); // jshint ignore:line if (aRv) { self._notifyServerStopped(aRv); } else { @@ -87,7 +87,7 @@ PresentationControlService.prototype = { } }, - _serverSocketInit: function(aPort, aCert) { + _serverSocketInit(aPort, aCert) { if (!this._serverSocket) { DEBUG && log("PresentationControlService - create server socket fail."); // jshint ignore:line throw Cr.NS_ERROR_FAILURE; @@ -121,7 +121,7 @@ PresentationControlService.prototype = { this._notifyServerReady(); }, - _notifyServerReady: function() { + _notifyServerReady() { Services.tm.dispatchToMainThread(() => { if (this._listener) { this._listener.onServerReady(this._port, this.certFingerprint); @@ -129,7 +129,7 @@ PresentationControlService.prototype = { }); }, - _notifyServerStopped: function(aRv) { + _notifyServerStopped(aRv) { Services.tm.dispatchToMainThread(() => { if (this._listener) { this._listener.onServerStopped(aRv); @@ -137,7 +137,7 @@ PresentationControlService.prototype = { }); }, - isCompatibleServer: function(aVersion) { + isCompatibleServer(aVersion) { // No compatibility issue for the first version of control protocol return this.version === aVersion; }, @@ -174,11 +174,11 @@ PresentationControlService.prototype = { return this._listener; }, - _isServiceInit: function() { + _isServiceInit() { return this._serverSocket !== null; }, - connect: function(aDeviceInfo) { + connect(aDeviceInfo) { if (!this.id) { DEBUG && log("PresentationControlService - Id has not initialized; connect fails"); // jshint ignore:line return null; @@ -192,7 +192,7 @@ PresentationControlService.prototype = { "sender"); }, - _attemptConnect: function(aDeviceInfo) { + _attemptConnect(aDeviceInfo) { let sts = Cc["@mozilla.org/network/socket-transport-service;1"] .getService(Ci.nsISocketTransportService); @@ -222,14 +222,14 @@ PresentationControlService.prototype = { // Shorten the connection failure procedure. socketTransport.setTimeout(Ci.nsISocketTransport.TIMEOUT_CONNECT, 2); } catch (e) { - DEBUG && log("PresentationControlService - createTransport throws: " + e); // jshint ignore:line + DEBUG && log("PresentationControlService - createTransport throws: " + e); // jshint ignore:line // Pop the exception to |TCPDevice.establishControlChannel| throw Cr.NS_ERROR_FAILURE; } return socketTransport; }, - responseSession: function(aDeviceInfo, aSocketTransport) { + responseSession(aDeviceInfo, aSocketTransport) { if (!this._isServiceInit()) { DEBUG && log("PresentationControlService - should never receive remote " + "session request before server socket initialization"); // jshint ignore:line @@ -244,7 +244,7 @@ PresentationControlService.prototype = { }, // Triggered by TCPControlChannel - onSessionRequest: function(aDeviceInfo, aUrl, aPresentationId, aControlChannel) { + onSessionRequest(aDeviceInfo, aUrl, aPresentationId, aControlChannel) { DEBUG && log("PresentationControlService - onSessionRequest: " + aDeviceInfo.address + ":" + aDeviceInfo.port); // jshint ignore:line if (!this.listener) { @@ -259,7 +259,7 @@ PresentationControlService.prototype = { this.releaseControlChannel(aControlChannel); }, - onSessionTerminate: function(aDeviceInfo, aPresentationId, aControlChannel, aIsFromReceiver) { + onSessionTerminate(aDeviceInfo, aPresentationId, aControlChannel, aIsFromReceiver) { DEBUG && log("TCPPresentationServer - onSessionTerminate: " + aDeviceInfo.address + ":" + aDeviceInfo.port); // jshint ignore:line if (!this.listener) { @@ -274,7 +274,7 @@ PresentationControlService.prototype = { this.releaseControlChannel(aControlChannel); }, - onSessionReconnect: function(aDeviceInfo, aUrl, aPresentationId, aControlChannel) { + onSessionReconnect(aDeviceInfo, aUrl, aPresentationId, aControlChannel) { DEBUG && log("TCPPresentationServer - onSessionReconnect: " + aDeviceInfo.address + ":" + aDeviceInfo.port); // jshint ignore:line if (!this.listener) { @@ -290,18 +290,18 @@ PresentationControlService.prototype = { }, // nsIServerSocketListener (Triggered by nsIServerSocket.init) - onSocketAccepted: function(aServerSocket, aClientSocket) { + onSocketAccepted(aServerSocket, aClientSocket) { DEBUG && log("PresentationControlService - onSocketAccepted: " + aClientSocket.host + ":" + aClientSocket.port); // jshint ignore:line let deviceInfo = new TCPDeviceInfo(aClientSocket.host, aClientSocket.port); this.holdControlChannel(this.responseSession(deviceInfo, aClientSocket)); }, - holdControlChannel: function(aControlChannel) { + holdControlChannel(aControlChannel) { this._controlChannels.push(aControlChannel); }, - releaseControlChannel: function(aControlChannel) { + releaseControlChannel(aControlChannel) { let index = this._controlChannels.indexOf(aControlChannel); if (index !== -1) { delete this._controlChannels[index]; @@ -309,11 +309,11 @@ PresentationControlService.prototype = { }, // nsIServerSocketListener (Triggered by nsIServerSocket.init) - onStopListening: function(aServerSocket, aStatus) { + onStopListening(aServerSocket, aStatus) { DEBUG && log("PresentationControlService - onStopListening: " + aStatus); // jshint ignore:line }, - close: function() { + close() { DEBUG && log("PresentationControlService - close"); // jshint ignore:line if (this._isServiceInit()) { DEBUG && log("PresentationControlService - close server socket"); // jshint ignore:line @@ -328,7 +328,7 @@ PresentationControlService.prototype = { }, // nsIObserver - observe: function(aSubject, aTopic, aData) { + observe(aSubject, aTopic, aData) { DEBUG && log("PresentationControlService - observe: " + aTopic); // jshint ignore:line switch (aTopic) { case "network:offline-status-changed": { @@ -342,7 +342,7 @@ PresentationControlService.prototype = { } }, - _restartServer: function() { + _restartServer() { DEBUG && log("PresentationControlService - restart service"); // jshint ignore:line // restart server socket @@ -358,9 +358,9 @@ PresentationControlService.prototype = { }, classID: Components.ID("{f4079b8b-ede5-4b90-a112-5b415a931deb}"), - QueryInterface : ChromeUtils.generateQI([Ci.nsIServerSocketListener, - Ci.nsIPresentationControlService, - Ci.nsIObserver]), + QueryInterface: ChromeUtils.generateQI([Ci.nsIServerSocketListener, + Ci.nsIPresentationControlService, + Ci.nsIObserver]), }; function ChannelDescription(aInit) { @@ -414,7 +414,7 @@ ChannelDescription.prototype = { function discriptionAsJson(aDescription) { let json = {}; json.type = aDescription.type; - switch(aDescription.type) { + switch (aDescription.type) { case Ci.nsIPresentationChannelDescription.TYPE_TCP: let addresses = aDescription.tcpAddress.QueryInterface(Ci.nsIArray); json.tcpAddress = []; @@ -488,23 +488,23 @@ TCPControlChannel.prototype = { _pendingCloseReason: null, _pendingReconnect: false, - sendOffer: function(aOffer) { + sendOffer(aOffer) { this._stateMachine.sendOffer(discriptionAsJson(aOffer)); }, - sendAnswer: function(aAnswer) { + sendAnswer(aAnswer) { this._stateMachine.sendAnswer(discriptionAsJson(aAnswer)); }, - sendIceCandidate: function(aCandidate) { + sendIceCandidate(aCandidate) { this._stateMachine.updateIceCandidate(aCandidate); }, - launch: function(aPresentationId, aUrl) { + launch(aPresentationId, aUrl) { this._stateMachine.launch(aPresentationId, aUrl); }, - terminate: function(aPresentationId) { + terminate(aPresentationId) { if (!this._terminatingId) { this._terminatingId = aPresentationId; this._stateMachine.terminate(aPresentationId); @@ -525,7 +525,7 @@ TCPControlChannel.prototype = { } }, - _flushOutgoing: function() { + _flushOutgoing() { if (!this._outgoingEnabled || this._outgoingMsgs.length === 0) { return; } @@ -534,7 +534,7 @@ TCPControlChannel.prototype = { }, // may throw an exception - _send: function(aMsg) { + _send(aMsg) { DEBUG && log("TCPControlChannel - Send: " + JSON.stringify(aMsg, null, 2)); // jshint ignore:line /** @@ -547,13 +547,13 @@ TCPControlChannel.prototype = { let message = JSON.stringify(aMsg).replace(["\n"], "") + "\n"; try { this._output.write(message, message.length); - } catch(e) { + } catch (e) { DEBUG && log("TCPControlChannel - Failed to send message: " + e.name); // jshint ignore:line throw e; } }, - _setSecurityObserver: function(observer) { + _setSecurityObserver(observer) { if (this._transport && this._transport.securityInfo) { DEBUG && log("TCPControlChannel - setSecurityObserver: " + observer); // jshint ignore:line let connectionInfo = this._transport.securityInfo @@ -563,7 +563,7 @@ TCPControlChannel.prototype = { }, // nsITLSServerSecurityObserver - onHandshakeDone: function(socket, clientStatus) { + onHandshakeDone(socket, clientStatus) { log("TCPControlChannel - onHandshakeDone: TLS version: " + clientStatus.tlsVersionUsed.toString(16)); this._setSecurityObserver(null); @@ -573,7 +573,7 @@ TCPControlChannel.prototype = { }, // nsIAsyncOutputStream - onOutputStreamReady: function() { + onOutputStreamReady() { DEBUG && log("TCPControlChannel - onOutputStreamReady"); // jshint ignore:line if (this._outgoingMsgs.length === 0) { return; @@ -596,7 +596,7 @@ TCPControlChannel.prototype = { // nsIAsyncInputStream (Triggered by nsIInputStream.asyncWait) // Only used for detecting connection refused - onInputStreamReady: function(aStream) { + onInputStreamReady(aStream) { DEBUG && log("TCPControlChannel - onInputStreamReady"); // jshint ignore:line try { aStream.available(); @@ -608,7 +608,7 @@ TCPControlChannel.prototype = { }, // nsITransportEventSink (Triggered by nsISocketTransport.setEventSink) - onTransportStatus: function(aTransport, aStatus) { + onTransportStatus(aTransport, aStatus) { DEBUG && log("TCPControlChannel - onTransportStatus: " + aStatus.toString(16) + " with role: " + this._direction); // jshint ignore:line if (aStatus === Ci.nsISocketTransport.STATUS_CONNECTED_TO) { @@ -618,21 +618,21 @@ TCPControlChannel.prototype = { }, // nsIRequestObserver (Triggered by nsIInputStreamPump.asyncRead) - onStartRequest: function() { + onStartRequest() { DEBUG && log("TCPControlChannel - onStartRequest with role: " + this._direction); // jshint ignore:line this._incomingEnabled = true; }, // nsIRequestObserver (Triggered by nsIInputStreamPump.asyncRead) - onStopRequest: function(aRequest, aContext, aStatus) { + onStopRequest(aRequest, aContext, aStatus) { DEBUG && log("TCPControlChannel - onStopRequest: " + aStatus + " with role: " + this._direction); // jshint ignore:line this._stateMachine.onChannelClosed(aStatus, true); }, // nsIStreamListener (Triggered by nsIInputStreamPump.asyncRead) - onDataAvailable: function(aRequest, aContext, aInputStream) { + onDataAvailable(aRequest, aContext, aInputStream) { let data = NetUtil.readInputStreamToString(aInputStream, aInputStream.available()); DEBUG && log("TCPControlChannel - onDataAvailable: " + data); // jshint ignore:line @@ -652,7 +652,7 @@ TCPControlChannel.prototype = { } }, - _createInputStreamPump: function() { + _createInputStreamPump() { if (this._pump) { return; } @@ -667,7 +667,7 @@ TCPControlChannel.prototype = { }, // Handle command from remote side - _handleMessage: function(aMsg) { + _handleMessage(aMsg) { DEBUG && log("TCPControlChannel - handleMessage from " + JSON.stringify(this._deviceInfo) + ": " + JSON.stringify(aMsg)); // jshint ignore:line this._stateMachine.onCommand(aMsg); @@ -724,7 +724,7 @@ TCPControlChannel.prototype = { * These functions are designed to handle the interaction with listener * appropriately. |_FUNC| is to handle |this._listener.FUNC|. */ - _onOffer: function(aOffer) { + _onOffer(aOffer) { if (!this._incomingEnabled) { return; } @@ -737,7 +737,7 @@ TCPControlChannel.prototype = { this._listener.onOffer(new ChannelDescription(aOffer)); }, - _onAnswer: function(aAnswer) { + _onAnswer(aAnswer) { if (!this._incomingEnabled) { return; } @@ -750,7 +750,7 @@ TCPControlChannel.prototype = { this._listener.onAnswer(new ChannelDescription(aAnswer)); }, - _notifyConnected: function() { + _notifyConnected() { this._pendingClose = false; this._pendingCloseReason = Cr.NS_OK; @@ -764,7 +764,7 @@ TCPControlChannel.prototype = { this._listener.notifyConnected(); }, - _notifyDisconnected: function(aReason) { + _notifyDisconnected(aReason) { this._pendingOpen = false; this._pendingOffer = null; this._pendingAnswer = null; @@ -785,7 +785,7 @@ TCPControlChannel.prototype = { this._listener.notifyDisconnected(aReason); }, - _notifyReconnected: function() { + _notifyReconnected() { if (!this._listener) { this._pendingReconnect = true; return; @@ -796,20 +796,20 @@ TCPControlChannel.prototype = { this._listener.notifyReconnected(); }, - _closeOutgoing: function() { + _closeOutgoing() { if (this._outgoingEnabled) { this._output.close(); this._outgoingEnabled = false; } }, - _closeIncoming: function() { + _closeIncoming() { if (this._incomingEnabled) { this._pump = null; this._input.close(); this._incomingEnabled = false; } }, - _closeTransport: function() { + _closeTransport() { if (this._disconnectTimer) { clearTimeout(this._disconnectTimer); delete this._disconnectTimer; @@ -829,7 +829,7 @@ TCPControlChannel.prototype = { this._presentationService.releaseControlChannel(this); }, - disconnect: function(aReason) { + disconnect(aReason) { DEBUG && log("TCPControlChannel - disconnect with reason: " + aReason); // jshint ignore:line // Pending disconnect during termination procedure. @@ -855,7 +855,7 @@ TCPControlChannel.prototype = { } }, - reconnect: function(aPresentationId, aUrl) { + reconnect(aPresentationId, aUrl) { DEBUG && log("TCPControlChannel - reconnect with role: " + this._direction); // jshint ignore:line if (this._direction != "sender") { @@ -866,12 +866,12 @@ TCPControlChannel.prototype = { }, // callback from state machine - sendCommand: function(command) { + sendCommand(command) { this._outgoingMsgs.push(command); this._flushOutgoing(); }, - notifyDeviceConnected: function(deviceId) { + notifyDeviceConnected(deviceId) { switch (this._direction) { case "receiver": this._deviceInfo.id = deviceId; @@ -880,12 +880,12 @@ TCPControlChannel.prototype = { this._notifyConnected(); }, - notifyDisconnected: function(reason) { + notifyDisconnected(reason) { this._closeTransport(); this._notifyDisconnected(reason); }, - notifyLaunch: function(presentationId, url) { + notifyLaunch(presentationId, url) { switch (this._direction) { case "receiver": this._presentationService.onSessionRequest(this._deviceInfo, @@ -896,7 +896,7 @@ TCPControlChannel.prototype = { } }, - notifyTerminate: function(presentationId) { + notifyTerminate(presentationId) { if (!this._terminatingId) { this._terminatingId = presentationId; this._presentationService.onSessionTerminate(this._deviceInfo, @@ -925,7 +925,7 @@ TCPControlChannel.prototype = { } }, - notifyReconnect: function(presentationId, url) { + notifyReconnect(presentationId, url) { switch (this._direction) { case "receiver": this._presentationService.onSessionReconnect(this._deviceInfo, @@ -939,15 +939,15 @@ TCPControlChannel.prototype = { } }, - notifyOffer: function(offer) { + notifyOffer(offer) { this._onOffer(offer); }, - notifyAnswer: function(answer) { + notifyAnswer(answer) { this._onAnswer(answer); }, - notifyIceCandidate: function(candidate) { + notifyIceCandidate(candidate) { this._listener.onIceCandidate(candidate); }, diff --git a/dom/presentation/provider/ReceiverStateMachine.jsm b/dom/presentation/provider/ReceiverStateMachine.jsm index 7fe5cd13e5eb..917848cd2595 100644 --- a/dom/presentation/provider/ReceiverStateMachine.jsm +++ b/dom/presentation/provider/ReceiverStateMachine.jsm @@ -113,7 +113,7 @@ ReceiverStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.TERMINATE, - presentationId: presentationId, + presentationId, }); } }, @@ -122,7 +122,7 @@ ReceiverStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.TERMINATE_ACK, - presentationId: presentationId, + presentationId, }); } }, @@ -140,7 +140,7 @@ ReceiverStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.ANSWER, - answer: answer, + answer, }); } }, @@ -149,7 +149,7 @@ ReceiverStateMachine.prototype = { if (this.state === State.CONNECTED) { this._sendCommand({ type: CommandType.ICE_CANDIDATE, - candidate: candidate, + candidate, }); } }, @@ -173,7 +173,7 @@ ReceiverStateMachine.prototype = { } else { this._sendCommand({ type: CommandType.DISCONNECT, - reason: reason + reason }); this.state = State.CLOSING; this._closeReason = reason; diff --git a/dom/presentation/tests/mochitest/PresentationDeviceInfoChromeScript.js b/dom/presentation/tests/mochitest/PresentationDeviceInfoChromeScript.js index c01d54a53c85..14e2430addb0 100644 --- a/dom/presentation/tests/mochitest/PresentationDeviceInfoChromeScript.js +++ b/dom/presentation/tests/mochitest/PresentationDeviceInfoChromeScript.js @@ -1,28 +1,28 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -'use strict'; +"use strict"; -const { XPCOMUtils } = ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm'); +const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -const manager = Cc['@mozilla.org/presentation-device/manager;1'] +const manager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); var testProvider = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDeviceProvider]), - forceDiscovery: function() { - sendAsyncMessage('force-discovery'); + forceDiscovery() { + sendAsyncMessage("force-discovery"); }, listener: null, }; var testDevice = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevice]), - establishControlChannel: function() { + establishControlChannel() { return null; }, - disconnect: function() {}, - isRequestedUrlSupported: function(requestedUrl) { + disconnect() {}, + isRequestedUrlSupported(requestedUrl) { return true; }, id: null, @@ -33,56 +33,56 @@ var testDevice = { var testDevice1 = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevice]), - id: 'dummyid', - name: 'dummyName', - type: 'dummyType', - establishControlChannel: function(url, presentationId) { + id: "dummyid", + name: "dummyName", + type: "dummyType", + establishControlChannel(url, presentationId) { return null; }, - disconnect: function() {}, - isRequestedUrlSupported: function(requestedUrl) { + disconnect() {}, + isRequestedUrlSupported(requestedUrl) { return true; }, }; var testDevice2 = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevice]), - id: 'dummyid', - name: 'dummyName', - type: 'dummyType', - establishControlChannel: function(url, presentationId) { + id: "dummyid", + name: "dummyName", + type: "dummyType", + establishControlChannel(url, presentationId) { return null; }, - disconnect: function() {}, - isRequestedUrlSupported: function(requestedUrl) { + disconnect() {}, + isRequestedUrlSupported(requestedUrl) { return true; }, }; var mockedDeviceWithoutSupportedURL = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevice]), - id: 'dummyid', - name: 'dummyName', - type: 'dummyType', - establishControlChannel: function(url, presentationId) { + id: "dummyid", + name: "dummyName", + type: "dummyType", + establishControlChannel(url, presentationId) { return null; }, - disconnect: function() {}, - isRequestedUrlSupported: function(requestedUrl) { + disconnect() {}, + isRequestedUrlSupported(requestedUrl) { return false; }, }; var mockedDeviceSupportHttpsURL = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevice]), - id: 'dummyid', - name: 'dummyName', - type: 'dummyType', - establishControlChannel: function(url, presentationId) { + id: "dummyid", + name: "dummyName", + type: "dummyType", + establishControlChannel(url, presentationId) { return null; }, - disconnect: function() {}, - isRequestedUrlSupported: function(requestedUrl) { + disconnect() {}, + isRequestedUrlSupported(requestedUrl) { if (requestedUrl.includes("https://")) { return true; } @@ -90,57 +90,57 @@ var mockedDeviceSupportHttpsURL = { }, }; -addMessageListener('setup', function() { +addMessageListener("setup", function() { manager.addDeviceProvider(testProvider); - sendAsyncMessage('setup-complete'); + sendAsyncMessage("setup-complete"); }); -addMessageListener('trigger-device-add', function(device) { +addMessageListener("trigger-device-add", function(device) { testDevice.id = device.id; testDevice.name = device.name; testDevice.type = device.type; manager.addDevice(testDevice); }); -addMessageListener('trigger-add-unsupport-url-device', function() { +addMessageListener("trigger-add-unsupport-url-device", function() { manager.addDevice(mockedDeviceWithoutSupportedURL); }); -addMessageListener('trigger-add-multiple-devices', function() { +addMessageListener("trigger-add-multiple-devices", function() { manager.addDevice(testDevice1); manager.addDevice(testDevice2); }); -addMessageListener('trigger-add-https-devices', function() { +addMessageListener("trigger-add-https-devices", function() { manager.addDevice(mockedDeviceSupportHttpsURL); }); -addMessageListener('trigger-device-update', function(device) { +addMessageListener("trigger-device-update", function(device) { testDevice.id = device.id; testDevice.name = device.name; testDevice.type = device.type; manager.updateDevice(testDevice); }); -addMessageListener('trigger-device-remove', function() { +addMessageListener("trigger-device-remove", function() { manager.removeDevice(testDevice); }); -addMessageListener('trigger-remove-unsupported-device', function() { +addMessageListener("trigger-remove-unsupported-device", function() { manager.removeDevice(mockedDeviceWithoutSupportedURL); }); -addMessageListener('trigger-remove-multiple-devices', function() { +addMessageListener("trigger-remove-multiple-devices", function() { manager.removeDevice(testDevice1); manager.removeDevice(testDevice2); }); -addMessageListener('trigger-remove-https-devices', function() { +addMessageListener("trigger-remove-https-devices", function() { manager.removeDevice(mockedDeviceSupportHttpsURL); }); -addMessageListener('teardown', function() { +addMessageListener("teardown", function() { manager.removeDeviceProvider(testProvider); }); diff --git a/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js b/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js index 8039ab6dd8e1..1dd5a32a08d0 100644 --- a/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js +++ b/dom/presentation/tests/mochitest/PresentationSessionChromeScript.js @@ -1,13 +1,13 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -'use strict'; +"use strict"; const Cm = Components.manager; -ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm'); -ChromeUtils.import('resource://gre/modules/Services.jsm'); -ChromeUtils.import('resource://gre/modules/Timer.jsm'); +ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +ChromeUtils.import("resource://gre/modules/Services.jsm"); +ChromeUtils.import("resource://gre/modules/Timer.jsm"); const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"] .getService(Ci.nsIUUIDGenerator); @@ -30,11 +30,11 @@ function registerMockedFactory(contractId, mockedClassId, mockedFactory) { registrar.registerFactory(mockedClassId, "", contractId, mockedFactory); } - return { contractId: contractId, - mockedClassId: mockedClassId, - mockedFactory: mockedFactory, - originalClassId: originalClassId, - originalFactory: originalFactory }; + return { contractId, + mockedClassId, + mockedFactory, + originalClassId, + originalFactory }; } function registerOriginalFactory(contractId, mockedClassId, mockedFactory, originalClassId, originalFactory) { @@ -45,7 +45,7 @@ function registerOriginalFactory(contractId, mockedClassId, mockedFactory, origi } } -var sessionId = 'test-session-id-' + uuidGenerator.generateUUID().toString(); +var sessionId = "test-session-id-" + uuidGenerator.generateUUID().toString(); const address = Cc["@mozilla.org/supports-cstring;1"] .createInstance(Ci.nsISupportsCString); @@ -68,7 +68,7 @@ const mockedChannelDescription = { const mockedServerSocket = { QueryInterface: ChromeUtils.generateQI([Ci.nsIServerSocket, Ci.nsIFactory]), - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } @@ -80,20 +80,20 @@ const mockedServerSocket = { set listener(listener) { this._listener = listener; }, - init: function(port, loopbackOnly, backLog) { + init(port, loopbackOnly, backLog) { if (port != -1) { this._port = port; } else { this._port = 5678; } }, - asyncListen: function(listener) { + asyncListen(listener) { this._listener = listener; }, - close: function() { + close() { this._listener.onStopListening(this, Cr.NS_BINDING_ABORTED); }, - simulateOnSocketAccepted: function(serverSocket, socketTransport) { + simulateOnSocketAccepted(serverSocket, socketTransport) { this._listener.onSocketAccepted(serverSocket, socketTransport); } }; @@ -110,17 +110,17 @@ const mockedControlChannel = { get listener() { return this._listener; }, - sendOffer: function(offer) { - sendAsyncMessage('offer-sent', this._isValidSDP(offer)); + sendOffer(offer) { + sendAsyncMessage("offer-sent", this._isValidSDP(offer)); }, - sendAnswer: function(answer) { - sendAsyncMessage('answer-sent', this._isValidSDP(answer)); + sendAnswer(answer) { + sendAsyncMessage("answer-sent", this._isValidSDP(answer)); if (answer.type == Ci.nsIPresentationChannelDescription.TYPE_TCP) { this._listener.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportReady(); } }, - _isValidSDP: function(aSDP) { + _isValidSDP(aSDP) { var isValid = false; if (aSDP.type == Ci.nsIPresentationChannelDescription.TYPE_TCP) { try { @@ -141,52 +141,52 @@ const mockedControlChannel = { } return isValid; }, - launch: function(presentationId, url) { + launch(presentationId, url) { sessionId = presentationId; }, - terminate: function(presentationId) { - sendAsyncMessage('sender-terminate', presentationId); + terminate(presentationId) { + sendAsyncMessage("sender-terminate", presentationId); }, - reconnect: function(presentationId, url) { - sendAsyncMessage('start-reconnect', url); + reconnect(presentationId, url) { + sendAsyncMessage("start-reconnect", url); }, - notifyReconnected: function() { + notifyReconnected() { this._listener .QueryInterface(Ci.nsIPresentationControlChannelListener) .notifyReconnected(); }, - disconnect: function(reason) { - sendAsyncMessage('control-channel-closed', reason); + disconnect(reason) { + sendAsyncMessage("control-channel-closed", reason); this._listener.QueryInterface(Ci.nsIPresentationControlChannelListener).notifyDisconnected(reason); }, - simulateReceiverReady: function() { + simulateReceiverReady() { this._listener.QueryInterface(Ci.nsIPresentationControlChannelListener).notifyReceiverReady(); }, - simulateOnOffer: function() { - sendAsyncMessage('offer-received'); + simulateOnOffer() { + sendAsyncMessage("offer-received"); this._listener.QueryInterface(Ci.nsIPresentationControlChannelListener).onOffer(mockedChannelDescription); }, - simulateOnAnswer: function() { - sendAsyncMessage('answer-received'); + simulateOnAnswer() { + sendAsyncMessage("answer-received"); this._listener.QueryInterface(Ci.nsIPresentationControlChannelListener).onAnswer(mockedChannelDescription); }, - simulateNotifyConnected: function() { - sendAsyncMessage('control-channel-opened'); + simulateNotifyConnected() { + sendAsyncMessage("control-channel-opened"); this._listener.QueryInterface(Ci.nsIPresentationControlChannelListener).notifyConnected(); }, }; const mockedDevice = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevice]), - id: 'id', - name: 'name', - type: 'type', - establishControlChannel: function(url, presentationId) { - sendAsyncMessage('control-channel-established'); + id: "id", + name: "name", + type: "type", + establishControlChannel(url, presentationId) { + sendAsyncMessage("control-channel-established"); return mockedControlChannel; }, - disconnect: function() {}, - isRequestedUrlSupported: function(requestedUrl) { + disconnect() {}, + isRequestedUrlSupported(requestedUrl) { return true; }, }; @@ -194,7 +194,7 @@ const mockedDevice = { const mockedDevicePrompt = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevicePrompt, Ci.nsIFactory]), - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } @@ -206,14 +206,14 @@ const mockedDevicePrompt = { get request() { return this._request; }, - promptDeviceSelection: function(request) { + promptDeviceSelection(request) { this._request = request; - sendAsyncMessage('device-prompt'); + sendAsyncMessage("device-prompt"); }, - simulateSelect: function() { + simulateSelect() { this._request.select(mockedDevice); }, - simulateCancel: function(result) { + simulateCancel(result) { this._request.cancel(result); } }; @@ -225,7 +225,7 @@ const mockedSessionTransport = { Ci.nsIPresentationDataChannelSessionTransportBuilder, Ci.nsIPresentationControlChannelListener, Ci.nsIFactory]), - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } @@ -240,18 +240,18 @@ const mockedSessionTransport = { get selfAddress() { return this._selfAddress; }, - buildTCPSenderTransport: function(transport, listener) { + buildTCPSenderTransport(transport, listener) { this._listener = listener; this._role = Ci.nsIPresentationService.ROLE_CONTROLLER; this._listener.onSessionTransport(this); this._listener = null; - sendAsyncMessage('data-transport-initialized'); + sendAsyncMessage("data-transport-initialized"); - setTimeout(()=>{ + setTimeout(() => { this.simulateTransportReady(); }, 0); }, - buildTCPReceiverTransport: function(description, listener) { + buildTCPReceiverTransport(description, listener) { this._listener = listener; this._role = Ci.nsIPresentationService.ROLE_RECEIVER; @@ -263,53 +263,53 @@ const mockedSessionTransport = { port: description.QueryInterface(Ci.nsIPresentationChannelDescription).tcpPort, }; - setTimeout(()=>{ + setTimeout(() => { this._listener.onSessionTransport(this); this._listener = null; }, 0); }, // in-process case - buildDataChannelTransport: function(role, window, listener) { + buildDataChannelTransport(role, window, listener) { this._listener = listener; this._role = role; var hasNavigator = window ? (typeof window.navigator != "undefined") : false; - sendAsyncMessage('check-navigator', hasNavigator); + sendAsyncMessage("check-navigator", hasNavigator); - setTimeout(()=>{ + setTimeout(() => { this._listener.onSessionTransport(this); this._listener = null; this.simulateTransportReady(); }, 0); }, - enableDataNotification: function() { - sendAsyncMessage('data-transport-notification-enabled'); + enableDataNotification() { + sendAsyncMessage("data-transport-notification-enabled"); }, - send: function(data) { - sendAsyncMessage('message-sent', data); + send(data) { + sendAsyncMessage("message-sent", data); }, - close: function(reason) { + close(reason) { // Don't send a message after tearDown, to avoid a leak. if (this._callback) { - sendAsyncMessage('data-transport-closed', reason); + sendAsyncMessage("data-transport-closed", reason); this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportClosed(reason); } }, - simulateTransportReady: function() { + simulateTransportReady() { this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportReady(); }, - simulateIncomingMessage: function(message) { + simulateIncomingMessage(message) { this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyData(message, false); }, - onOffer: function(aOffer) { + onOffer(aOffer) { }, - onAnswer: function(aAnswer) { + onAnswer(aAnswer) { } }; const mockedNetworkInfo = { QueryInterface: ChromeUtils.generateQI([Ci.nsINetworkInfo]), - getAddresses: function(ips, prefixLengths) { + getAddresses(ips, prefixLengths) { ips.value = ["127.0.0.1"]; prefixLengths.value = [0]; return 1; @@ -319,7 +319,7 @@ const mockedNetworkInfo = { const mockedNetworkManager = { QueryInterface: ChromeUtils.generateQI([Ci.nsINetworkManager, Ci.nsIFactory]), - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } @@ -335,14 +335,14 @@ var requestPromise = null; const mockedRequestUIGlue = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationRequestUIGlue, Ci.nsIFactory]), - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } return this.QueryInterface(aIID); }, - sendRequest: function(aUrl, aSessionId) { - sendAsyncMessage('receiver-launching', aSessionId); + sendRequest(aUrl, aSessionId) { + sendAsyncMessage("receiver-launching", aSessionId); return requestPromise; }, }; @@ -376,7 +376,7 @@ function tearDown() { mockedDevicePrompt.request = null; mockedSessionTransport.callback = null; - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener).removeDevice(mockedDevice); @@ -387,79 +387,79 @@ function tearDown() { data.originalFactory); } - sendAsyncMessage('teardown-complete'); + sendAsyncMessage("teardown-complete"); } -addMessageListener('trigger-device-add', function() { - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] +addMessageListener("trigger-device-add", function() { + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener).addDevice(mockedDevice); }); -addMessageListener('trigger-device-prompt-select', function() { +addMessageListener("trigger-device-prompt-select", function() { mockedDevicePrompt.simulateSelect(); }); -addMessageListener('trigger-device-prompt-cancel', function(result) { +addMessageListener("trigger-device-prompt-cancel", function(result) { mockedDevicePrompt.simulateCancel(result); }); -addMessageListener('trigger-incoming-session-request', function(url) { - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] +addMessageListener("trigger-incoming-session-request", function(url) { + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener) .onSessionRequest(mockedDevice, url, sessionId, mockedControlChannel); }); -addMessageListener('trigger-incoming-terminate-request', function() { - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] +addMessageListener("trigger-incoming-terminate-request", function() { + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener) .onTerminateRequest(mockedDevice, sessionId, mockedControlChannel, true); }); -addMessageListener('trigger-reconnected-acked', function(url) { +addMessageListener("trigger-reconnected-acked", function(url) { mockedControlChannel.notifyReconnected(); }); -addMessageListener('trigger-incoming-offer', function() { +addMessageListener("trigger-incoming-offer", function() { mockedControlChannel.simulateOnOffer(); }); -addMessageListener('trigger-incoming-answer', function() { +addMessageListener("trigger-incoming-answer", function() { mockedControlChannel.simulateOnAnswer(); }); -addMessageListener('trigger-incoming-transport', function() { +addMessageListener("trigger-incoming-transport", function() { mockedServerSocket.simulateOnSocketAccepted(mockedServerSocket, mockedSocketTransport); }); -addMessageListener('trigger-control-channel-open', function(reason) { +addMessageListener("trigger-control-channel-open", function(reason) { mockedControlChannel.simulateNotifyConnected(); }); -addMessageListener('trigger-control-channel-close', function(reason) { +addMessageListener("trigger-control-channel-close", function(reason) { mockedControlChannel.disconnect(reason); }); -addMessageListener('trigger-data-transport-close', function(reason) { +addMessageListener("trigger-data-transport-close", function(reason) { mockedSessionTransport.close(reason); }); -addMessageListener('trigger-incoming-message', function(message) { +addMessageListener("trigger-incoming-message", function(message) { mockedSessionTransport.simulateIncomingMessage(message); }); -addMessageListener('teardown', function() { +addMessageListener("teardown", function() { tearDown(); }); var controlChannelListener; -addMessageListener('save-control-channel-listener', function() { +addMessageListener("save-control-channel-listener", function() { controlChannelListener = mockedControlChannel.listener; }); -addMessageListener('restore-control-channel-listener', function(message) { +addMessageListener("restore-control-channel-listener", function(message) { mockedControlChannel.listener = controlChannelListener; controlChannelListener = null; }); @@ -470,4 +470,4 @@ obs.addObserver(function observer(aSubject, aTopic, aData) { obs.removeObserver(observer, aTopic); requestPromise = aSubject; -}, 'setup-request-promise'); +}, "setup-request-promise"); diff --git a/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js b/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js index cf125cfccc47..f30af0bdad7c 100644 --- a/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js +++ b/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js @@ -3,12 +3,12 @@ * 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/. */ -'use strict'; +"use strict"; const Cm = Components.manager; -ChromeUtils.import('resource://gre/modules/XPCOMUtils.jsm'); -ChromeUtils.import('resource://gre/modules/Services.jsm'); +ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +ChromeUtils.import("resource://gre/modules/Services.jsm"); const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"] .getService(Ci.nsIUUIDGenerator); @@ -27,42 +27,42 @@ const mockControlChannelOfSender = { set listener(listener) { // PresentationControllingInfo::SetControlChannel if (listener) { - debug('set listener for mockControlChannelOfSender without null'); + debug("set listener for mockControlChannelOfSender without null"); } else { - debug('set listener for mockControlChannelOfSender with null'); + debug("set listener for mockControlChannelOfSender with null"); } this._listener = listener; }, get listener() { return this._listener; }, - notifyConnected: function() { + notifyConnected() { // send offer after notifyConnected immediately this._listener .QueryInterface(Ci.nsIPresentationControlChannelListener) .notifyConnected(); }, - notifyReconnected: function() { + notifyReconnected() { // send offer after notifyOpened immediately this._listener .QueryInterface(Ci.nsIPresentationControlChannelListener) .notifyReconnected(); }, - sendOffer: function(offer) { + sendOffer(offer) { Services.tm.dispatchToMainThread(() => { mockControlChannelOfReceiver.onOffer(offer); }); }, - onAnswer: function(answer) { + onAnswer(answer) { this._listener .QueryInterface(Ci.nsIPresentationControlChannelListener) .onAnswer(answer); }, - launch: function(presentationId, url) { + launch(presentationId, url) { sessionId = presentationId; - sendAsyncMessage('sender-launch', url); + sendAsyncMessage("sender-launch", url); }, - disconnect: function(reason) { + disconnect(reason) { if (!this._listener) { return; } @@ -71,16 +71,16 @@ const mockControlChannelOfSender = { .notifyDisconnected(reason); mockControlChannelOfReceiver.disconnect(); }, - terminate: function(presentationId) { - sendAsyncMessage('sender-terminate'); + terminate(presentationId) { + sendAsyncMessage("sender-terminate"); }, - reconnect: function(presentationId, url) { - sendAsyncMessage('start-reconnect', url); + reconnect(presentationId, url) { + sendAsyncMessage("start-reconnect", url); }, - sendIceCandidate: function(candidate) { + sendIceCandidate(candidate) { mockControlChannelOfReceiver.notifyIceCandidate(candidate); }, - notifyIceCandidate: function(candidate) { + notifyIceCandidate(candidate) { if (!this._listener) { return; } @@ -97,9 +97,9 @@ const mockControlChannelOfReceiver = { set listener(listener) { // PresentationPresentingInfo::SetControlChannel if (listener) { - debug('set listener for mockControlChannelOfReceiver without null'); + debug("set listener for mockControlChannelOfReceiver without null"); } else { - debug('set listener for mockControlChannelOfReceiver with null'); + debug("set listener for mockControlChannelOfReceiver with null"); } this._listener = listener; @@ -111,7 +111,7 @@ const mockControlChannelOfReceiver = { get listener() { return this._listener; }, - notifyConnected: function() { + notifyConnected() { // do nothing if (!this._listener) { this._pendingOpened = true; @@ -121,17 +121,17 @@ const mockControlChannelOfReceiver = { .QueryInterface(Ci.nsIPresentationControlChannelListener) .notifyConnected(); }, - onOffer: function(offer) { + onOffer(offer) { this._listener .QueryInterface(Ci.nsIPresentationControlChannelListener) .onOffer(offer); }, - sendAnswer: function(answer) { + sendAnswer(answer) { Services.tm.dispatchToMainThread(() => { mockControlChannelOfSender.onAnswer(answer); }); }, - disconnect: function(reason) { + disconnect(reason) { if (!this._listener) { return; } @@ -139,14 +139,14 @@ const mockControlChannelOfReceiver = { this._listener .QueryInterface(Ci.nsIPresentationControlChannelListener) .notifyDisconnected(reason); - sendAsyncMessage('control-channel-receiver-closed', reason); + sendAsyncMessage("control-channel-receiver-closed", reason); }, - terminate: function(presentaionId) { + terminate(presentaionId) { }, - sendIceCandidate: function(candidate) { + sendIceCandidate(candidate) { mockControlChannelOfReceiver.notifyIceCandidate(candidate); }, - notifyIceCandidate: function(candidate) { + notifyIceCandidate(candidate) { if (!this._listener) { return; } @@ -159,20 +159,20 @@ const mockControlChannelOfReceiver = { const mockDevice = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevice]), - id: 'id', - name: 'name', - type: 'type', - establishControlChannel: function(url, presentationId) { + id: "id", + name: "name", + type: "type", + establishControlChannel(url, presentationId) { if (triggerControlChannelError) { throw Cr.NS_ERROR_FAILURE; } - sendAsyncMessage('control-channel-established'); + sendAsyncMessage("control-channel-established"); return mockControlChannelOfSender; }, - disconnect: function() { - sendAsyncMessage('device-disconnected'); + disconnect() { + sendAsyncMessage("device-disconnected"); }, - isRequestedUrlSupported: function(requestedUrl) { + isRequestedUrlSupported(requestedUrl) { return true; }, }; @@ -180,7 +180,7 @@ const mockDevice = { const mockDevicePrompt = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationDevicePrompt, Ci.nsIFactory]), - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } @@ -192,14 +192,14 @@ const mockDevicePrompt = { get request() { return this._request; }, - promptDeviceSelection: function(request) { + promptDeviceSelection(request) { this._request = request; - sendAsyncMessage('device-prompt'); + sendAsyncMessage("device-prompt"); }, - simulateSelect: function() { + simulateSelect() { this._request.select(mockDevice); }, - simulateCancel: function() { + simulateCancel() { this._request.cancel(); } }; @@ -208,18 +208,18 @@ const mockRequestUIGlue = { QueryInterface: ChromeUtils.generateQI([Ci.nsIPresentationRequestUIGlue, Ci.nsIFactory]), set promise(aPromise) { - this._promise = aPromise + this._promise = aPromise; }, get promise() { return this._promise; }, - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } return this.QueryInterface(aIID); }, - sendRequest: function(aUrl, aSessionId) { + sendRequest(aUrl, aSessionId) { return this.promise; }, }; @@ -244,11 +244,11 @@ function initMockAndListener() { registrar.registerFactory(mockClassId, "", contractId, mockFactory); } - return { contractId: contractId, - mockClassId: mockClassId, - mockFactory: mockFactory, - originalClassId: originalClassId, - originalFactory: originalFactory }; + return { contractId, + mockClassId, + mockFactory, + originalClassId, + originalFactory }; } // Register mock factories. const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"] @@ -260,22 +260,22 @@ function initMockAndListener() { uuidGenerator.generateUUID(), mockRequestUIGlue)); - addMessageListener('trigger-device-add', function() { - debug('Got message: trigger-device-add'); - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] + addMessageListener("trigger-device-add", function() { + debug("Got message: trigger-device-add"); + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener) .addDevice(mockDevice); }); - addMessageListener('trigger-device-prompt-select', function() { - debug('Got message: trigger-device-prompt-select'); + addMessageListener("trigger-device-prompt-select", function() { + debug("Got message: trigger-device-prompt-select"); mockDevicePrompt.simulateSelect(); }); - addMessageListener('trigger-on-session-request', function(url) { - debug('Got message: trigger-on-session-request'); - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] + addMessageListener("trigger-on-session-request", function(url) { + debug("Got message: trigger-on-session-request"); + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener) .onSessionRequest(mockDevice, @@ -284,9 +284,9 @@ function initMockAndListener() { mockControlChannelOfReceiver); }); - addMessageListener('trigger-on-terminate-request', function() { - debug('Got message: trigger-on-terminate-request'); - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] + addMessageListener("trigger-on-terminate-request", function() { + debug("Got message: trigger-on-terminate-request"); + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener) .onTerminateRequest(mockDevice, @@ -295,21 +295,21 @@ function initMockAndListener() { false); }); - addMessageListener('trigger-control-channel-open', function(reason) { - debug('Got message: trigger-control-channel-open'); + addMessageListener("trigger-control-channel-open", function(reason) { + debug("Got message: trigger-control-channel-open"); mockControlChannelOfSender.notifyConnected(); mockControlChannelOfReceiver.notifyConnected(); }); - addMessageListener('trigger-control-channel-error', function(reason) { - debug('Got message: trigger-control-channel-open'); + addMessageListener("trigger-control-channel-error", function(reason) { + debug("Got message: trigger-control-channel-open"); triggerControlChannelError = true; }); - addMessageListener('trigger-reconnected-acked', function(url) { - debug('Got message: trigger-reconnected-acked'); + addMessageListener("trigger-reconnected-acked", function(url) { + debug("Got message: trigger-reconnected-acked"); mockControlChannelOfSender.notifyReconnected(); - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener) .onReconnectRequest(mockDevice, @@ -319,20 +319,20 @@ function initMockAndListener() { }); // Used to call sendAsyncMessage in chrome script from receiver. - addMessageListener('forward-command', function(command_data) { + addMessageListener("forward-command", function(command_data) { let command = JSON.parse(command_data); sendAsyncMessage(command.name, command.data); }); - addMessageListener('teardown', teardown); + addMessageListener("teardown", teardown); var obs = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); obs.addObserver(function setupRequestPromiseHandler(aSubject, aTopic, aData) { - debug('Got observer: setup-request-promise'); + debug("Got observer: setup-request-promise"); obs.removeObserver(setupRequestPromiseHandler, aTopic); mockRequestUIGlue.promise = aSubject; - sendAsyncMessage('promise-setup-ready'); - }, 'setup-request-promise'); + sendAsyncMessage("promise-setup-ready"); + }, "setup-request-promise"); } function teardown() { @@ -350,7 +350,7 @@ function teardown() { mockControlChannelOfReceiver.listener = null; mockDevicePrompt.request = null; - var deviceManager = Cc['@mozilla.org/presentation-device/manager;1'] + var deviceManager = Cc["@mozilla.org/presentation-device/manager;1"] .getService(Ci.nsIPresentationDeviceManager); deviceManager.QueryInterface(Ci.nsIPresentationDeviceListener) .removeDevice(mockDevice); @@ -360,7 +360,7 @@ function teardown() { data.mockFactory, data.originalClassId, data.originalFactory); } - sendAsyncMessage('teardown-complete'); + sendAsyncMessage("teardown-complete"); } initMockAndListener(); diff --git a/dom/presentation/tests/mochitest/PresentationSessionFrameScript.js b/dom/presentation/tests/mochitest/PresentationSessionFrameScript.js index ef9edf417002..31f9c441528f 100644 --- a/dom/presentation/tests/mochitest/PresentationSessionFrameScript.js +++ b/dom/presentation/tests/mochitest/PresentationSessionFrameScript.js @@ -12,10 +12,10 @@ function loadPrivilegedScriptTest() { */ function sendMessage(type, data) { if (typeof port == "undefined") { - sendAsyncMessage(type, {'data': data}); + sendAsyncMessage(type, {"data": data}); } else { - port.postMessage({'type': type, - 'data': data + port.postMessage({"type": type, + "data": data }); } } @@ -26,7 +26,7 @@ function loadPrivilegedScriptTest() { * are exposed to this script. */ port.onmessage = (e) => { - var type = e.data['type']; + var type = e.data.type; if (!handlers.hasOwnProperty(type)) { return; } @@ -55,7 +55,7 @@ function loadPrivilegedScriptTest() { const Cm = Components.manager; const mockedChannelDescription = { - QueryInterface : function (iid) { + QueryInterface(iid) { const interfaces = [Ci.nsIPresentationChannelDescription]; if (!interfaces.some(v => iid.equals(v))) { @@ -83,7 +83,7 @@ function loadPrivilegedScriptTest() { } const mockedSessionTransport = { - QueryInterface : function (iid) { + QueryInterface(iid) { const interfaces = [Ci.nsIPresentationSessionTransport, Ci.nsIPresentationDataChannelSessionTransportBuilder, Ci.nsIFactory]; @@ -93,7 +93,7 @@ function loadPrivilegedScriptTest() { } return this; }, - createInstance: function(aOuter, aIID) { + createInstance(aOuter, aIID) { if (aOuter) { throw Cr.NS_ERROR_NO_AGGREGATION; } @@ -106,45 +106,45 @@ function loadPrivilegedScriptTest() { return this._callback; }, /* OOP case */ - buildDataChannelTransport: function(role, window, listener) { + buildDataChannelTransport(role, window, listener) { dump("PresentationSessionFrameScript: build data channel transport\n"); this._listener = listener; this._role = role; var hasNavigator = window ? (typeof window.navigator != "undefined") : false; - sendMessage('check-navigator', hasNavigator); + sendMessage("check-navigator", hasNavigator); if (this._role == Ci.nsIPresentationService.ROLE_CONTROLLER) { this._listener.sendOffer(mockedChannelDescription); } }, - enableDataNotification: function() { - sendMessage('data-transport-notification-enabled'); + enableDataNotification() { + sendMessage("data-transport-notification-enabled"); }, - send: function(data) { - sendMessage('message-sent', data); + send(data) { + sendMessage("message-sent", data); }, - close: function(reason) { - sendMessage('data-transport-closed', reason); + close(reason) { + sendMessage("data-transport-closed", reason); this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportClosed(reason); this._callback = null; }, - simulateTransportReady: function() { + simulateTransportReady() { this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyTransportReady(); }, - simulateIncomingMessage: function(message) { + simulateIncomingMessage(message) { this._callback.QueryInterface(Ci.nsIPresentationSessionTransportCallback).notifyData(message, false); }, - onOffer: function(aOffer) { + onOffer(aOffer) { this._listener.sendAnswer(mockedChannelDescription); this._onSessionTransport(); }, - onAnswer: function(aAnswer) { + onAnswer(aAnswer) { this._onSessionTransport(); }, - _onSessionTransport: function() { - setTimeout(()=>{ + _onSessionTransport() { + setTimeout(() => { this._listener.onSessionTransport(this); this.simulateTransportReady(); this._listener = null; @@ -184,11 +184,11 @@ function loadPrivilegedScriptTest() { registrar.registerFactory(mockedClassId, "", contractId, mockedFactory); } - return { contractId: contractId, - mockedClassId: mockedClassId, - mockedFactory: mockedFactory, - originalClassId: originalClassId, - originalFactory: originalFactory }; + return { contractId, + mockedClassId, + mockedFactory, + originalClassId, + originalFactory }; } function registerOriginalFactory(contractId, mockedClassId, mockedFactory, originalClassId, originalFactory) { @@ -207,23 +207,23 @@ function loadPrivilegedScriptTest() { uuidGenerator.generateUUID(), mockedSessionTransport)); - addMessageListener('trigger-incoming-message', function(event) { + addMessageListener("trigger-incoming-message", function(event) { mockedSessionTransport.simulateIncomingMessage(event.data.data); }); - addMessageListener('teardown', ()=>tearDown()); + addMessageListener("teardown", () => tearDown()); } // Exposed to the caller of |loadPrivilegedScript| var contentScript = { handlers: {}, - addMessageListener: function(message, handler) { + addMessageListener(message, handler) { if (this.handlers.hasOwnProperty(message)) { this.handlers[message].push(handler); } else { this.handlers[message] = [handler]; } }, - removeMessageListener: function(message, handler) { + removeMessageListener(message, handler) { if (!handler || !this.handlers.hasOwnProperty(message)) { return; } @@ -232,12 +232,12 @@ var contentScript = { this.handlers[message].splice(index, 1); } }, - sendAsyncMessage: function(message, data) { - port.postMessage({'type': message, - 'data': data + sendAsyncMessage(message, data) { + port.postMessage({"type": message, + "data": data }); } -} +}; if (!SpecialPowers.isMainProcess()) { var port; @@ -248,11 +248,11 @@ if (!SpecialPowers.isMainProcess()) { } port.onmessage = (e) => { - var type = e.data['type']; + var type = e.data.type; if (!contentScript.handlers.hasOwnProperty(type)) { return; } - var args = [e.data['data']]; + var args = [e.data.data]; contentScript.handlers[type].forEach(handler => handler.apply(null, args)); }; } diff --git a/dom/presentation/tests/mochitest/file_presentation_1ua_receiver.html b/dom/presentation/tests/mochitest/file_presentation_1ua_receiver.html index 1162507be91e..3d98d12a2b0e 100644 --- a/dom/presentation/tests/mochitest/file_presentation_1ua_receiver.html +++ b/dom/presentation/tests/mochitest/file_presentation_1ua_receiver.html @@ -13,26 +13,26 @@ function is(a, b, msg) { if (a === b) { - alert('OK ' + msg); + alert("OK " + msg); } else { - alert('KO ' + msg + ' | reason: ' + a + ' != ' + b); + alert("KO " + msg + " | reason: " + a + " != " + b); } } function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function info(msg) { - alert('INFO ' + msg); + alert("INFO " + msg); } function command(name, data) { - alert('COMMAND ' + JSON.stringify({name: name, data: data})); + alert("COMMAND " + JSON.stringify({name, data})); } function finish() { - alert('DONE'); + alert("DONE"); } var connection; @@ -51,7 +51,7 @@ function is_same_buffer(recv_data, expect_data) { for (let i = 0; i < recv_dataview.length; i++) { if (recv_dataview[i] != expected_dataview[i]) { - info('discover byte differenct at ' + i); + info("discover byte differenct at " + i); return false; } } @@ -60,7 +60,7 @@ function is_same_buffer(recv_data, expect_data) { function testConnectionAvailable() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testConnectionAvailable ---'); + info("Receiver: --- testConnectionAvailable ---"); ok(navigator.presentation, "Receiver: navigator.presentation should be available."); ok(navigator.presentation.receiver, "Receiver: navigator.presentation.receiver should be available."); is(navigator.presentation.defaultRequest, null, "Receiver: navigator.presentation.defaultRequest should be null."); @@ -83,10 +83,10 @@ function testConnectionAvailable() { function testConnectionReady() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testConnectionReady ---'); + info("Receiver: --- testConnectionReady ---"); connection.onconnect = function() { connection.onconnect = null; - ok(false, "Should not get |onconnect| event.") + ok(false, "Should not get |onconnect| event."); aReject(); }; if (connection.state === "connected") { @@ -99,27 +99,27 @@ function testConnectionReady() { function testIncomingMessage() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testIncomingMessage ---'); - connection.addEventListener('message', function(evt) { + info("Receiver: --- testIncomingMessage ---"); + connection.addEventListener("message", function(evt) { let msg = evt.data; - is(msg, 'msg-sender-to-receiver', 'Receiver: Receiver should receive message from sender.'); - command('forward-command', JSON.stringify({ name: 'message-from-sender-received' })); + is(msg, "msg-sender-to-receiver", "Receiver: Receiver should receive message from sender."); + command("forward-command", JSON.stringify({ name: "message-from-sender-received" })); aResolve(); }, {once: true}); - command('forward-command', JSON.stringify({ name: 'trigger-message-from-sender' })); + command("forward-command", JSON.stringify({ name: "trigger-message-from-sender" })); }); } function testSendMessage() { return new Promise(function(aResolve, aReject) { - window.addEventListener('hashchange', function hashchangeHandler(evt) { + window.addEventListener("hashchange", function hashchangeHandler(evt) { var message = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); - if (message.type === 'trigger-message-from-receiver') { - info('Receiver: --- testSendMessage ---'); - connection.send('msg-receiver-to-sender'); + if (message.type === "trigger-message-from-receiver") { + info("Receiver: --- testSendMessage ---"); + connection.send("msg-receiver-to-sender"); } - if (message.type === 'message-from-receiver-received') { - window.removeEventListener('hashchange', hashchangeHandler); + if (message.type === "message-from-receiver-received") { + window.removeEventListener("hashchange", hashchangeHandler); aResolve(); } }); @@ -128,11 +128,11 @@ function testSendMessage() { function testIncomingBlobMessage() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testIncomingBlobMessage ---'); - connection.send('testIncomingBlobMessage'); - connection.addEventListener('message', function(evt) { - let recvData= String.fromCharCode.apply(null, new Uint8Array(evt.data)); - is(recvData, "Hello World", 'expected same string data'); + info("Receiver: --- testIncomingBlobMessage ---"); + connection.send("testIncomingBlobMessage"); + connection.addEventListener("message", function(evt) { + let recvData = String.fromCharCode.apply(null, new Uint8Array(evt.data)); + is(recvData, "Hello World", "expected same string data"); aResolve(); }, {once: true}); }); @@ -140,29 +140,29 @@ function testIncomingBlobMessage() { function testConnectionClosed() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testConnectionClosed ---'); + info("Receiver: --- testConnectionClosed ---"); connection.onclose = function() { connection.onclose = null; is(connection.state, "closed", "Receiver: Connection should be closed."); - command('forward-command', JSON.stringify({ name: 'receiver-closed' })); + command("forward-command", JSON.stringify({ name: "receiver-closed" })); aResolve(); }; - command('forward-command', JSON.stringify({ name: 'ready-to-close' })); + command("forward-command", JSON.stringify({ name: "ready-to-close" })); }); } function testReconnectConnection() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testReconnectConnection ---'); - window.addEventListener('hashchange', function hashchangeHandler(evt) { + info("Receiver: --- testReconnectConnection ---"); + window.addEventListener("hashchange", function hashchangeHandler(evt) { var message = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); - if (message.type === 'prepare-for-reconnect') { - command('forward-command', JSON.stringify({ name: 'ready-to-reconnect' })); + if (message.type === "prepare-for-reconnect") { + command("forward-command", JSON.stringify({ name: "ready-to-reconnect" })); } }); connection.onconnect = function() { connection.onconnect = null; - ok(true, "The connection is reconnected.") + ok(true, "The connection is reconnected."); aResolve(); }; }); @@ -170,10 +170,10 @@ function testReconnectConnection() { function testIncomingArrayBuffer() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testIncomingArrayBuffer ---'); + info("Receiver: --- testIncomingArrayBuffer ---"); connection.binaryType = "blob"; - connection.send('testIncomingArrayBuffer'); - connection.addEventListener('message', function(evt) { + connection.send("testIncomingArrayBuffer"); + connection.addEventListener("message", function(evt) { var fileReader = new FileReader(); fileReader.onload = function() { ok(is_same_buffer(DATA_ARRAY_BUFFER, this.result), "expected same buffer data"); @@ -186,10 +186,10 @@ function testIncomingArrayBuffer() { function testIncomingArrayBufferView() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testIncomingArrayBufferView ---'); + info("Receiver: --- testIncomingArrayBufferView ---"); connection.binaryType = "arraybuffer"; - connection.send('testIncomingArrayBufferView'); - connection.addEventListener('message', function(evt) { + connection.send("testIncomingArrayBufferView"); + connection.addEventListener("message", function(evt) { ok(is_same_buffer(evt.data, TYPED_DATA_ARRAY), "expected same buffer data"); aResolve(); }, {once: true}); diff --git a/dom/presentation/tests/mochitest/file_presentation_1ua_wentaway.html b/dom/presentation/tests/mochitest/file_presentation_1ua_wentaway.html index 25a5f18fa166..5198e76be8f5 100644 --- a/dom/presentation/tests/mochitest/file_presentation_1ua_wentaway.html +++ b/dom/presentation/tests/mochitest/file_presentation_1ua_wentaway.html @@ -13,33 +13,33 @@ function is(a, b, msg) { if (a === b) { - alert('OK ' + msg); + alert("OK " + msg); } else { - alert('KO ' + msg + ' | reason: ' + a + ' != ' + b); + alert("KO " + msg + " | reason: " + a + " != " + b); } } function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function info(msg) { - alert('INFO ' + msg); + alert("INFO " + msg); } function command(name, data) { - alert('COMMAND ' + JSON.stringify({name: name, data: data})); + alert("COMMAND " + JSON.stringify({name, data})); } function finish() { - alert('DONE'); + alert("DONE"); } var connection; function testConnectionAvailable() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testConnectionAvailable ---'); + info("Receiver: --- testConnectionAvailable ---"); ok(navigator.presentation, "Receiver: navigator.presentation should be available."); ok(navigator.presentation.receiver, "Receiver: navigator.presentation.receiver should be available."); @@ -61,10 +61,10 @@ function testConnectionAvailable() { function testConnectionReady() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testConnectionReady ---'); + info("Receiver: --- testConnectionReady ---"); connection.onconnect = function() { connection.onconnect = null; - ok(false, "Should not get |onconnect| event.") + ok(false, "Should not get |onconnect| event."); aReject(); }; if (connection.state === "connected") { @@ -77,8 +77,8 @@ function testConnectionReady() { function testConnectionWentaway() { return new Promise(function(aResolve, aReject) { - info('Receiver: --- testConnectionWentaway ---\n'); - command('forward-command', JSON.stringify({ name: 'ready-to-remove-receiverFrame' })); + info("Receiver: --- testConnectionWentaway ---\n"); + command("forward-command", JSON.stringify({ name: "ready-to-remove-receiverFrame" })); }); } diff --git a/dom/presentation/tests/mochitest/file_presentation_fingerprinting_resistance_receiver.html b/dom/presentation/tests/mochitest/file_presentation_fingerprinting_resistance_receiver.html index ca9e81c1a3cd..5fd19673310b 100644 --- a/dom/presentation/tests/mochitest/file_presentation_fingerprinting_resistance_receiver.html +++ b/dom/presentation/tests/mochitest/file_presentation_fingerprinting_resistance_receiver.html @@ -6,5 +6,5 @@ function testReceiver() { } testReceiver(); -window.addEventListener('hashchange', testReceiver); +window.addEventListener("hashchange", testReceiver); diff --git a/dom/presentation/tests/mochitest/file_presentation_non_receiver.html b/dom/presentation/tests/mochitest/file_presentation_non_receiver.html index 62dd89c8d059..75ffe6b4ad22 100644 --- a/dom/presentation/tests/mochitest/file_presentation_non_receiver.html +++ b/dom/presentation/tests/mochitest/file_presentation_non_receiver.html @@ -11,19 +11,19 @@ "use strict"; function is(a, b, msg) { - alert((a === b ? 'OK ' : 'KO ') + msg); + alert((a === b ? "OK " : "KO ") + msg); } function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function info(msg) { - alert('INFO ' + msg); + alert("INFO " + msg); } function finish() { - alert('DONE'); + alert("DONE"); } function testConnectionAvailable() { diff --git a/dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe.html b/dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe.html index 8b6822ca6ff2..38652839b3c5 100644 --- a/dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe.html +++ b/dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe.html @@ -11,7 +11,7 @@ "use strict"; function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function testConnectionAvailable() { diff --git a/dom/presentation/tests/mochitest/file_presentation_receiver.html b/dom/presentation/tests/mochitest/file_presentation_receiver.html index 1ce7c48871e6..8099ed0c89fa 100644 --- a/dom/presentation/tests/mochitest/file_presentation_receiver.html +++ b/dom/presentation/tests/mochitest/file_presentation_receiver.html @@ -11,23 +11,23 @@ "use strict"; function is(a, b, msg) { - alert((a === b ? 'OK ' : 'KO ') + msg); + alert((a === b ? "OK " : "KO ") + msg); } function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function info(msg) { - alert('INFO ' + msg); + alert("INFO " + msg); } function command(msg) { - alert('COMMAND ' + JSON.stringify(msg)); + alert("COMMAND " + JSON.stringify(msg)); } function finish() { - alert('DONE'); + alert("DONE"); } var connection; @@ -51,7 +51,7 @@ function testConnectionAvailable() { aReject(); } ); - command({ name: 'trigger-incoming-offer' }); + command({ name: "trigger-incoming-offer" }); }); } @@ -64,8 +64,8 @@ function testDefaultRequestIsUndefined() { function testConnectionAvailableSameOriginInnerIframe() { return new Promise(function(aResolve, aReject) { - var iframe = document.createElement('iframe'); - iframe.setAttribute('src', './file_presentation_receiver_inner_iframe.html'); + var iframe = document.createElement("iframe"); + iframe.setAttribute("src", "./file_presentation_receiver_inner_iframe.html"); document.body.appendChild(iframe); aResolve(); @@ -74,8 +74,8 @@ function testConnectionAvailableSameOriginInnerIframe() { function testConnectionUnavailableDiffOriginInnerIframe() { return new Promise(function(aResolve, aReject) { - var iframe = document.createElement('iframe'); - iframe.setAttribute('src', 'http://example.com/tests/dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe.html'); + var iframe = document.createElement("iframe"); + iframe.setAttribute("src", "http://example.com/tests/dom/presentation/tests/mochitest/file_presentation_non_receiver_inner_iframe.html"); document.body.appendChild(iframe); aResolve(); @@ -103,12 +103,12 @@ function testIncomingMessage() { return new Promise(function(aResolve, aReject) { const incomingMessage = "test incoming message"; - connection.addEventListener('message', function(aEvent) { + connection.addEventListener("message", function(aEvent) { is(aEvent.data, incomingMessage, "An incoming message should be received."); aResolve(); }, {once: true}); - command({ name: 'trigger-incoming-message', + command({ name: "trigger-incoming-message", data: incomingMessage }); }); } diff --git a/dom/presentation/tests/mochitest/file_presentation_receiver_auxiliary_navigation.html b/dom/presentation/tests/mochitest/file_presentation_receiver_auxiliary_navigation.html index 3fb7ba552977..6bd3da1f47bf 100644 --- a/dom/presentation/tests/mochitest/file_presentation_receiver_auxiliary_navigation.html +++ b/dom/presentation/tests/mochitest/file_presentation_receiver_auxiliary_navigation.html @@ -11,23 +11,23 @@ "use strict"; function is(a, b, msg) { - alert((a === b ? 'OK ' : 'KO ') + msg); + alert((a === b ? "OK " : "KO ") + msg); } function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function info(msg) { - alert('INFO ' + msg); + alert("INFO " + msg); } function command(msg) { - alert('COMMAND ' + JSON.stringify(msg)); + alert("COMMAND " + JSON.stringify(msg)); } function finish() { - alert('DONE'); + alert("DONE"); } function testConnectionAvailable() { @@ -44,7 +44,7 @@ function testOpenWindow() { try { window.open("http://example.com"); ok(false, "receiver page should not be able to open a new window."); - } catch(e) { + } catch (e) { ok(true, "receiver page should not be able to open a new window."); aResolve(); } diff --git a/dom/presentation/tests/mochitest/file_presentation_receiver_establish_connection_error.html b/dom/presentation/tests/mochitest/file_presentation_receiver_establish_connection_error.html index 14caca9971a7..f6dd10797e76 100644 --- a/dom/presentation/tests/mochitest/file_presentation_receiver_establish_connection_error.html +++ b/dom/presentation/tests/mochitest/file_presentation_receiver_establish_connection_error.html @@ -12,26 +12,26 @@ function is(a, b, msg) { if (a === b) { - alert('OK ' + msg); + alert("OK " + msg); } else { - alert('KO ' + msg + ' | reason: ' + a + ' != ' + b); + alert("KO " + msg + " | reason: " + a + " != " + b); } } function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function info(msg) { - alert('INFO ' + msg); + alert("INFO " + msg); } function command(name, data) { - alert('COMMAND ' + JSON.stringify({name: name, data: data})); + alert("COMMAND " + JSON.stringify({name, data})); } function finish() { - alert('DONE'); + alert("DONE"); } function testConnectionAvailable() { @@ -44,13 +44,13 @@ function testConnectionAvailable() { function testUnexpectedControlChannelClose() { // Trigger the control channel to be closed with error code. - command({ name: 'trigger-control-channel-close', data: 0x80004004 /* NS_ERROR_ABORT */ }); + command({ name: "trigger-control-channel-close", data: 0x80004004 /* NS_ERROR_ABORT */ }); return new Promise(function(aResolve, aReject) { return Promise.race([ navigator.presentation.receiver.connectionList.then( (aList) => { - ok(false, "Should not get a connection list.") + ok(false, "Should not get a connection list."); aReject(); }, (aError) => { diff --git a/dom/presentation/tests/mochitest/file_presentation_receiver_inner_iframe.html b/dom/presentation/tests/mochitest/file_presentation_receiver_inner_iframe.html index 6f31acd3e39b..dac1abac143b 100644 --- a/dom/presentation/tests/mochitest/file_presentation_receiver_inner_iframe.html +++ b/dom/presentation/tests/mochitest/file_presentation_receiver_inner_iframe.html @@ -11,7 +11,7 @@ "use strict"; function ok(a, msg) { - alert((a ? 'OK ' : 'KO ') + msg); + alert((a ? "OK " : "KO ") + msg); } function testConnectionAvailable() { diff --git a/dom/presentation/tests/mochitest/file_presentation_reconnect.html b/dom/presentation/tests/mochitest/file_presentation_reconnect.html index 029ccc68eca1..4c2d581ea9ab 100644 --- a/dom/presentation/tests/mochitest/file_presentation_reconnect.html +++ b/dom/presentation/tests/mochitest/file_presentation_reconnect.html @@ -81,14 +81,13 @@ function testCloseConnection() { window.addEventListener("message", function onMessage(evt) { if (evt.data === "startConnection") { testStartRequest().then( - function () { + function() { command({ name: "connection-connected", id: connection.id }); } ); - } - else if (evt.data === "closeConnection") { + } else if (evt.data === "closeConnection") { testCloseConnection().then( - function () { + function() { command({ name: "connection-closed", id: connection.id }); } ); diff --git a/dom/presentation/tests/mochitest/file_presentation_terminate.html b/dom/presentation/tests/mochitest/file_presentation_terminate.html index 0aa6d19b78e6..db5972f8d181 100644 --- a/dom/presentation/tests/mochitest/file_presentation_terminate.html +++ b/dom/presentation/tests/mochitest/file_presentation_terminate.html @@ -9,50 +9,50 @@
diff --git a/dom/presentation/tests/mochitest/test_presentation_mixed_security_contexts.html b/dom/presentation/tests/mochitest/test_presentation_mixed_security_contexts.html index 834001fbc18a..2ace5c8b762f 100644 --- a/dom/presentation/tests/mochitest/test_presentation_mixed_security_contexts.html +++ b/dom/presentation/tests/mochitest/test_presentation_mixed_security_contexts.html @@ -42,7 +42,7 @@ function setup() { startTest(); } } else if (/^DONE$/.exec(message)) { - window.removeEventListener('message', listener); + window.removeEventListener("message", listener); SimpleTest.finish(); } }, false); diff --git a/dom/presentation/tests/mochitest/test_presentation_receiver_auxiliary_navigation.js b/dom/presentation/tests/mochitest/test_presentation_receiver_auxiliary_navigation.js index 791d71de700f..aafd97491162 100644 --- a/dom/presentation/tests/mochitest/test_presentation_receiver_auxiliary_navigation.js +++ b/dom/presentation/tests/mochitest/test_presentation_receiver_auxiliary_navigation.js @@ -13,7 +13,7 @@ function setup() { var iframe = document.createElement("iframe"); iframe.setAttribute("mozbrowser", "true"); iframe.setAttribute("mozpresentation", receiverUrl); - var oop = !location.pathname.includes('_inproc'); + var oop = !location.pathname.includes("_inproc"); iframe.setAttribute("remote", oop); iframe.setAttribute("src", receiverUrl); diff --git a/dom/presentation/tests/mochitest/test_presentation_reconnect.html b/dom/presentation/tests/mochitest/test_presentation_reconnect.html index d12b998f1e35..89a3f5467109 100644 --- a/dom/presentation/tests/mochitest/test_presentation_reconnect.html +++ b/dom/presentation/tests/mochitest/test_presentation_reconnect.html @@ -14,10 +14,10 @@