Skip to content

Commit 3ad597c

Browse files
authored
Merge pull request #375 from floating-cat/deprecate_domerror
Fix #374: Deprecate DOMError in favor of DOMException.
2 parents 0ede725 + 33d64c2 commit 3ad597c

File tree

6 files changed

+82
-133
lines changed

6 files changed

+82
-133
lines changed

src/main/scala/org/scalajs/dom/experimental/mediastream/MediaStream.scala

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ package org.scalajs.dom.experimental.mediastream
66
import scala.scalajs.js
77
import scala.scalajs.js.|
88
import scala.scalajs.js.annotation._
9-
10-
import org.scalajs.dom.raw.{DOMError, Event, EventInit, EventTarget}
9+
import org.scalajs.dom.raw.{DOMException, Event, EventInit, EventTarget}
1110

1211
/**
1312
* The MediaStream
@@ -566,14 +565,6 @@ object MediaDeviceInfo {
566565
}
567566
}
568567

569-
@js.native
570-
trait NavigatorMediaStream extends js.Object {
571-
572-
def getUserMedia(constraints: MediaStreamConstraints,
573-
success: js.Function1[MediaStream, Any],
574-
error: js.Function1[DOMError, Any]): Unit = js.native
575-
}
576-
577568
/**
578569
* The MediaDevices interface provides access to connected media input devices
579570
* like cameras and microphones, as well as screen sharing. In essence, it

src/main/scala/org/scalajs/dom/experimental/webrtc/WebRTC.scala

+20-87
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import scala.scalajs.js.|
1010

1111
import org.scalajs.dom.Blob
1212
import org.scalajs.dom.raw.{
13-
DOMError, Event, EventInit, EventTarget, MessageEvent
13+
DOMException, Event, EventInit, EventTarget, MessageEvent
1414
}
1515
import org.scalajs.dom.experimental.mediastream._
1616

@@ -1036,98 +1036,31 @@ class RTCPeerConnection(
10361036
var onsignalingstatechange: js.Function1[Event, Any] = js.native
10371037

10381038
/**
1039-
* The createOffer method generates a blob of SDP that contains an RFC 3264
1040-
* offer with the supported configurations for the session, including
1041-
* descriptions of the local MediaStreams attached to this RTCPeerConnection,
1042-
* the codec/RTP/RTCP options supported by this implementation, and any
1043-
* candidates that have been gathered by the ICE Agent. The options parameter
1044-
* may be supplied to provide additional control over the offer generated.
1045-
*
1046-
* As an offer, the generated SDP will contain the full set of capabilities
1047-
* supported by the session (as opposed to an answer, which will include only
1048-
* a specific negotiated subset to use); for each SDP line, the generation
1049-
* of the SDP must follow the appropriate process for generating an offer.
1050-
* In the event createOffer is called after the session is established,
1051-
* createOffer will generate an offer that is compatible with the current
1052-
* session, incorporating any changes that have been made to the session
1053-
* since the last complete offer-answer exchange, such as addition or removal
1054-
* of streams. If no changes have been made, the offer will include the
1055-
* capabilities of the current local description as well as any additional
1056-
* capabilities that could be negotiated in an updated offer.
1057-
*
1058-
* Session descriptions generated by createOffer must be immediately usable
1059-
* by setLocalDescription without causing an error as long as
1060-
* setLocalDescription is called reasonably soon. If a system has limited
1061-
* resources (e.g. a finite number of decoders), createOffer needs to return
1062-
* an offer that reflects the current state of the system, so that
1063-
* setLocalDescription will succeed when it attempts to acquire those
1064-
* resources. The session descriptions must remain usable by
1065-
* setLocalDescription without causing an error until at least the end of
1066-
* the fulfillment callback of the returned promise. Calling this method
1067-
* is needed to get the ICE user name fragment and password.
1068-
*
1069-
* If the RTCPeerConnection is configured to generate Identity assertions,
1070-
* then the session description shall contain an appropriate assertion.
1071-
*
1072-
* If this RTCPeerConnection object is closed before the SDP generation
1073-
* process completes, the USER agent must suppress the result and not resolve
1074-
* or reject the returned promise.
1075-
*
1076-
* If the SDP generation process completed successfully, the user agent must
1077-
* resolve the returned promise with a newly created RTCSessionDescription
1078-
* object, representing the generated offer.
1079-
*
1080-
* If the SDP generation process failed for any reason, the user agent must
1081-
* reject the returned promise with an DOMError object of type TBD as its
1082-
* argument.
1083-
*
1084-
* To Do: Discuss privacy aspects of this from a fingerprinting point of
1085-
* view - it's probably around as bad as access to a canvas :-)
1039+
* The createOffer() method of the RTCPeerConnection interface initiates the
1040+
* creation of an SDP offer for the purpose of starting a new WebRTC connection
1041+
* to a remote peer. The SDP offer includes information about any MediaStreamTracks
1042+
* already attached to the WebRTC session, codec, and options supported by the
1043+
* browser, and any candidates already gathered by the ICE agent, for the purpose
1044+
* of being sent over the signaling channel to a potential peer to request a connection
1045+
* or to update the configuration of an existing connection.
10861046
*
1047+
* The return value is a Promise which, when the offer has been created, is resolved
1048+
* with a RTCSessionDescription object containing the newly-created offer.
1049+
*
1050+
* MDN
10871051
*/
10881052
def createOffer(
10891053
options: RTCOfferOptions = js.native): js.Promise[RTCSessionDescription] = js.native
10901054

