Skip to content

Commit d7cdbb6

Browse files
committed
Add Navigator's ProtocolHandler methods
Add to Navigator the two protocol handler methods: - registerProtocolHandler - https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler - unregisterProtocolHandler - https://developer.mozilla.org/en-US/docs/Web/API/Navigator/unregisterProtocolHandler
1 parent 7d0508c commit d7cdbb6

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

api-reports/2_12.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16477,9 +16477,11 @@ Navigator[JC] def mediaDevices: MediaDevices
1647716477
Navigator[JC] def onLine: Boolean
1647816478
Navigator[JC] val permissions: Permissions
1647916479
Navigator[JC] def platform: String
16480+
Navigator[JC] def registerProtocolHandler(scheme: String, url: String): Unit
1648016481
Navigator[JC] def sendBeacon(url: String, data: BodyInit?): Boolean
1648116482
Navigator[JC] val serviceWorker: ServiceWorkerContainer
1648216483
Navigator[JC] def storage: StorageManager
16484+
Navigator[JC] def unregisterProtocolHandler(scheme: String, url: String): Unit
1648316485
Navigator[JC] def userAgent: String
1648416486
Navigator[JC] def vibrate(duration: Double): Boolean
1648516487
Navigator[JC] def vibrate(pattern: js.Array[Double]): Boolean
@@ -16493,6 +16495,8 @@ NavigatorLanguage[JT] def language: String
1649316495
NavigatorLanguage[JT] def languages: js.Array[String]
1649416496
NavigatorLocks[JT] def locks: LockManager
1649516497
NavigatorOnLine[JT] def onLine: Boolean
16498+
NavigatorProtocolHandler[JT] def registerProtocolHandler(scheme: String, url: String): Unit
16499+
NavigatorProtocolHandler[JT] def unregisterProtocolHandler(scheme: String, url: String): Unit
1649616500
NavigatorStorageUtils[JT]
1649716501
NavigatorVibration[JT] def vibrate(duration: Double): Boolean
1649816502
NavigatorVibration[JT] def vibrate(pattern: js.Array[Double]): Boolean

api-reports/2_13.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16477,9 +16477,11 @@ Navigator[JC] def mediaDevices: MediaDevices
1647716477
Navigator[JC] def onLine: Boolean
1647816478
Navigator[JC] val permissions: Permissions
1647916479
Navigator[JC] def platform: String
16480+
Navigator[JC] def registerProtocolHandler(scheme: String, url: String): Unit
1648016481
Navigator[JC] def sendBeacon(url: String, data: BodyInit?): Boolean
1648116482
Navigator[JC] val serviceWorker: ServiceWorkerContainer
1648216483
Navigator[JC] def storage: StorageManager
16484+
Navigator[JC] def unregisterProtocolHandler(scheme: String, url: String): Unit
1648316485
Navigator[JC] def userAgent: String
1648416486
Navigator[JC] def vibrate(duration: Double): Boolean
1648516487
Navigator[JC] def vibrate(pattern: js.Array[Double]): Boolean
@@ -16493,6 +16495,8 @@ NavigatorLanguage[JT] def language: String
1649316495
NavigatorLanguage[JT] def languages: js.Array[String]
1649416496
NavigatorLocks[JT] def locks: LockManager
1649516497
NavigatorOnLine[JT] def onLine: Boolean
16498+
NavigatorProtocolHandler[JT] def registerProtocolHandler(scheme: String, url: String): Unit
16499+
NavigatorProtocolHandler[JT] def unregisterProtocolHandler(scheme: String, url: String): Unit
1649616500
NavigatorStorageUtils[JT]
1649716501
NavigatorVibration[JT] def vibrate(duration: Double): Boolean
1649816502
NavigatorVibration[JT] def vibrate(pattern: js.Array[Double]): Boolean

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import scala.scalajs.js.annotation._
1818
@JSGlobal
1919
class Navigator
2020
extends NavigatorID with NavigatorOnLine with NavigatorContentUtils with NavigatorGeolocation
21-
with NavigatorStorageUtils with NavigatorLanguage with NavigatorLocks with NavigatorVibration {
21+
with NavigatorStorageUtils with NavigatorLanguage with NavigatorLocks with NavigatorVibration
22+
with NavigatorProtocolHandler {
2223

2324
/** The Clipboard API adds to the Navigator interface the read-only clipboard property, which returns the Clipboard
2425
* object used to read and write the clipboard's contents. The Clipboard API can be used to implement cut, copy, and
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.scalajs.dom
2+
3+
import scala.scalajs.js
4+
5+
@js.native
6+
trait NavigatorProtocolHandler extends js.Object {
7+
8+
/** The Navigator method registerProtocolHandler() lets websites register their ability to open or handle particular
9+
* URL schemes (aka protocols).
10+
*
11+
* For example, this API lets webmail sites open mailto: URLs, or VoIP sites open tel: URLs.
12+
*
13+
* @see
14+
* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
15+
*
16+
* @param scheme
17+
* A string containing the permitted scheme for the protocol that the site wishes to handle. For example, you can
18+
* register to handle SMS text message links by passing the "sms" scheme.
19+
* @param url
20+
* A string containing the URL of the handler. This URL must include %s, as a placeholder that will be replaced
21+
* with the escaped URL to be handled.
22+
* @return
23+
* undefined
24+
*
25+
* @throws SecurityError
26+
* DOMException: The user agent blocked the registration. This might happen if:
27+
* - The registered scheme (protocol) is invalid, such as a scheme the browser handles itself (https:, about:,
28+
* etc.)
29+
* - The handler URL's origin does not match the origin of the page calling this API.
30+
* - The browser requires that this function is called from a secure context.
31+
* - The browser requires that the handler's URL be over HTTPS.
32+
*
33+
* @throws SyntaxError
34+
* DOMException: The %s placeholder is missing from the handler URL
35+
*/
36+
def registerProtocolHandler(scheme: String, url: String): Unit = js.native
37+
38+
/** The Navigator method unregisterProtocolHandler() removes a protocol handler for a given URL scheme.
39+
*
40+
* This method is the inverse of registerProtocolHandler().
41+
*
42+
* @see
43+
* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/unregisterProtocolHandler
44+
*
45+
* @param scheme
46+
* A string containing the permitted scheme in the protocol handler that will be unregistered. For example, you can
47+
* unregister the handler for SMS text message links by passing the "sms" scheme.
48+
* @param url
49+
* A string containing the URL of the handler. This URL should match the one that was used to register the handler
50+
* (e.g. it must include %s).
51+
* @return
52+
* undefined
53+
*
54+
* @throws SecurityError
55+
* DOMException: The user agent blocked unregistration. This might happen if:
56+
* - The registered scheme (protocol) is invalid, such as a scheme the browser handles itself (https:, about:,
57+
* etc.)
58+
* - The handler URL's origin does not match the origin of the page calling this API.
59+
* - The browser requires that this function is called from a secure context.
60+
* - The browser requires that the handler's URL be over HTTPS.
61+
*
62+
* @throws SyntaxError
63+
* DOMException: The %s placeholder is missing from the handler URL
64+
*/
65+
def unregisterProtocolHandler(scheme: String, url: String): Unit = js.native
66+
67+
}

0 commit comments

Comments
 (0)