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:
Pavel V. Talanov
2012-08-13 16:10:51 +04:00
parent 8ec0f8af3f
commit 310d926747
3 changed files with 27 additions and 0 deletions
@@ -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({});
}