10911055
/**
1092-
* The createAnswer method generates an [SDP] answer with the supported
1093-
* configuration for the session that is compatible with the parameters in
1094-
* the remote configuration. Like createOffer, the returned blob contains
1095-
* descriptions of the local MediaStreams attached to this RTCPeerConnection,
1096-
* the codec/RTP/RTCP options negotiated for this session, and any candidates
1097-
* that have been gathered by the ICE Agent. The options parameter may be
1098-
* supplied to provide additional control over the generated answer.
1099-
*
1100-
* As an answer, the generated SDP will contain a specific configuration
1101-
* that, along with the corresponding offer, specifies how the media plane
1102-
* should be established. The generation of the SDP must follow the
1103-
* appropriate process for generating an answer.
1104-
*
1105-
* Session descriptions generated by createAnswer must be immediately usable
1106-
* by setLocalDescription without causing an error as long as
1107-
* setLocalDescription is called reasonably soon. Like createOffer, the
1108-
* returned description should reflect the current state of the system. The
1109-
* session descriptions must remain usable by setLocalDescription without
1110-
* causing an error until at least the end of the fulfillment callback of
1111-
* the returned promise. Calling this method is needed to get the ICE user
1112-
* name fragment and password.
1113-
*
1114-
* An answer can be marked as provisional, as described in [RTCWEB-JSEP], by
1115-
* setting the type to "pranswer".
1116-
*
1117-
* If the RTCPeerConnection is configured to generate Identity assertions,
1118-
* then the session description shall contain an appropriate assertion.
1119-
*
1120-
* If this RTCPeerConnection object is closed before the SDP generation process
1121-
* completes, the USER agent must suppress the result and not resolve or reject
1122-
* the returned promise.
1123-
*
1124-
* If the SDP generation process completed successfully, the user agent must
1125-
* resolve the returned promise with a newly created RTCSessionDescription
1126-
* object, representing the generated answer.
1127-
*
1128-
* If the SDP generation process failed for any reason, the user agent must
1129-
* reject the returned promise with a DOMError object of type TBD.
1056+
* The createAnswer() method on the RTCPeerConnection interface creates an SDP answer to
1057+
* an offer received from a remote peer during the offer/answer negotiation of a WebRTC
1058+
* connection. The answer contains information about any media already attached to the
1059+
* session, codecs and options supported by the browser, and any ICE candidates already
1060+
* gathered. The answer is delivered to the returned Promise, and should then be sent to
1061+
* the source of the offer to continue the negotiation process.
11301062
*
1063+
* MDN
11311064
*/
11321065
def createAnswer(): js.Promise[RTCSessionDescription] = js.native
11331066

@@ -1258,7 +1191,7 @@ class RTCPeerConnection(
12581191
*/
12591192
def getStats(selector: MediaStreamTrack,
12601193
callback: js.Function1[RTCStatsReport, Any],
1261-
error: js.Function1[DOMError, Any]): RTCStatsReport = js.native
1194+
error: js.Function1[DOMException, Any]): RTCStatsReport = js.native
12621195

