added the start of an experimental browser API so we can access the browser environment from a typesafe kotlin API which can be implemented on a JVM (e.g. with JavaFX) or compiled natively to JS to reuse the browser global variables

This commit is contained in:
James Strachan
2012-05-24 09:56:57 +01:00
parent 3fe9a8beca
commit bedadb1472
3 changed files with 50 additions and 0 deletions
@@ -0,0 +1,33 @@
package test.browser
import kotlin.dom.*
import kotlin.browser.*
import kotlin.test.*
import org.junit.Test as test
class BrowserTest {
test fun accessBrowserDOM() {
registerBrowserPage()
val h1 = document["h1"].first()
assertEquals("Hello World!", h1.text)
}
protected fun registerBrowserPage() {
// lets simulate being a browser registering its DOM
val doc = createDocument()
doc.addElement("html") {
addElement("body") {
addElement("h1") {
addText("Hello World!")
}
addElement("p") {
addText("This is some text content")
}
}
}
document = doc
}
}