File tree Expand file tree Collapse file tree 2 files changed +11
-20
lines changed
commonMain/kotlin/org/jetbrains/skiko
jsTest/kotlin/org/jetbrains/skiko Expand file tree Collapse file tree 2 files changed +11
-20
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,6 @@ enum class OS(val id: String) {
77 MacOS (" macos" ),
88 Ios (" ios" ),
99 Tvos (" tvos" ),
10-
11- @Deprecated(" JS is invalid host OS name. Consider using enum KotlinBackend to detect JS." )
12- JS (" js" ),
1310 Unknown (" unknown" )
1411 ;
1512
@@ -26,10 +23,6 @@ enum class OS(val id: String) {
2623enum class Arch (val id : String ) {
2724 X64 (" x64" ),
2825 Arm64 (" arm64" ),
29- @Deprecated(" JS is not valid Arch value" )
30- JS (" js" ),
31- @Deprecated(" WASM is not valid Arch value" )
32- WASM (" wasm" ),
3326 Unknown (" unknown" ),
3427 ;
3528}
Original file line number Diff line number Diff line change 1- package org.jetbrains.skiko.tests.org.jetbrains.skiko
1+ package org.jetbrains.skiko
22
3- import org.jetbrains.skiko.OS
4- import org.jetbrains.skiko.detectHostOs
5- import org.jetbrains.skiko.hostOs
63import kotlin.test.Test
74import kotlin.test.assertEquals
8- import kotlin.test.assertNotEquals
95
106class HostOsTest {
11- @Test
12- fun canGetHostOs () {
13- assertNotEquals(OS .JS , hostOs)
14- }
15-
167 @Test
178 fun canGetLinux () {
189 spoofUserAgentData(" linux" )
@@ -51,6 +42,13 @@ class HostOsTest {
5142 }
5243}
5344
54- private fun spoofUserAgentData (newValue : String ) =
55- js(""" navigator.__defineGetter__('userAgentData', function () { return { platform:newValue }; });""" )
56-
45+ private fun spoofUserAgentData (newValue : String ) {
46+ val userAgentData = js(" ({})" )
47+ userAgentData.platform = newValue
48+ js(
49+ """ Object.defineProperty(navigator, 'userAgentData', {
50+ configurable: true,
51+ value: userAgentData
52+ });"""
53+ )
54+ }
You can’t perform that action at this time.
0 commit comments