12631196
/**
12641197
* Sets the identity provider to be used for a given RTCPeerConnection object.

src/main/scala/org/scalajs/dom/experimental/webrtc/package.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package org.scalajs.dom.experimental
22

3-
import org.scalajs.dom.DOMError
43
import org.scalajs.dom.experimental.mediastream._
4+
import org.scalajs.dom.raw.DOMException
5+
56
import scala.scalajs.js
67
import scala.language.implicitConversions
78

@@ -26,7 +27,7 @@ package object webrtc {
2627
"Navigator.getUserMedia() is deprecated, use Navigator.mediaDevices.getUserMedia() instead.",
2728
"2014-05-28")
2829
def getUserMedia(constraints: MediaStreamConstraints,
29-
success: js.Function1[MediaStream, Any],
30-
error: js.Function1[DOMError, Any]): Unit = js.native
30+
successCallback: js.Function1[MediaStream, Any],
31+
errorCallback: js.Function1[DOMException, Any]): Unit = js.native
3132
}
3233
}

src/main/scala/org/scalajs/dom/package.scala

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ package object dom {
5959
type DOMException = raw.DOMException
6060
type DOMImplementation = raw.DOMImplementation
6161
lazy val DOMException: raw.DOMException.type = raw.DOMException
62+
@deprecated("Use DOMException instead", "DOM Level 3 Core")
6263
type DOMError = raw.DOMError
6364
type DOMList[T] = raw.DOMList[T]
6465
type DOMParser = raw.DOMParser

src/main/scala/org/scalajs/dom/raw/Idb.scala

+10-13
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class IDBObjectStore extends js.Object {
9999
def deleteIndex(indexName: String): Unit = js.native
100100

101101
/**
102-
* This method may raise a DOMException with a DOMError of the following types:
102+
* This method may raise a DOMException of one of the following types:
103103
*
104104
* MDN
105105
*/
@@ -300,7 +300,7 @@ class IDBCursor extends js.Object {
300300
def primaryKey: js.Any = js.native
301301

302302
/**
303-
* This method may raise a DOMException with a DOMError of the following types:
303+
* This method may raise a DOMException of one of the following types:
304304
*
305305
* MDN
306306
*/
@@ -436,7 +436,7 @@ object IDBKeyRange extends js.Object {
436436
upperOpen: Boolean = js.native): IDBKeyRange = js.native
437437

438438
/**
439-
* This method may raise a DOMException with a DOMError of the following types:
439+
* This method may raise a DOMException of the following types:
440440
*
441441
* MDN
442442
*/
@@ -496,16 +496,13 @@ class IDBTransaction extends EventTarget {
496496
def mode: String = js.native
497497

498498
/**
499-
* The error returned in the event of an unsuccessful transaction. Null if the
500-
* transaction is not finished, is finished and successfully committed, or was
501-
* aborted with IDBTransaction.abort function. Returns the same DOMError as the
502-
* request object which caused the transaction to be aborted due to a failed request,
503-
* or a DOMError for the transaction failure not due to a failed request (such as
504-
* QuotaExceededError or UnknownError).
499+
* Returns a DOMException indicating the type of error that occured when there is an
500+
* unsuccessful transaction. This property is null if the transaction is not finished,
501+
* is finished and successfully committed, or was aborted with IDBTransaction.abort function.
505502
*
506503
* MDN
507504
*/
508-
def error: DOMError = js.native
505+
def error: DOMException = js.native
509506

510507
/**
511508
* The event handler for the onerror event.
@@ -770,12 +767,12 @@ class IDBRequest extends EventTarget {
770767
var onsuccess: js.Function1[Event, _] = js.native
771768

772769
/**
773-
* A DOMError containing the relevant error. The following error codes are returned
774-
* under certain conditions:
770+
* Returns a DOMException in the event of an unsuccessful request, indicating what
771+
* went wrong.
775772
*
776773
* MDN
777774
*/
778-
def error: DOMError = js.native
775+
def error: DOMException = js.native
779776

780777
/**
781778
* The transaction for the request. This property can be null for certain requests,

src/main/scala/org/scalajs/dom/raw/lib.scala

+46-20
Original file line numberDiff line numberDiff line change
@@ -6665,45 +6665,62 @@ abstract class CharacterData extends Node with NonDocumentTypeChildNode {
66656665
class DOMException extends js.Object {
66666666

66676667
/**
6668-
* Readonly short. Returns one of the exception code constants (see below).
6669-
* Deprecated use DOMError.name instead.
6668+
* Returns a short that contains one of the error code constants one of the
6669+
* exception code constants (see below) or 0 if none match. This field is used
6670+
* for historical reasons. New DOM exceptions don't use this anymore: they put
6671+
* this info in the name attribute.
66706672
*
66716673
* MDN
66726674
*/
66736675
@deprecated("Obsolete.", "DOM4")
66746676
def code: Int = js.native
66756677

6678+
/**
6679+
* Returns a DOMString representing a message or description associated with
6680+
* the given error name.
6681+
*
6682+
* MDN
6683+
*/
66766684
def message: String = js.native
6685+
6686+
/**
6687+
* Returns a DOMString that contains one of the strings associated with an
6688+
* error name.
6689+
*
6690+
* MDN
6691+
*/
6692+
def name: String = js.native
66776693
}
66786694

66796695
@js.native
66806696
@JSGlobal
66816697
object DOMException extends js.Object {
66826698

6699+
val INDEX_SIZE_ERR: Int = js.native
6700+
val DOMSTRING_SIZE_ERR: Int = js.native
66836701
val HIERARCHY_REQUEST_ERR: Int = js.native
6702+
val WRONG_DOCUMENT_ERR: Int = js.native
6703+
val INVALID_CHARACTER_ERR: Int = js.native
6704+
val NO_DATA_ALLOWED_ERR: Int = js.native
66846705
val NO_MODIFICATION_ALLOWED_ERR: Int = js.native
6706+
val NOT_FOUND_ERR: Int = js.native
6707+
val NOT_SUPPORTED_ERR: Int = js.native
6708+
val INUSE_ATTRIBUTE_ERR: Int = js.native
6709+
val INVALID_STATE_ERR: Int = js.native
6710+
val SYNTAX_ERR: Int = js.native
66856711
val INVALID_MODIFICATION_ERR: Int = js.native
66866712
val NAMESPACE_ERR: Int = js.native
6687-
val INVALID_CHARACTER_ERR: Int = js.native
6713+
val INVALID_ACCESS_ERR: Int = js.native
6714+
val VALIDATION_ERR: Int = js.native
66886715
val TYPE_MISMATCH_ERR: Int = js.native
6689-
val ABORT_ERR: Int = js.native
6690-
val INVALID_STATE_ERR: Int = js.native
66916716
val SECURITY_ERR: Int = js.native
66926717
val NETWORK_ERR: Int = js.native
6693-
val WRONG_DOCUMENT_ERR: Int = js.native
6694-
val QUOTA_EXCEEDED_ERR: Int = js.native
6695-
val INDEX_SIZE_ERR: Int = js.native
6696-
val DOMSTRING_SIZE_ERR: Int = js.native
6697-
val SYNTAX_ERR: Int = js.native
6698-
val SERIALIZE_ERR: Int = js.native
6699-
val VALIDATION_ERR: Int = js.native
6700-
val NOT_FOUND_ERR: Int = js.native
6718+
val ABORT_ERR: Int = js.native
67016719
val URL_MISMATCH_ERR: Int = js.native
6702-
val PARSE_ERR: Int = js.native
6703-
val NO_DATA_ALLOWED_ERR: Int = js.native
6704-
val NOT_SUPPORTED_ERR: Int = js.native
6705-
val INVALID_ACCESS_ERR: Int = js.native
6706-
val INUSE_ATTRIBUTE_ERR: Int = js.native
6720+
val QUOTA_EXCEEDED_ERR: Int = js.native
6721+
val TIMEOUT_ERR: Int = js.native
6722+
val INVALID_NODE_TYPE_ERR: Int = js.native
6723+
val DATA_CLONE_ERR: Int = js.native
67076724
}
67086725

67096726
/**
@@ -6992,6 +7009,7 @@ trait MediaQueryList extends js.Object {
69927009
*
69937010
* MDN
69947011
*/
7012+
@deprecated("Use DOMException instead", "DOM Level 3 Core")
69957013
@js.native
69967014
trait DOMError extends js.Object {
69977015

@@ -7001,6 +7019,14 @@ trait DOMError extends js.Object {
70017019
* MDN
70027020
*/
70037021
def name: String = js.native
7022+
7023+
/**
7024+
* Readonly DOMString. Returns a message or description associated with the given
7025+
* error type name.
7026+
*
7027+
* MDN
7028+
*/
7029+
def message: String = js.native
70047030
}
70057031

70067032
/**
@@ -7808,11 +7834,11 @@ trait MessagePort extends EventTarget {
78087834
class FileReader() extends EventTarget {
78097835

78107836
/**
7811-
* A DOMError representing the error that occurred while reading the file.
7837+
* A DOMException representing the error that occurred while reading the file.
78127838
*
78137839
* MDN
78147840
*/
7815-
def error: DOMError = js.native
7841+
def error: DOMException = js.native
78167842

78177843
/**
78187844
* A number indicating the state of the FileReader. This will be one of the State constants.

0 commit comments

Comments
 (0)