Test for KT-2388: if function passed as setTimeout callback, all "this" references will be point to HTML window instead of real object.
#KT-2388 fixed
This commit is contained in:
@@ -75,4 +75,8 @@ public final class NativeInteropTest extends SingleFileTranslationTest {
|
||||
public void testKt2209() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testKt2388() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package foo
|
||||
|
||||
native
|
||||
fun _setTimeout(callback:()->Unit):Unit = noImpl
|
||||
|
||||
var done = false
|
||||
|
||||
object foo {
|
||||
var timeoutId: Long = 1
|
||||
|
||||
val callbackWrapper = {
|
||||
timeoutId = -1 as Long
|
||||
done = true
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
_setTimeout(foo.callbackWrapper)
|
||||
return foo.timeoutId == -1 as Long
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
function _setTimeout(callback) {
|
||||
callback.call({});
|
||||
}
|
||||
Reference in New Issue
Block a user